From 1a3ba9426b1c4973799548416878e3576b751cf0 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Sun, 30 Jun 2024 22:36:15 +0200 Subject: [PATCH] * lisp/avy.el: Minor fixes. --- lisp/avy.el | 117 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 71 insertions(+), 46 deletions(-) diff --git a/lisp/avy.el b/lisp/avy.el index 8bf4f77ad61..cba9348d44b 100644 --- a/lisp/avy.el +++ b/lisp/avy.el @@ -3,9 +3,6 @@ ;; Copyright (C) 2015-2020 Free Software Foundation, Inc. ;; Author: Oleh Krehel -;; URL: https://github.com/abo-abo/avy -;; Version: 0.5.0 -;; Package-Requires: ((emacs "24.1") (cl-lib "0.5")) ;; Keywords: point, location ;; This file is part of GNU Emacs. @@ -26,22 +23,22 @@ ;;; Commentary: ;; ;; With Avy, you can move point to any position in Emacs – even in a -;; different window – using very few keystrokes. For this, you look at +;; different window – using very few keystrokes. For this, you look at ;; the position where you want point to be, invoke Avy, and then enter ;; the sequence of characters displayed at that position. ;; ;; If the position you want to jump to can be determined after only ;; issuing a single keystroke, point is moved to the desired position -;; immediately after that keystroke. In case this isn't possible, the +;; immediately after that keystroke. In case this isn't possible, the ;; sequence of keystrokes you need to enter is comprised of more than -;; one character. Avy uses a decision tree where each candidate position +;; one character. Avy uses a decision tree where each candidate position ;; is a leaf and each edge is described by a character which is distinct -;; per level of the tree. By entering those characters, you navigate the +;; per level of the tree. By entering those characters, you navigate the ;; tree, quickly arriving at the desired candidate position, such that ;; Avy can move point to it. ;; ;; Note that this only makes sense for positions you are able to see -;; when invoking Avy. These kinds of positions are supported: +;; when invoking Avy. These kinds of positions are supported: ;; ;; * character positions ;; * word or subword start positions @@ -76,7 +73,8 @@ If `avy-style' is set to words, make sure there are at least three keys different than the following: a, e, i, o, u, y" :type '(repeat :tag "Keys" (choice (character :tag "char") - (symbol :tag "non-printing key")))) + (symbol :tag "non-printing key"))) + :version "31.1") (defconst avy--key-type '(choice :tag "Command" @@ -99,17 +97,19 @@ keys different than the following: a, e, i, o, u, y" (function :tag "Other command"))) (defcustom avy-keys-alist nil - "Alist of avy-jump commands to `avy-keys' overriding the default `avy-keys'." + "Alist of `avy-jump' commands to `avy-keys' overriding the default `avy-keys'." :type `(alist :key-type ,avy--key-type - :value-type (repeat :tag "Keys" character))) + :value-type (repeat :tag "Keys" character)) + :version "31.1") (defcustom avy-orders-alist '((avy-goto-char . avy-order-closest)) "Alist of candidate ordering functions. Usually, candidates appear in their point position order." :type `(alist :key-type ,avy--key-type - :value-type function)) + :value-type function) + :version "31.1") (defcustom avy-words '("am" "by" "if" "is" "it" "my" "ox" "up" @@ -142,7 +142,8 @@ Usually, candidates appear in their point position order." Every word should contain at least one vowel i.e. one of the following characters: a, e, i, o, u, y They do not have to be sorted but no word should be a prefix of another one." - :type '(repeat string)) + :type '(repeat string) + :version "31.1") (defcustom avy-style 'at-full "The default method of displaying the overlays. @@ -153,10 +154,11 @@ Use `avy-styles-alist' to customize this per-command." (const :tag "At Full" at-full) (const :tag "Post" post) (const :tag "De Bruijn" de-bruijn) - (const :tag "Words" words))) + (const :tag "Words" words)) + :version "31.1") (defcustom avy-styles-alist nil - "Alist of avy-jump commands to the style for each command. + "Alist of `avy-jump' commands to the style for each command. If the commands isn't on the list, `avy-style' is used." :type '(alist :key-type (choice :tag "Command" @@ -183,7 +185,8 @@ If the commands isn't on the list, `avy-style' is used." (const :tag "At Full" at-full) (const :tag "Post" post) (const :tag "De Bruijn" de-bruijn) - (const :tag "Words" words)))) + (const :tag "Words" words))) + :version "31.1") (defcustom avy-dispatch-alist '((?x . avy-action-kill-move) @@ -207,11 +210,13 @@ pressed during the dispatch, ACTION is set to replace the default (const :tag "Mark" avy-action-mark) (const :tag "Copy" avy-action-copy) (const :tag "Kill and move point" avy-action-kill-move) - (const :tag "Kill" avy-action-kill-stay)))) + (const :tag "Kill" avy-action-kill-stay))) + :version "31.1") (defcustom avy-background nil "When non-nil, a gray background will be added during the selection." - :type 'boolean) + :type 'boolean + :version "31.1") (defcustom avy-all-windows t "Determine the list of windows to consider in search of candidates." @@ -219,18 +224,21 @@ pressed during the dispatch, ACTION is set to replace the default '(choice (const :tag "All Frames" all-frames) (const :tag "This Frame" t) - (const :tag "This Window" nil))) + (const :tag "This Window" nil)) + :version "31.1") (defcustom avy-case-fold-search t "Non-nil if searches should ignore case." - :type 'boolean) + :type 'boolean + :version "31.1") (defcustom avy-word-punc-regexp "[!-/:-@[-`{-~]" "Regexp of punctuation chars that count as word starts for `avy-goto-word-1. When nil, punctuation chars will not be matched. \"[!-/:-@[-`{-~]\" will match all printable punctuation chars." - :type 'regexp) + :type 'regexp + :version "31.1") (defcustom avy-goto-word-0-regexp "\\b\\sw" "Regexp that determines positions for `avy-goto-word-0'." @@ -238,26 +246,31 @@ When nil, punctuation chars will not be matched. (const :tag "Default" "\\b\\sw") (const :tag "Symbol" "\\_<\\(\\sw\\|\\s_\\)") (const :tag "Not whitespace" "[^ \r\n\t]+") - (regexp :tag "Regex"))) + (regexp :tag "Regex")) + :version "31.1") (defcustom avy-ignored-modes '(image-mode doc-view-mode pdf-view-mode) "List of modes to ignore when searching for candidates. Typically, these modes don't use the text representation." - :type 'list) + :type '(repeat symbol) + :version "31.1") (defcustom avy-single-candidate-jump t "In case there is only one candidate jumps directly to it." - :type 'boolean) + :type 'boolean + :version "31.1") (defcustom avy-del-last-char-by '(?\b ?\d) - "List of event types, i.e. key presses, that delete the last -character read. The default represents `C-h' and `DEL'. See + "List of event types that delete the last character read. +The default represents `C-h' and `DEL'. See `event-convert-list'." - :type 'list) + :type '(repeat character) + :version "31.1") (defcustom avy-escape-chars '(?\e ?\C-g) "List of characters that quit avy during `read-char'." - :type 'list) + :type '(repeat character) + :version "31.1") (defvar avy-ring (make-ring 20) "Hold the window and point history.") @@ -645,7 +658,8 @@ multiple DISPLAY-FN invocations." :type '(choice (const :tag "Current window" nil) (const :tag "All windows on the current frame" t) - (const :tag "All windows on all frames" all-frames))) + (const :tag "All windows on all frames" all-frames)) + :version "31.1") (defmacro avy-dowindows (flip &rest body) "Depending on FLIP and `avy-all-windows' run BODY in each or selected window." @@ -769,9 +783,9 @@ Set `avy-style' according to COMMAND as well." (declare-function flyspell-correct-word-before-point "flyspell") (defcustom avy-flyspell-correct-function #'flyspell-correct-word-before-point - "Function called to correct word by `avy-action-ispell' when -`flyspell-mode' is enabled." - :type 'function) + "Function for correcting word by `avy-action-ispell'." + :type 'function + :version "31.1") (defun avy-action-ispell (pt) "Auto correct word at PT." @@ -985,7 +999,8 @@ When GROUP is non-nil, (BEG . END) should delimit that regex group." (cons (match-beginning group) (match-end group)) (funcall group)) - wnd) candidates))))))) + wnd) + candidates))))))) (nreverse candidates))) (defvar avy--overlay-offset 0 @@ -1042,7 +1057,8 @@ COMPOSE-FN is a lambda that concatenates the old string at BEG with STR." (defcustom avy-highlight-first nil "When non-nil highlight the first decision char with `avy-lead-face-0'. Do this even when the char is terminating." - :type 'boolean) + :type 'boolean + :version "31.1") (defun avy--key-to-char (c) "If C is no character, translate it using `avy-key-to-char-alist'." @@ -1539,7 +1555,8 @@ When ARG is non-nil, do the opposite of `avy-all-windows'." (defcustom avy-subword-extra-word-chars '(?{ ?= ?} ?* ?: ?> ?<) "A list of characters that should temporarily match \"\\w\". This variable is used by `avy-goto-subword-0' and `avy-goto-subword-1'." - :type '(repeat character)) + :type '(repeat character) + :version "31.1") ;;;###autoload (defun avy-goto-subword-0 (&optional arg predicate beg end) @@ -1572,14 +1589,16 @@ BEG and END narrow the scope where candidates are searched." (and predicate (funcall predicate))) (unless (not (avy--visible-p (point))) (push (cons (cons (point) (1+ (point))) - (selected-window)) window-cands))) + (selected-window)) + window-cands))) (subword-backward)) (and (= (point) ws) (or (null predicate) (and predicate (funcall predicate))) (not (get-char-property (point) 'invisible)) (push (cons (cons (point) (1+ (point))) - (selected-window)) window-cands))) + (selected-window)) + window-cands))) (setq candidates (nconc candidates window-cands)))))) (avy-process candidates)))) @@ -1611,7 +1630,8 @@ Which one depends on variable `subword-mode'." (defcustom avy-indent-line-overlay nil "When non-nil, display line overlay next to the first non-whitespace character. This affects `avy-goto-line'." - :type 'boolean) + :type 'boolean + :version "31.1") (defun avy--line-cands (&optional arg beg end bottom-up) "Get candidates for selecting a line. @@ -1628,7 +1648,8 @@ When BOTTOM-UP is non-nil, display avy candidates from top to bottom" (goto-char (point-min)) (while (< (point) (point-max)) (when (member (get-char-property - (max (1- (point)) ws) 'invisible) '(nil org-link)) + (max (1- (point)) ws) 'invisible) + '(nil org-link)) (push (cons (if (eq avy-style 'post) (line-end-position) @@ -1636,7 +1657,8 @@ When BOTTOM-UP is non-nil, display avy candidates from top to bottom" (when avy-indent-line-overlay (skip-chars-forward " \t")) (point))) - (selected-window)) candidates)) + (selected-window)) + candidates)) (if visual-line-mode (line-move-visual 1 t) (forward-line 1))))))) @@ -1719,7 +1741,7 @@ When BOTTOM-UP is non-nil, display avy candidates from top to bottom" (overlay-put ov 'linum-str str)))) ;; Text may contain those nasty intangible properties, but that ;; shouldn't prevent us from counting those lines. - (let ((inhibit-point-motion-hooks t)) + (let ((cursor-sensor-inhibit (cons 'avy cursor-sensor-inhibit))) (forward-line)) (setq line (1+ line))) (when (display-graphic-p) @@ -1817,11 +1839,12 @@ When BOTTOM-UP is non-nil, display avy candidates from top to bottom" "How to insert the newly copied/cut line." :type '(choice (const :tag "Above" above) - (const :tag "Below" below))) + (const :tag "Below" below)) + :version "31.1") ;;;###autoload (defun avy-goto-end-of-line (&optional arg) - "Call `avy-goto-line' and move to the end of the line." + "Call `avy-goto-line' with ARG and move to the end of the line." (interactive "p") (avy-goto-line arg) (end-of-line)) @@ -2043,11 +2066,13 @@ newline." (defcustom avy-timeout-seconds 0.5 "How many seconds to wait for the second char." - :type 'float) + :type 'float + :version "31.1") (defcustom avy-enter-times-out t - "Whether enter exits avy-goto-char-timer early. If nil it matches newline" - :type 'boolean) + "Whether \\`RET' exits `avy-goto-char-timer' early." + :type 'boolean + :version "31.1") (defvar avy-text "" "Store the input read by `avy--read-candidates'.") -- 2.39.2