diff options
| author | Phillip Lord | 2016-06-10 22:30:49 +0100 |
|---|---|---|
| committer | Phillip Lord | 2016-06-11 20:32:31 +0100 |
| commit | 291fe0aade6560490abbe5c08d231c18edbb4737 (patch) | |
| tree | 3d6e16d93a94ec251a0eb01781c517d7916e7b23 | |
| parent | 6921f4a5961fb53f8fb24d1a5a3f94266f990f6e (diff) | |
| download | emacs-291fe0aade6560490abbe5c08d231c18edbb4737.tar.gz emacs-291fe0aade6560490abbe5c08d231c18edbb4737.zip | |
Revert "Fix viper undo breakage from undo-boundary changes"
This reverts commit c0139e32f1f3bb287b04e02a69a7848d6a040003.
| -rw-r--r-- | lisp/emulation/viper-cmd.el | 43 | ||||
| -rw-r--r-- | lisp/emulation/viper-init.el | 9 | ||||
| -rw-r--r-- | lisp/simple.el | 23 |
3 files changed, 43 insertions, 32 deletions
diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el index 6b8fa46362d..93cf3b0fb10 100644 --- a/lisp/emulation/viper-cmd.el +++ b/lisp/emulation/viper-cmd.el | |||
| @@ -631,7 +631,7 @@ | |||
| 631 | (viper-over-whitespace-line)) | 631 | (viper-over-whitespace-line)) |
| 632 | (indent-to-left-margin)) | 632 | (indent-to-left-margin)) |
| 633 | (viper-add-newline-at-eob-if-necessary) | 633 | (viper-add-newline-at-eob-if-necessary) |
| 634 | (viper-complete-complex-command-for-undo) | 634 | (viper-adjust-undo) |
| 635 | 635 | ||
| 636 | (if (eq viper-current-state 'emacs-state) | 636 | (if (eq viper-current-state 'emacs-state) |
| 637 | (viper-restore-cursor-color 'after-emacs-mode) | 637 | (viper-restore-cursor-color 'after-emacs-mode) |
| @@ -1570,7 +1570,7 @@ If the prefix argument ARG is non-nil, it is used instead of `val'." | |||
| 1570 | (if (and (eolp) (not (bolp))) | 1570 | (if (and (eolp) (not (bolp))) |
| 1571 | (backward-char 1)) | 1571 | (backward-char 1)) |
| 1572 | )) | 1572 | )) |
| 1573 | (viper-complete-complex-command-for-undo) ; take care of undo | 1573 | (viper-adjust-undo) ; take care of undo |
| 1574 | ;; If the prev cmd was rotating the command ring, this means that `.' has | 1574 | ;; If the prev cmd was rotating the command ring, this means that `.' has |
| 1575 | ;; just executed a command from that ring. So, push it on the ring again. | 1575 | ;; just executed a command from that ring. So, push it on the ring again. |
| 1576 | ;; If we are just executing previous command , then don't push viper-d-com | 1576 | ;; If we are just executing previous command , then don't push viper-d-com |
| @@ -1671,7 +1671,6 @@ invokes the command before that, etc." | |||
| 1671 | 1671 | ||
| 1672 | (undo-start) | 1672 | (undo-start) |
| 1673 | (undo-more 2) | 1673 | (undo-more 2) |
| 1674 | (viper-complete-complex-command-for-undo) | ||
| 1675 | ;;(setq undo-beg-posn (or undo-beg-posn (point)) | 1674 | ;;(setq undo-beg-posn (or undo-beg-posn (point)) |
| 1676 | ;; undo-end-posn (or undo-end-posn (point))) | 1675 | ;; undo-end-posn (or undo-end-posn (point))) |
| 1677 | ;;(setq undo-beg-posn (or undo-beg-posn before-undo-pt) | 1676 | ;;(setq undo-beg-posn (or undo-beg-posn before-undo-pt) |
| @@ -1711,17 +1710,37 @@ invokes the command before that, etc." | |||
| 1711 | ;; The following two functions are used to set up undo properly. | 1710 | ;; The following two functions are used to set up undo properly. |
| 1712 | ;; In VI, unlike Emacs, if you open a line, say, and add a bunch of lines, | 1711 | ;; In VI, unlike Emacs, if you open a line, say, and add a bunch of lines, |
| 1713 | ;; they are undone all at once. | 1712 | ;; they are undone all at once. |
| 1714 | (defun viper-complete-complex-command-for-undo () | 1713 | (defun viper-adjust-undo () |
| 1715 | (setq undo-auto-disable-boundaries nil) | 1714 | (if viper-undo-needs-adjustment |
| 1716 | (setq viper-undo-in-complex-command nil) | 1715 | (let ((inhibit-quit t) |
| 1717 | (undo-boundary)) | 1716 | tmp tmp2) |
| 1717 | (setq viper-undo-needs-adjustment nil) | ||
| 1718 | (if (listp buffer-undo-list) | ||
| 1719 | (if (setq tmp (memq viper-buffer-undo-list-mark buffer-undo-list)) | ||
| 1720 | (progn | ||
| 1721 | (setq tmp2 (cdr tmp)) ; the part after mark | ||
| 1722 | |||
| 1723 | ;; cut tail from buffer-undo-list temporarily by direct | ||
| 1724 | ;; manipulation with pointers in buffer-undo-list | ||
| 1725 | (setcdr tmp nil) | ||
| 1726 | |||
| 1727 | (setq buffer-undo-list (delq nil buffer-undo-list)) | ||
| 1728 | (setq buffer-undo-list | ||
| 1729 | (delq viper-buffer-undo-list-mark buffer-undo-list)) | ||
| 1730 | ;; restore tail of buffer-undo-list | ||
| 1731 | (setq buffer-undo-list (nconc buffer-undo-list tmp2))) | ||
| 1732 | (setq buffer-undo-list (delq nil buffer-undo-list))))) | ||
| 1733 | )) | ||
| 1718 | 1734 | ||
| 1719 | 1735 | ||
| 1720 | (defun viper-set-complex-command-for-undo () | 1736 | (defun viper-set-complex-command-for-undo () |
| 1721 | (when (not viper-undo-in-complex-command) | 1737 | (if (listp buffer-undo-list) |
| 1722 | (setq undo-auto-disable-boundaries t) | 1738 | (if (not viper-undo-needs-adjustment) |
| 1723 | (setq viper-undo-in-complex-command t) | 1739 | (let ((inhibit-quit t)) |
| 1724 | (undo-boundary))) | 1740 | (setq buffer-undo-list |
| 1741 | (cons viper-buffer-undo-list-mark buffer-undo-list)) | ||
| 1742 | (setq viper-undo-needs-adjustment t))))) | ||
| 1743 | |||
| 1725 | 1744 | ||
| 1726 | ;;; Viper's destructive Command ring utilities | 1745 | ;;; Viper's destructive Command ring utilities |
| 1727 | 1746 | ||
| @@ -2585,7 +2604,7 @@ These keys are ESC, RET, and LineFeed." | |||
| 2585 | (delete-char 1 t) | 2604 | (delete-char 1 t) |
| 2586 | (insert char)) | 2605 | (insert char)) |
| 2587 | 2606 | ||
| 2588 | (viper-complete-complex-command-for-undo) | 2607 | (viper-adjust-undo) |
| 2589 | (backward-char arg) | 2608 | (backward-char arg) |
| 2590 | )) | 2609 | )) |
| 2591 | 2610 | ||
diff --git a/lisp/emulation/viper-init.el b/lisp/emulation/viper-init.el index c1e76629477..104245b7571 100644 --- a/lisp/emulation/viper-init.el +++ b/lisp/emulation/viper-init.el | |||
| @@ -370,8 +370,13 @@ Use `\\[viper-set-expert-level]' to change this.") | |||
| 370 | ;; VI-style Undo | 370 | ;; VI-style Undo |
| 371 | 371 | ||
| 372 | ;; Used to 'undo' complex commands, such as replace and insert commands. | 372 | ;; Used to 'undo' complex commands, such as replace and insert commands. |
| 373 | (viper-deflocalvar viper-undo-in-complex-command nil) | 373 | (viper-deflocalvar viper-undo-needs-adjustment nil) |
| 374 | (put 'viper-undo-in-complex-command 'permanent-local t) | 374 | (put 'viper-undo-needs-adjustment 'permanent-local t) |
| 375 | |||
| 376 | ;; A mark that Viper puts on buffer-undo-list. Marks the beginning of a | ||
| 377 | ;; complex command that must be undone atomically. If inserted, it is | ||
| 378 | ;; erased by viper-change-state-to-vi and viper-repeat. | ||
| 379 | (defconst viper-buffer-undo-list-mark 'viper) | ||
| 375 | 380 | ||
| 376 | (defcustom viper-keep-point-on-undo nil | 381 | (defcustom viper-keep-point-on-undo nil |
| 377 | "Non-nil means not to move point while undoing commands. | 382 | "Non-nil means not to move point while undoing commands. |
diff --git a/lisp/simple.el b/lisp/simple.el index e38bf70f520..b66827dfa63 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -2839,18 +2839,6 @@ buffers that were changed during the last command.") | |||
| 2839 | 2839 | ||
| 2840 | If set to non-nil, this will effectively disable the timer.") | 2840 | If set to non-nil, this will effectively disable the timer.") |
| 2841 | 2841 | ||
| 2842 | (defvar-local undo-auto-disable-boundaries nil | ||
| 2843 | "Disable the automatic addition of boundaries. | ||
| 2844 | |||
| 2845 | If set to non-nil, `undo-boundary' will not be called | ||
| 2846 | automatically in a buffer either at the end of a command, or as a | ||
| 2847 | result of `undo-auto-current-boundary-timer'. | ||
| 2848 | |||
| 2849 | When this is set to non-nil, it is important to ensure that | ||
| 2850 | `undo-boundary' is called frequently enough. Failure to do so | ||
| 2851 | will result in user-visible warnings that the situation is | ||
| 2852 | probably a bug.") | ||
| 2853 | |||
| 2854 | (defvar undo-auto--this-command-amalgamating nil | 2842 | (defvar undo-auto--this-command-amalgamating nil |
| 2855 | "Non-nil if `this-command' should be amalgamated. | 2843 | "Non-nil if `this-command' should be amalgamated. |
| 2856 | This variable is set to nil by `undo-auto--boundaries' and is set | 2844 | This variable is set to nil by `undo-auto--boundaries' and is set |
| @@ -2890,8 +2878,7 @@ REASON describes the reason that the boundary is being added; see | |||
| 2890 | (dolist (b undo-auto--undoably-changed-buffers) | 2878 | (dolist (b undo-auto--undoably-changed-buffers) |
| 2891 | (when (buffer-live-p b) | 2879 | (when (buffer-live-p b) |
| 2892 | (with-current-buffer b | 2880 | (with-current-buffer b |
| 2893 | (unless undo-auto-disable-boundaries | 2881 | (undo-auto--ensure-boundary cause)))) |
| 2894 | (undo-auto--ensure-boundary cause))))) | ||
| 2895 | (setq undo-auto--undoably-changed-buffers nil)) | 2882 | (setq undo-auto--undoably-changed-buffers nil)) |
| 2896 | 2883 | ||
| 2897 | (defun undo-auto--boundary-timer () | 2884 | (defun undo-auto--boundary-timer () |
| @@ -2916,10 +2903,10 @@ default values.") | |||
| 2916 | "Add an `undo-boundary' in appropriate buffers." | 2903 | "Add an `undo-boundary' in appropriate buffers." |
| 2917 | (undo-auto--boundaries | 2904 | (undo-auto--boundaries |
| 2918 | (let ((amal undo-auto--this-command-amalgamating)) | 2905 | (let ((amal undo-auto--this-command-amalgamating)) |
| 2919 | (setq undo-auto--this-command-amalgamating nil) | 2906 | (setq undo-auto--this-command-amalgamating nil) |
| 2920 | (if amal | 2907 | (if amal |
| 2921 | 'amalgamate | 2908 | 'amalgamate |
| 2922 | 'command)))) | 2909 | 'command)))) |
| 2923 | 2910 | ||
| 2924 | (defun undo-auto-amalgamate () | 2911 | (defun undo-auto-amalgamate () |
| 2925 | "Amalgamate undo if necessary. | 2912 | "Amalgamate undo if necessary. |