From 956da4fa8cd470f6b538693aff1b0d3588e4e172 Mon Sep 17 00:00:00 2001 From: Jacques Garrigue Date: Mon, 10 Jun 2002 02:40:08 +0000 Subject: [PATCH] simplify electric git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4913 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02 --- emacs/caml.el | 54 +++++++++++++++------------------------------------ 1 file changed, 16 insertions(+), 38 deletions(-) diff --git a/emacs/caml.el b/emacs/caml.el index 1d313168a..bfe1b598f 100644 --- a/emacs/caml.el +++ b/emacs/caml.el @@ -1565,17 +1565,7 @@ followed by |." (caml-in-indentation) (not (caml-in-comment-p))))) (self-insert-command 1) - (if electric - (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))))))))) + (if electric (save-excursion (caml-indent-command))))) (defun caml-electric-rb () "If inserting a ] operator at beginning of line, reindent the line. @@ -1585,38 +1575,26 @@ by |, insert one." (interactive "*") (let* ((prec (preceding-char)) - (look-pipe (and caml-electric-close-vector - (not (caml-in-comment-p)) - (not (caml-in-literal-p)) - (or (not (numberp prec)) - (not (char-equal ?| prec))) - (set-marker (make-marker) (point)))) + (use-pipe (and caml-electric-close-vector + (not (caml-in-comment-p)) + (not (caml-in-literal-p)) + (or (not (numberp prec)) + (not (char-equal ?| prec))))) (electric (and caml-electric-indent (caml-in-indentation) (not (caml-in-comment-p))))) (self-insert-command 1) - (if electric - (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))))))) - (if look-pipe - (save-excursion - (let ((insert-pipe - (condition-case nil - (prog2 + (if electric (save-excursion (caml-indent-command))) + (if (and use-pipe + (save-excursion + (condition-case nil + (prog2 (backward-list 1) - (if (looking-at "\\[|") "|" "")) - (error "")))) - (goto-char look-pipe) - (insert insert-pipe)) - (set-marker look-pipe nil))))) + (looking-at "\\[|")) + (error "")))) + (save-excursion + (backward-char 1) + (insert "|"))))) (defun caml-abbrev-hook () "If inserting a leading keyword at beginning of line, reindent the line."