comparison lisp/emulation/viper-cmd.el @ 106192:a2ee981efbec

2009-11-22 Michael Kifer <kifer@cs.stonybrook.edu> * viper-cmd.el: use viper-last-command-char instead of last-command-char/last-command-event. (viper-prefix-arg-value): do correct conversion of event-char for XEmacs. * viper-util.el, viper.el: use viper-last-command-char instead of last-command-char/last-command-event. * ediff-init.el, ediff-mult.el, ediff-util.el: relpace last-command-char and last-command-event with (ediff-last-command-char) everywhere. * ediff-vers.el (ediff-rcs-get-output-buffer): make sure the buffer is created in fundamental mode. * ediff.el (ediff-version): revert the change of interactive-p to called-interactively-p.
author Michael Kifer <kifer@cs.stonybrook.edu>
date Sun, 22 Nov 2009 03:14:14 +0000
parents 328150f0cf76
children 1d1d5d9bd884
comparison
equal deleted inserted replaced
106191:baf1843cbc25 106192:a2ee981efbec
717 (defun viper-escape-to-emacs (arg &optional events) 717 (defun viper-escape-to-emacs (arg &optional events)
718 "Escape to Emacs state from Vi state for one Emacs command. 718 "Escape to Emacs state from Vi state for one Emacs command.
719 ARG is used as the prefix value for the executed command. If 719 ARG is used as the prefix value for the executed command. If
720 EVENTS is a list of events, which become the beginning of the command." 720 EVENTS is a list of events, which become the beginning of the command."
721 (interactive "P") 721 (interactive "P")
722 (if (viper= last-command-event ?\\) 722 (if (viper= (viper-last-command-char) ?\\)
723 (message "Switched to EMACS state for the next command...")) 723 (message "Switched to EMACS state for the next command..."))
724 (viper-escape-to-state arg events 'emacs-state)) 724 (viper-escape-to-state arg events 'emacs-state))
725 725
726 ;; escape to Vi mode termporarily 726 ;; escape to Vi mode termporarily
727 (defun viper-escape-to-vi (arg) 727 (defun viper-escape-to-vi (arg)
1179 ;; we typed. 1179 ;; we typed.
1180 (cond ((eq event-char 'return) (setq event-char ?\C-m)) 1180 (cond ((eq event-char 'return) (setq event-char ?\C-m))
1181 ((eq event-char 'delete) (setq event-char ?\C-?)) 1181 ((eq event-char 'delete) (setq event-char ?\C-?))
1182 ((eq event-char 'backspace) (setq event-char ?\C-h)) 1182 ((eq event-char 'backspace) (setq event-char ?\C-h))
1183 ((eq event-char 'space) (setq event-char ?\ ))) 1183 ((eq event-char 'space) (setq event-char ?\ )))
1184 (setq last-command-event (or com event-char)) 1184 (setq last-command-event
1185 (if (featurep 'xemacs)
1186 (character-to-event (or com event-char))
1187 (or com event-char)))
1185 (setq func (viper-exec-form-in-vi 1188 (setq func (viper-exec-form-in-vi
1186 `(key-binding (char-to-string ,event-char)))) 1189 `(key-binding (char-to-string ,event-char))))
1187 (funcall func prefix-arg) 1190 (funcall func prefix-arg)
1188 (setq prefix-arg nil)) 1191 (setq prefix-arg nil))
1189 ;; some other command -- let emacs do it in its own way 1192 ;; some other command -- let emacs do it in its own way
1309 (defun viper-digit-argument (arg) 1312 (defun viper-digit-argument (arg)
1310 "Begin numeric argument for the next command." 1313 "Begin numeric argument for the next command."
1311 (interactive "P") 1314 (interactive "P")
1312 (viper-leave-region-active) 1315 (viper-leave-region-active)
1313 (viper-prefix-arg-value 1316 (viper-prefix-arg-value
1314 last-command-event (if (consp arg) (cdr arg) nil))) 1317 (viper-last-command-char) (if (consp arg) (cdr arg) nil)))
1315 1318
1316 (defun viper-command-argument (arg) 1319 (defun viper-command-argument (arg)
1317 "Accept a motion command as an argument." 1320 "Accept a motion command as an argument."
1318 (interactive "P") 1321 (interactive "P")
1319 (let ((viper-intermediate-command 'viper-command-argument)) 1322 (let ((viper-intermediate-command 'viper-command-argument))
1320 (condition-case nil 1323 (condition-case nil
1321 (viper-prefix-arg-com 1324 (viper-prefix-arg-com
1322 last-command-event 1325 (viper-last-command-char)
1323 (cond ((null arg) nil) 1326 (cond ((null arg) nil)
1324 ((consp arg) (car arg)) 1327 ((consp arg) (car arg))
1325 ((integerp arg) arg) 1328 ((integerp arg) arg)
1326 (t (error viper-InvalidCommandArgument))) 1329 (t (error viper-InvalidCommandArgument)))
1327 (cond ((null arg) nil) 1330 (cond ((null arg) nil)
2094 ;; Run viper-minibuffer-exit-hook before exiting. 2097 ;; Run viper-minibuffer-exit-hook before exiting.
2095 (defun viper-exit-minibuffer () 2098 (defun viper-exit-minibuffer ()
2096 "Exit minibuffer Viper way." 2099 "Exit minibuffer Viper way."
2097 (interactive) 2100 (interactive)
2098 (let (command) 2101 (let (command)
2099 (setq command (local-key-binding (char-to-string last-command-event))) 2102 (setq command (local-key-binding (char-to-string (viper-last-command-char))))
2100 (run-hooks 'viper-minibuffer-exit-hook) 2103 (run-hooks 'viper-minibuffer-exit-hook)
2101 (if command 2104 (if command
2102 (command-execute command) 2105 (command-execute command)
2103 (exit-minibuffer)))) 2106 (exit-minibuffer))))
2104 2107
3769 ;; toggle regexp/vanila search 3772 ;; toggle regexp/vanila search
3770 (viper-record-kbd-macro 3773 (viper-record-kbd-macro
3771 "///" 'vi-state 3774 "///" 'vi-state
3772 [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] 3775 [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]
3773 scope) 3776 scope)
3774 (if (called-interactively-p 'interactive) 3777 ;; XEmacs has no called-interactively-p
3778 ;; (if (called-interactively-p 'interactive)
3779 (if (interactive-p)
3775 (message 3780 (message
3776 "// and /// now toggle case-sensitivity and regexp search"))) 3781 "// and /// now toggle case-sensitivity and regexp search")))
3777 (viper-unrecord-kbd-macro "//" 'vi-state) 3782 (viper-unrecord-kbd-macro "//" 'vi-state)
3778 (sit-for 2) 3783 (sit-for 2)
3779 (viper-unrecord-kbd-macro "///" 'vi-state))) 3784 (viper-unrecord-kbd-macro "///" 'vi-state)))
3792 ;; Make %%% toggle parsing comments for matching parentheses 3797 ;; Make %%% toggle parsing comments for matching parentheses
3793 (viper-record-kbd-macro 3798 (viper-record-kbd-macro
3794 "%%%" 'vi-state 3799 "%%%" 'vi-state
3795 [(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] 3800 [(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]
3796 't) 3801 't)
3797 (if (called-interactively-p 'interactive) 3802 ;; XEmacs has no called-interactively-p. And interactive-p
3803 ;; works fine here.
3804 ;; (if (called-interactively-p 'interactive)
3805 (if (interactive-p)
3798 (message 3806 (message
3799 "%%%%%% now toggles whether comments should be parsed for matching parentheses"))) 3807 "%%%%%% now toggles whether comments should be parsed for matching parentheses")))
3800 (viper-unrecord-kbd-macro "%%%" 'vi-state)))) 3808 (viper-unrecord-kbd-macro "%%%" 'vi-state))))
3801 3809
3802 3810
3821 ;; toggle regexp/vanila search 3829 ;; toggle regexp/vanila search
3822 (viper-record-kbd-macro 3830 (viper-record-kbd-macro
3823 "///" 'emacs-state 3831 "///" 'emacs-state
3824 [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] 3832 [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]
3825 (or arg-majormode major-mode)) 3833 (or arg-majormode major-mode))
3826 (if (called-interactively-p 'interactive) 3834 ;; called-interactively-p does not work for
3835 ;; XEmacs. interactive-p is ok here.
3836 ;; (if (called-interactively-p 'interactive)
3837 (if (interactive-p)
3827 (message 3838 (message
3828 "// and /// now toggle case-sensitivity and regexp search."))) 3839 "// and /// now toggle case-sensitivity and regexp search.")))
3829 (viper-unrecord-kbd-macro "//" 'emacs-state) 3840 (viper-unrecord-kbd-macro "//" 'emacs-state)
3830 (sit-for 2) 3841 (sit-for 2)
3831 (viper-unrecord-kbd-macro "///" 'emacs-state)))) 3842 (viper-unrecord-kbd-macro "///" 'emacs-state))))