Commits

Peter Szilagyi committed dad9972

integrated new ocp-indent Emacs Lisp bindings and latest updates

  • Participants
  • Parent commits a91f2c0

Comments (0)

Files changed (5)

 =======
 - unbound "C-c C-c" in edit-server (Google Chrome Edit with Emacs) to
   focus attention on the emacsclient-compatible "C-x #" binding
+- integrated new ocp-indent Emacs Lisp bindings and latest updates
 
 bug fixes
 =========

elisp/jane/README

 (setq jane-make-command
       (concat jane-make-command " --output-only-errors --no--print-timing"))
 
+;; If you use `Omake.compile', you'll need to edit a file,
+;; ~/.omake-server/config, instead
+;;   ((omake_command "jomake --output-only-errors --no--print-timing"))
+
 ;; If the buffer in question is already displayed in a frame, raise
 ;; that frame.
 (custom-set-variables '(display-buffer-reuse-frames t))

elisp/jane/jane-ocaml.el

  '(tuareg-indent-comments nil) ; don't accidentally clobber carefully indented comments
  )
 
-;; CR pszilagyi: This variable is not used anymore and confuses me.
-;; Remove after Hurricane Sandy recovery.
+;; This is no longer used by `Omake.compile', but is still used by
+;; `compile'.
 (defvar jane-make-command "jomake -j 12 -P -w")
 
 (defcustom ocaml-indenter 'tuareg
   :type '(choice (const tuareg)
                  (const ocp-indent)))
 
-(defun ocaml-indenter ()
+(defun ocaml-indenters ()
   (case ocaml-indenter
-    ((tuareg) 'Jane.tuareg-indent-line-with-syntax)
-    ((ocp-indent) 'Ocp.indent-buffer)
+    ((tuareg) '(Jane.tuareg-indent-line-with-syntax nil))
+    ((ocp-indent) '(ocp-indent-line ocp-indent-region))
     (t (error "Bad key for ocaml-indenter.  Should be 'tuareg or 'ocp-indent"))))
 
+;; ocp-indent-line and ocp-indent-region
+(load (expand-file-name "../ocaml/contrib/ocp-indent/emacs.el"
+                        (and (boundp 'load-file)
+                             (file-name-directory load-file))))
+(remove-hook 'tuareg-mode-hook 'ocp-setup-indent)
+
 (defun jane-tuareg-mode-hook ()
   (auto-fill-mode 1)
   (setq fill-column 90)
   (set (make-local-variable 'compile-command) jane-make-command)
   (setq whitespace-style '(lines-tail tabs tab-mark trailing))
   (add-hook 'before-save-hook 'whitespace-cleanup)
-  ;;(setq indent-line-function 'Jane.tuareg-indent-line-with-syntax)
   (Whitespace.delete-trailing)
-  (setq indent-line-function (ocaml-indenter))
+  (let ((funs (ocaml-indenters)))
+    (setq indent-line-function (car funs))
+    (setq indent-region-function (cadr funs)))
   (let ((mycaml (expand-file-name "mycaml" default-directory)))
     (when (file-exists-p mycaml)
       (set (make-local-variable 'tuareg-interactive-program) mycaml))))
 
 (add-hook 'tuareg-mode-hook 'jane-tuareg-mode-hook)
-;; (setq tuareg-mode-hook nil)
 
 
 

ocp-indent/ocp-indent-stdin

-#!/bin/bash
-
-set -e -u -o pipefail
-
-ocp-indent /dev/stdin

ocp-indent/ocp-indent.el

-
-(defcustom Ocp.indent-program
-  (concat (file-name-directory load-file-name) "ocp-indent-stdin")
-  "Program to use to indent your code")
-
-(defun Ocp.indentation ()
-  (save-excursion
-    (beginning-of-line)
-    (let ((beg (point)))
-      (forward-to-indentation 0)
-      (- (point) beg))))
-
-(defun Ocp.in-indentation ()
-  "t iff cursor is before the first non-whitespace char on a line"
-  (let* ((beg (save-excursion (beginning-of-line) (point)))
-         (s (buffer-substring beg (point))))
-    (if (string-match "^\\s-*$" s) t nil)))
-
-;; ;; If cursor is before any characters, tab sends you to the new indentation
-;; ;; Otherwise, go to (oldCol - oldIndent + newIndent)
-;; ;; oldCol - oldIndent is nonnegative
-(defun Ocp.indent-region (beg end)
-  (interactive "r")
-  (let* ((coding-system-for-write 'utf-8)
-         (coding-system-for-read 'utf-8)
-         (windows (get-buffer-window-list (current-buffer)))
-         (window-info
-          (mapcar (lambda (w) (list w (window-point w) (window-start w))) windows))
-         (pt (point))
-         (mk (mark))
-         (old-indent (Ocp.indentation))
-         (in-indentation (Ocp.in-indentation))
-         (old-col (current-column))
-         (ws (window-start))
-         (ln (line-number-at-pos pt)))
-    (call-process-region beg end Ocp.indent-program t t)
-    (goto-char (point-min))
-    (forward-line (1- ln))
-    (if in-indentation (forward-to-indentation 0)
-      (let ((new-indent (Ocp.indentation))
-            (col (- old-col old-indent)))
-        (assert (>= col 0))
-        (forward-char (+ col new-indent))))
-    (set-mark mk)
-    (mapc (lambda (info)
-            (let ((w (nth 0 info))
-                  (pt (nth 1 info))
-                  (st (nth 2 info)))
-              (set-window-start w st))) window-info)))
-
-(defun Ocp.indent-buffer ()
-  (interactive)
-  (Ocp.indent-region (point-min) (point-max)))
-
-;; (defun Ocp.indent-line ()
-;;   (interactive)
-;;   (let ((end
-;;          (progn
-;;            (end-of-line)
-;;            (point)))
-;;         (beg
-;;          (progn
-;;            (previous-line 1)
-;;            (beginning-of-line)
-;;            (point))))
-;;     (Ocp.indent-region beg end)
-;;     (forward-line 1)
-;;     (forward-to-indentation 0)
-;;     ))
-
-(provide 'ocp-indent)