simplify electric
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4913 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02master
parent
d13715755c
commit
956da4fa8c
|
@ -1565,17 +1565,7 @@ followed by |."
|
||||||
(caml-in-indentation)
|
(caml-in-indentation)
|
||||||
(not (caml-in-comment-p)))))
|
(not (caml-in-comment-p)))))
|
||||||
(self-insert-command 1)
|
(self-insert-command 1)
|
||||||
(if electric
|
(if electric (save-excursion (caml-indent-command)))))
|
||||||
(let ((indent
|
|
||||||
(save-excursion
|
|
||||||
(backward-char 1)
|
|
||||||
(caml-indent-command)
|
|
||||||
(current-column))))
|
|
||||||
(indent-to (- indent
|
|
||||||
(symbol-value
|
|
||||||
(nth 1 (assoc
|
|
||||||
(char-to-string last-command-char)
|
|
||||||
caml-leading-kwops-alist)))))))))
|
|
||||||
|
|
||||||
(defun caml-electric-rb ()
|
(defun caml-electric-rb ()
|
||||||
"If inserting a ] operator at beginning of line, reindent the line.
|
"If inserting a ] operator at beginning of line, reindent the line.
|
||||||
|
@ -1585,38 +1575,26 @@ by |, insert one."
|
||||||
|
|
||||||
(interactive "*")
|
(interactive "*")
|
||||||
(let* ((prec (preceding-char))
|
(let* ((prec (preceding-char))
|
||||||
(look-pipe (and caml-electric-close-vector
|
(use-pipe (and caml-electric-close-vector
|
||||||
(not (caml-in-comment-p))
|
(not (caml-in-comment-p))
|
||||||
(not (caml-in-literal-p))
|
(not (caml-in-literal-p))
|
||||||
(or (not (numberp prec))
|
(or (not (numberp prec))
|
||||||
(not (char-equal ?| prec)))
|
(not (char-equal ?| prec)))))
|
||||||
(set-marker (make-marker) (point))))
|
|
||||||
(electric (and caml-electric-indent
|
(electric (and caml-electric-indent
|
||||||
(caml-in-indentation)
|
(caml-in-indentation)
|
||||||
(not (caml-in-comment-p)))))
|
(not (caml-in-comment-p)))))
|
||||||
(self-insert-command 1)
|
(self-insert-command 1)
|
||||||
(if electric
|
(if electric (save-excursion (caml-indent-command)))
|
||||||
(let ((indent
|
(if (and use-pipe
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(backward-char 1)
|
(condition-case nil
|
||||||
(caml-indent-command)
|
(prog2
|
||||||
(current-column))))
|
|
||||||
(indent-to (- indent
|
|
||||||
(symbol-value
|
|
||||||
(nth 1 (assoc
|
|
||||||
(char-to-string last-command-char)
|
|
||||||
caml-leading-kwops-alist)))))))
|
|
||||||
(if look-pipe
|
|
||||||
(save-excursion
|
|
||||||
(let ((insert-pipe
|
|
||||||
(condition-case nil
|
|
||||||
(prog2
|
|
||||||
(backward-list 1)
|
(backward-list 1)
|
||||||
(if (looking-at "\\[|") "|" ""))
|
(looking-at "\\[|"))
|
||||||
(error ""))))
|
(error ""))))
|
||||||
(goto-char look-pipe)
|
(save-excursion
|
||||||
(insert insert-pipe))
|
(backward-char 1)
|
||||||
(set-marker look-pipe nil)))))
|
(insert "|")))))
|
||||||
|
|
||||||
(defun caml-abbrev-hook ()
|
(defun caml-abbrev-hook ()
|
||||||
"If inserting a leading keyword at beginning of line, reindent the line."
|
"If inserting a leading keyword at beginning of line, reindent the line."
|
||||||
|
|
Loading…
Reference in New Issue