diff options
Diffstat (limited to 'lisp/emulation')
-rw-r--r-- | lisp/emulation/cua-base.el | 19 | ||||
-rw-r--r-- | lisp/emulation/viper-cmd.el | 9 | ||||
-rw-r--r-- | lisp/emulation/viper-ex.el | 10 | ||||
-rw-r--r-- | lisp/emulation/viper-keym.el | 8 | ||||
-rw-r--r-- | lisp/emulation/viper-macs.el | 13 | ||||
-rw-r--r-- | lisp/emulation/viper-util.el | 68 | ||||
-rw-r--r-- | lisp/emulation/viper.el | 111 |
7 files changed, 42 insertions, 196 deletions
diff --git a/lisp/emulation/cua-base.el b/lisp/emulation/cua-base.el index a737bb6c11c..f9a3fb0fb4a 100644 --- a/lisp/emulation/cua-base.el +++ b/lisp/emulation/cua-base.el @@ -39,7 +39,7 @@ ;; C-v -> paste ;; ;; The tricky part is the handling of the C-x and C-c keys which -;; are normally used as prefix keys for most of emacs' built-in +;; are normally used as prefix keys for most of Emacs' built-in ;; commands. With CUA they still do!!! ;; ;; Only when the region is currently active (and highlighted since @@ -69,7 +69,7 @@ ;; [C-space] to start the region and use unshifted movement keys to extend ;; it. To cancel the region, use [C-space] or [C-g]. -;; If you prefer to use the standard emacs cut, copy, paste, and undo +;; If you prefer to use the standard Emacs cut, copy, paste, and undo ;; bindings, customize cua-enable-cua-keys to nil. @@ -138,7 +138,7 @@ ;; cua-mode's superior rectangle support uses a true visual ;; representation of the selected rectangle, i.e. it highlights the ;; actual part of the buffer that is currently selected as part of the -;; rectangle. Unlike emacs' traditional rectangle commands, the +;; rectangle. Unlike Emacs' traditional rectangle commands, the ;; selected rectangle always as straight left and right edges, even ;; when those are in the middle of a TAB character or beyond the end ;; of the current line. And it does this without actually modifying @@ -852,8 +852,6 @@ With numeric prefix arg, copy to register 0-9 instead." (if (fboundp 'cua--cancel-rectangle) (cua--cancel-rectangle))) -(declare-function x-clipboard-yank "../term/x-win" ()) - (put 'cua-paste 'delete-selection 'yank) (defun cua-paste (arg) "Paste last cut or copied region or rectangle. @@ -884,10 +882,8 @@ If global mark is active, copy from register or one character." ((consp regtxt) (cua--insert-rectangle regtxt)) ((stringp regtxt) (insert-for-yank regtxt)) (t (message "Unknown data in register %c" cua--register)))) - ((eq this-original-command 'clipboard-yank) - (clipboard-yank)) - ((eq this-original-command 'x-clipboard-yank) - (x-clipboard-yank)) + ((memq this-original-command '(clipboard-yank x-clipboard-yank)) + (funcall this-original-command)) (t (yank arg))))))) @@ -1051,7 +1047,6 @@ If ARG is the atom `-', scroll downward by nearly full screen." (scroll-up arg) (end-of-buffer (goto-char (point-max))))))) -(put 'cua-scroll-up 'CUA 'move) (put 'cua-scroll-up 'isearch-scroll t) (defun cua-scroll-down (&optional arg) @@ -1072,7 +1067,6 @@ If ARG is the atom `-', scroll upward by nearly full screen." (scroll-down arg) (beginning-of-buffer (goto-char (point-min))))))) -(put 'cua-scroll-down 'CUA 'move) (put 'cua-scroll-down 'isearch-scroll t) ;;; Cursor indications @@ -1322,9 +1316,6 @@ If ARG is the atom `-', scroll upward by nearly full screen." ;;;###autoload (define-minor-mode cua-mode "Toggle Common User Access style editing (CUA mode). -With a prefix argument ARG, enable CUA mode if ARG is positive, -and disable it otherwise. If called from Lisp, enable the mode -if ARG is omitted or nil. CUA mode is a global minor mode. When enabled, typed text replaces the active selection, and you can use C-z, C-x, C-c, and diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el index fe57535a14b..3b617a42abc 100644 --- a/lisp/emulation/viper-cmd.el +++ b/lisp/emulation/viper-cmd.el @@ -45,8 +45,6 @@ (defvar undo-beg-posn) (defvar undo-end-posn) -(eval-and-compile - (unless (fboundp 'declare-function) (defmacro declare-function (&rest _)))) ;; end pacifier @@ -131,9 +129,6 @@ ;; define viper-vi-command-p (viper-test-com-defun viper-vi-command) -;; Where viper saves mark. This mark is resurrected by m^ -(defvar viper-saved-mark nil) - ;; Contains user settings for vars affected by viper-set-expert-level function. ;; Not a user option. (defvar viper-saved-user-settings nil) @@ -753,7 +748,7 @@ Vi's prefix argument will be used. Otherwise, the prefix argument passed to (unwind-protect (progn (setq com - (key-binding (setq key (viper-read-key-sequence nil)))) + (key-binding (setq key (read-key-sequence nil)))) ;; In case of binding indirection--chase definitions. ;; Have to do it here because we execute this command under ;; different keymaps, so command-execute may not do the @@ -2454,7 +2449,7 @@ These keys are ESC, RET, and LineFeed." (if (eq this-command 'viper-intercept-ESC-key) (setq com 'viper-exit-insert-state) (viper-set-unread-command-events last-input-event) - (setq com (key-binding (viper-read-key-sequence nil)))) + (setq com (key-binding (read-key-sequence nil)))) (condition-case conds (command-execute com) diff --git a/lisp/emulation/viper-ex.el b/lisp/emulation/viper-ex.el index 347e66f8ff1..d95a828614e 100644 --- a/lisp/emulation/viper-ex.el +++ b/lisp/emulation/viper-ex.el @@ -548,9 +548,13 @@ reversed." (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name)) (set-buffer viper-ex-work-buf) (goto-char (point-max))) - (cond ((looking-back quit-regex1) (exit-minibuffer)) - ((looking-back stay-regex) (insert " ")) - ((looking-back quit-regex2) (exit-minibuffer)) + (cond ((looking-back quit-regex1 (line-beginning-position)) + (exit-minibuffer)) + ;; Almost certainly point-min should be line-beginning-position, + ;; but probably the two are identical anyway, and who really cares? + ((looking-back stay-regex (point-min)) (insert " ")) + ((looking-back quit-regex2 (line-beginning-position)) + (exit-minibuffer)) (t (insert " "))))) (declare-function viper-tmp-insert-at-eob "viper-cmd" (msg)) diff --git a/lisp/emulation/viper-keym.el b/lisp/emulation/viper-keym.el index e72842232e4..cc0b7ebc379 100644 --- a/lisp/emulation/viper-keym.el +++ b/lisp/emulation/viper-keym.el @@ -1,4 +1,4 @@ -;;; viper-keym.el --- Viper keymaps +;;; viper-keym.el --- Viper keymaps -*- lexical-binding:t -*- ;; Copyright (C) 1994-1997, 2000-2018 Free Software Foundation, Inc. @@ -32,8 +32,6 @@ (defvar viper-ex-style-editing) (defvar viper-ex-style-motion) -(eval-and-compile - (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))) ;; end pacifier (require 'viper-util) @@ -84,10 +82,6 @@ major mode in effect." (defvar viper-insert-intercept-map (make-sparse-keymap)) (defvar viper-emacs-intercept-map (make-sparse-keymap)) -;; keymap used to zap all keymaps other than function-key-map, -;; device-function-key-map, etc. -(defvar viper-overriding-map (make-sparse-keymap)) - (viper-deflocalvar viper-vi-local-user-map (make-sparse-keymap) "Keymap for user-defined local bindings. Useful for changing bindings such as ZZ in certain major modes. diff --git a/lisp/emulation/viper-macs.el b/lisp/emulation/viper-macs.el index 247180c803c..cfb46cc19a8 100644 --- a/lisp/emulation/viper-macs.el +++ b/lisp/emulation/viper-macs.el @@ -1,4 +1,4 @@ -;;; viper-macs.el --- functions implementing keyboard macros for Viper +;;; viper-macs.el --- functions implementing keyboard macros for Viper -*- lexical-binding:t -*- ;; Copyright (C) 1994-1997, 2000-2018 Free Software Foundation, Inc. @@ -174,7 +174,7 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g., (prin1-to-string (viper-display-macro key-seq)) ""))) (message "%s" message) - (setq event (viper-read-key)) + (setq event (read-key)) ;;(setq event (viper-read-event)) (setq key (if (viper-mouse-event-p event) @@ -251,7 +251,7 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g., (viper-display-macro key-seq)) ""))) (message "%s" message) - (setq event (viper-read-key)) + (setq event (read-key)) ;;(setq event (viper-read-event)) (setq key (if (viper-mouse-event-p event) @@ -867,15 +867,18 @@ mistakes in macro names to be passed to this function is to use ;; A fast keysequence is one that is terminated by a pause longer than ;; viper-fast-keyseq-timeout. (defun viper-read-fast-keysequence (event macro-alist) + ;; FIXME: Do we still need this? Now that the discrimination between the ESC + ;; key and the ESC byte sent as part of terminal escape sequences is performed + ;; in the input-decode-map, I suspect that we don't need this hack any more. (let ((lis (vector event)) next-event) (while (and (viper-fast-keysequence-p) (viper-keyseq-is-a-possible-macro lis macro-alist)) ;; Seems that viper-read-event is more robust here. We need to be able to ;; place these events on unread-command-events list. If we use - ;; viper-read-key then events will be converted to keys, and sometimes + ;; read-key then events will be converted to keys, and sometimes ;; (e.g., (control \[)) those keys differ from the corresponding events. - ;; So, do not use (setq next-event (viper-read-key)) + ;; So, do not use (setq next-event (read-key)) (setq next-event (viper-read-event)) (or (viper-mouse-event-p next-event) (setq lis (vconcat lis (vector next-event))))) diff --git a/lisp/emulation/viper-util.el b/lisp/emulation/viper-util.el index f0540401803..aa456551a68 100644 --- a/lisp/emulation/viper-util.el +++ b/lisp/emulation/viper-util.el @@ -1,4 +1,4 @@ -;;; viper-util.el --- Utilities used by viper.el +;;; viper-util.el --- Utilities used by viper.el -*- lexical-binding:t -*- ;; Copyright (C) 1994-1997, 1999-2018 Free Software Foundation, Inc. @@ -28,7 +28,6 @@ ;; Compiler pacifier -(defvar viper-overriding-map) (defvar viper-minibuffer-current-face) (defvar viper-minibuffer-insert-face) (defvar viper-minibuffer-vi-face) @@ -39,13 +38,9 @@ (defvar ex-unix-type-shell-options) (defvar viper-ex-tmp-buf-name) (defvar viper-syntax-preference) -(defvar viper-saved-mark) (require 'ring) -(eval-and-compile - (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))) - ;; end pacifier (require 'viper-init) @@ -635,15 +630,15 @@ Otherwise return the normal value." ;;; Saving settings in custom file -;; Save the current setting of VAR in CUSTOM-FILE. +;; Save the current setting of VAR in FILE. ;; If given, MESSAGE is a message to be displayed after that. ;; This message is erased after 2 secs, if erase-msg is non-nil. -;; Arguments: var message custom-file &optional erase-message -(defun viper-save-setting (var message custom-file &optional erase-msg) +;; Arguments: var message file &optional erase-message +(defun viper-save-setting (var message file &optional erase-msg) (let* ((var-name (symbol-name var)) (var-val (if (boundp var) (eval var))) (regexp (format "^[^;]*%s[ \t\n]*[a-zA-Z---_']*[ \t\n)]" var-name)) - (buf (find-file-noselect (substitute-in-file-name custom-file))) + (buf (find-file-noselect (substitute-in-file-name file))) ) (message "%s" (or message "")) (with-current-buffer buf @@ -665,12 +660,12 @@ Otherwise return the normal value." (message ""))) )) -;; Save STRING in CUSTOM-FILE. If PATTERN is non-nil, remove strings that +;; Save STRING in FILE. If PATTERN is non-nil, remove strings that ;; match this pattern. -(defun viper-save-string-in-file (string custom-file &optional pattern) - (let ((buf (find-file-noselect (substitute-in-file-name custom-file)))) +(defun viper-save-string-in-file (string file &optional pattern) + (let ((buf (find-file-noselect (substitute-in-file-name file)))) (with-current-buffer buf - (let (buffer-read-only) + (let ((inhibit-read-only t)) (goto-char (point-min)) (if pattern (delete-matching-lines pattern)) (goto-char (point-max)) @@ -886,6 +881,9 @@ Otherwise return the normal value." (if (featurep 'xemacs) (mark-marker t) (mark-marker))) +(defvar viper-saved-mark nil + "Where viper saves mark. This mark is resurrected by m^.") + ;; like (set-mark-command nil) but doesn't push twice, if (car mark-ring) ;; is the same as (mark t). (defsubst viper-set-mark-if-necessary () @@ -945,48 +943,6 @@ Otherwise return the normal value." event)) (read-event)))) -;; Viperized read-key-sequence -(defun viper-read-key-sequence (prompt &optional continue-echo) - (let (inhibit-quit event keyseq) - (setq keyseq (read-key-sequence prompt continue-echo)) - (setq event (if (featurep 'xemacs) - (elt keyseq 0) ; XEmacs returns vector of events - (elt (listify-key-sequence keyseq) 0))) - (if (viper-ESC-event-p event) - (let (unread-command-events) - (if (viper-fast-keysequence-p) - (let ((viper-vi-global-user-minor-mode nil) - (viper-vi-local-user-minor-mode nil) - (viper-vi-intercept-minor-mode nil) - (viper-insert-intercept-minor-mode nil) - (viper-replace-minor-mode nil) ; actually unnecessary - (viper-insert-global-user-minor-mode nil) - (viper-insert-local-user-minor-mode nil)) - ;; Note: set unread-command-events only after testing for fast - ;; keysequence. Otherwise, viper-fast-keysequence-p will be - ;; always t -- whether there is anything after ESC or not - (viper-set-unread-command-events keyseq) - (setq keyseq (read-key-sequence nil))) - (viper-set-unread-command-events keyseq) - (setq keyseq (read-key-sequence nil))))) - keyseq)) - - -;; This function lets function-key-map convert key sequences into logical -;; keys. This does a better job than viper-read-event when it comes to kbd -;; macros, since it enables certain macros to be shared between X and TTY modes -;; by correctly mapping key sequences for Left/Right/... (on an ascii -;; terminal) into logical keys left, right, etc. -(defun viper-read-key () ;; FIXME: Use `read-key'? - (let ((overriding-local-map viper-overriding-map) - (inhibit-quit t) - help-char key) - (use-global-map viper-overriding-map) - (unwind-protect - (setq key (elt (viper-read-key-sequence nil) 0)) - (use-global-map global-map)) - key)) - ;; Emacs has a bug in eventp, which causes (eventp nil) to return (nil) ;; instead of nil, if '(nil) was previously inadvertently assigned to diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el index c8eca30e88b..8dd150bf7c8 100644 --- a/lisp/emulation/viper.el +++ b/lisp/emulation/viper.el @@ -937,8 +937,13 @@ Two differences: (if (and (eq viper-current-state 'vi-state) ;; Do not use called-interactively-p here. XEmacs does not have it ;; and interactive-p is just fine. - ;; (called-interactively-p 'interactive)) - (interactive-p)) + (if (featurep 'xemacs) + (interactive-p) + ;; Respect the spirit of the above comment, though it + ;; seems pointless, since XE doesn't have advice-add or + ;; lexical binding or any other of the newer features + ;; this file uses. + (called-interactively-p 'interactive))) (beep 1) (apply orig-fun args)))) @@ -1052,108 +1057,6 @@ Two differences: (setq global-mode-string (append '("" viper-mode-string) (cdr global-mode-string)))) - (if (featurep 'xemacs) - ;; XEmacs - (defadvice describe-key (before viper-describe-key-ad protect activate) - "Force to read key via `viper-read-key-sequence'." - (interactive (list (viper-read-key-sequence "Describe key: ")))) - ;; Emacs - (viper--advice-add 'describe-key :before - (lambda (&rest _) - "Force to read key via `viper-read-key-sequence'." - (interactive (let ((key (viper-read-key-sequence - "Describe key (or click or menu item): "))) - (list key - (prefix-numeric-value current-prefix-arg) - ;; If KEY is a down-event, read also the - ;; corresponding up-event. - (and (vectorp key) - (let ((last-idx (1- (length key)))) - (and (eventp (aref key last-idx)) - (memq 'down (event-modifiers - (aref key last-idx))))) - (or (and (eventp (aref key 0)) - (memq 'down (event-modifiers - (aref key 0))) - ;; For the C-down-mouse-2 popup menu, - ;; there is no subsequent up-event - (= (length key) 1)) - (and (> (length key) 1) - (eventp (aref key 1)) - (memq 'down (event-modifiers (aref key 1))))) - (read-event))))) - nil)) - - ) ; (if (featurep 'xemacs) - - (if (featurep 'xemacs) - ;; XEmacs - (defadvice describe-key-briefly - (before viper-describe-key-briefly-ad protect activate) - "Force to read key via `viper-read-key-sequence'." - (interactive (list (viper-read-key-sequence "Describe key briefly: ")))) - ;; Emacs - (viper--advice-add 'describe-key-briefly :before - (lambda (&rest _) - "Force to read key via `viper-read-key-sequence'." - (interactive (let ((key (viper-read-key-sequence - "Describe key (or click or menu item): "))) - ;; If KEY is a down-event, read and discard the - ;; corresponding up-event. - (and (vectorp key) - (let ((last-idx (1- (length key)))) - (and (eventp (aref key last-idx)) - (memq 'down (event-modifiers (aref key last-idx))))) - (read-event)) - (list key - (if current-prefix-arg - (prefix-numeric-value current-prefix-arg)) - 1))) - nil)) - ) ; (if (featurep 'xemacs) - - ;; FIXME: The default already uses read-file-name, so it looks like this - ;; advice is not needed any more. - ;; (defadvice find-file (before viper-add-suffix-advice activate) - ;; "Use `read-file-name' for reading arguments." - ;; (interactive (cons (read-file-name "Find file: " nil default-directory) - ;; ;; XEmacs: if Mule & prefix arg, ask for coding system - ;; (cond ((and (featurep 'xemacs) (featurep 'mule)) - ;; (list - ;; (and current-prefix-arg - ;; (read-coding-system "Coding-system: ")))) - ;; ;; Emacs: do wildcards - ;; ((and (featurep 'emacs) (boundp 'find-file-wildcards)) - ;; (list find-file-wildcards)))) - ;; )) - ;; (defadvice find-file-other-window (before viper-add-suffix-advice activate) - ;; "Use `read-file-name' for reading arguments." - ;; (interactive (cons (read-file-name "Find file in other window: " - ;; nil default-directory) - ;; ;; XEmacs: if Mule & prefix arg, ask for coding system - ;; (cond ((and (featurep 'xemacs) (featurep 'mule)) - ;; (list - ;; (and current-prefix-arg - ;; (read-coding-system "Coding-system: ")))) - ;; ;; Emacs: do wildcards - ;; ((and (featurep 'emacs) (boundp 'find-file-wildcards)) - ;; (list find-file-wildcards)))) - ;; )) - ;; (defadvice find-file-other-frame (before viper-add-suffix-advice activate) - ;; "Use `read-file-name' for reading arguments." - ;; (interactive (cons (read-file-name "Find file in other frame: " - ;; nil default-directory) - ;; ;; XEmacs: if Mule & prefix arg, ask for coding system - ;; (cond ((and (featurep 'xemacs) (featurep 'mule)) - ;; (list - ;; (and current-prefix-arg - ;; (read-coding-system "Coding-system: ")))) - ;; ;; Emacs: do wildcards - ;; ((and (featurep 'emacs) (boundp 'find-file-wildcards)) - ;; (list find-file-wildcards)))) - ;; )) - - (viper--advice-add 'read-file-name :around (lambda (orig-fun &rest args) "Tell `exit-minibuffer' to run `viper-file-add-suffix' as a hook." |