emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master f066999: (viper-read-key, viper-read-key-sequence):


From: Stefan Monnier
Subject: [Emacs-diffs] master f066999: (viper-read-key, viper-read-key-sequence): Remove
Date: Wed, 12 Sep 2018 21:47:46 -0400 (EDT)

branch: master
commit f066999b6540451c590cbe32113fae61c4778ba3
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    (viper-read-key, viper-read-key-sequence): Remove
    
    Ever since the time-dependent ESC handling was moved to input-decode-map,
    viper-read-key-sequence has been obsolete.  Clean up accordingly.
    
    * lisp/emulation/viper-keym.el: Use lexical-binding.
    (viper-overriding-map): Remove.
    
    * lisp/emulation/viper-macs.el: Use lexical-binding and 'read-key'.
    
    * lisp/emulation/viper-util.el: Use lexical-binding.
    (viper-read-key, viper-read-key-sequence): Remove.
    
    * lisp/emulation/viper.el (viper-non-hook-settings): Remove obsolete advice.
---
 lisp/emulation/viper-cmd.el  |   4 +-
 lisp/emulation/viper-keym.el |   6 +--
 lisp/emulation/viper-macs.el |  13 +++---
 lisp/emulation/viper-util.el |  61 ++++----------------------
 lisp/emulation/viper.el      | 102 -------------------------------------------
 5 files changed, 20 insertions(+), 166 deletions(-)

diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el
index 3c66abe..3b617a4 100644
--- a/lisp/emulation/viper-cmd.el
+++ b/lisp/emulation/viper-cmd.el
@@ -748,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
@@ -2449,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-keym.el b/lisp/emulation/viper-keym.el
index 5196ca6..cc0b7eb 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.
 
@@ -82,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 247180c..cfb46cc 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 2e759bc..aa45655 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)
@@ -631,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
@@ -661,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))
@@ -944,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 8604020..8dd150b 100644
--- a/lisp/emulation/viper.el
+++ b/lisp/emulation/viper.el
@@ -1057,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."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]