diff options
| author | Sam Steingold | 2014-06-23 16:23:33 -0400 |
|---|---|---|
| committer | Sam Steingold | 2014-06-23 16:23:33 -0400 |
| commit | 2fde356acb722a54aa0a4f18cbe2b56c216dbb1e (patch) | |
| tree | 514d013cb9f892e769c9d68ac209f71fadbd017f | |
| parent | 5d2638bd31586fc276ddd4444a49627e855cf7fa (diff) | |
| download | emacs-2fde356acb722a54aa0a4f18cbe2b56c216dbb1e.tar.gz emacs-2fde356acb722a54aa0a4f18cbe2b56c216dbb1e.zip | |
Optionally, undo several consequential deletion in one step.
* lisp/simple.el (kill-append): Remove undo boundary depending on ...
(kill-append-merge-undo): New user option.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/simple.el | 22 |
2 files changed, 26 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8c2fb12da4e..3f7896fd1c5 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2014-06-23 Sam Steingold <sds@gnu.org> | ||
| 2 | |||
| 3 | * simple.el (kill-append): Remove undo boundary depending on ... | ||
| 4 | (kill-append-merge-undo): New user option. | ||
| 5 | |||
| 1 | 2014-06-23 Stefan Monnier <monnier@iro.umontreal.ca> | 6 | 2014-06-23 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 7 | ||
| 3 | * simple.el (handle-shift-selection, exchange-point-and-mark) | 8 | * simple.el (handle-shift-selection, exchange-point-and-mark) |
diff --git a/lisp/simple.el b/lisp/simple.el index 9983943298f..a8689aaf2e3 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -3742,14 +3742,34 @@ argument should still be a \"useful\" string for such uses." | |||
| 3742 | (if interprogram-cut-function | 3742 | (if interprogram-cut-function |
| 3743 | (funcall interprogram-cut-function string))) | 3743 | (funcall interprogram-cut-function string))) |
| 3744 | 3744 | ||
| 3745 | ;; It has been argued that this should work similar to `self-insert-command' | ||
| 3746 | ;; which merges insertions in undo-list in groups of 20 (hard-coded in cmds.c). | ||
| 3747 | (defcustom kill-append-merge-undo nil | ||
| 3748 | "Whether appending to kill ring also makes \\[undo] restore both pieces of text simultaneously." | ||
| 3749 | :type 'boolean | ||
| 3750 | :group 'killing | ||
| 3751 | :version "24.5") | ||
| 3752 | |||
| 3745 | (defun kill-append (string before-p) | 3753 | (defun kill-append (string before-p) |
| 3746 | "Append STRING to the end of the latest kill in the kill ring. | 3754 | "Append STRING to the end of the latest kill in the kill ring. |
| 3747 | If BEFORE-P is non-nil, prepend STRING to the kill. | 3755 | If BEFORE-P is non-nil, prepend STRING to the kill. |
| 3756 | Also removes the last undo boundary in the current buffer, | ||
| 3757 | depending on `kill-append-merge-undo'. | ||
| 3748 | If `interprogram-cut-function' is set, pass the resulting kill to it." | 3758 | If `interprogram-cut-function' is set, pass the resulting kill to it." |
| 3749 | (let* ((cur (car kill-ring))) | 3759 | (let* ((cur (car kill-ring))) |
| 3750 | (kill-new (if before-p (concat string cur) (concat cur string)) | 3760 | (kill-new (if before-p (concat string cur) (concat cur string)) |
| 3751 | (or (= (length cur) 0) | 3761 | (or (= (length cur) 0) |
| 3752 | (equal nil (get-text-property 0 'yank-handler cur)))))) | 3762 | (equal nil (get-text-property 0 'yank-handler cur)))) |
| 3763 | (when (and kill-append-merge-undo (not buffer-read-only)) | ||
| 3764 | (let ((prev buffer-undo-list) | ||
| 3765 | (next (cdr buffer-undo-list))) | ||
| 3766 | ;; find the next undo boundary | ||
| 3767 | (while (car next) | ||
| 3768 | (pop next) | ||
| 3769 | (pop prev)) | ||
| 3770 | ;; remove this undo boundary | ||
| 3771 | (when prev | ||
| 3772 | (setcdr prev (cdr next))))))) | ||
| 3753 | 3773 | ||
| 3754 | (defcustom yank-pop-change-selection nil | 3774 | (defcustom yank-pop-change-selection nil |
| 3755 | "Whether rotating the kill ring changes the window system selection. | 3775 | "Whether rotating the kill ring changes the window system selection. |