aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-06-20 00:09:04 +0200
committerLars Ingebrigtsen2019-06-20 12:51:38 +0200
commita4047f9d9817c6b39bff4ce31fb4a1270598cdad (patch)
treefa9b2755c3df8623703c3affd3cba9ee8de8db2d
parent1f6e6ee4f78457dca0165773b964874229005e9c (diff)
downloademacs-a4047f9d9817c6b39bff4ce31fb4a1270598cdad.tar.gz
emacs-a4047f9d9817c6b39bff4ce31fb4a1270598cdad.zip
Remove XEmacs compat code from viper-cmd.el
* lisp/emulation/viper-cmd.el (viper-change-state) (viper-escape-to-state, viper-special-read-and-insert-char) (viper-prefix-arg-value, viper-prefix-arg-com) (viper-display-current-destructive-command) (viper-file-add-suffix, viper-adjust-window) (viper-set-searchstyle-toggling-macros) (viper-set-parsing-style-toggling-macro) (viper-set-emacs-state-searchstyle-macros): Remove XEmacs compat code.
-rw-r--r--lisp/emulation/viper-cmd.el109
1 files changed, 18 insertions, 91 deletions
diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el
index f52ce72a6d8..dc05634f7e3 100644
--- a/lisp/emulation/viper-cmd.el
+++ b/lisp/emulation/viper-cmd.el
@@ -293,12 +293,6 @@
293 ;; desirable that viper-pre-command-sentinel is the last hook and 293 ;; desirable that viper-pre-command-sentinel is the last hook and
294 ;; viper-post-command-sentinel is the first hook. 294 ;; viper-post-command-sentinel is the first hook.
295 295
296 (when (featurep 'xemacs)
297 (make-local-hook 'viper-after-change-functions)
298 (make-local-hook 'viper-before-change-functions)
299 (make-local-hook 'viper-post-command-hooks)
300 (make-local-hook 'viper-pre-command-hooks))
301
302 (remove-hook 'post-command-hook 'viper-post-command-sentinel) 296 (remove-hook 'post-command-hook 'viper-post-command-sentinel)
303 (add-hook 'post-command-hook 'viper-post-command-sentinel) 297 (add-hook 'post-command-hook 'viper-post-command-sentinel)
304 (remove-hook 'pre-command-hook 'viper-pre-command-sentinel) 298 (remove-hook 'pre-command-hook 'viper-pre-command-sentinel)
@@ -764,21 +758,15 @@ Vi's prefix argument will be used. Otherwise, the prefix argument passed to
764 758
765 ;; this-command, last-command-char, last-command-event 759 ;; this-command, last-command-char, last-command-event
766 (setq this-command com) 760 (setq this-command com)
767 (if (featurep 'xemacs) 761 ;; Emacs represents key sequences as sequences (str or vec)
768 ;; XEmacs represents key sequences as vectors 762 (setq last-command-event
769 (setq last-command-event 763 (viper-copy-event (viper-seq-last-elt key)))
770 (viper-copy-event (viper-seq-last-elt key))
771 last-command-char (event-to-character last-command-event))
772 ;; Emacs represents them as sequences (str or vec)
773 (setq last-command-event
774 (viper-copy-event (viper-seq-last-elt key))))
775 764
776 (if (commandp com) 765 (if (commandp com)
777 ;; pretend that current state is the state we escaped to 766 ;; pretend that current state is the state we escaped to
778 (let ((viper-current-state state)) 767 (let ((viper-current-state state))
779 (setq prefix-arg (or prefix-arg arg)) 768 (setq prefix-arg (or prefix-arg arg))
780 (command-execute com))) 769 (command-execute com))))
781 )
782 (quit (ding)) 770 (quit (ding))
783 (error (beep 1)))) 771 (error (beep 1))))
784 ;; set state in the new buffer 772 ;; set state in the new buffer
@@ -826,30 +814,7 @@ Vi's prefix argument will be used. Otherwise, the prefix argument passed to
826 (insert quail-current-str)) 814 (insert quail-current-str))
827 (setq ch (or ch 815 (setq ch (or ch
828 (aref quail-current-str 816 (aref quail-current-str
829 (1- (length quail-current-str))))) 817 (1- (length quail-current-str)))))))
830 ))
831 ((and viper-special-input-method
832 (featurep 'xemacs)
833 (fboundp 'quail-start-translation))
834 ;; same as above but for XEmacs, which doesn't have
835 ;; quail-input-method
836 (let (unread-command-events)
837 (setq ch (read-char-exclusive))
838 ;; replace ^M with the newline
839 (if (eq ch ?\C-m) (setq ch ?\n))
840 ;; Make sure ^V and ^Q work as quotation chars
841 (if (memq ch '(?\C-v ?\C-q))
842 (setq ch (read-char-exclusive)))
843 (viper-set-unread-command-events ch)
844 (quail-start-translation nil)
845
846 (if (and ch (string= quail-current-str ""))
847 (insert ch)
848 (insert quail-current-str))
849 (setq ch (or ch
850 (aref quail-current-str
851 (1- (length quail-current-str)))))
852 ))
853 ((and (boundp 'iso-accents-mode) iso-accents-mode) 818 ((and (boundp 'iso-accents-mode) iso-accents-mode)
854 (setq ch (aref (read-key-sequence nil) 0)) 819 (setq ch (aref (read-key-sequence nil) 0))
855 ;; replace ^M with the newline 820 ;; replace ^M with the newline
@@ -859,25 +824,14 @@ Vi's prefix argument will be used. Otherwise, the prefix argument passed to
859 (setq ch (aref (read-key-sequence nil) 0))) 824 (setq ch (aref (read-key-sequence nil) 0)))
860 (insert ch)) 825 (insert ch))
861 (t 826 (t
862 ;;(setq ch (read-char-exclusive))
863 (setq ch (aref (read-key-sequence nil) 0)) 827 (setq ch (aref (read-key-sequence nil) 0))
864 (if (featurep 'xemacs)
865 (setq ch (event-to-character ch)))
866 ;; replace ^M with the newline 828 ;; replace ^M with the newline
867 (if (eq ch ?\C-m) (setq ch ?\n)) 829 (if (eq ch ?\C-m) (setq ch ?\n))
868 ;; Make sure ^V and ^Q work as quotation chars 830 ;; Make sure ^V and ^Q work as quotation chars
869 (if (memq ch '(?\C-v ?\C-q)) 831 (if (memq ch '(?\C-v ?\C-q))
870 (progn 832 (setq ch (aref (read-key-sequence nil) 0)))
871 ;;(setq ch (read-char-exclusive)) 833 (insert ch)))
872 (setq ch (aref (read-key-sequence nil) 0)) 834 (setq last-command-event (viper-copy-event ch))
873 (if (featurep 'xemacs)
874 (setq ch (event-to-character ch))))
875 )
876 (insert ch))
877 )
878 (setq last-command-event
879 (viper-copy-event (if (featurep 'xemacs)
880 (character-to-event ch) ch)))
881 ) ; let 835 ) ; let
882 (error nil) 836 (error nil)
883 ) ; condition-case 837 ) ; condition-case
@@ -1096,10 +1050,7 @@ as a Meta key and any number of multiple escapes are allowed."
1096 ((eq event-char 'delete) (setq event-char ?\C-?)) 1050 ((eq event-char 'delete) (setq event-char ?\C-?))
1097 ((eq event-char 'backspace) (setq event-char ?\C-h)) 1051 ((eq event-char 'backspace) (setq event-char ?\C-h))
1098 ((eq event-char 'space) (setq event-char ?\ ))) 1052 ((eq event-char 'space) (setq event-char ?\ )))
1099 (setq last-command-event 1053 (setq last-command-event (or com event-char))
1100 (if (featurep 'xemacs)
1101 (character-to-event (or com event-char))
1102 (or com event-char)))
1103 (setq func (viper-exec-form-in-vi 1054 (setq func (viper-exec-form-in-vi
1104 `(key-binding (char-to-string ,event-char)))) 1055 `(key-binding (char-to-string ,event-char))))
1105 (funcall func prefix-arg) 1056 (funcall func prefix-arg)
@@ -1203,9 +1154,7 @@ as a Meta key and any number of multiple escapes are allowed."
1203 1154
1204 (if cmd-to-exec-at-end 1155 (if cmd-to-exec-at-end
1205 (progn 1156 (progn
1206 (setq last-command-event 1157 (setq last-command-event (viper-copy-event char))
1207 (viper-copy-event
1208 (if (featurep 'xemacs) (character-to-event char) char)))
1209 (condition-case err 1158 (condition-case err
1210 (funcall cmd-to-exec-at-end cmd-info) 1159 (funcall cmd-to-exec-at-end cmd-info)
1211 (error 1160 (error
@@ -1732,18 +1681,9 @@ invokes the command before that, etc."
1732 (message " `.' runs `%s'%s" 1681 (message " `.' runs `%s'%s"
1733 (viper-array-to-string keys) 1682 (viper-array-to-string keys)
1734 (viper-abbreviate-string 1683 (viper-abbreviate-string
1735 (if (featurep 'xemacs) 1684 text max-text-len
1736 (replace-in-string ; xemacs
1737 (cond ((characterp text) (char-to-string text))
1738 ((stringp text) text)
1739 (t ""))
1740 "\n" "^J")
1741 text ; emacs
1742 )
1743 max-text-len
1744 (format-message " inserting `") (format-message "'") 1685 (format-message " inserting `") (format-message "'")
1745 " .......")) 1686 " ......."))))
1746 ))
1747 1687
1748 1688
1749;; don't change viper-d-com if it was viper-repeat command invoked with `.' 1689;; don't change viper-d-com if it was viper-repeat command invoked with `.'
@@ -2053,15 +1993,10 @@ To turn this feature off, set this variable to nil."
2053 (setq cmd 1993 (setq cmd
2054 (key-binding (setq key (read-key-sequence nil)))) 1994 (key-binding (setq key (read-key-sequence nil))))
2055 (cond ((eq cmd 'self-insert-command) 1995 (cond ((eq cmd 'self-insert-command)
2056 (if (featurep 'xemacs) 1996 (insert key))
2057 (insert (events-to-keys key)) ; xemacs
2058 (insert key) ; emacs
2059 ))
2060 ((memq cmd '(exit-minibuffer viper-exit-minibuffer)) 1997 ((memq cmd '(exit-minibuffer viper-exit-minibuffer))
2061 nil) 1998 nil)
2062 (t (command-execute cmd))) 1999 (t (command-execute cmd))))))))))
2063 )))
2064 ))))
2065 2000
2066 2001
2067(defun viper-minibuffer-trim-tail () 2002(defun viper-minibuffer-trim-tail ()
@@ -3351,9 +3286,7 @@ controlled by the sign of prefix numeric value."
3351;; (which is called from viper-search-forward/backward/next). If the value of 3286;; (which is called from viper-search-forward/backward/next). If the value of
3352;; viper-search-scroll-threshold is negative - don't scroll. 3287;; viper-search-scroll-threshold is negative - don't scroll.
3353(defun viper-adjust-window () 3288(defun viper-adjust-window ()
3354 (let ((win-height (if (featurep 'xemacs) 3289 (let ((win-height (1- (window-height))) ; adjust for mode line
3355 (window-displayed-height)
3356 (1- (window-height)))) ; adjust for mode line
3357 (pt (point)) 3290 (pt (point))
3358 at-top-p at-bottom-p 3291 at-top-p at-bottom-p
3359 min-scroll direction) 3292 min-scroll direction)
@@ -3671,9 +3604,7 @@ If MODE is set, set the macros only in that major mode."
3671 "///" 'vi-state 3604 "///" 'vi-state
3672 [2 (meta x) v i p e r - t o g g l e - s e a r c h - s t y l e return] 3605 [2 (meta x) v i p e r - t o g g l e - s e a r c h - s t y l e return]
3673 scope) 3606 scope)
3674 (if (if (featurep 'xemacs) 3607 (if (called-interactively-p 'interactive)
3675 (interactive-p)
3676 (called-interactively-p 'interactive))
3677 (message 3608 (message
3678 "// and /// now toggle case-sensitivity and regexp search"))) 3609 "// and /// now toggle case-sensitivity and regexp search")))
3679 (viper-unrecord-kbd-macro "//" 'vi-state) 3610 (viper-unrecord-kbd-macro "//" 'vi-state)
@@ -3696,9 +3627,7 @@ With a prefix argument, unsets the macro."
3696 "%%%" 'vi-state 3627 "%%%" 'vi-state
3697 [(meta x) v i p e r - t o g g l e - p a r s e - s e x p - i g n o r e - c o m m e n t s return] 3628 [(meta x) v i p e r - t o g g l e - p a r s e - s e x p - i g n o r e - c o m m e n t s return]
3698 't) 3629 't)
3699 (if (if (featurep 'xemacs) 3630 (if (called-interactively-p 'interactive)
3700 (interactive-p)
3701 (called-interactively-p 'interactive))
3702 (message 3631 (message
3703 "%%%%%% now toggles whether comments should be parsed for matching parentheses"))) 3632 "%%%%%% now toggles whether comments should be parsed for matching parentheses")))
3704 (viper-unrecord-kbd-macro "%%%" 'vi-state)))) 3633 (viper-unrecord-kbd-macro "%%%" 'vi-state))))
@@ -3727,9 +3656,7 @@ the macros are set in the current major mode.
3727 "///" 'emacs-state 3656 "///" 'emacs-state
3728 [2 (meta x) v i p e r - t o g g l e - s e a r c h - s t y l e return] 3657 [2 (meta x) v i p e r - t o g g l e - s e a r c h - s t y l e return]
3729 (or arg-majormode major-mode)) 3658 (or arg-majormode major-mode))
3730 (if (if (featurep 'xemacs) 3659 (if (called-interactively-p 'interactive)
3731 (interactive-p)
3732 (called-interactively-p 'interactive))
3733 (message 3660 (message
3734 "// and /// now toggle case-sensitivity and regexp search."))) 3661 "// and /// now toggle case-sensitivity and regexp search.")))
3735 (viper-unrecord-kbd-macro "//" 'emacs-state) 3662 (viper-unrecord-kbd-macro "//" 'emacs-state)