;; Copyright (C) 2015-2020 Free Software Foundation, Inc.
;; Author: Oleh Krehel <ohwoeowho@gmail.com>
-;; 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.
;;; 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
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"
(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"
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.
(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"
(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)
(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."
'(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'."
(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.")
: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."
(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."
(cons (match-beginning group)
(match-end group))
(funcall group))
- wnd) candidates)))))))
+ wnd)
+ candidates)))))))
(nreverse candidates)))
(defvar avy--overlay-offset 0
(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'."
(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)
(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))))
(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.
(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)
(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)))))))
(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)
"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))
(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'.")