summaryrefslogtreecommitdiff
path: root/lisp/emulation/viper-util.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emulation/viper-util.el')
-rw-r--r--lisp/emulation/viper-util.el68
1 files changed, 12 insertions, 56 deletions
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