diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2010-11-12 08:33:44 -0500 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2010-11-12 08:33:44 -0500 |
commit | 4490f87580a8f9ade324ea1d3a095dddca8ecf1d (patch) | |
tree | 7b4531540354aaec750d7902498825e72c60739f /lisp/skeleton.el | |
parent | c156a63bb337b2bc2ce19b06e0175fbd75a790cc (diff) | |
download | emacs-4490f87580a8f9ade324ea1d3a095dddca8ecf1d.tar.gz |
* lisp/skeleton.el (skeleton-newline): New function.
(skeleton-internal-1): Use it.
(skeleton-read): Don't use `newline' since it may strip trailing space.
Diffstat (limited to 'lisp/skeleton.el')
-rw-r--r-- | lisp/skeleton.el | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lisp/skeleton.el b/lisp/skeleton.el index c98e06fe76f..0c3e0e8c413 100644 --- a/lisp/skeleton.el +++ b/lisp/skeleton.el @@ -299,7 +299,10 @@ automatically, and you are prompted to fill in the variable parts."))) (eolp (eolp))) ;; since Emacs doesn't show main window's cursor, do something noticeable (or eolp - (open-line 1)) + ;; We used open-line before, but that can do a lot more than we want, + ;; since it runs self-insert-command. E.g. it may remove spaces + ;; before point. + (save-excursion (insert "\n"))) (unwind-protect (setq prompt (if (stringp prompt) (read-string (format prompt skeleton-subprompt) @@ -352,6 +355,16 @@ automatically, and you are prompted to fill in the variable parts."))) (signal 'quit 'recursive) recursive)) +(defun skeleton-newline () + (if (or (eq (point) skeleton-point) + (eq (point) (car skeleton-positions))) + ;; If point is recorded, avoid `newline' since it may do things like + ;; strip trailing spaces, and since recorded points are commonly placed + ;; right after a trailing space, calling `newline' can destroy the + ;; position and renders the recorded position incorrect. + (insert "\n") + (newline))) + (defun skeleton-internal-1 (element &optional literal recursive) (cond ((or (integerp element) (stringp element)) @@ -379,13 +392,13 @@ automatically, and you are prompted to fill in the variable parts."))) (if pos (indent-according-to-mode))) (skeleton-newline-indent-rigidly (let ((pt (point))) - (newline) + (skeleton-newline) (indent-to (save-excursion (goto-char pt) (if pos (indent-according-to-mode)) (current-indentation))))) (t (if pos (reindent-then-newline-and-indent) - (newline) + (skeleton-newline) (indent-according-to-mode)))))) ((eq element '>) (if (and skeleton-regions (eq (nth 1 skeleton-il) '_)) |