* lisp/emulation/cua-base.el: Use lexical-binding.
Remove redundant `:group` arguments.
(cua-mode): Don't use `:require` since the autoload on `define-minor-mode`
takes care of loading the mode when custom-setting it.
* lisp/emulation/cua-gmrk.el: Use lexical-binding.
(cua--copy-rectangle-to-global-mark): Remove unused var `src-buf`.
* lisp/emulation/edt-mapper.el: Use lexical-binding.
* lisp/emulation/edt.el: Use lexical-binding.
Remove redundant `:group` arguments.
(edt-with-position): Allow `top`, `left`, and `far` to be left unused
in `body`.
* lisp/emulation/keypad.el: Use lexical-binding.
* lisp/emulation/viper-cmd.el: Move `provide` to the end.
(viper-read-string-with-history): Strength reduce `eval` to `symbol-value`.
* lisp/emulation/viper-ex.el: Use lexical-binding.
Remove redundant `:group` arguments.
Move `provide` to the end.
* lisp/emulation/viper-init.el: Use lexical-binding.
* lisp/emulation/viper-keym.el (viper-toggle-key): Use `dolist`.
(viper-insert-diehard-map): Use `string`.
(viper-modify-major-mode): Use `alist-get` and `setf`.
* lisp/emulation/viper-macs.el (viper-ex-work-buf):
Move `provide` to the end.
(viper-record-kbd-macro): Strength reduce `eval` to `symbol-value`.
(viper-describe-kbd-macros): Return value is not significant.
(viper-keyseq-is-a-possible-macro): Use `seq-some`.
(viper-common-seq-prefix): Use `seq-every-p`.
* lisp/emulation/viper-mous.el: Use lexical-binding.
Remove redundant `:group` arguments.
Move `provide` to the end.
(viper-remember-current-frame): Accept arbitrary ignored args.
(viper-parse-mouse-key): Strength reduce `eval` to `symbol-value`.
Remove unused var `key-spec`.
(viper-bind-mouse-search-key, viper-bind-mouse-insert-key):
Apply de Morgan.
* lisp/emulation/viper-util.el: Move `provide` to the end.
(viper-move-marker-locally, viper-push-onto-ring, viper-save-setting):
Strength reduce `eval` to `symbol-value`.
(viper-event-vector-p, viper-char-symbol-sequence-p, viper-char-array-p):
Use `seq-every-p`.
* lisp/emulation/viper.el (viper-non-hook-settings): Eta-reduce use of
`viper-remember-current-frame`.
-;;; cua-base.el --- emulate CUA key bindings
+;;; cua-base.el --- emulate CUA key bindings -*- lexical-binding: t; -*-
;; Copyright (C) 1997-2021 Free Software Foundation, Inc.
enabled."
:type '(choice (const :tag "Disabled" nil)
(const :tag "Shift region only" shift)
- (other :tag "Enabled" t))
- :group 'cua)
+ (other :tag "Enabled" t)))
(defcustom cua-remap-control-v t
"If non-nil, C-v binding is used for paste (yank).
Also, M-v is mapped to `delete-selection-repeat-replace-region'."
- :type 'boolean
- :group 'cua)
+ :type 'boolean)
(defcustom cua-remap-control-z t
"If non-nil, C-z binding is used for undo."
- :type 'boolean
- :group 'cua)
+ :type 'boolean)
(defcustom cua-highlight-region-shift-only nil
"If non-nil, only highlight region if marked with S-<move>.
is marked using shifted movement keys, and off when the mark is cleared.
But when the mark was set using \\[cua-set-mark], Transient Mark mode
is not turned on."
- :type 'boolean
- :group 'cua)
+ :type 'boolean)
(make-obsolete-variable 'cua-highlight-region-shift-only
'transient-mark-mode "24.4")
succession will also inhibit overriding the prefix key.
If the value is nil, use a shifted prefix key to inhibit the override."
:type '(choice (number :tag "Inhibit delay")
- (const :tag "No delay" nil))
- :group 'cua)
+ (const :tag "No delay" nil)))
(defcustom cua-delete-selection t
"If non-nil, typed text replaces text in the active selection."
:type '(choice (const :tag "Disabled" nil)
- (other :tag "Enabled" t))
- :group 'cua)
+ (other :tag "Enabled" t)))
(defcustom cua-keep-region-after-copy nil
"If non-nil, don't deselect the region after copying."
- :type 'boolean
- :group 'cua)
+ :type 'boolean)
(defcustom cua-toggle-set-mark t
"If non-nil, the `cua-set-mark' command toggles the mark."
:type '(choice (const :tag "Disabled" nil)
- (other :tag "Enabled" t))
- :group 'cua)
+ (other :tag "Enabled" t)))
(defcustom cua-auto-mark-last-change nil
"If non-nil, set implicit mark at position of last buffer change.
This means that \\[universal-argument] \\[cua-set-mark] will jump to the position
of the last buffer change before jumping to the explicit marks on the mark ring.
See `cua-set-mark' for details."
- :type 'boolean
- :group 'cua)
+ :type 'boolean)
(defcustom cua-enable-register-prefix 'not-ctrl-u
"If non-nil, registers are supported via numeric prefix arg.
:type '(choice (const :tag "Disabled" nil)
(const :tag "Enabled, but C-u arg is not a register" not-ctrl-u)
(const :tag "Enabled, but only for C-u arg" ctrl-u-only)
- (other :tag "Enabled" t))
- :group 'cua)
+ (other :tag "Enabled" t)))
(defcustom cua-delete-copy-to-register-0 t
;; FIXME: Obey delete-selection-save-to-register rather than hardcoding
;; register 0.
"If non-nil, save last deleted region or rectangle to register 0."
- :type 'boolean
- :group 'cua)
+ :type 'boolean)
(defcustom cua-enable-region-auto-help nil
"If non-nil, automatically show help for active region."
- :type 'boolean
- :group 'cua)
+ :type 'boolean)
(defcustom cua-enable-modeline-indications nil
"If non-nil, use minor-mode hook to show status in mode line."
- :type 'boolean
- :group 'cua)
+ :type 'boolean)
(defcustom cua-check-pending-input t
"If non-nil, don't override prefix key if input pending.
It is rumored that `input-pending-p' is unreliable under some window
managers, so try setting this to nil, if prefix override doesn't work."
- :type 'boolean
- :group 'cua)
+ :type 'boolean)
(defcustom cua-paste-pop-rotate-temporarily nil
"If non-nil, \\[cua-paste-pop] only rotates the kill-ring temporarily.
replaces the previous text with the next older element on the `kill-ring'.
With prefix arg, \\[universal-argument] \\[yank-pop] inserts the same text as the
most recent \\[yank-pop] (or \\[yank]) command."
- :type 'boolean
- :group 'cua)
+ :type 'boolean)
;;; Rectangle Customization
Note that although rectangles are always DISPLAYED with straight edges, the
buffer is NOT modified, until you execute a command that actually modifies it.
M-p toggles this feature when a rectangle is active."
- :type 'boolean
- :group 'cua)
+ :type 'boolean)
(defcustom cua-auto-tabify-rectangles 1000
"If non-nil, automatically tabify after rectangle commands.
and after the region marked by the rectangle to search."
:type '(choice (number :tag "Auto detect (limit)")
(const :tag "Disabled" nil)
- (other :tag "Enabled" t))
- :group 'cua)
+ (other :tag "Enabled" t)))
(defvar cua-global-keymap) ; forward
(defvar cua--region-keymap) ; forward
+(declare-function cua-clear-rectangle-mark "cua-rect" ())
+(declare-function cua-mouse-set-rectangle-mark "cua-rect" (event))
(defcustom cua-rectangle-mark-key [(control return)]
"Global key used to toggle the cua rectangle mark."
(when (and (boundp 'cua--keymaps-initialized)
cua--keymaps-initialized)
(define-key cua-global-keymap value
- 'cua-set-rectangle-mark)
+ #'cua-set-rectangle-mark)
(when (boundp 'cua--rectangle-keymap)
(define-key cua--rectangle-keymap value
- 'cua-clear-rectangle-mark)
+ #'cua-clear-rectangle-mark)
(define-key cua--region-keymap value
- 'cua-toggle-rectangle-mark))))
- :type 'key-sequence
- :group 'cua)
+ #'cua-toggle-rectangle-mark))))
+ :type 'key-sequence)
(defcustom cua-rectangle-modifier-key 'meta
"Modifier key used for rectangle commands bindings.
:type '(choice (const :tag "Meta key" meta)
(const :tag "Alt key" alt)
(const :tag "Hyper key" hyper)
- (const :tag "Super key" super))
- :group 'cua)
+ (const :tag "Super key" super)))
(defcustom cua-rectangle-terminal-modifier-key 'meta
"Modifier key used for rectangle commands bindings in terminals.
(const :tag "Alt key" alt)
(const :tag "Hyper key" hyper)
(const :tag "Super key" super))
- :group 'cua
:version "27.1")
(defcustom cua-enable-rectangle-auto-help t
"If non-nil, automatically show help for region, rectangle and global mark."
- :type 'boolean
- :group 'cua)
+ :type 'boolean)
(defface cua-rectangle
'((default :inherit region)
(((class color)) :foreground "white" :background "maroon"))
- "Font used by CUA for highlighting the rectangle."
- :group 'cua)
+ "Font used by CUA for highlighting the rectangle.")
(defface cua-rectangle-noselect
'((default :inherit region)
(((class color)) :foreground "white" :background "dimgray"))
- "Font used by CUA for highlighting the non-selected rectangle lines."
- :group 'cua)
+ "Font used by CUA for highlighting the non-selected rectangle lines.")
;;; Global Mark Customization
(defcustom cua-global-mark-keep-visible t
"If non-nil, always keep global mark visible in other window."
- :type 'boolean
- :group 'cua)
+ :type 'boolean)
(defface cua-global-mark
'((((min-colors 88)(class color)) :foreground "black" :background "yellow1")
(((class color)) :foreground "black" :background "yellow")
(t :weight bold))
- "Font used by CUA for highlighting the global mark."
- :group 'cua)
+ "Font used by CUA for highlighting the global mark.")
(defcustom cua-global-mark-blink-cursor-interval 0.20
"Blink cursor at this interval when global mark is active."
:type '(choice (number :tag "Blink interval")
- (const :tag "No blink" nil))
- :group 'cua)
+ (const :tag "No blink" nil)))
;;; Cursor Indication Customization
(defcustom cua-enable-cursor-indications nil
"If non-nil, use different cursor colors for indications."
- :type 'boolean
- :group 'cua)
+ :type 'boolean)
(defcustom cua-normal-cursor-color (or (and (boundp 'initial-cursor-color) initial-cursor-color)
(and (boundp 'initial-frame-alist)
affected. If the value is a cursor TYPE (one of: box, hollow, bar, or hbar),
then only the `cursor-type' property will be affected. If the value is
a cons (TYPE . COLOR), then both properties are affected."
- :initialize 'custom-initialize-default
+ :initialize #'custom-initialize-default
:type '(choice
(color :tag "Color")
(choice :tag "Type"
(const :tag "Vertical bar" bar)
(const :tag "Horizontal bar" hbar)
(const :tag "Hollow box" hollow))
- (color :tag "Color")))
- :group 'cua)
+ (color :tag "Color"))))
(defcustom cua-read-only-cursor-color "darkgreen"
"Cursor color used in read-only buffers, if non-nil.
(const :tag "Vertical bar" bar)
(const :tag "Horizontal bar" hbar)
(const :tag "Hollow box" hollow))
- (color :tag "Color")))
- :group 'cua)
+ (color :tag "Color"))))
(defcustom cua-overwrite-cursor-color "yellow"
"Cursor color used when overwrite mode is set, if non-nil.
(const :tag "Vertical bar" bar)
(const :tag "Horizontal bar" hbar)
(const :tag "Hollow box" hollow))
- (color :tag "Color")))
- :group 'cua)
+ (color :tag "Color"))))
(defcustom cua-global-mark-cursor-color "cyan"
"Indication for active global mark.
(const :tag "Vertical bar" bar)
(const :tag "Horizontal bar" hbar)
(const :tag "Hollow box" hollow))
- (color :tag "Color")))
- :group 'cua)
+ (color :tag "Color"))))
;;; Rectangle support is in cua-rect.el
(<= cua-prefix-override-inhibit-delay 0)
;; In state [1], start [T] and change to state [2]
(run-with-timer cua-prefix-override-inhibit-delay nil
- 'cua--prefix-override-timeout)))
+ #'cua--prefix-override-timeout)))
;; Don't record this command
(setq this-command last-command)
;; Restore the prefix arg
(interactive)
(cua--shift-control-prefix ?\C-x))
+(declare-function delete-selection-repeat-replace-region "delsel" (arg))
+
(defun cua--init-keymaps ()
;; Cache actual rectangle modifier key.
(setq cua--rectangle-modifier-key
cua-rectangle-terminal-modifier-key
cua-rectangle-modifier-key))
;; C-return always toggles rectangle mark
- (define-key cua-global-keymap cua-rectangle-mark-key 'cua-set-rectangle-mark)
+ (define-key cua-global-keymap cua-rectangle-mark-key #'cua-set-rectangle-mark)
(unless (eq cua--rectangle-modifier-key 'meta)
- (cua--M/H-key cua-global-keymap ?\s 'cua-set-rectangle-mark)
+ (cua--M/H-key cua-global-keymap ?\s #'cua-set-rectangle-mark)
(define-key cua-global-keymap
- (vector (list cua--rectangle-modifier-key 'mouse-1)) 'cua-mouse-set-rectangle-mark))
+ (vector (list cua--rectangle-modifier-key 'mouse-1))
+ #'cua-mouse-set-rectangle-mark))
- (define-key cua-global-keymap [(shift control ?\s)] 'cua-toggle-global-mark)
+ (define-key cua-global-keymap [(shift control ?\s)] #'cua-toggle-global-mark)
;; replace region with rectangle or element on kill ring
- (define-key cua-global-keymap [remap yank] 'cua-paste)
- (define-key cua-global-keymap [remap clipboard-yank] 'cua-paste)
- (define-key cua-global-keymap [remap x-clipboard-yank] 'cua-paste)
+ (define-key cua-global-keymap [remap yank] #'cua-paste)
+ (define-key cua-global-keymap [remap clipboard-yank] #'cua-paste)
+ (define-key cua-global-keymap [remap x-clipboard-yank] #'cua-paste)
;; replace current yank with previous kill ring element
- (define-key cua-global-keymap [remap yank-pop] 'cua-paste-pop)
+ (define-key cua-global-keymap [remap yank-pop] #'cua-paste-pop)
;; set mark
- (define-key cua-global-keymap [remap set-mark-command] 'cua-set-mark)
- (define-key cua-global-keymap [remap exchange-point-and-mark] 'cua-exchange-point-and-mark)
+ (define-key cua-global-keymap [remap set-mark-command] #'cua-set-mark)
+ (define-key cua-global-keymap [remap exchange-point-and-mark]
+ #'cua-exchange-point-and-mark)
;; scrolling
- (define-key cua-global-keymap [remap scroll-up] 'cua-scroll-up)
- (define-key cua-global-keymap [remap scroll-down] 'cua-scroll-down)
- (define-key cua-global-keymap [remap scroll-up-command] 'cua-scroll-up)
- (define-key cua-global-keymap [remap scroll-down-command] 'cua-scroll-down)
+ (define-key cua-global-keymap [remap scroll-up] #'cua-scroll-up)
+ (define-key cua-global-keymap [remap scroll-down] #'cua-scroll-down)
+ (define-key cua-global-keymap [remap scroll-up-command] #'cua-scroll-up)
+ (define-key cua-global-keymap [remap scroll-down-command] #'cua-scroll-down)
- (define-key cua--cua-keys-keymap [(control x) timeout] 'kill-region)
- (define-key cua--cua-keys-keymap [(control c) timeout] 'copy-region-as-kill)
+ (define-key cua--cua-keys-keymap [(control x) timeout] #'kill-region)
+ (define-key cua--cua-keys-keymap [(control c) timeout] #'copy-region-as-kill)
(when cua-remap-control-z
- (define-key cua--cua-keys-keymap [(control z)] 'undo))
+ (define-key cua--cua-keys-keymap [(control z)] #'undo))
(when cua-remap-control-v
- (define-key cua--cua-keys-keymap [(control v)] 'yank)
+ (define-key cua--cua-keys-keymap [(control v)] #'yank)
(define-key cua--cua-keys-keymap [(meta v)]
- 'delete-selection-repeat-replace-region))
+ #'delete-selection-repeat-replace-region))
- (define-key cua--prefix-override-keymap [(control x)] 'cua--prefix-override-handler)
- (define-key cua--prefix-override-keymap [(control c)] 'cua--prefix-override-handler)
+ (define-key cua--prefix-override-keymap [(control x)]
+ #'cua--prefix-override-handler)
+ (define-key cua--prefix-override-keymap [(control c)]
+ #'cua--prefix-override-handler)
- (define-key cua--prefix-repeat-keymap [(control x) (control x)] 'cua--prefix-repeat-handler)
- (define-key cua--prefix-repeat-keymap [(control c) (control c)] 'cua--prefix-repeat-handler)
+ (define-key cua--prefix-repeat-keymap [(control x) (control x)]
+ #'cua--prefix-repeat-handler)
+ (define-key cua--prefix-repeat-keymap [(control c) (control c)]
+ #'cua--prefix-repeat-handler)
(dolist (key '(up down left right home end next prior))
- (define-key cua--prefix-repeat-keymap (vector '(control x) key) 'cua--prefix-cut-handler)
- (define-key cua--prefix-repeat-keymap (vector '(control c) key) 'cua--prefix-copy-handler))
+ (define-key cua--prefix-repeat-keymap (vector '(control x) key)
+ #'cua--prefix-cut-handler)
+ (define-key cua--prefix-repeat-keymap (vector '(control c) key)
+ #'cua--prefix-copy-handler))
;; Enable shifted fallbacks for C-x and C-c when region is active
- (define-key cua--region-keymap [(shift control x)] 'cua--shift-control-x-prefix)
- (define-key cua--region-keymap [(shift control c)] 'cua--shift-control-c-prefix)
+ (define-key cua--region-keymap [(shift control x)]
+ #'cua--shift-control-x-prefix)
+ (define-key cua--region-keymap [(shift control c)]
+ #'cua--shift-control-c-prefix)
;; delete current region
- (define-key cua--region-keymap [remap delete-backward-char] 'cua-delete-region)
- (define-key cua--region-keymap [remap backward-delete-char] 'cua-delete-region)
- (define-key cua--region-keymap [remap backward-delete-char-untabify] 'cua-delete-region)
- (define-key cua--region-keymap [remap delete-char] 'cua-delete-region)
- (define-key cua--region-keymap [remap delete-forward-char] 'cua-delete-region)
+ (define-key cua--region-keymap [remap delete-backward-char]
+ #'cua-delete-region)
+ (define-key cua--region-keymap [remap backward-delete-char]
+ #'cua-delete-region)
+ (define-key cua--region-keymap [remap backward-delete-char-untabify]
+ #'cua-delete-region)
+ (define-key cua--region-keymap [remap delete-char]
+ #'cua-delete-region)
+ (define-key cua--region-keymap [remap delete-forward-char]
+ #'cua-delete-region)
;; kill region
- (define-key cua--region-keymap [remap kill-region] 'cua-cut-region)
- (define-key cua--region-keymap [remap clipboard-kill-region] 'cua-cut-region)
+ (define-key cua--region-keymap [remap kill-region] #'cua-cut-region)
+ (define-key cua--region-keymap [remap clipboard-kill-region] #'cua-cut-region)
;; copy region
- (define-key cua--region-keymap [remap copy-region-as-kill] 'cua-copy-region)
- (define-key cua--region-keymap [remap kill-ring-save] 'cua-copy-region)
- (define-key cua--region-keymap [remap clipboard-kill-ring-save] 'cua-copy-region)
+ (define-key cua--region-keymap [remap copy-region-as-kill] #'cua-copy-region)
+ (define-key cua--region-keymap [remap kill-ring-save] #'cua-copy-region)
+ (define-key cua--region-keymap [remap clipboard-kill-ring-save]
+ #'cua-copy-region)
;; cancel current region/rectangle
- (define-key cua--region-keymap [remap keyboard-escape-quit] 'cua-cancel)
- (define-key cua--region-keymap [remap keyboard-quit] 'cua-cancel)
+ (define-key cua--region-keymap [remap keyboard-escape-quit] #'cua-cancel)
+ (define-key cua--region-keymap [remap keyboard-quit] #'cua-cancel)
)
CUA bindings, or `cua-prefix-override-inhibit-delay' to change
the prefix fallback behavior."
:global t
- :group 'cua
:set-after '(cua-enable-modeline-indications
cua-remap-control-v cua-remap-control-z
cua-rectangle-mark-key cua-rectangle-modifier-key)
- :require 'cua-base
:link '(emacs-commentary-link "cua-base.el")
(setq mark-even-if-inactive t)
(setq highlight-nonselected-windows nil)
(if cua-mode
(progn
- (add-hook 'pre-command-hook 'cua--pre-command-handler)
- (add-hook 'post-command-hook 'cua--post-command-handler)
+ (add-hook 'pre-command-hook #'cua--pre-command-handler)
+ (add-hook 'post-command-hook #'cua--post-command-handler)
(if (and cua-enable-modeline-indications (not (assoc 'cua-mode minor-mode-alist)))
(setq minor-mode-alist (cons '(cua-mode cua--status-string) minor-mode-alist)))
(if cua-enable-cursor-indications
(cua--update-indications)))
- (remove-hook 'pre-command-hook 'cua--pre-command-handler)
- (remove-hook 'post-command-hook 'cua--post-command-handler))
+ (remove-hook 'pre-command-hook #'cua--pre-command-handler)
+ (remove-hook 'post-command-hook #'cua--post-command-handler))
(if (not cua-mode)
(setq emulation-mode-map-alists
-;;; cua-gmrk.el --- CUA unified global mark support
+;;; cua-gmrk.el --- CUA unified global mark support -*- lexical-binding: t; -*-
;; Copyright (C) 1997-2021 Free Software Foundation, Inc.
(defun cua--copy-rectangle-to-global-mark (as-text)
;; Copy rectangle to global mark buffer/position.
(if (cua--global-mark-active)
- (let ((src-buf (current-buffer))
+ (let (;; (src-buf (current-buffer))
(text (cua--extract-rectangle)))
(with-current-buffer (marker-buffer cua--global-mark-marker)
(goto-char (marker-position cua--global-mark-marker))
;;; Initialization
(defun cua--init-global-mark ()
- (define-key cua--global-mark-keymap [remap copy-region-as-kill] 'cua-copy-to-global-mark)
- (define-key cua--global-mark-keymap [remap kill-ring-save] 'cua-copy-to-global-mark)
- (define-key cua--global-mark-keymap [remap kill-region] 'cua-cut-to-global-mark)
- (define-key cua--global-mark-keymap [remap yank] 'cua-copy-next-to-global-mark)
-
- (define-key cua--global-mark-keymap [remap keyboard-escape-quit] 'cua-cancel-global-mark)
- (define-key cua--global-mark-keymap [remap keyboard-quit] 'cua-cancel-global-mark)
-
- (define-key cua--global-mark-keymap [(control ?d)] 'cua-cut-next-to-global-mark)
- (define-key cua--global-mark-keymap [remap delete-backward-char] 'cua-delete-backward-char-at-global-mark)
- (define-key cua--global-mark-keymap [remap backward-delete-char] 'cua-delete-backward-char-at-global-mark)
- (define-key cua--global-mark-keymap [remap backward-delete-char-untabify] 'cua-delete-backward-char-at-global-mark)
- (define-key cua--global-mark-keymap [remap self-insert-command] 'cua-insert-char-at-global-mark)
+ (define-key cua--global-mark-keymap [remap copy-region-as-kill]
+ #'cua-copy-to-global-mark)
+ (define-key cua--global-mark-keymap [remap kill-ring-save]
+ #'cua-copy-to-global-mark)
+ (define-key cua--global-mark-keymap [remap kill-region]
+ #'cua-cut-to-global-mark)
+ (define-key cua--global-mark-keymap [remap yank]
+ #'cua-copy-next-to-global-mark)
+
+ (define-key cua--global-mark-keymap [remap keyboard-escape-quit]
+ #'cua-cancel-global-mark)
+ (define-key cua--global-mark-keymap [remap keyboard-quit]
+ #'cua-cancel-global-mark)
+
+ (define-key cua--global-mark-keymap [(control ?d)]
+ #'cua-cut-next-to-global-mark)
+ (define-key cua--global-mark-keymap [remap delete-backward-char]
+ #'cua-delete-backward-char-at-global-mark)
+ (define-key cua--global-mark-keymap [remap backward-delete-char]
+ #'cua-delete-backward-char-at-global-mark)
+ (define-key cua--global-mark-keymap [remap backward-delete-char-untabify]
+ #'cua-delete-backward-char-at-global-mark)
+ (define-key cua--global-mark-keymap [remap self-insert-command]
+ #'cua-insert-char-at-global-mark)
;; Catch self-inserting characters which are "stolen" by other modes
(define-key cua--global-mark-keymap [t]
'(menu-item "sic" cua-insert-char-at-global-mark :filter cua--self-insert-char-p))
- (define-key cua--global-mark-keymap [remap newline] 'cua-insert-newline-at-global-mark)
- (define-key cua--global-mark-keymap [remap newline-and-indent] 'cua-insert-newline-at-global-mark)
- (define-key cua--global-mark-keymap "\r" 'cua-insert-newline-at-global-mark)
+ (define-key cua--global-mark-keymap [remap newline]
+ #'cua-insert-newline-at-global-mark)
+ (define-key cua--global-mark-keymap [remap newline-and-indent]
+ #'cua-insert-newline-at-global-mark)
+ (define-key cua--global-mark-keymap "\r"
+ #'cua-insert-newline-at-global-mark)
- (define-key cua--global-mark-keymap "\t" 'cua-indent-to-global-mark-column)
+ (define-key cua--global-mark-keymap "\t"
+ #'cua-indent-to-global-mark-column)
(setq cua--global-mark-initialized t))
(defvar cua--overlay-keymap
(let ((map (make-sparse-keymap)))
- (define-key map "\r" 'cua-rotate-rectangle)))
+ (define-key map "\r" #'cua-rotate-rectangle)))
(defvar cua--virtual-edges-debug nil)
(e (cua--rect-end-position)))
(undo-boundary)
(push (list 'apply 0 s e
- 'cua--rect-undo-handler
+ #'cua--rect-undo-handler
(copy-sequence cua--rectangle) t s e)
buffer-undo-list))))
(setq cua--restored-rectangle (copy-sequence rect))
(setq cua--buffer-and-point-before-command nil))
(push (list 'apply 0 s (if on e s)
- 'cua--rect-undo-handler rect on s e)
+ #'cua--rect-undo-handler rect on s e)
buffer-undo-list))
;;;###autoload
(cua--M/H-key cua--rectangle-keymap key cmd))
(defun cua--init-rectangles ()
- (define-key cua--rectangle-keymap cua-rectangle-mark-key 'cua-clear-rectangle-mark)
- (define-key cua--region-keymap cua-rectangle-mark-key 'cua-toggle-rectangle-mark)
+ (define-key cua--rectangle-keymap cua-rectangle-mark-key #'cua-clear-rectangle-mark)
+ (define-key cua--region-keymap cua-rectangle-mark-key #'cua-toggle-rectangle-mark)
(unless (eq cua--rectangle-modifier-key 'meta)
- (cua--rect-M/H-key ?\s 'cua-clear-rectangle-mark)
- (cua--M/H-key cua--region-keymap ?\s 'cua-toggle-rectangle-mark))
-
- (define-key cua--rectangle-keymap [remap set-mark-command] 'cua-toggle-rectangle-mark)
-
- (define-key cua--rectangle-keymap [remap forward-char] 'cua-resize-rectangle-right)
- (define-key cua--rectangle-keymap [remap right-char] 'cua-resize-rectangle-right)
- (define-key cua--rectangle-keymap [remap backward-char] 'cua-resize-rectangle-left)
- (define-key cua--rectangle-keymap [remap left-char] 'cua-resize-rectangle-left)
- (define-key cua--rectangle-keymap [remap next-line] 'cua-resize-rectangle-down)
- (define-key cua--rectangle-keymap [remap previous-line] 'cua-resize-rectangle-up)
- (define-key cua--rectangle-keymap [remap end-of-line] 'cua-resize-rectangle-eol)
- (define-key cua--rectangle-keymap [remap beginning-of-line] 'cua-resize-rectangle-bol)
- (define-key cua--rectangle-keymap [remap end-of-buffer] 'cua-resize-rectangle-bot)
- (define-key cua--rectangle-keymap [remap beginning-of-buffer] 'cua-resize-rectangle-top)
- (define-key cua--rectangle-keymap [remap scroll-down] 'cua-resize-rectangle-page-up)
- (define-key cua--rectangle-keymap [remap scroll-up] 'cua-resize-rectangle-page-down)
- (define-key cua--rectangle-keymap [remap scroll-down-command] 'cua-resize-rectangle-page-up)
- (define-key cua--rectangle-keymap [remap scroll-up-command] 'cua-resize-rectangle-page-down)
-
- (define-key cua--rectangle-keymap [remap delete-backward-char] 'cua-delete-char-rectangle)
- (define-key cua--rectangle-keymap [remap backward-delete-char] 'cua-delete-char-rectangle)
- (define-key cua--rectangle-keymap [remap backward-delete-char-untabify] 'cua-delete-char-rectangle)
- (define-key cua--rectangle-keymap [remap self-insert-command] 'cua-insert-char-rectangle)
+ (cua--rect-M/H-key ?\s #'cua-clear-rectangle-mark)
+ (cua--M/H-key cua--region-keymap ?\s #'cua-toggle-rectangle-mark))
+
+ (define-key cua--rectangle-keymap [remap set-mark-command] #'cua-toggle-rectangle-mark)
+
+ (define-key cua--rectangle-keymap [remap forward-char] #'cua-resize-rectangle-right)
+ (define-key cua--rectangle-keymap [remap right-char] #'cua-resize-rectangle-right)
+ (define-key cua--rectangle-keymap [remap backward-char] #'cua-resize-rectangle-left)
+ (define-key cua--rectangle-keymap [remap left-char] #'cua-resize-rectangle-left)
+ (define-key cua--rectangle-keymap [remap next-line] #'cua-resize-rectangle-down)
+ (define-key cua--rectangle-keymap [remap previous-line] #'cua-resize-rectangle-up)
+ (define-key cua--rectangle-keymap [remap end-of-line] #'cua-resize-rectangle-eol)
+ (define-key cua--rectangle-keymap [remap beginning-of-line] #'cua-resize-rectangle-bol)
+ (define-key cua--rectangle-keymap [remap end-of-buffer] #'cua-resize-rectangle-bot)
+ (define-key cua--rectangle-keymap [remap beginning-of-buffer] #'cua-resize-rectangle-top)
+ (define-key cua--rectangle-keymap [remap scroll-down] #'cua-resize-rectangle-page-up)
+ (define-key cua--rectangle-keymap [remap scroll-up] #'cua-resize-rectangle-page-down)
+ (define-key cua--rectangle-keymap [remap scroll-down-command] #'cua-resize-rectangle-page-up)
+ (define-key cua--rectangle-keymap [remap scroll-up-command] #'cua-resize-rectangle-page-down)
+
+ (define-key cua--rectangle-keymap [remap delete-backward-char] #'cua-delete-char-rectangle)
+ (define-key cua--rectangle-keymap [remap backward-delete-char] #'cua-delete-char-rectangle)
+ (define-key cua--rectangle-keymap [remap backward-delete-char-untabify] #'cua-delete-char-rectangle)
+ (define-key cua--rectangle-keymap [remap self-insert-command] #'cua-insert-char-rectangle)
;; Catch self-inserting characters which are "stolen" by other modes
(define-key cua--rectangle-keymap [t]
'(menu-item "sic" cua-insert-char-rectangle :filter cua--self-insert-char-p))
- (define-key cua--rectangle-keymap "\r" 'cua-rotate-rectangle)
- (define-key cua--rectangle-keymap "\t" 'cua-indent-rectangle)
-
- (define-key cua--rectangle-keymap [(control ??)] 'cua-help-for-rectangle)
-
- (define-key cua--rectangle-keymap [mouse-1] 'cua-mouse-set-rectangle-mark)
- (define-key cua--rectangle-keymap [down-mouse-1] 'cua--mouse-ignore)
- (define-key cua--rectangle-keymap [drag-mouse-1] 'cua--mouse-ignore)
- (define-key cua--rectangle-keymap [mouse-3] 'cua-mouse-save-then-kill-rectangle)
- (define-key cua--rectangle-keymap [down-mouse-3] 'cua--mouse-ignore)
- (define-key cua--rectangle-keymap [drag-mouse-3] 'cua--mouse-ignore)
-
- (cua--rect-M/H-key 'up 'cua-move-rectangle-up)
- (cua--rect-M/H-key 'down 'cua-move-rectangle-down)
- (cua--rect-M/H-key 'left 'cua-move-rectangle-left)
- (cua--rect-M/H-key 'right 'cua-move-rectangle-right)
-
- (cua--rect-M/H-key '(control up) 'cua-scroll-rectangle-up)
- (cua--rect-M/H-key '(control down) 'cua-scroll-rectangle-down)
-
- (cua--rect-M/H-key ?a 'cua-align-rectangle)
- (cua--rect-M/H-key ?b 'cua-blank-rectangle)
- (cua--rect-M/H-key ?c 'cua-close-rectangle)
- (cua--rect-M/H-key ?f 'cua-fill-char-rectangle)
- (cua--rect-M/H-key ?i 'cua-incr-rectangle)
- (cua--rect-M/H-key ?k 'cua-cut-rectangle-as-text)
- (cua--rect-M/H-key ?l 'cua-downcase-rectangle)
- (cua--rect-M/H-key ?m 'cua-copy-rectangle-as-text)
- (cua--rect-M/H-key ?n 'cua-sequence-rectangle)
- (cua--rect-M/H-key ?o 'cua-open-rectangle)
- (cua--rect-M/H-key ?p 'cua-toggle-rectangle-virtual-edges)
- (cua--rect-M/H-key ?P 'cua-do-rectangle-padding)
- (cua--rect-M/H-key ?q 'cua-refill-rectangle)
- (cua--rect-M/H-key ?r 'cua-replace-in-rectangle)
- (cua--rect-M/H-key ?R 'cua-reverse-rectangle)
- (cua--rect-M/H-key ?s 'cua-string-rectangle)
- (cua--rect-M/H-key ?t 'cua-text-fill-rectangle)
- (cua--rect-M/H-key ?u 'cua-upcase-rectangle)
- (cua--rect-M/H-key ?| 'cua-shell-command-on-rectangle)
- (cua--rect-M/H-key ?' 'cua-restrict-prefix-rectangle)
- (cua--rect-M/H-key ?/ 'cua-restrict-regexp-rectangle)
+ (define-key cua--rectangle-keymap "\r" #'cua-rotate-rectangle)
+ (define-key cua--rectangle-keymap "\t" #'cua-indent-rectangle)
+
+ (define-key cua--rectangle-keymap [(control ??)] #'cua-help-for-rectangle)
+
+ (define-key cua--rectangle-keymap [mouse-1] #'cua-mouse-set-rectangle-mark)
+ (define-key cua--rectangle-keymap [down-mouse-1] #'cua--mouse-ignore)
+ (define-key cua--rectangle-keymap [drag-mouse-1] #'cua--mouse-ignore)
+ (define-key cua--rectangle-keymap [mouse-3] #'cua-mouse-save-then-kill-rectangle)
+ (define-key cua--rectangle-keymap [down-mouse-3] #'cua--mouse-ignore)
+ (define-key cua--rectangle-keymap [drag-mouse-3] #'cua--mouse-ignore)
+
+ (cua--rect-M/H-key 'up #'cua-move-rectangle-up)
+ (cua--rect-M/H-key 'down #'cua-move-rectangle-down)
+ (cua--rect-M/H-key 'left #'cua-move-rectangle-left)
+ (cua--rect-M/H-key 'right #'cua-move-rectangle-right)
+
+ (cua--rect-M/H-key '(control up) #'cua-scroll-rectangle-up)
+ (cua--rect-M/H-key '(control down) #'cua-scroll-rectangle-down)
+
+ (cua--rect-M/H-key ?a #'cua-align-rectangle)
+ (cua--rect-M/H-key ?b #'cua-blank-rectangle)
+ (cua--rect-M/H-key ?c #'cua-close-rectangle)
+ (cua--rect-M/H-key ?f #'cua-fill-char-rectangle)
+ (cua--rect-M/H-key ?i #'cua-incr-rectangle)
+ (cua--rect-M/H-key ?k #'cua-cut-rectangle-as-text)
+ (cua--rect-M/H-key ?l #'cua-downcase-rectangle)
+ (cua--rect-M/H-key ?m #'cua-copy-rectangle-as-text)
+ (cua--rect-M/H-key ?n #'cua-sequence-rectangle)
+ (cua--rect-M/H-key ?o #'cua-open-rectangle)
+ (cua--rect-M/H-key ?p #'cua-toggle-rectangle-virtual-edges)
+ (cua--rect-M/H-key ?P #'cua-do-rectangle-padding)
+ (cua--rect-M/H-key ?q #'cua-refill-rectangle)
+ (cua--rect-M/H-key ?r #'cua-replace-in-rectangle)
+ (cua--rect-M/H-key ?R #'cua-reverse-rectangle)
+ (cua--rect-M/H-key ?s #'cua-string-rectangle)
+ (cua--rect-M/H-key ?t #'cua-text-fill-rectangle)
+ (cua--rect-M/H-key ?u #'cua-upcase-rectangle)
+ (cua--rect-M/H-key ?| #'cua-shell-command-on-rectangle)
+ (cua--rect-M/H-key ?' #'cua-restrict-prefix-rectangle)
+ (cua--rect-M/H-key ?/ #'cua-restrict-regexp-rectangle)
(setq cua--rectangle-initialized t))
-;;; edt-mapper.el --- create an EDT LK-201 map file for X-Windows Emacs
+;;; edt-mapper.el --- create an EDT LK-201 map file for X-Windows Emacs -*- lexical-binding: t; -*-
;; Copyright (C) 1994-1995, 2000-2021 Free Software Foundation, Inc.
(mapc
(lambda (function-key)
(if (not (lookup-key (current-global-map) function-key))
- (define-key (current-global-map) function-key 'forward-char)))
+ (define-key (current-global-map) function-key #'forward-char)))
'([kp-0] [kp-1] [kp-2] [kp-3] [kp-4]
[kp-5] [kp-6] [kp-7] [kp-8] [kp-9]
[kp-space]
-;;; edt.el --- enhanced EDT keypad mode emulation for GNU Emacs
+;;; edt.el --- enhanced EDT keypad mode emulation for GNU Emacs -*- lexical-binding: t; -*-
;; Copyright (C) 1986, 1992-1995, 2000-2021 Free Software Foundation,
;; Inc.
is set to \"\\f\" when edt-emulation-on is first invoked. This
setting replicates EDT's page delimiter behavior. The original value
is restored when edt-emulation-off is called."
- :type 'boolean
- :group 'edt)
+ :type 'boolean)
(defcustom edt-use-EDT-control-key-bindings nil
"Emacs MUST be restarted for a change in value to take effect!
bindings. If set to nil (the default), EDT control key bindings are
not used and the current Emacs control key bindings are retained for
use within the EDT emulation."
- :type 'boolean
- :group 'edt)
+ :type 'boolean)
(defcustom edt-word-entities '(?\t)
"Specifies the list of EDT word entity characters.
In EDT Emulation movement-by-word commands, each character in the list
will be treated as if it were a separate word."
- :type '(repeat integer)
- :group 'edt)
+ :type '(repeat integer))
(defcustom edt-top-scroll-margin 10
"Scroll margin at the top of the screen.
Interpreted as a percent of the current window size with a default
setting of 10%. If set to 0, top scroll margin is disabled."
- :type 'integer
- :group 'edt)
+ :type 'integer)
(defcustom edt-bottom-scroll-margin 15
"Scroll margin at the bottom of the screen.
Interpreted as a percent of the current window size with a default
setting of 15%. If set to 0, bottom scroll margin is disabled."
- :type 'integer
- :group 'edt)
+ :type 'integer)
;;;
;;; Internal Variables
;;;; EDT Emulation Commands
;;;;
-;;; Almost all of EDT's keypad mode commands have equivalent Emacs
-;;; function counterparts. But many of these counterparts behave
-;;; somewhat differently in Emacs.
-;;;
-;;; So, the following Emacs functions emulate, where practical, the
-;;; exact behavior of the corresponding EDT keypad mode commands. In
-;;; a few cases, the emulation is not exact, but it should be close
-;;; enough for most EDT die-hards.
-;;;
+;; Almost all of EDT's keypad mode commands have equivalent Emacs
+;; function counterparts. But many of these counterparts behave
+;; somewhat differently in Emacs.
+;;
+;; So, the following Emacs functions emulate, where practical, the
+;; exact behavior of the corresponding EDT keypad mode commands. In
+;; a few cases, the emulation is not exact, but it should be close
+;; enough for most EDT die-hards.
+;;
;;;
;;; PAGE
;;;
-;;; Emacs uses the regexp assigned to page-delimiter to determine what
-;;; marks a page break. This is normally "^\f", which causes the
-;;; edt-page command to ignore form feeds not located at the beginning
-;;; of a line. To emulate the EDT PAGE command exactly,
-;;; page-delimiter is set to "\f" when EDT emulation is turned on, and
-;;; restored to its original value when EDT emulation is turned off.
-;;; But this can be overridden if the EDT definition is not desired by
-;;; placing
-;;;
-;;; (setq edt-keep-current-page-delimiter t)
-;;;
-;;; in your init file.
+;; Emacs uses the regexp assigned to page-delimiter to determine what
+;; marks a page break. This is normally "^\f", which causes the
+;; edt-page command to ignore form feeds not located at the beginning
+;; of a line. To emulate the EDT PAGE command exactly,
+;; page-delimiter is set to "\f" when EDT emulation is turned on, and
+;; restored to its original value when EDT emulation is turned off.
+;; But this can be overridden if the EDT definition is not desired by
+;; placing
+;;
+;; (setq edt-keep-current-page-delimiter t)
+;;
+;; in your init file.
(defun edt-page-forward (num)
"Move forward to just after next page delimiter.
;;;
;;; SECT
;;;
-;;; EDT defaults a section size to be 16 lines of its one and only
-;;; 24-line window. That's two-thirds of the window at a time. The
-;;; EDT SECT commands moves the cursor, not the window.
-;;;
-;;; This emulation of EDT's SECT moves the cursor approximately
-;;; two-thirds of the current window at a time.
+;; EDT defaults a section size to be 16 lines of its one and only
+;; 24-line window. That's two-thirds of the window at a time. The
+;; EDT SECT commands moves the cursor, not the window.
+;;
+;; This emulation of EDT's SECT moves the cursor approximately
+;; two-thirds of the current window at a time.
(defun edt-sect-forward (num)
"Move cursor forward two-thirds of a window's number of lines.
;;;
;;; BEGINNING OF LINE
;;;
-;;; EDT's beginning-of-line command is not affected by current
-;;; direction, for some unknown reason.
+;; EDT's beginning-of-line command is not affected by current
+;; direction, for some unknown reason.
(defun edt-beginning-of-line (num)
"Move backward to next beginning of line mark.
;;;
;;; WORD
;;;
-;;; This one is a tad messy. To emulate EDT's behavior everywhere in
-;;; the file (beginning of file, end of file, beginning of line, end
-;;; of line, etc.) it takes a bit of special handling.
-;;;
-;;; The variable edt-word-entities contains a list of characters which
-;;; are to be viewed as distinct words wherever they appear in the
-;;; buffer. This emulates the EDT line mode command SET ENTITY WORD.
+;; This one is a tad messy. To emulate EDT's behavior everywhere in
+;; the file (beginning of file, end of file, beginning of line, end
+;; of line, etc.) it takes a bit of special handling.
+;;
+;; The variable edt-word-entities contains a list of characters which
+;; are to be viewed as distinct words wherever they appear in the
+;; buffer. This emulates the EDT line mode command SET ENTITY WORD.
(defun edt-one-word-forward ()
;;;
;;; LINE
;;;
-;;; When direction is set to BACKUP, LINE behaves just like BEGINNING
-;;; OF LINE in EDT. So edt-line-backward is not really needed as a
-;;; separate function.
+;; When direction is set to BACKUP, LINE behaves just like BEGINNING
+;; OF LINE in EDT. So edt-line-backward is not really needed as a
+;; separate function.
(defun edt-line-backward (num)
"Move backward to next beginning of line mark.
(far (save-excursion
(goto-char bottom)
(point-at-bol (1- height)))))
+ (ignore top left far)
,@body))
;;;
;;;;
;;;
-;;; Several enhancements and additions to EDT keypad mode commands are
-;;; provided here. Some of these have been motivated by similar
-;;; TPU/EVE and EVE-Plus commands. Others are new.
+;; Several enhancements and additions to EDT keypad mode commands are
+;; provided here. Some of these have been motivated by similar
+;; TPU/EVE and EVE-Plus commands. Others are new.
;;;
;;; CHANGE DIRECTION
;;;
;;; SCROLL WINDOW
;;;
-;;; Scroll a window (less one line) at a time. Leave cursor in center of
-;;; window.
+;; Scroll a window (less one line) at a time. Leave cursor in center of
+;; window.
(defun edt-scroll-window-forward (num)
"Scroll forward one window in buffer, less one line.
(fset 'edt-emulation-on (symbol-function 'edt-select-default-global-map))
(edt-select-default-global-map)))
;; Keep the menu bar Buffers menu up-to-date in edt-default-global-map.
- (add-hook 'menu-bar-update-hook 'edt-default-menu-bar-update-buffers))
+ (add-hook 'menu-bar-update-hook #'edt-default-menu-bar-update-buffers))
(defun edt-user-emulation-setup ()
"Setup user custom emulation of DEC's EDT editor."
(edt-setup-user-bindings))
(edt-select-user-global-map)
;; Keep the menu bar Buffers menu up-to-date in edt-user-global-map.
- (add-hook 'menu-bar-update-hook 'edt-user-menu-bar-update-buffers))
+ (add-hook 'menu-bar-update-hook #'edt-user-menu-bar-update-buffers))
(defun edt-select-default-global-map()
"Select default EDT emulation key bindings."
(and b
(with-current-buffer b
(set-buffer-modified-p t)))
- (fset 'help-print-return-message 'ignore)
+ (fset 'help-print-return-message #'ignore)
(call-interactively fun)
(and (get-buffer name)
(get-buffer-window (get-buffer name))
-;;; keypad.el --- simplified keypad bindings
+;;; keypad.el --- simplified keypad bindings -*- lexical-binding: t; -*-
;; Copyright (C) 2002-2021 Free Software Foundation, Inc.
"Specifies the keypad setup for unshifted keypad keys when NumLock is off.
When selecting the plain numeric keypad setup, the character returned by the
decimal key must be specified."
- :set (lambda (symbol value)
+ :set (lambda (_symbol value)
(if value
(keypad-setup value nil nil value)))
- :initialize 'custom-initialize-default
+ :initialize #'custom-initialize-default
:link '(emacs-commentary-link "keypad.el")
:version "22.1"
:type '(choice (const :tag "Plain numeric keypad" numeric)
"Specifies the keypad setup for unshifted keypad keys when NumLock is on.
When selecting the plain numeric keypad setup, the character returned by the
decimal key must be specified."
- :set (lambda (symbol value)
+ :set (lambda (_symbol value)
(if value
(keypad-setup value t nil value)))
- :initialize 'custom-initialize-default
+ :initialize #'custom-initialize-default
:link '(emacs-commentary-link "keypad.el")
:version "22.1"
:type '(choice (const :tag "Plain numeric keypad" numeric)
"Specifies the keypad setup for shifted keypad keys when NumLock is off.
When selecting the plain numeric keypad setup, the character returned by the
decimal key must be specified."
- :set (lambda (symbol value)
+ :set (lambda (_symbol value)
(if value
(keypad-setup value nil t value)))
- :initialize 'custom-initialize-default
+ :initialize #'custom-initialize-default
:link '(emacs-commentary-link "keypad.el")
:version "22.1"
:type '(choice (const :tag "Plain numeric keypad" numeric)
"Specifies the keypad setup for shifted keypad keys when NumLock is off.
When selecting the plain numeric keypad setup, the character returned by the
decimal key must be specified."
- :set (lambda (symbol value)
+ :set (lambda (_symbol value)
(if value
(keypad-setup value t t value)))
- :initialize 'custom-initialize-default
+ :initialize #'custom-initialize-default
:link '(emacs-commentary-link "keypad.el")
:version "22.1"
:type '(choice (const :tag "Plain numeric keypad" numeric)
;;; Code:
-(provide 'viper-cmd)
-
;; Compiler pacifier
(defvar viper-minibuffer-current-face)
(defvar viper-minibuffer-insert-face)
;; desirable that viper-pre-command-sentinel is the last hook and
;; viper-post-command-sentinel is the first hook.
- (remove-hook 'post-command-hook 'viper-post-command-sentinel)
- (add-hook 'post-command-hook 'viper-post-command-sentinel)
- (remove-hook 'pre-command-hook 'viper-pre-command-sentinel)
- (add-hook 'pre-command-hook 'viper-pre-command-sentinel t)
+ (remove-hook 'post-command-hook #'viper-post-command-sentinel)
+ (add-hook 'post-command-hook #'viper-post-command-sentinel)
+ (remove-hook 'pre-command-hook #'viper-pre-command-sentinel)
+ (add-hook 'pre-command-hook #'viper-pre-command-sentinel t)
;; These hooks will be added back if switching to insert/replace mode
(remove-hook 'viper-post-command-hooks
- 'viper-insert-state-post-command-sentinel 'local)
+ #'viper-insert-state-post-command-sentinel 'local)
(remove-hook 'viper-pre-command-hooks
- 'viper-insert-state-pre-command-sentinel 'local)
+ #'viper-insert-state-pre-command-sentinel 'local)
(setq viper-intermediate-command nil)
(cond ((eq new-state 'vi-state)
(cond ((member viper-current-state '(insert-state replace-state))
(viper-move-marker-locally
'viper-last-posn-while-in-insert-state (point))
(add-hook 'viper-post-command-hooks
- 'viper-insert-state-post-command-sentinel t 'local)
+ #'viper-insert-state-post-command-sentinel t 'local)
(add-hook 'viper-pre-command-hooks
- 'viper-insert-state-pre-command-sentinel t 'local))
+ #'viper-insert-state-pre-command-sentinel t 'local))
) ; outermost cond
;; Nothing needs to be done to switch to emacs mode! Just set some
(cond ((memq state '(insert-state replace-state))
(if viper-auto-indent
(progn
- (define-key viper-insert-basic-map "\C-m" 'viper-autoindent)
+ (define-key viper-insert-basic-map "\C-m" #'viper-autoindent)
(if viper-want-emacs-keys-in-insert
;; expert
(define-key viper-insert-basic-map "\C-j" nil)
;; novice
- (define-key viper-insert-basic-map "\C-j" 'viper-autoindent)))
+ (define-key viper-insert-basic-map "\C-j" #'viper-autoindent)))
(define-key viper-insert-basic-map "\C-m" nil)
(define-key viper-insert-basic-map "\C-j" nil))
(if viper-want-ctl-h-help
(progn
- (define-key viper-insert-basic-map "\C-h" 'help-command)
- (define-key viper-replace-map "\C-h" 'help-command))
+ (define-key viper-insert-basic-map "\C-h" #'help-command)
+ (define-key viper-replace-map "\C-h" #'help-command))
(define-key viper-insert-basic-map
- "\C-h" 'viper-del-backward-char-in-insert)
+ "\C-h" #'viper-del-backward-char-in-insert)
(define-key viper-replace-map
- "\C-h" 'viper-del-backward-char-in-replace))
+ "\C-h" #'viper-del-backward-char-in-replace))
;; In XEmacs, C-h overrides backspace, so we make sure it doesn't.
(define-key viper-insert-basic-map
- [backspace] 'viper-del-backward-char-in-insert)
+ [backspace] #'viper-del-backward-char-in-insert)
(define-key viper-replace-map
- [backspace] 'viper-del-backward-char-in-replace)
+ [backspace] #'viper-del-backward-char-in-replace)
) ; end insert/replace case
(t ; Vi state
(setq viper-vi-diehard-minor-mode (not viper-want-emacs-keys-in-vi))
- (if viper-want-ctl-h-help
- (define-key viper-vi-basic-map "\C-h" 'help-command)
- (define-key viper-vi-basic-map "\C-h" 'viper-backward-char))
+ (define-key viper-vi-basic-map "\C-h"
+ (if viper-want-ctl-h-help #'help-command #'viper-backward-char))
;; In XEmacs, C-h overrides backspace, so we make sure it doesn't.
- (define-key viper-vi-basic-map [backspace] 'viper-backward-char))
+ (define-key viper-vi-basic-map [backspace] #'viper-backward-char))
))
(condition-case nil
(let (viper-vi-kbd-minor-mode) ; execute without kbd macros
- (setq result (eval form)))
+ (setq result (eval form t)))
(error
(signal 'quit nil)))
(let ((buff (current-buffer))
result)
(viper-set-mode-vars-for 'emacs-state)
- (setq result (eval form))
+ (setq result (eval form t))
(if (not (equal buff (current-buffer))) ; cmd switched buffer
(with-current-buffer buff
(viper-set-mode-vars-for viper-current-state)))
;; without affecting other functions. Buffer search can now be bound
;; to any character.
-(aset viper-exec-array ?c 'viper-exec-change)
-(aset viper-exec-array ?C 'viper-exec-Change)
-(aset viper-exec-array ?d 'viper-exec-delete)
-(aset viper-exec-array ?D 'viper-exec-Delete)
-(aset viper-exec-array ?y 'viper-exec-yank)
-(aset viper-exec-array ?Y 'viper-exec-Yank)
-(aset viper-exec-array ?r 'viper-exec-dummy)
-(aset viper-exec-array ?! 'viper-exec-bang)
-(aset viper-exec-array ?< 'viper-exec-shift)
-(aset viper-exec-array ?> 'viper-exec-shift)
-(aset viper-exec-array ?= 'viper-exec-equals)
+(aset viper-exec-array ?c #'viper-exec-change)
+(aset viper-exec-array ?C #'viper-exec-Change)
+(aset viper-exec-array ?d #'viper-exec-delete)
+(aset viper-exec-array ?D #'viper-exec-Delete)
+(aset viper-exec-array ?y #'viper-exec-yank)
+(aset viper-exec-array ?Y #'viper-exec-Yank)
+(aset viper-exec-array ?r #'viper-exec-dummy)
+(aset viper-exec-array ?! #'viper-exec-bang)
+(aset viper-exec-array ?< #'viper-exec-shift)
+(aset viper-exec-array ?> #'viper-exec-shift)
+(aset viper-exec-array ?= #'viper-exec-equals)
(defun viper-undo-sentinel (beg end length)
(run-hook-with-args 'viper-undo-functions beg end length))
-(add-hook 'after-change-functions 'viper-undo-sentinel)
+(add-hook 'after-change-functions #'viper-undo-sentinel)
;; Hook used in viper-undo
(defun viper-after-change-undo-hook (beg end _len)
;; some other hooks may be changing various text properties in
;; the buffer in response to 'undo'; so remove this hook to avoid
;; its repeated invocation
- (remove-hook 'viper-undo-functions 'viper-after-change-undo-hook 'local)
+ (remove-hook 'viper-undo-functions #'viper-after-change-undo-hook 'local)
))
(defun viper-undo ()
undo-beg-posn undo-end-posn)
;; the viper-after-change-undo-hook removes itself after the 1st invocation
- (add-hook 'viper-undo-functions 'viper-after-change-undo-hook nil 'local)
+ (add-hook 'viper-undo-functions #'viper-after-change-undo-hook nil 'local)
(undo-start)
(undo-more 2)
;;; Minibuffer business
(defsubst viper-set-minibuffer-style ()
- (add-hook 'minibuffer-setup-hook 'viper-minibuffer-setup-sentinel)
- (add-hook 'post-command-hook 'viper-minibuffer-post-command-hook))
+ (add-hook 'minibuffer-setup-hook #'viper-minibuffer-setup-sentinel)
+ (add-hook 'post-command-hook #'viper-minibuffer-post-command-hook))
(defun viper-minibuffer-setup-sentinel ()
padding (viper-array-to-string (this-command-keys))
temp-msg "")
;; the following tries to be smart about what to put in history
- (if (not (string= val (car (eval history-var))))
- (set history-var (cons val (eval history-var))))
- (if (or (string= (nth 0 (eval history-var)) (nth 1 (eval history-var)))
- (string= (nth 0 (eval history-var)) ""))
- (set history-var (cdr (eval history-var))))
+ (if (not (string= val (car (symbol-value history-var))))
+ (push val (symbol-value history-var)))
+ (if (or (string= (nth 0 (symbol-value history-var))
+ (nth 1 (symbol-value history-var)))
+ (string= (nth 0 (symbol-value history-var)) ""))
+ (pop (symbol-value history-var)))
;; If the user enters nothing but the prev cmd wasn't viper-ex,
;; viper-command-argument, or `! shell-command', this probably means
;; that the user typed something then erased. Return "" in this case, not
viper-sitting-in-replace t
viper-replace-chars-to-delete 0)
(add-hook
- 'viper-after-change-functions 'viper-replace-mode-spy-after t 'local)
+ 'viper-after-change-functions #'viper-replace-mode-spy-after t 'local)
(add-hook
- 'viper-before-change-functions 'viper-replace-mode-spy-before t 'local)
+ 'viper-before-change-functions #'viper-replace-mode-spy-before t 'local)
;; this will get added repeatedly, but no harm
- (add-hook 'after-change-functions 'viper-after-change-sentinel t)
- (add-hook 'before-change-functions 'viper-before-change-sentinel t)
+ (add-hook 'after-change-functions #'viper-after-change-sentinel t)
+ (add-hook 'before-change-functions #'viper-before-change-sentinel t)
(viper-move-marker-locally
'viper-last-posn-in-replace-region (viper-replace-start))
(add-hook
- 'viper-post-command-hooks 'viper-replace-state-post-command-sentinel
+ 'viper-post-command-hooks #'viper-replace-state-post-command-sentinel
t 'local)
(add-hook
- 'viper-pre-command-hooks 'viper-replace-state-pre-command-sentinel t 'local)
+ 'viper-pre-command-hooks #'viper-replace-state-pre-command-sentinel t 'local)
;; guard against a smarty who switched from R-replace to normal replace
(remove-hook
- 'viper-post-command-hooks 'viper-R-state-post-command-sentinel 'local)
+ 'viper-post-command-hooks #'viper-R-state-post-command-sentinel 'local)
(if overwrite-mode (overwrite-mode -1))
)
;; Don't delete anything if current point is past the end of the overlay.
(defun viper-finish-change ()
(remove-hook
- 'viper-after-change-functions 'viper-replace-mode-spy-after 'local)
+ 'viper-after-change-functions #'viper-replace-mode-spy-after 'local)
(remove-hook
- 'viper-before-change-functions 'viper-replace-mode-spy-before 'local)
+ 'viper-before-change-functions #'viper-replace-mode-spy-before 'local)
(remove-hook
- 'viper-post-command-hooks 'viper-replace-state-post-command-sentinel 'local)
+ 'viper-post-command-hooks #'viper-replace-state-post-command-sentinel 'local)
(remove-hook
- 'viper-pre-command-hooks 'viper-replace-state-pre-command-sentinel 'local)
+ 'viper-pre-command-hooks #'viper-replace-state-pre-command-sentinel 'local)
(viper-restore-cursor-color 'after-replace-mode)
(setq viper-sitting-in-replace nil) ; just in case we'll need to know it
(save-excursion
(defun viper-finish-R-mode ()
(remove-hook
- 'viper-post-command-hooks 'viper-R-state-post-command-sentinel 'local)
+ 'viper-post-command-hooks #'viper-R-state-post-command-sentinel 'local)
(remove-hook
- 'viper-pre-command-hooks 'viper-replace-state-pre-command-sentinel 'local)
+ 'viper-pre-command-hooks #'viper-replace-state-pre-command-sentinel 'local)
(viper-downgrade-to-insert))
(defun viper-start-R-mode ()
;; Leave arg as 1, not t: XEmacs insists that it must be a pos number
(overwrite-mode 1)
(add-hook
- 'viper-post-command-hooks 'viper-R-state-post-command-sentinel t 'local)
+ 'viper-post-command-hooks #'viper-R-state-post-command-sentinel t 'local)
(add-hook
- 'viper-pre-command-hooks 'viper-replace-state-pre-command-sentinel t 'local)
+ 'viper-pre-command-hooks #'viper-replace-state-pre-command-sentinel t 'local)
;; guard against a smarty who switched from R-replace to normal replace
(remove-hook
- 'viper-post-command-hooks 'viper-replace-state-post-command-sentinel 'local)
+ 'viper-post-command-hooks #'viper-replace-state-post-command-sentinel 'local)
)
'(viper-command-argument viper-digit-argument viper-repeat))
(setq viper-this-command-keys (this-command-keys)))
(let* ((keymap (let ((keymap (copy-keymap minibuffer-local-map)))
- (define-key keymap [(control ?s)] 'viper-insert-isearch-string)
+ (define-key keymap [(control ?s)]
+ #'viper-insert-isearch-string)
keymap))
(s (viper-read-string-with-history
prompt
(char-to-string viper-buffer-search-char))
(t (error "viper-buffer-search-char: wrong value type, %S"
viper-buffer-search-char)))
- 'viper-command-argument)
- (aset viper-exec-array viper-buffer-search-char 'viper-exec-buffer-search)
+ #'viper-command-argument)
+ (aset viper-exec-array viper-buffer-search-char #'viper-exec-buffer-search)
(setq viper-prefix-commands
(cons viper-buffer-search-char viper-prefix-commands)))
;; Input Mode Indentation
-(define-obsolete-function-alias 'viper-looking-back 'looking-back "24.4")
+(define-obsolete-function-alias 'viper-looking-back #'looking-back "24.4")
(defun viper-forward-indent ()
;; standard value. Otherwise, get the value saved in the alist STORAGE. If
;; STORAGE is nil, use viper-saved-user-settings.
(defun viper-standard-value (symbol &optional storage)
- (or (eval (car (get symbol 'customized-value)))
- (eval (car (get symbol 'saved-value)))
+ (or (eval (car (get symbol 'customized-value)) t)
+ (eval (car (get symbol 'saved-value)) t)
(nth 1 (assoc symbol (or storage viper-saved-user-settings)))))
nil 'delete-other-windows
salutation)))
-
-
-
+(provide 'viper-cmd)
;;; viper-cmd.el ends here
-;;; viper-ex.el --- functions implementing the Ex commands for Viper
+;;; viper-ex.el --- functions implementing the Ex commands for Viper -*- lexical-binding: t; -*-
;; Copyright (C) 1994-1998, 2000-2021 Free Software Foundation, Inc.
;;; Code:
-(provide 'viper-ex)
-
;; Compiler pacifier
(defvar read-file-name-map)
(defvar viper-use-register)
;; Executes the function associated with the command
(defun ex-cmd-execute (cmd)
- (eval (cadr cmd)))
+ (eval (cadr cmd) t))
;; If this is a one-letter magic command, splice in args.
(defun ex-splice-args-in-1-letr-cmd (key list)
"\\)")
shell-file-name)))
"Is the user using a unix-type shell under a non-OS?"
- :type 'boolean
- :group 'viper-ex)
+ :type 'boolean)
(defcustom ex-unix-type-shell-options
(let ((case-fold-search t))
)))
"Options to pass to the Unix-style shell.
Don't put `-c' here, as it is added automatically."
- :type '(choice (const nil) string)
- :group 'viper-ex)
+ :type '(choice (const nil) string))
(defcustom ex-compile-command "make"
"The command to run when the user types :make."
- :type 'string
- :group 'viper-ex)
+ :type 'string)
(defcustom viper-glob-function
(cond (ex-unix-type-shell 'viper-glob-unix-files)
However, if it doesn't work right for some types of Unix shells or some OS,
the user should supply the appropriate function and set this variable to the
corresponding function symbol."
- :type 'symbol
- :group 'viper-ex)
+ :type 'symbol)
;; Remembers the previous Ex tag.
"If t, :n and :b cycles through files and buffers in other window.
Then :N and :B cycles in the current window. If nil, this behavior is
reversed."
- :type 'boolean
- :group 'viper-ex)
+ :type 'boolean)
(defcustom ex-cycle-through-non-files nil
"Cycle through *scratch* and other buffers that don't visit any file."
- :type 'boolean
- :group 'viper-ex)
+ :type 'boolean)
;; Last shell command executed with :! command.
(defvar viper-ex-last-shell-com nil)
(let ((nonstandard-filename-chars "[^-a-zA-Z0-9_./,~$\\]"))
(cond ((file-exists-p filespec) (find-file filespec))
((string-match nonstandard-filename-chars filespec)
- (mapcar 'find-file (funcall viper-glob-function filespec)))
+ (mapcar #'find-file (funcall viper-glob-function filespec)))
(t (find-file filespec)))
))
;; this function fixes ex-history for some commands like ex-read, ex-edit
(defun ex-fixup-history (&rest args)
(setq viper-ex-history
- (cons (mapconcat 'identity args " ") (cdr viper-ex-history))))
+ (cons (mapconcat #'identity args " ") (cdr viper-ex-history))))
;; Ex recover from emacs \#file\#
(cursor-in-echo-area t)
str batch)
(define-key
- minibuffer-local-completion-map " " 'minibuffer-complete-and-exit)
- (define-key minibuffer-local-completion-map "=" 'exit-minibuffer)
+ minibuffer-local-completion-map " " #'minibuffer-complete-and-exit)
+ (define-key minibuffer-local-completion-map "=" #'exit-minibuffer)
(if (viper-set-unread-command-events
(ex-get-inline-cmd-args "[ \t]*[a-zA-Z]*[ \t]*" nil "\C-m"))
(progn
(format "%S" val)
val)))
(if actual-lisp-cmd
- (eval (car (read-from-string actual-lisp-cmd))))
+ (eval (car (read-from-string actual-lisp-cmd)) t))
(if (string= var "fill-column")
(if (> val2 0)
(auto-fill-mode 1)
(with-output-to-temp-buffer " *viper-info*"
(princ lines))))))
+(provide 'viper-ex)
;;; viper-ex.el ends here
-;;; viper-init.el --- some common definitions for Viper
+;;; viper-init.el --- some common definitions for Viper -*- lexical-binding: t; -*-
;; Copyright (C) 1997-2021 Free Software Foundation, Inc.
;; Tell whether we are running as a window application or on a TTY
-(define-obsolete-function-alias 'viper-device-type 'window-system "27.1")
+(define-obsolete-function-alias 'viper-device-type #'window-system "27.1")
(defun viper-color-display-p ()
(condition-case nil
(append (vconcat string) nil))
(defsubst viper-charlist-to-string (list)
- (mapconcat 'char-to-string list ""))
+ (mapconcat #'char-to-string list ""))
;; like char-after/before, but saves typing
(defun viper-char-at-pos (direction &optional offset)
(let ((old-value (if (boundp 'viper-toggle-key)
viper-toggle-key
[(control ?z)])))
- (mapc
- (lambda (buf)
- (with-current-buffer buf
- (when (and (boundp 'viper-insert-basic-map)
- (keymapp viper-insert-basic-map))
- (when old-value
- (define-key viper-insert-basic-map old-value nil))
- (define-key viper-insert-basic-map value 'viper-escape-to-vi))
- (when (and (boundp 'viper-vi-intercept-map)
- (keymapp viper-vi-intercept-map))
- (when old-value
- (define-key viper-vi-intercept-map old-value nil))
- (define-key
- viper-vi-intercept-map value 'viper-toggle-key-action))
- (when (and (boundp 'viper-emacs-intercept-map)
- (keymapp viper-emacs-intercept-map))
- (define-key viper-emacs-intercept-map old-value nil)
- (define-key
- viper-emacs-intercept-map value 'viper-change-state-to-vi))
- ))
- (buffer-list))
- (set-default symbol value)
- )))
+ (dolist (buf (buffer-list))
+ (with-current-buffer buf
+ (when (and (boundp 'viper-insert-basic-map)
+ (keymapp viper-insert-basic-map))
+ (when old-value
+ (define-key viper-insert-basic-map old-value nil))
+ (define-key viper-insert-basic-map value 'viper-escape-to-vi))
+ (when (and (boundp 'viper-vi-intercept-map)
+ (keymapp viper-vi-intercept-map))
+ (when old-value
+ (define-key viper-vi-intercept-map old-value nil))
+ (define-key
+ viper-vi-intercept-map value 'viper-toggle-key-action))
+ (when (and (boundp 'viper-emacs-intercept-map)
+ (keymapp viper-emacs-intercept-map))
+ (define-key viper-emacs-intercept-map old-value nil)
+ (define-key
+ viper-emacs-intercept-map value 'viper-change-state-to-vi))
+ ))
+ (set-default symbol value))))
(defcustom viper-quoted-insert-key "\C-v"
"The key used to quote special characters when inserting them in Insert state."
(let ((i ?\ ))
(while (<= i ?~)
- (define-key viper-insert-diehard-map (make-string 1 i) 'self-insert-command)
+ (define-key viper-insert-diehard-map (string i) #'self-insert-command)
(setq i (1+ i))))
;; Insert mode map when user wants emacs style
The effect is seen in the current buffer only.
Useful for customizing mailer buffers, gnus, etc.
STATE is `vi-state', `insert-state', or `emacs-state'.
-ALIST is of the form ((key . func) (key . func) ...)
+ALIST is of the form ((KEY . FUNC) (KEY . FUNC) ...)
Normally, this would be called from a hook to a major mode or
on a per buffer basis.
Usage:
state by default.
Arguments: (major-mode viper-state keymap)"
- (let ((alist
- (cond ((eq state 'vi-state) 'viper-vi-state-modifier-alist)
- ((eq state 'insert-state) 'viper-insert-state-modifier-alist)
- ((eq state 'emacs-state) 'viper-emacs-state-modifier-alist)))
- elt)
- (if (setq elt (assoc mode (eval alist)))
- (set alist (delq elt (eval alist))))
- (set alist (cons (cons mode keymap) (eval alist)))
+ (let* ((alist
+ (cond ((eq state 'vi-state) 'viper-vi-state-modifier-alist)
+ ((eq state 'insert-state) 'viper-insert-state-modifier-alist)
+ ((eq state 'emacs-state) 'viper-emacs-state-modifier-alist))))
+ (setf (alist-get mode (symbol-value alist)) keymap)
;; Normalization usually doesn't help here, since one needs to
;; normalize in the actual buffer where changes to the keymap are
(cdr mapsrc)))
(defun viper-modify-keymap (map alist)
- "Modifies MAP with bindings specified in the ALIST. The alist has the
-form ((key . function) (key . function) ... )."
- (mapcar (lambda (p) (define-key map (eval (car p)) (cdr p)))
+ "Modifies MAP with bindings specified in the ALIST.
+The ALIST has the form ((KEY . FUNCTION) (KEY . FUNCTION) ... )."
+ (mapcar (lambda (p) (define-key map (eval (car p) t) (cdr p)))
alist))
;;; Code:
-(provide 'viper-macs)
-
;; compiler pacifier
(defvar viper-ex-work-buf)
(defvar viper-custom-file-name)
(require 'viper-util)
(require 'viper-keym)
-
+(require 'seq)
;;; Variables
;; if defining macro for insert, switch there for authentic WYSIWYG
(if ins (viper-change-state-to-insert))
(start-kbd-macro nil)
- (define-key viper-vi-intercept-map "\C-x)" 'viper-end-mapping-kbd-macro)
- (define-key viper-insert-intercept-map "\C-x)" 'viper-end-mapping-kbd-macro)
- (define-key viper-emacs-intercept-map "\C-x)" 'viper-end-mapping-kbd-macro)
+ (define-key viper-vi-intercept-map "\C-x)" #'viper-end-mapping-kbd-macro)
+ (define-key viper-insert-intercept-map "\C-x)"
+ #'viper-end-mapping-kbd-macro)
+ (define-key viper-emacs-intercept-map "\C-x)"
+ #'viper-end-mapping-kbd-macro)
(message "Mapping %S in %s state. Type macro definition followed by `C-x )'"
(viper-display-macro macro-name)
(if ins "Insert" "Vi")))
(list nil (list (cons scope nil)) (cons t nil)))
((stringp scope)
(list (list (cons scope nil)) nil (cons t nil))))))
- (setq old-elt (assoc macro-name (eval macro-alist-var)))
+ (setq old-elt (assoc macro-name (symbol-value macro-alist-var)))
(if (null old-elt)
(progn
(define-key
keymap
(vector (viper-key-to-emacs-key (aref macro-name 0)))
- 'viper-exec-mapped-kbd-macro)
- (setq lis (eval macro-alist-var))
+ #'viper-exec-mapped-kbd-macro)
+ (setq lis (symbol-value macro-alist-var))
(while (and lis (string< (viper-array-to-string (car (car lis)))
(viper-array-to-string macro-name)))
(setq lis2 (cons (car lis) lis2))
(if (viper-char-array-p macro-name)
(setq macro-name (viper-char-array-to-macro macro-name)))
- (setq macro-entry (assoc macro-name (eval macro-alist-var)))
+ (setq macro-entry (assoc macro-name (symbol-value macro-alist-var)))
(if (= (length macro-name) 0)
(error "Can't unmap an empty macro name"))
(if (null macro-entry)
(cdr mode-mapping)
(cdr global-mapping)
(progn
- (set macro-alist-var (delq macro-entry (eval macro-alist-var)))
+ (set macro-alist-var (delq macro-entry
+ (symbol-value macro-alist-var)))
(if (viper-can-release-key (aref macro-name 0)
- (eval macro-alist-var))
+ (symbol-value macro-alist-var))
(define-key
keymap
(vector (viper-key-to-emacs-key (aref macro-name 0)))
(interactive)
(with-output-to-temp-buffer " *viper-info*"
(princ "Macros in Vi state:\n===================\n")
- (mapc 'viper-describe-one-macro viper-vi-kbd-macro-alist)
+ (mapc #'viper-describe-one-macro viper-vi-kbd-macro-alist)
(princ "\n\nMacros in Insert and Replace states:\n====================================\n")
- (mapc 'viper-describe-one-macro viper-insert-kbd-macro-alist)
+ (mapc #'viper-describe-one-macro viper-insert-kbd-macro-alist)
(princ "\n\nMacros in Emacs state:\n======================\n")
- (mapcar 'viper-describe-one-macro viper-emacs-kbd-macro-alist)
+ (mapc #'viper-describe-one-macro viper-emacs-kbd-macro-alist)
))
(defun viper-describe-one-macro (macro)
(viper-display-macro (car macro))))
(princ " ** Buffer-specific:")
(if (viper-kbd-buf-alist macro)
- (mapc 'viper-describe-one-macro-elt (viper-kbd-buf-alist macro))
+ (mapc #'viper-describe-one-macro-elt (viper-kbd-buf-alist macro))
(princ " none\n"))
(princ "\n ** Mode-specific:")
(if (viper-kbd-mode-alist macro)
- (mapc 'viper-describe-one-macro-elt (viper-kbd-mode-alist macro))
+ (mapc #'viper-describe-one-macro-elt (viper-kbd-mode-alist macro))
(princ " none\n"))
(princ "\n ** Global:")
(if (viper-kbd-global-definition macro)
;; check if SEQ is a prefix of some car of an element in ALIST
(defun viper-keyseq-is-a-possible-macro (seq alist)
(let ((converted-seq (viper-events-to-macro seq)))
- (eval (cons 'or
- (mapcar
- (lambda (elt) (viper-prefix-subseq-p converted-seq elt))
- (viper-this-buffer-macros alist))))))
+ (seq-some
+ (lambda (elt) (viper-prefix-subseq-p converted-seq elt))
+ (viper-this-buffer-macros alist))))
;; whether SEQ1 is a prefix of SEQ2
(defun viper-prefix-subseq-p (seq1 seq2)
len)
(if (= (length seqs) 0)
(setq len 0)
- (setq len (apply 'min (mapcar 'length seqs))))
+ (setq len (apply #'min (mapcar #'length seqs))))
(while (< idx len)
- (if (eval (cons 'and
- (mapcar (lambda (s) (equal (elt first idx) (elt s idx)))
- rest)))
+ (if (seq-every-p (lambda (s) (equal (elt first idx) (elt s idx)))
+ rest)
(setq pref (vconcat pref (vector (elt first idx)))))
(setq idx (1+ idx)))
pref))
(defun viper-do-sequence-completion (seq alist compl-message)
(let* ((matches (viper-extract-matching-alist-members seq alist))
- (new-seq (apply 'viper-common-seq-prefix matches))
+ (new-seq (apply #'viper-common-seq-prefix matches))
)
(cond ((and (equal seq new-seq) (= (length matches) 1))
(message "%s (Sole completion)" compl-message)
(defun viper-display-vector-completions (list)
(with-output-to-temp-buffer "*Completions*"
(display-completion-list
- (mapcar 'prin1-to-string
- (mapcar 'viper-display-macro list)))))
+ (mapcar #'prin1-to-string
+ (mapcar #'viper-display-macro list)))))
;; string--do so. Otherwise, do nothing.
(defun viper-display-macro (macro-name-or-body)
(cond ((viper-char-symbol-sequence-p macro-name-or-body)
- (mapconcat 'symbol-name macro-name-or-body ""))
+ (mapconcat #'symbol-name macro-name-or-body ""))
((viper-char-array-p macro-name-or-body)
- (mapconcat 'char-to-string macro-name-or-body ""))
+ (mapconcat #'char-to-string macro-name-or-body ""))
(t macro-name-or-body)))
;; convert sequence of events (that came presumably from emacs kbd macro) into
;; convert strings or arrays of characters to Viper macro form
(defun viper-char-array-to-macro (array)
- (vconcat (mapcar 'viper-event-key (vconcat array))))
+ (vconcat (mapcar #'viper-event-key (vconcat array))))
;; For macros bodies and names, goes over MACRO and checks if all members are
;; names of keys (actually, it only checks if they are symbols or lists
macro)))
(defun viper-macro-to-events (macro-body)
- (vconcat (mapcar 'viper-key-to-emacs-key macro-body)))
+ (vconcat (mapcar #'viper-key-to-emacs-key macro-body)))
\f
(beginning-of-line)
(call-last-kbd-macro)))
-
+(provide 'viper-macs)
;;; viper-macs.el ends here
-;;; viper-mous.el --- mouse support for Viper
+;;; viper-mous.el --- mouse support for Viper -*- lexical-binding: t; -*-
;; Copyright (C) 1994-1997, 2001-2021 Free Software Foundation, Inc.
;;; Code:
-(provide 'viper-mous)
-
;; compiler pacifier
(defvar double-click-time)
(defvar mouse-track-multi-click-time)
Takes two parameters: a COUNT, indicating how many words to return,
and CLICK-COUNT, telling whether this is the first click, a double-click,
or a triple-click."
- :type 'symbol
- :group 'viper-mouse)
+ :type 'symbol)
;; time interval in millisecond within which successive clicks are
;; considered related
500)
"Time interval in millisecond within which successive mouse clicks are
considered related."
- :type 'integer
- :group 'viper-mouse)
+ :type 'integer)
;; Local variable used to toggle wraparound search on click.
(defvar-local viper-mouse-click-search-noerror t)
(prin1-to-string (viper-event-key event)))))
(define-obsolete-function-alias 'viper-event-click-count
- 'event-click-count "28.1")
+ #'event-click-count "28.1")
(declare-function viper-forward-word "viper-cmd" (arg))
(declare-function viper-adjust-window "viper-cmd" ())
(setq arg (1- arg)))
))))
-(defun viper-mouse-catch-frame-switch (event arg)
+(defun viper-mouse-catch-frame-switch (_event arg)
"Catch the event of switching frame.
Usually is bound to a `down-mouse' event to work properly. See sample
bindings in the Viper manual."
;; until you do something other than viper-mouse-click-* command.
;; In XEmacs, you have to manually select frame B (with the mouse click) in
;; order to shift focus to frame B.
-(defsubst viper-remember-current-frame (frame)
- (setq last-command 'handle-switch-frame
+(defun viper-remember-current-frame (&rest _)
+ "Remember the selected frame before the switch-frame event."
+ (setq last-command #'handle-switch-frame
viper-current-frame-saved (selected-frame)))
;; Emacs. EVENT-TYPE is either `up' or `down'. Up returns button-up key; down
;; returns button-down key.
(defun viper-parse-mouse-key (key-var event-type)
- (let ((key (eval key-var))
- button-spec meta-spec shift-spec control-spec key-spec)
+ (let ((key (symbol-value key-var))
+ button-spec meta-spec shift-spec control-spec)
(if (null key)
;; just return nil
()
control-spec
(if (memq 'control key) "C-" ""))
- (setq key-spec
- (vector
- (intern (concat control-spec meta-spec
- shift-spec button-spec)))))))
+ (vector
+ (intern (concat control-spec meta-spec
+ shift-spec button-spec))))))
(defun viper-unbind-mouse-search-key ()
(if viper-mouse-up-search-key-parsed
(viper-parse-mouse-key 'viper-mouse-search-key 'up)
viper-mouse-down-search-key-parsed
(viper-parse-mouse-key 'viper-mouse-search-key 'down))
- (cond ((or (null viper-mouse-up-search-key-parsed)
- (null viper-mouse-down-search-key-parsed))
+ (cond ((not (and viper-mouse-up-search-key-parsed
+ viper-mouse-down-search-key-parsed))
nil) ; just quit
((and (null force)
(key-binding viper-mouse-up-search-key-parsed)
viper-mouse-down-search-key-parsed))
(t
(global-set-key viper-mouse-up-search-key-parsed
- 'viper-mouse-click-search-word)
+ #'viper-mouse-click-search-word)
(global-set-key viper-mouse-down-search-key-parsed
- 'viper-mouse-catch-frame-switch))))
+ #'viper-mouse-catch-frame-switch))))
;; If FORCE, bind even if this mouse action is already bound to something else
(defun viper-bind-mouse-insert-key (&optional force)
(viper-parse-mouse-key 'viper-mouse-insert-key 'up)
viper-mouse-down-insert-key-parsed
(viper-parse-mouse-key 'viper-mouse-insert-key 'down))
- (cond ((or (null viper-mouse-up-insert-key-parsed)
- (null viper-mouse-down-insert-key-parsed))
+ (cond ((not (and viper-mouse-up-insert-key-parsed
+ viper-mouse-down-insert-key-parsed))
nil) ; just quit
((and (null force)
(key-binding viper-mouse-up-insert-key-parsed)
viper-mouse-down-insert-key-parsed))
(t
(global-set-key viper-mouse-up-insert-key-parsed
- 'viper-mouse-click-insert-word)
+ #'viper-mouse-click-insert-word)
(global-set-key viper-mouse-down-insert-key-parsed
- 'viper-mouse-catch-frame-switch))))
+ #'viper-mouse-catch-frame-switch))))
(defun viper-reset-mouse-search-key (symb val)
(viper-unbind-mouse-search-key)
(const :format "%v " shift)
(const control))
(integer :tag "Button"))
- :set 'viper-reset-mouse-search-key
- :group 'viper-mouse)
+ :set #'viper-reset-mouse-search-key)
(defcustom viper-mouse-insert-key '(meta shift 2)
"Key used to click-insert in Viper.
(const :format "%v " shift)
(const control))
(integer :tag "Button"))
- :set 'viper-reset-mouse-insert-key
- :group 'viper-mouse)
+ :set #'viper-reset-mouse-insert-key)
+(provide 'viper-mous)
;;; viper-mous.el ends here
;;; Code:
-(provide 'viper-util)
-
+(require 'seq)
;; Compiler pacifier
(defvar viper-minibuffer-current-face)
\f
-(define-obsolete-function-alias 'viper-overlay-p 'overlayp "27.1")
-(define-obsolete-function-alias 'viper-make-overlay 'make-overlay "27.1")
-(define-obsolete-function-alias 'viper-overlay-live-p 'overlayp "27.1")
-(define-obsolete-function-alias 'viper-move-overlay 'move-overlay "27.1")
-(define-obsolete-function-alias 'viper-overlay-start 'overlay-start "27.1")
-(define-obsolete-function-alias 'viper-overlay-end 'overlay-end "27.1")
-(define-obsolete-function-alias 'viper-overlay-get 'overlay-get "27.1")
-(define-obsolete-function-alias 'viper-overlay-put 'overlay-put "27.1")
-(define-obsolete-function-alias 'viper-read-event 'read-event "27.1")
-(define-obsolete-function-alias 'viper-characterp 'integerp "27.1")
-(define-obsolete-function-alias 'viper-int-to-char 'identity "27.1")
-(define-obsolete-function-alias 'viper-get-face 'facep "27.1")
+(define-obsolete-function-alias 'viper-overlay-p #'overlayp "27.1")
+(define-obsolete-function-alias 'viper-make-overlay #'make-overlay "27.1")
+(define-obsolete-function-alias 'viper-overlay-live-p #'overlayp "27.1")
+(define-obsolete-function-alias 'viper-move-overlay #'move-overlay "27.1")
+(define-obsolete-function-alias 'viper-overlay-start #'overlay-start "27.1")
+(define-obsolete-function-alias 'viper-overlay-end #'overlay-end "27.1")
+(define-obsolete-function-alias 'viper-overlay-get #'overlay-get "27.1")
+(define-obsolete-function-alias 'viper-overlay-put #'overlay-put "27.1")
+(define-obsolete-function-alias 'viper-read-event #'read-event "27.1")
+(define-obsolete-function-alias 'viper-characterp #'integerp "27.1")
+(define-obsolete-function-alias 'viper-int-to-char #'identity "27.1")
+(define-obsolete-function-alias 'viper-get-face #'facep "27.1")
(define-obsolete-function-alias 'viper-color-defined-p
- 'x-color-defined-p "27.1")
+ #'x-color-defined-p "27.1")
(define-obsolete-function-alias 'viper-iconify
- 'iconify-or-deiconify-frame "27.1")
+ #'iconify-or-deiconify-frame "27.1")
;; CHAR is supposed to be a char or an integer (positive or negative)
;; Then, each time this var is used in `viper-move-marker-locally' in a new
;; buffer, a new marker will be created.
(defun viper-move-marker-locally (var pos &optional buffer)
- (if (markerp (eval var))
+ (if (markerp (symbol-value var))
()
(set var (make-marker)))
- (move-marker (eval var) pos buffer))
+ (move-marker (symbol-value var) pos buffer))
;; Print CONDITIONS as a message.
(let ((case (car conditions)) (msg (cdr conditions)))
(if (null msg)
(message "%s" case)
- (message "%s: %s" case (mapconcat 'prin1-to-string msg " ")))
+ (message "%s: %s" case (mapconcat #'prin1-to-string msg " ")))
(beep 1)))
"$"))
tmp2))
(setq tmp (cdr tmp)))
- (reverse (apply 'append tmp2)))))
+ (reverse (apply #'append tmp2)))))
\f
;;; Insertion ring
;; Push item onto ring. The second argument is a ring-variable, not value.
(defun viper-push-onto-ring (item ring-var)
- (or (ring-p (eval ring-var))
- (set ring-var (make-ring (eval (intern (format "%S-size" ring-var))))))
+ (or (ring-p (symbol-value ring-var))
+ (set ring-var (make-ring (symbol-value (intern (format "%S-size" ring-var))))))
(or (null item) ; don't push nil
(and (stringp item) (string= item "")) ; or empty strings
- (equal item (viper-current-ring-item (eval ring-var))) ; or old stuff
+ (equal item (viper-current-ring-item (symbol-value ring-var))) ; or old stuff
;; Since viper-set-destructive-command checks if we are inside
;; viper-repeat, we don't check whether this-command-keys is a `.'. The
;; cmd viper-repeat makes a call to the current function only if `.' is
(and (eq ring-var 'viper-command-ring)
(string-match "\\([0-9]*\e\\|^[ \t]*$\\|escape\\)"
(viper-array-to-string (this-command-keys))))
- (viper-ring-insert (eval ring-var) item))
+ (viper-ring-insert (symbol-value ring-var) item))
)
;; 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)))
+ (var-val (if (boundp var) (symbol-value var)))
(regexp (format "^[^;]*%s[ \t\n]*[a-zA-Z0-9---_']*[ \t\n)]" var-name))
(buf (find-file-noselect (substitute-in-file-name file)))
)
;;; XEmacs compatibility
(define-obsolete-function-alias 'viper-abbreviate-file-name
- 'abbreviate-file-name "27.1")
+ #'abbreviate-file-name "27.1")
(defsubst viper-sit-for-short (val &optional nodisp)
(declare (obsolete nil "28.1"))
(with-current-buffer buf
(and (<= pos (point-max)) (<= (point-min) pos))))))
-(define-obsolete-function-alias 'viper-mark-marker 'mark-marker "27.1")
+(define-obsolete-function-alias 'viper-mark-marker #'mark-marker "27.1")
(defvar viper-saved-mark nil
"Where viper saves mark. This mark is resurrected by m^.")
;; highlighted due to Viper's pushing marks. So, we deactivate marks,
;; unless the user explicitly wants highlighting, e.g., by hitting ''
;; or ``
-(define-obsolete-function-alias 'viper-deactivate-mark 'deactivate-mark "27.1")
+(define-obsolete-function-alias 'viper-deactivate-mark #'deactivate-mark "27.1")
-(define-obsolete-function-alias 'viper-leave-region-active 'ignore "27.1")
+(define-obsolete-function-alias 'viper-leave-region-active #'ignore "27.1")
;; Check if arg is a valid character for register
;; TYPE is a list that can contain `letter', `Letter', and `digit'.
-(define-obsolete-function-alias 'viper-copy-event 'identity "27.1")
+(define-obsolete-function-alias 'viper-copy-event #'identity "27.1")
;; Uses different timeouts for ESC-sequences and others
(defun viper-fast-keysequence-p ()
t)))
(define-obsolete-function-alias 'viper-read-event-convert-to-char
- 'read-event "27.1")
+ #'read-event "27.1")
;; Emacs has a bug in eventp, which causes (eventp nil) to return (nil)
(car (read-from-string
(concat
"?\\"
- (mapconcat 'identity mod-char-list "-\\")
+ (mapconcat #'identity mod-char-list "-\\")
"-"
base-key-name))))
(setq key-name
(intern
(concat
- (mapconcat 'identity mod-char-list "-")
+ (mapconcat #'identity mod-char-list "-")
"-"
base-key-name))))))
))
;; LIS is assumed to be a list of events of characters
-(define-obsolete-function-alias 'viper-eventify-list-xemacs 'ignore "27.1")
+(define-obsolete-function-alias 'viper-eventify-list-xemacs #'ignore "27.1")
;; Arg is a character, an event, a list of events or a sequence of
;; XEmacs only
(defun viper-event-vector-p (vec)
(and (vectorp vec)
- (eval (cons 'and (mapcar (lambda (elt) (if (eventp elt) t)) vec)))))
+ (seq-every-p (lambda (elt) (if (eventp elt) t)) vec)))
;; check if vec is a vector of character symbols
(defun viper-char-symbol-sequence-p (vec)
(and
(sequencep vec)
- (eval
- (cons 'and
- (mapcar (lambda (elt)
- (and (symbolp elt) (= (length (symbol-name elt)) 1)))
- vec)))))
+ (seq-every-p (lambda (elt)
+ (and (symbolp elt) (= (length (symbol-name elt)) 1)))
+ vec)))
(defun viper-char-array-p (array)
- (eval (cons 'and (mapcar 'characterp array))))
+ (seq-every-p #'characterp array))
;; Args can be a sequence of events, a string, or a Viper macro. Will try to
(let (temp temp2)
(cond ((stringp event-seq) event-seq)
((viper-event-vector-p event-seq)
- (setq temp (mapcar 'viper-event-key event-seq))
+ (setq temp (mapcar #'viper-event-key event-seq))
(cond ((viper-char-symbol-sequence-p temp)
- (mapconcat 'symbol-name temp ""))
+ (mapconcat #'symbol-name temp ""))
((and (viper-char-array-p
- (setq temp2 (mapcar 'viper-key-to-character temp))))
- (mapconcat 'char-to-string temp2 ""))
+ (setq temp2 (mapcar #'viper-key-to-character temp))))
+ (mapconcat #'char-to-string temp2 ""))
(t (prin1-to-string (vconcat temp)))))
((viper-char-symbol-sequence-p event-seq)
- (mapconcat 'symbol-name event-seq ""))
+ (mapconcat #'symbol-name event-seq ""))
((and (vectorp event-seq)
(viper-char-array-p
- (setq temp (mapcar 'viper-key-to-character event-seq))))
- (mapconcat 'char-to-string temp ""))
+ (setq temp (mapcar #'viper-key-to-character event-seq))))
+ (mapconcat #'char-to-string temp ""))
(t (prin1-to-string event-seq)))))
(defun viper-key-press-events-to-chars (events)
This option is appropriate if you like Emacs-style words."
:type '(radio (const strict-vi) (const reformed-vi)
(const extended) (const emacs))
- :set 'viper-set-syntax-preference
+ :set #'viper-set-syntax-preference
:group 'viper)
(make-variable-buffer-local 'viper-syntax-preference)
(setq i (1+ i) start (1+ start)))
res))))))
+(provide 'viper-util)
;;; viper-util.el ends here
(if (viper-window-display-p)
(viper--advice-add
'handle-switch-frame :before
- (lambda (&rest _)
- "Remember the selected frame before the switch-frame event."
- (viper-remember-current-frame (selected-frame)))))
+ #'viper-remember-current-frame))
) ; end viper-non-hook-settings
;; The default viper-toggle-key is \C-z; for the novice, it suspends or
;; iconifies Emacs
-(define-key viper-vi-intercept-map viper-toggle-key 'viper-toggle-key-action)
+(define-key viper-vi-intercept-map viper-toggle-key #'viper-toggle-key-action)
(define-key
viper-emacs-intercept-map viper-toggle-key #'viper-change-state-to-vi)