diff --git a/lisp/vcursor.el b/lisp/vcursor.el index 595a25381ab..e219dc2d1a5 100644 --- a/lisp/vcursor.el +++ b/lisp/vcursor.el @@ -1,4 +1,4 @@ -;;; vcursor.el --- manipulate an alternative ("virtual") cursor +;;; vcursor.el --- manipulate an alternative ("virtual") cursor -*- lexical-binding: t; -*- ;; Copyright (C) 1994, 1996, 1998, 2001-2021 Free Software Foundation, ;; Inc. @@ -27,24 +27,24 @@ ;; Latest changes ;; ============== ;; -;; - *IMPORTANT* vcursor-key-bindings is now nil by default, to avoid +;; - *IMPORTANT* `vcursor-key-bindings' is now nil by default, to avoid ;; side-effects when the package is loaded. This means no keys are ;; bound by default. Use customize to change it to t to restore ;; the old behavior. (If you do it by hand in .emacs, it ;; must come before vcursor is loaded.) ;; - You can alter the main variables and the vcursor face via ;; M-x customize: go to the Editing group and find Vcursor. -;; - vcursor-auto-disable can now be 'copy (actually any value not nil +;; - `vcursor-auto-disable' can now be 'copy (actually any value not nil ;; or t), which means that copying from the vcursor will be turned ;; off after any operation not involving the vcursor, but the ;; vcursor itself will be left alone. ;; - works on dumb terminals ;; - new keymap vcursor-map for binding to a prefix key -;; - vcursor-compare-windows substantially improved -;; - vcursor-execute-{key,command} much better about using the +;; - `vcursor-compare-windows' substantially improved +;; - `vcursor-execute-{key,command}' much better about using the ;; right keymaps and arranging for the correct windows to be used -;; - vcursor-window-funcall can call functions interactively -;; - vcursor-interpret-input for special effects +;; - `vcursor-window-funcall' can call functions interactively +;; - `vcursor-interpret-input' for special effects ;; ;; Introduction ;; ============ @@ -326,21 +326,18 @@ (defface vcursor '((((class color)) (:foreground "blue" :background "cyan" :underline t)) (t (:inverse-video t :underline t))) - "Face for the virtual cursor." - :group 'vcursor) + "Face for the virtual cursor.") (defcustom vcursor-auto-disable nil "If non-nil, disable the virtual cursor after use. Any non-vcursor command will force `vcursor-disable' to be called. If non-nil but not t, just make sure copying is toggled off, but don't disable the vcursor." - :type '(choice (const t) (const nil) (const copy)) - :group 'vcursor) + :type '(choice (const t) (const nil) (const copy))) (defcustom vcursor-modifiers (list 'control 'shift) "A list of modifiers that are used to define vcursor key bindings." - :type '(repeat symbol) - :group 'vcursor) + :type '(repeat symbol)) ;; Needed for defcustom, must be up here (defun vcursor-cs-binding (base &optional meta) @@ -349,112 +346,114 @@ disable the vcursor." (cons 'meta key) key)))) +;; (defvar vcursor) + (defun vcursor-bind-keys (var value) "Alter the value of the variable VAR to VALUE, binding keys as required. VAR is usually `vcursor-key-bindings'. Normally this function is called on loading vcursor and from the customize package." (set var value) (cond - ((not value));; don't set any key bindings + ((not value)) ;; Don't set any key bindings. ((or (eq value 'oemacs) (and (eq value t) (fboundp 'oemacs-version))) - (global-set-key [C-f1] 'vcursor-toggle-copy) - (global-set-key [C-f2] 'vcursor-copy) - (global-set-key [C-f3] 'vcursor-copy-word) - (global-set-key [C-f4] 'vcursor-copy-line) + (global-set-key [C-f1] #'vcursor-toggle-copy) + (global-set-key [C-f2] #'vcursor-copy) + (global-set-key [C-f3] #'vcursor-copy-word) + (global-set-key [C-f4] #'vcursor-copy-line) - (global-set-key [S-f1] 'vcursor-disable) - (global-set-key [S-f2] 'vcursor-other-window) - (global-set-key [S-f3] 'vcursor-goto) - (global-set-key [S-f4] 'vcursor-swap-point) + (global-set-key [S-f1] #'vcursor-disable) + (global-set-key [S-f2] #'vcursor-other-window) + (global-set-key [S-f3] #'vcursor-goto) + (global-set-key [S-f4] #'vcursor-swap-point) - (global-set-key [C-f5] 'vcursor-backward-char) - (global-set-key [C-f6] 'vcursor-previous-line) - (global-set-key [C-f7] 'vcursor-next-line) - (global-set-key [C-f8] 'vcursor-forward-char) + (global-set-key [C-f5] #'vcursor-backward-char) + (global-set-key [C-f6] #'vcursor-previous-line) + (global-set-key [C-f7] #'vcursor-next-line) + (global-set-key [C-f8] #'vcursor-forward-char) - (global-set-key [M-f5] 'vcursor-beginning-of-line) - (global-set-key [M-f6] 'vcursor-backward-word) - (global-set-key [M-f6] 'vcursor-forward-word) - (global-set-key [M-f8] 'vcursor-end-of-line) + (global-set-key [M-f5] #'vcursor-beginning-of-line) + (global-set-key [M-f6] #'vcursor-backward-word) + (global-set-key [M-f6] #'vcursor-forward-word) + (global-set-key [M-f8] #'vcursor-end-of-line) - (global-set-key [S-f5] 'vcursor-beginning-of-buffer) - (global-set-key [S-f6] 'vcursor-scroll-down) - (global-set-key [S-f7] 'vcursor-scroll-up) - (global-set-key [S-f8] 'vcursor-end-of-buffer) + (global-set-key [S-f5] #'vcursor-beginning-of-buffer) + (global-set-key [S-f6] #'vcursor-scroll-down) + (global-set-key [S-f7] #'vcursor-scroll-up) + (global-set-key [S-f8] #'vcursor-end-of-buffer) - (global-set-key [C-f9] 'vcursor-isearch-forward) + (global-set-key [C-f9] #'vcursor-isearch-forward) - (global-set-key [S-f9] 'vcursor-execute-key) - (global-set-key [S-f10] 'vcursor-execute-command) + (global-set-key [S-f9] #'vcursor-execute-key) + (global-set-key [S-f10] #'vcursor-execute-command) -;;; Partial dictionary of Oemacs key sequences for you to roll your own, -;;; e.g C-S-up: (global-set-key "\M-[\C-f\M-\C-m" 'vcursor-previous-line) -;;; Sequence: Sends: -;;; "\M-[\C-f\M-\C-m" C-S-up -;;; "\M-[\C-f\M-\C-q" C-S-down -;;; "\M-[\C-fs" C-S-left -;;; "\M-[\C-ft" C-S-right -;;; -;;; "\M-[\C-fw" C-S-home -;;; "\M-[\C-b\C-o" S-tab -;;; "\M-[\C-f\M-\C-r" C-S-insert -;;; "\M-[\C-fu" C-S-end -;;; "\M-[\C-f\M-\C-s" C-S-delete -;;; "\M-[\C-f\M-\C-d" C-S-prior -;;; "\M-[\C-fv" C-S-next -;;; -;;; "\M-[\C-f^" C-S-f1 -;;; "\M-[\C-f_" C-S-f2 -;;; "\M-[\C-f`" C-S-f3 -;;; "\M-[\C-fa" C-S-f4 -;;; "\M-[\C-fb" C-S-f5 -;;; "\M-[\C-fc" C-S-f6 -;;; "\M-[\C-fd" C-S-f7 -;;; "\M-[\C-fe" C-S-f8 -;;; "\M-[\C-ff" C-S-f9 -;;; "\M-[\C-fg" C-S-f10 + ;; Partial dictionary of Oemacs key sequences for you to roll your own, + ;; e.g C-S-up: (global-set-key "\M-[\C-f\M-\C-m" 'vcursor-previous-line) + ;; Sequence: Sends: + ;; "\M-[\C-f\M-\C-m" C-S-up + ;; "\M-[\C-f\M-\C-q" C-S-down + ;; "\M-[\C-fs" C-S-left + ;; "\M-[\C-ft" C-S-right + ;; + ;; "\M-[\C-fw" C-S-home + ;; "\M-[\C-b\C-o" S-tab + ;; "\M-[\C-f\M-\C-r" C-S-insert + ;; "\M-[\C-fu" C-S-end + ;; "\M-[\C-f\M-\C-s" C-S-delete + ;; "\M-[\C-f\M-\C-d" C-S-prior + ;; "\M-[\C-fv" C-S-next + ;; + ;; "\M-[\C-f^" C-S-f1 + ;; "\M-[\C-f_" C-S-f2 + ;; "\M-[\C-f`" C-S-f3 + ;; "\M-[\C-fa" C-S-f4 + ;; "\M-[\C-fb" C-S-f5 + ;; "\M-[\C-fc" C-S-f6 + ;; "\M-[\C-fd" C-S-f7 + ;; "\M-[\C-fe" C-S-f8 + ;; "\M-[\C-ff" C-S-f9 + ;; "\M-[\C-fg" C-S-f10 ) (t - (global-set-key (vcursor-cs-binding "up") 'vcursor-previous-line) - (global-set-key (vcursor-cs-binding "down") 'vcursor-next-line) - (global-set-key (vcursor-cs-binding "left") 'vcursor-backward-char) - (global-set-key (vcursor-cs-binding "right") 'vcursor-forward-char) + (global-set-key (vcursor-cs-binding "up") #'vcursor-previous-line) + (global-set-key (vcursor-cs-binding "down") #'vcursor-next-line) + (global-set-key (vcursor-cs-binding "left") #'vcursor-backward-char) + (global-set-key (vcursor-cs-binding "right") #'vcursor-forward-char) - (global-set-key (vcursor-cs-binding "return") 'vcursor-disable) - (global-set-key (vcursor-cs-binding "insert") 'vcursor-copy) - (global-set-key (vcursor-cs-binding "delete") 'vcursor-copy-word) - (global-set-key (vcursor-cs-binding "remove") 'vcursor-copy-word) - (global-set-key (vcursor-cs-binding "tab") 'vcursor-toggle-copy) - (global-set-key (vcursor-cs-binding "backtab") 'vcursor-toggle-copy) - (global-set-key (vcursor-cs-binding "home") 'vcursor-beginning-of-buffer) - (global-set-key (vcursor-cs-binding "up" t) 'vcursor-beginning-of-buffer) - (global-set-key (vcursor-cs-binding "end") 'vcursor-end-of-buffer) - (global-set-key (vcursor-cs-binding "down" t) 'vcursor-end-of-buffer) - (global-set-key (vcursor-cs-binding "prior") 'vcursor-scroll-down) - (global-set-key (vcursor-cs-binding "next") 'vcursor-scroll-up) + (global-set-key (vcursor-cs-binding "return") #'vcursor-disable) + (global-set-key (vcursor-cs-binding "insert") #'vcursor-copy) + (global-set-key (vcursor-cs-binding "delete") #'vcursor-copy-word) + (global-set-key (vcursor-cs-binding "remove") #'vcursor-copy-word) + (global-set-key (vcursor-cs-binding "tab") #'vcursor-toggle-copy) + (global-set-key (vcursor-cs-binding "backtab") #'vcursor-toggle-copy) + (global-set-key (vcursor-cs-binding "home") #'vcursor-beginning-of-buffer) + (global-set-key (vcursor-cs-binding "up" t) #'vcursor-beginning-of-buffer) + (global-set-key (vcursor-cs-binding "end") #'vcursor-end-of-buffer) + (global-set-key (vcursor-cs-binding "down" t) #'vcursor-end-of-buffer) + (global-set-key (vcursor-cs-binding "prior") #'vcursor-scroll-down) + (global-set-key (vcursor-cs-binding "next") #'vcursor-scroll-up) - (global-set-key (vcursor-cs-binding "f6") 'vcursor-other-window) - (global-set-key (vcursor-cs-binding "f7") 'vcursor-goto) + (global-set-key (vcursor-cs-binding "f6") #'vcursor-other-window) + (global-set-key (vcursor-cs-binding "f7") #'vcursor-goto) (global-set-key (vcursor-cs-binding "select") - 'vcursor-swap-point) ; DEC keyboards - (global-set-key (vcursor-cs-binding "tab" t) 'vcursor-swap-point) + #'vcursor-swap-point) ; DEC keyboards + (global-set-key (vcursor-cs-binding "tab" t) #'vcursor-swap-point) (global-set-key (vcursor-cs-binding "find") - 'vcursor-isearch-forward) ; DEC keyboards - (global-set-key (vcursor-cs-binding "f8") 'vcursor-isearch-forward) + #'vcursor-isearch-forward) ; DEC keyboards + (global-set-key (vcursor-cs-binding "f8") #'vcursor-isearch-forward) - (global-set-key (vcursor-cs-binding "left" t) 'vcursor-beginning-of-line) - (global-set-key (vcursor-cs-binding "right" t) 'vcursor-end-of-line) + (global-set-key (vcursor-cs-binding "left" t) #'vcursor-beginning-of-line) + (global-set-key (vcursor-cs-binding "right" t) #'vcursor-end-of-line) - (global-set-key (vcursor-cs-binding "prior" t) 'vcursor-backward-word) - (global-set-key (vcursor-cs-binding "next" t) 'vcursor-forward-word) + (global-set-key (vcursor-cs-binding "prior" t) #'vcursor-backward-word) + (global-set-key (vcursor-cs-binding "next" t) #'vcursor-forward-word) - (global-set-key (vcursor-cs-binding "return" t) 'vcursor-copy-line) + (global-set-key (vcursor-cs-binding "return" t) #'vcursor-copy-line) - (global-set-key (vcursor-cs-binding "f9") 'vcursor-execute-key) - (global-set-key (vcursor-cs-binding "f10") 'vcursor-execute-command) + (global-set-key (vcursor-cs-binding "f9") #'vcursor-execute-key) + (global-set-key (vcursor-cs-binding "f10") #'vcursor-execute-command) ))) (defcustom vcursor-key-bindings nil @@ -465,8 +464,7 @@ define any key bindings. Default is nil." :type '(choice (const t) (const nil) (const xterm) (const oemacs)) - :group 'vcursor - :set 'vcursor-bind-keys + :set #'vcursor-bind-keys :version "20.3") (defcustom vcursor-interpret-input nil @@ -475,13 +473,11 @@ This will cause text insertion to be much slower. Note that no special interpretation of strings is done: \"\C-x\" is a string of four characters. The default is simply to copy strings." :type 'boolean - :group 'vcursor :version "20.3") (defcustom vcursor-string "**>" "String used to show the vcursor position on dumb terminals." :type 'string - :group 'vcursor :version "20.3") (defvar vcursor-overlay nil @@ -501,42 +497,41 @@ scrolling set this. It is used by the `vcursor-auto-disable' code.") (defcustom vcursor-copy-flag nil "Non-nil means moving vcursor should copy characters moved over to point." - :type 'boolean - :group 'vcursor) + :type 'boolean) (defvar vcursor-temp-goal-column nil "Keeps track of temporary goal columns for the virtual cursor.") (defvar vcursor-map (let ((map (make-sparse-keymap))) - (define-key map "t" 'vcursor-use-vcursor-map) + (define-key map "t" #'vcursor-use-vcursor-map) - (define-key map "\C-p" 'vcursor-previous-line) - (define-key map "\C-n" 'vcursor-next-line) - (define-key map "\C-b" 'vcursor-backward-char) - (define-key map "\C-f" 'vcursor-forward-char) + (define-key map "\C-p" #'vcursor-previous-line) + (define-key map "\C-n" #'vcursor-next-line) + (define-key map "\C-b" #'vcursor-backward-char) + (define-key map "\C-f" #'vcursor-forward-char) - (define-key map "\r" 'vcursor-disable) - (define-key map " " 'vcursor-copy) - (define-key map "\C-y" 'vcursor-copy-word) - (define-key map "\C-i" 'vcursor-toggle-copy) - (define-key map "<" 'vcursor-beginning-of-buffer) - (define-key map ">" 'vcursor-end-of-buffer) - (define-key map "\M-v" 'vcursor-scroll-down) - (define-key map "\C-v" 'vcursor-scroll-up) - (define-key map "o" 'vcursor-other-window) - (define-key map "g" 'vcursor-goto) - (define-key map "x" 'vcursor-swap-point) - (define-key map "\C-s" 'vcursor-isearch-forward) - (define-key map "\C-r" 'vcursor-isearch-backward) - (define-key map "\C-a" 'vcursor-beginning-of-line) - (define-key map "\C-e" 'vcursor-end-of-line) - (define-key map "\M-w" 'vcursor-forward-word) - (define-key map "\M-b" 'vcursor-backward-word) - (define-key map "\M-l" 'vcursor-copy-line) - (define-key map "c" 'vcursor-compare-windows) - (define-key map "k" 'vcursor-execute-key) - (define-key map "\M-x" 'vcursor-execute-command) + (define-key map "\r" #'vcursor-disable) + (define-key map " " #'vcursor-copy) + (define-key map "\C-y" #'vcursor-copy-word) + (define-key map "\C-i" #'vcursor-toggle-copy) + (define-key map "<" #'vcursor-beginning-of-buffer) + (define-key map ">" #'vcursor-end-of-buffer) + (define-key map "\M-v" #'vcursor-scroll-down) + (define-key map "\C-v" #'vcursor-scroll-up) + (define-key map "o" #'vcursor-other-window) + (define-key map "g" #'vcursor-goto) + (define-key map "x" #'vcursor-swap-point) + (define-key map "\C-s" #'vcursor-isearch-forward) + (define-key map "\C-r" #'vcursor-isearch-backward) + (define-key map "\C-a" #'vcursor-beginning-of-line) + (define-key map "\C-e" #'vcursor-end-of-line) + (define-key map "\M-w" #'vcursor-forward-word) + (define-key map "\M-b" #'vcursor-backward-word) + (define-key map "\M-l" #'vcursor-copy-line) + (define-key map "c" #'vcursor-compare-windows) + (define-key map "k" #'vcursor-execute-key) + (define-key map "\M-x" #'vcursor-execute-command) map) "Keymap for vcursor command.") ;; This seems unused, but it was done as part of define-prefix-command, @@ -611,7 +606,8 @@ Set `vcursor-window' to the returned value as a side effect." (cond (winok) ; choice 2 ((and vcursor-window ; choice 3 - (not (eq thiswin vcursor-window))) vcursor-window) + (not (eq thiswin vcursor-window))) + vcursor-window) (winbuf) ; choice 4 (new-win (display-buffer (current-buffer) t)) ; choice 5 (t nil))))))) ; default (choice 6) @@ -719,16 +715,14 @@ not be visible otherwise, display it in another window." The vcursor will always appear in an unselected window." (interactive "P") - (vcursor-window-funcall 'scroll-up n) -) + (vcursor-window-funcall #'scroll-up n)) (defun vcursor-scroll-down (&optional n) "Scroll down the vcursor window ARG lines or near full screen if none. The vcursor will always appear in an unselected window." (interactive "P") - (vcursor-window-funcall 'scroll-down n) - ) + (vcursor-window-funcall #'scroll-down n)) (defun vcursor-isearch-forward (&optional rep norecurs) "Perform forward incremental search in the virtual cursor window. @@ -736,7 +730,7 @@ The virtual cursor is moved to the resulting point; the ordinary cursor stays where it was." (interactive "P") - (vcursor-window-funcall 'isearch-forward rep norecurs) + (vcursor-window-funcall #'isearch-forward rep norecurs) ) (defun vcursor-isearch-backward (&optional rep norecurs) @@ -745,7 +739,7 @@ The virtual cursor is moved to the resulting point; the ordinary cursor stays where it was." (interactive "P") - (vcursor-window-funcall 'isearch-backward rep norecurs) + (vcursor-window-funcall #'isearch-backward rep norecurs) ) (defun vcursor-window-funcall (func &rest args) @@ -891,7 +885,7 @@ A prefix argument, if any, means ignore changes in whitespace. The variable `compare-windows-whitespace' controls how whitespace is skipped. If `compare-ignore-case' is non-nil, changes in case are also ignored." (interactive "P") - ;; (vcursor-window-funcall 'compare-windows arg) + ;; (vcursor-window-funcall #'compare-windows arg) (require 'compare-w) (let* (p1 p2 maxp1 maxp2 b1 b2 w2 success @@ -1005,32 +999,32 @@ If `compare-ignore-case' is non-nil, changes in case are also ignored." (defun vcursor-forward-char (arg) "Move the virtual cursor forward ARG characters." (interactive "p") - (vcursor-relative-move 'forward-char arg) + (vcursor-relative-move #'forward-char arg) ) (defun vcursor-backward-char (arg) "Move the virtual cursor backward ARG characters." (interactive "p") - (vcursor-relative-move 'backward-char arg) + (vcursor-relative-move #'backward-char arg) ) (defun vcursor-forward-word (arg) "Move the virtual cursor forward ARG words." (interactive "p") - (vcursor-relative-move 'forward-word arg) + (vcursor-relative-move #'forward-word arg) ) (defun vcursor-backward-word (arg) "Move the virtual cursor backward ARG words." (interactive "p") - (vcursor-relative-move 'backward-word arg) + (vcursor-relative-move #'backward-word arg) ) (defun vcursor-beginning-of-line (arg) "Move the virtual cursor to beginning of its current line. ARG is as for `beginning-of-line'." (interactive "P") - (vcursor-relative-move 'beginning-of-line + (vcursor-relative-move #'beginning-of-line (if arg (prefix-numeric-value arg))) ) @@ -1038,7 +1032,7 @@ ARG is as for `beginning-of-line'." "Move the virtual cursor to end of its current line. ARG is as for `end-of-line'." (interactive "P") - (vcursor-relative-move 'end-of-line + (vcursor-relative-move #'end-of-line (if arg (prefix-numeric-value arg))) ) @@ -1110,7 +1104,7 @@ is called interactively, so prefix argument etc. are usable." (defun vcursor-copy-word (arg) "Copy ARG words from the virtual cursor position to point." (interactive "p") - (vcursor-copy (vcursor-get-char-count 'forward-word arg)) + (vcursor-copy (vcursor-get-char-count #'forward-word arg)) ) (defun vcursor-copy-line (arg) @@ -1123,7 +1117,7 @@ line is treated like ordinary characters." (interactive "P") (let* ((num (prefix-numeric-value arg)) - (count (vcursor-get-char-count 'end-of-line num))) + (count (vcursor-get-char-count #'end-of-line num))) (vcursor-copy (if (or (= count 0) arg) (1+ count) count))) ) @@ -1136,7 +1130,7 @@ line is treated like ordinary characters." (setq vcursor-last-command nil) ) -(add-hook 'post-command-hook 'vcursor-post-command) +(add-hook 'post-command-hook #'vcursor-post-command) (provide 'vcursor)