diff options
author | Richard M. Stallman <[email protected]> | 1992-10-03 02:21:51 +0000 |
---|---|---|
committer | Richard M. Stallman <[email protected]> | 1992-10-03 02:21:51 +0000 |
commit | 62c48f87e90d4b7ff89082c8b4e833d0804d00c1 (patch) | |
tree | e09d3f00e010309bb197042c7b61ddc1af826a1c | |
parent | f28f04cca2914a9fb8178900d60a0a0654670fe1 (diff) |
(open-line): Shield undo from the hack to insert at pt-1.
-rw-r--r-- | lisp/simple.el | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index d4eac802e3..243b1eeb21 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -28,7 +28,17 @@ With arg N, insert N newlines." (interactive "*p") (let* ((do-fill-prefix (and fill-prefix (bolp))) (flag (and (null do-fill-prefix) (bolp) (not (bobp))))) - (if flag (forward-char -1)) + ;; If this is a simple case, and we are at the beginning of a line, + ;; actually insert the newline *before* the preceding newline + ;; instead of after. That makes better display behavior. + (if flag + (progn + ;; If undo is enabled, don't let this hack be visible: + ;; record the real value of point as the place to move back to + ;; if we undo this insert. + (if (and buffer-undo-list (not (eq buffer-undo-list t))) + (setq buffer-undo-list (cons (point) buffer-undo-list))) + (forward-char -1))) (while (> arg 0) (save-excursion (insert ?\n)) |