Compare commits

..

No commits in common. "master" and "0.2.0" have entirely different histories.

9 changed files with 619 additions and 2691 deletions

2
.github/FUNDING.yml vendored
View File

@ -1,2 +0,0 @@
liberapay: abo-abo
patreon: abo_abo

View File

@ -3,21 +3,18 @@ emacs ?= emacs
LOAD = -l avy.el -l avy-test.el LOAD = -l avy.el -l avy-test.el
.PHONY: all test clean checkdoc .PHONY: all test clean
all: compile test checkdoc all: test
test: test:
$(emacs) -batch $(LOAD) -f ert-run-tests-batch-and-exit $(emacs) -batch $(LOAD) -f ert-run-tests-batch-and-exit
checkdoc:
$(emacs) -batch -l targets/checkdoc.el
compile: compile:
$(emacs) -batch -l targets/avy-init.el $(emacs) -batch -l avy-init.el
run: run:
$(emacs) -Q -l targets/avy-init.el $(emacs) -Q -l avy-init.el
clean: clean:
rm -f *.elc rm -f *.elc

View File

@ -1,12 +1,8 @@
[![GNU ELPA](https://elpa.gnu.org/packages/avy.svg)](https://elpa.gnu.org/packages/avy.html)
[![MELPA](https://melpa.org/packages/avy-badge.svg)](https://melpa.org/#/avy)
[![MELPA Stable](https://stable.melpa.org/packages/avy-badge.svg)](https://stable.melpa.org/#/avy)
## Introduction ## Introduction
`avy` is a GNU Emacs package for jumping to visible text using a char-based decision tree. See also [ace-jump-mode](https://github.com/winterTTr/ace-jump-mode) and [vim-easymotion](https://github.com/Lokaltog/vim-easymotion) - `avy` uses the same idea. `avy-jump` is a GNU Emacs package for jumping to visible text using a char-based decision tree. See also [ace-jump-mode](https://github.com/winterTTr/ace-jump-mode) and [vim-easymotion](https://github.com/Lokaltog/vim-easymotion) - `avy-jump` uses the same idea.
![logo](https://raw.githubusercontent.com/wiki/abo-abo/avy/images/avy-avatar-1.png) ![logo](https://raw.githubusercontent.com/wiki/abo-abo/avy-jump/images/avy-avatar-1.png)
## Command overview ## Command overview
@ -17,12 +13,12 @@ You can bind some of these useful commands in your config.
> Input one char, jump to it with a tree. > Input one char, jump to it with a tree.
```elisp ```elisp
(global-set-key (kbd "C-:") 'avy-goto-char) (global-set-key (kbd "π") 'avy-goto-char)
``` ```
After <kbd>C-: b</kbd>: After <kbd>πb</kbd>:
![avy-goto-char](https://raw.githubusercontent.com/wiki/nloyola/avy/images/avy-goto-char.png) ![avy-goto-char](http://oremacs.com/download/avi-goto-char.png)
### `avy-goto-char-2` ### `avy-goto-char-2`
@ -38,13 +34,6 @@ After <kbd>C-' bu</kbd>:
![avy-goto-char-2](http://oremacs.com/download/avi-goto-char-2.png) ![avy-goto-char-2](http://oremacs.com/download/avi-goto-char-2.png)
### `avy-goto-char-timer`
> Input an arbitrary amount of consecutive chars, jump to the first one with a tree.
This is a more flexible version of `avy-goto-char-2`. First part works similarly to `isearch`: you type a query and it's highlighted dynamically on the screen. When you stop typing for `avy-timeout-seconds` (0.5s by default), you'll be able to select one of the candidates with `avy`. As you're inputting characters, you can use `C-h` (backspace) or `DEL` (delete) to
forget the last typed character and `RET` to end the input sequence immediately and select a candidate.
### `avy-goto-line` ### `avy-goto-line`
> Input zero chars, jump to a line start with a tree. > Input zero chars, jump to a line start with a tree.
@ -57,8 +46,6 @@ After <kbd>M-g f</kbd>:
![avy-goto-line](http://oremacs.com/download/avi-goto-line.png) ![avy-goto-line](http://oremacs.com/download/avi-goto-line.png)
You can actually replace the <kbd>M-g g</kbd> binding of `goto-line`, since if you enter a digit for `avy-goto-line`, it will switch to `goto-line` with that digit already entered.
### `avy-goto-word-1` ### `avy-goto-word-1`
> Input one char at word start, jump to a word start with a tree. > Input one char at word start, jump to a word start with a tree.
@ -85,10 +72,6 @@ After <kbd>M-g e</kbd>:
![avy-goto-word-0](http://oremacs.com/download/avi-goto-word-0.png) ![avy-goto-word-0](http://oremacs.com/download/avi-goto-word-0.png)
### Org-mode commands
* `avy-org-goto-heading-timer`: Type part of an Org heading. When you stop typing, if only one heading on the screen matches, it will be jumped to; if more than one matches, you can jump to a heading with Avy. This is like `avy-goto-char-timer` but for Org headings.
* `avy-org-refile-as-child`: With point in an entry you want to refile, run this command, select a heading with Avy, and the entry will be refiled as its first child heading. This makes it quick and easy to refile to headings that are visible on-screen, even to other windows or buffers.
### Other commands ### Other commands
@ -100,29 +83,18 @@ You add this to your config to bind some stuff:
```elisp ```elisp
(avy-setup-default) (avy-setup-default)
(global-set-key (kbd "C-c C-j") 'avy-resume)
``` ```
It will bind, for example, `avy-isearch` to <kbd>C-'</kbd> in `isearch-mode-map`, so that you can select one of the currently visible `isearch` candidates using `avy`. It will bind, for example, `avy-isearch` to <kbd>C-'</kbd> in `isearch-mode-map`, so that you can select one of the currently visible `isearch` candidates using `avy`.
### Customization ### Style customization
See the comprehensive custom variable list on [the defcustom wiki page](https://github.com/abo-abo/avy/wiki/defcustom). There are four styles of overlay functions to choose from. You can choose to use one style for all functions, or you can select a different style for each function. Customize `avy-style` and `avy-styles-alist` respectively for this.
The styles to choose from:
See how to write your own avy commands on [the custom-commands wiki page](https://github.com/abo-abo/avy/wiki/custom-commands). - pre: the full path will be displayed before target, leaving all original text
- at: the single character path will be displayed on target, obscuring the target
- at-full: the full path will be displayed on target, obscuring the target and the text behind it
- post: the full path will be displayed after target, leaving all original text
## Contributing At first it seems that `pre` and `post` are advantageous over `at` and `at-full`, since you can still see the original text with them. However, they make the text shift a bit. If you don't like that, use either `at` or `at-full`.
### Copyright Assignment
Avy is subject to the same [copyright assignment](http://www.gnu.org/prep/maintain/html_node/Copyright-Papers.html) policy as Emacs itself, org-mode, CEDET and other packages in [GNU ELPA](http://elpa.gnu.org/packages/). Any [legally significant](http://www.gnu.org/prep/maintain/html_node/Legally-Significant.html#Legally-Significant) contributions can only be accepted after the author has completed their paperwork. Please see [the request form](http://git.savannah.gnu.org/cgit/gnulib.git/tree/doc/Copyright/request-assign.future) if you want to proceed.
The copyright assignment isn't a big deal, it just says that the copyright for your submitted changes to Emacs belongs to the FSF. This assignment works for all projects related to Emacs. To obtain it, you need to send one email, then send one letter (if you live in the US, it's digital), and wait for some time (in my case, I had to wait for one month).
### Style
The basic code style guide is to use `(setq indent-tabs-mode nil)`. It is provided for you in [.dir-locals.el](https://github.com/abo-abo/avy/blob/master/.dir-locals.el), please obey it.
Before submitting the change, run `make compile` and `make test` to make sure that it doesn't introduce new compile warnings or test failures. Also run `make checkdoc` to see that your changes obey the documentation guidelines.
Use your own judgment for the commit messages, I recommend a verbose style using `magit-commit-add-log`.

View File

@ -20,7 +20,7 @@
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
(add-to-list 'load-path default-directory) (add-to-list 'load-path default-directory)
(mapc #'byte-compile-file '("avy.el")) (mapc #'byte-compile-file '("avy.el" "avy-jump.el"))
(require 'avy) (require 'avy-jump)
(global-set-key (kbd "C-c j") 'avy-goto-char) (global-set-key (kbd "C-c j") 'avy-goto-char)
(global-set-key (kbd "C-'") 'avy-goto-char-2) (global-set-key (kbd "C-'") 'avy-goto-char-2)

579
avy-jump.el Normal file
View File

@ -0,0 +1,579 @@
;;; avy-jump.el --- jump to things tree-style. -*- lexical-binding: t -*-
;; Copyright (C) 2015 Free Software Foundation, Inc.
;; Author: Oleh Krehel
;; This file is part of GNU Emacs.
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; For a full copy of the GNU General Public License
;; see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; This package offers various commands for navigating to things using `avy'.
;; They are in the "Commands" outline.
;;; Code:
;;* Requires
(require 'cl-lib)
(require 'avy)
;;* Customization
(defgroup avy-jump nil
"Jump to things tree-style."
:group 'convenience
:prefix "avy-")
(defcustom avy-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)
"Default keys for jumping."
:type '(repeat :tag "Keys" character))
(defcustom avy-keys-alist nil
"Alist of avy-jump commands to `avy-keys' overriding the default `avy-keys'."
:type '(alist
:key-type (choice :tag "Command"
(const avy-goto-char)
(const avy-goto-char-2)
(const avy-isearch)
(const avy-goto-line)
(const avy-goto-subword-0)
(const avy-goto-subword-1)
(const avy-goto-word-0)
(const avy-goto-word-1)
(const avy-copy-line)
(const avy-copy-region)
(const avy-move-line))
:value-type (repeat :tag "Keys" character)))
(defcustom avy-style 'pre
"The default method of displaying the overlays.
Use `avy-styles-alist' to customize this per-command."
:type '(choice
(const :tag "Pre" pre)
(const :tag "At" at)
(const :tag "At Full" at-full)
(const :tag "Post" post)))
(defcustom avy-styles-alist nil
"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 avy-goto-char)
(const avy-goto-char-2)
(const avy-isearch)
(const avy-goto-line)
(const avy-goto-subword-0)
(const avy-goto-subword-1)
(const avy-goto-word-0)
(const avy-goto-word-1)
(const avy-copy-line)
(const avy-copy-region)
(const avy-move-line))
:value-type (choice
(const :tag "Pre" pre)
(const :tag "At" at)
(const :tag "At Full" at-full)
(const :tag "Post" post))))
(defmacro avy--with-avy-keys (command &rest body)
"Set `avy-keys' according to COMMAND and execute BODY."
(declare (indent 1))
`(let ((avy-keys (or (cdr (assq ',command avy-keys-alist))
avy-keys))
(avy-style (or (cdr (assq ',command avy-styles-alist))
avy-style)))
,@body))
(defcustom avy-background nil
"When non-nil, a gray background will be added during the selection."
:type 'boolean)
(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)
(defface avy-lead-face
'((t (:foreground "white" :background "#e52b50")))
"Face used for the leading chars.")
(defface avy-background-face
'((t (:foreground "gray40")))
"Face for whole window background during selection.")
;;* Internals
(defcustom avy-all-windows t
"When non-nil, loop though all windows for candidates."
:type 'boolean)
(defmacro avy-dowindows (flip &rest body)
"Depending on FLIP and `avy-all-windows' run BODY in each or selected window."
(declare (indent 1))
`(let ((avy-all-windows (if ,flip
(not avy-all-windows)
avy-all-windows)))
(dolist (wnd (if avy-all-windows
(cons (selected-window)
(delete (selected-window) (window-list)))
(list (selected-window))))
(with-selected-window wnd
(unless (memq major-mode '(image-mode doc-view-mode))
,@body)))))
(defun avy--goto (x)
"Goto X.
X is (POS . WND)
POS is either a position or (BEG . END)."
(if (null x)
(message "zero candidates")
(select-window (cdr x))
(let ((pt (car x)))
(when (consp pt)
(setq pt (car pt)))
(unless (= pt (point)) (push-mark))
(goto-char pt))))
(defun avy--process (candidates overlay-fn)
"Select one of CANDIDATES using `avy-read'.
Use OVERLAY-FN to visualize the decision overlay."
(unwind-protect
(cl-case (length candidates)
(0
nil)
(1
(car candidates))
(t
(avy--make-backgrounds
(if avy-all-windows
(window-list)
(list (selected-window))))
(avy-read (avy-tree candidates avy-keys)
overlay-fn
#'avy--remove-leading-chars)))
(avy--done)))
(defvar avy--overlays-back nil
"Hold overlays for when `avy-background' is t.")
(defun avy--make-backgrounds (wnd-list)
"Create a dim background overlay for each window on WND-LIST."
(when avy-background
(setq avy--overlays-back
(mapcar (lambda (w)
(let ((ol (make-overlay
(window-start w)
(window-end w)
(window-buffer w))))
(overlay-put ol 'face 'avy-background-face)
(overlay-put ol 'window w)
ol))
wnd-list))))
(defun avy--done ()
"Clean up overlays."
(mapc #'delete-overlay avy--overlays-back)
(setq avy--overlays-back nil)
(avy--remove-leading-chars))
(defun avy--regex-candidates (regex &optional beg end pred)
"Return all elements that match REGEX.
Each element of the list is ((BEG . END) . WND)
When PRED is non-nil, it's a filter for matching point positions."
(let (candidates)
(avy-dowindows nil
(let ((we (or end (window-end (selected-window) t))))
(save-excursion
(goto-char (or beg (window-start)))
(while (re-search-forward regex we t)
(unless (get-char-property (point) 'invisible)
(when (or (null pred)
(funcall pred))
(push (cons (cons (match-beginning 0)
(match-end 0))
wnd) candidates)))))))
(nreverse candidates)))
(defvar avy--overlay-offset 0
"The offset to apply in `avy--overlay'.")
(defvar avy--overlays-lead nil
"Hold overlays for leading chars.")
(defun avy--remove-leading-chars ()
"Remove leading char overlays."
(mapc #'delete-overlay avy--overlays-lead)
(setq avy--overlays-lead nil))
(defun avy--overlay (str pt wnd)
"Create an overlay with STR at PT in WND."
(when (<= (1+ pt) (with-selected-window wnd (point-max)))
(let* ((pt (+ pt avy--overlay-offset))
(ol (make-overlay pt (1+ pt) (window-buffer wnd)))
(old-str (with-selected-window wnd
(buffer-substring pt (1+ pt)))))
(when avy-background
(setq old-str (propertize
old-str 'face 'avy-background-face)))
(overlay-put ol 'window wnd)
(overlay-put ol 'display (concat str old-str))
(push ol avy--overlays-lead))))
(defun avy--overlay-pre (path leaf)
"Create an overlay with PATH at LEAF.
PATH is a list of keys from tree root to LEAF.
LEAF is normally ((BEG . END) . WND)."
(avy--overlay
(propertize (apply #'string (reverse path))
'face 'avy-lead-face)
(cond ((numberp leaf)
leaf)
((consp (car leaf))
(caar leaf))
(t
(car leaf)))
(if (consp leaf)
(cdr leaf)
(selected-window))))
(defun avy--overlay-at (path leaf)
"Create an overlay with PATH at LEAF.
PATH is a list of keys from tree root to LEAF.
LEAF is normally ((BEG . END) . WND)."
(let ((str (propertize
(string (car (last path)))
'face 'avy-lead-face))
(pt (if (consp (car leaf))
(caar leaf)
(car leaf)))
(wnd (cdr leaf)))
(let ((ol (make-overlay pt (1+ pt)
(window-buffer wnd)))
(old-str (with-selected-window wnd
(buffer-substring pt (1+ pt)))))
(when avy-background
(setq old-str (propertize
old-str 'face 'avy-background-face)))
(overlay-put ol 'window wnd)
(overlay-put ol 'display (if (string= old-str "\n")
(concat str "\n")
str))
(push ol avy--overlays-lead))))
(defun avy--overlay-at-full (path leaf)
"Create an overlay with PATH at LEAF.
PATH is a list of keys from tree root to LEAF.
LEAF is normally ((BEG . END) . WND)."
(let* ((str (propertize
(apply #'string (reverse path))
'face 'avy-lead-face))
(len (length path))
(pt (if (consp (car leaf))
(caar leaf)
(car leaf)))
(wnd (cdr leaf)))
(let ((ol (make-overlay pt (+ pt len)
(window-buffer wnd)))
(old-str (with-selected-window wnd
(buffer-substring pt (1+ pt)))))
(when avy-background
(setq old-str (propertize
old-str 'face 'avy-background-face)))
(overlay-put ol 'window wnd)
(overlay-put ol 'display (if (string= old-str "\n")
(concat str "\n")
str))
(push ol avy--overlays-lead))))
(defun avy--overlay-post (path leaf)
"Create an overlay with PATH at LEAF.
PATH is a list of keys from tree root to LEAF.
LEAF is normally ((BEG . END) . WND)."
(avy--overlay
(propertize (apply #'string (reverse path))
'face 'avy-lead-face)
(cond ((numberp leaf)
leaf)
((consp (car leaf))
(cdar leaf))
(t
(car leaf)))
(if (consp leaf)
(cdr leaf)
(selected-window))))
(defun avy--style-fn (style)
"Transform STYLE symbol to a style function."
(cl-case style
(pre #'avy--overlay-pre)
(at #'avy--overlay-at)
(at-full 'avy--overlay-at-full)
(post #'avy--overlay-post)
(t (error "Unexpected style %S" style))))
(defun avy--generic-jump (regex window-flip style)
"Jump to REGEX.
When WINDOW-FLIP is non-nil, do the opposite of `avy-all-windows'.
STYLE determines the leading char overlay style."
(let ((avy-all-windows
(if window-flip
(not avy-all-windows)
avy-all-windows)))
(avy--goto
(avy--process
(avy--regex-candidates regex)
(avy--style-fn style)))))
;;* Commands
;;;###autoload
(defun avy-goto-char (&optional arg)
"Read one char and jump to it.
The window scope is determined by `avy-all-windows' (ARG negates it)."
(interactive "P")
(avy--with-avy-keys avy-goto-char
(avy--generic-jump
(let ((c (read-char "char: ")))
(if (= 13 c)
"\n"
(regexp-quote (string c))))
arg
avy-style)))
;;;###autoload
(defun avy-goto-char-2 (&optional arg)
"Read two consecutive chars and jump to the first one.
The window scope is determined by `avy-all-windows' (ARG negates it)."
(interactive "P")
(avy--with-avy-keys avy-goto-char-2
(avy--generic-jump
(regexp-quote (string
(read-char "char 1: ")
(read-char "char 2: ")))
arg
avy-style)))
;;;###autoload
(defun avy-isearch ()
"Jump to one of the current isearch candidates."
(interactive)
(avy--with-avy-keys avy-isearch
(let* ((candidates
(avy--regex-candidates isearch-string))
(avy-background nil)
(candidate
(avy--process candidates #'avy--overlay-post)))
(isearch-done)
(avy--goto candidate))))
;;;###autoload
(defun avy-goto-word-0 (arg)
"Jump to a word start.
The window scope is determined by `avy-all-windows' (ARG negates it)."
(interactive "P")
(avy--with-avy-keys avy-goto-word-0
(avy--generic-jump "\\b\\sw" arg avy-style)))
;;;###autoload
(defun avy-goto-word-1 (&optional arg)
"Read one char at word start and jump there.
The window scope is determined by `avy-all-windows' (ARG negates it)."
(interactive "P")
(avy--with-avy-keys avy-goto-word-1
(let* ((str (string (read-char "char: ")))
(regex (cond ((string= str ".")
"\\.")
((and avy-word-punc-regexp
(string-match avy-word-punc-regexp str))
str)
(t
(concat
"\\b"
str)))))
(avy--generic-jump regex arg avy-style))))
(declare-function subword-backward "subword")
;;;###autoload
(defun avy-goto-subword-0 (&optional arg predicate)
"Jump to a word or subword start.
The window scope is determined by `avy-all-windows' (ARG negates it).
When PREDICATE is non-nil it's a function of zero parameters that
should return true."
(interactive "P")
(require 'subword)
(avy--with-avy-keys avy-goto-subword-0
(let ((case-fold-search nil)
candidates)
(avy-dowindows arg
(let ((ws (window-start)))
(save-excursion
(goto-char (window-end (selected-window) t))
(subword-backward)
(while (> (point) ws)
(when (or (null predicate)
(and predicate (funcall predicate)))
(push (cons (point) (selected-window)) candidates))
(subword-backward)))))
(avy--goto
(avy--process candidates (avy--style-fn avy-style))))))
;;;###autoload
(defun avy-goto-subword-1 (&optional arg)
"Prompt for a subword start char and jump there.
The window scope is determined by `avy-all-windows' (ARG negates it).
The case is ignored."
(interactive "P")
(avy--with-avy-keys avy-goto-subword-1
(let ((char (downcase (read-char "char: "))))
(avy-goto-subword-0
arg (lambda () (eq (downcase (char-after)) char))))))
(defun avy--line (&optional arg)
"Select a line.
The window scope is determined by `avy-all-windows' (ARG negates it)."
(let ((avy-background nil)
candidates)
(avy-dowindows arg
(let ((ws (window-start)))
(save-excursion
(save-restriction
(narrow-to-region ws (window-end (selected-window) t))
(goto-char (point-min))
(while (< (point) (point-max))
(unless (get-char-property
(max (1- (point)) ws) 'invisible)
(push (cons (point) (selected-window)) candidates))
(forward-line 1))))))
(avy--process (nreverse candidates) #'avy--overlay-pre)))
;;;###autoload
(defun avy-goto-line (&optional arg)
"Jump to a line start in current buffer.
The window scope is determined by `avy-all-windows' (ARG negates it)."
(interactive "P")
(avy--with-avy-keys avy-goto-line
(avy--goto (avy--line arg))))
;;;###autoload
(defun avy-copy-line (arg)
"Copy a selected line above the current line.
ARG lines can be used."
(interactive "p")
(avy--with-avy-keys avy-copy-line
(let ((start (car (avy--line))))
(move-beginning-of-line nil)
(save-excursion
(insert
(buffer-substring-no-properties
start
(save-excursion
(goto-char start)
(move-end-of-line arg)
(point)))
"\n")))))
;;;###autoload
(defun avy-move-line (arg)
"Move a selected line above the current line.
ARG lines can be used."
(interactive "p")
(avy--with-avy-keys avy-move-line
(let ((start (car (avy--line))))
(move-beginning-of-line nil)
(save-excursion
(save-excursion
(goto-char start)
(move-end-of-line arg)
(kill-region start (point)))
(insert
(current-kill 0)
"\n")))))
;;;###autoload
(defun avy-copy-region ()
"Select two lines and copy the text between them here."
(interactive)
(avy--with-avy-keys avy-copy-region
(let ((beg (car (avy--line)))
(end (car (avy--line)))
(pad (if (bolp) "" "\n")))
(move-beginning-of-line nil)
(save-excursion
(insert
(buffer-substring-no-properties
beg
(save-excursion
(goto-char end)
(line-end-position)))
pad)))))
;;;###autoload
(defun avy-setup-default ()
"Setup the default shortcuts."
(eval-after-load "isearch"
'(define-key isearch-mode-map (kbd "C-'") 'avy-isearch)))
(defcustom avy-timeout-seconds 0.5
"How many seconds to wait for the second char.")
;;;###autoload
(defun avy-goto-char-timer (&optional arg)
"Read one or two consecutive chars and jump to the first one.
The window scope is determined by `avy-all-windows' (ARG negates it)."
(interactive "P")
(let ((c1 (read-char "char 1: "))
(c2 (read-char "char 2: " nil avy-timeout-seconds)))
(avy--generic-jump
(regexp-quote
(if c2
(string c1 c2)
(string c1)))
arg
avy-style)))
(define-obsolete-variable-alias
'avy-goto-char-style 'avy-style "0.1.0"
"Use `avy-style' and `avy-styles-alist' instead.")
(define-obsolete-variable-alias
'avy-goto-word-style 'avy-style "0.1.0"
"Use `avy-style' and `avy-styles-alist' instead.")
(define-obsolete-variable-alias 'avi-keys 'avy-keys "0.1.0")
(define-obsolete-variable-alias 'avi-background 'avy-background "0.1.0")
(define-obsolete-variable-alias 'avi-word-punc-regexp 'avy-word-punc-regexp "0.1.0")
(define-obsolete-face-alias 'avi-lead-face 'avy-lead-face "0.1.0")
(define-obsolete-function-alias 'avi--goto 'avy--goto "0.1.0")
(define-obsolete-function-alias 'avi--process 'avy--process "0.1.0")
(define-obsolete-variable-alias 'avi-all-windows 'avy-all-windows "0.1.0")
(define-obsolete-function-alias 'avi--overlay-pre 'avy--overlay-pre "0.1.0")
(define-obsolete-function-alias 'avi--overlay-at 'avy--overlay-at "0.1.0")
(define-obsolete-function-alias 'avi--overlay-post 'avy--overlay-post "0.1.0")
(define-obsolete-function-alias 'avi-goto-char 'avy-goto-char "0.1.0")
(define-obsolete-function-alias 'avi-goto-char-2 'avy-goto-char-2 "0.1.0")
(define-obsolete-function-alias 'avi-isearch 'avy-isearch "0.1.0")
(define-obsolete-function-alias 'avi-goto-word-0 'avy-goto-word-0 "0.1.0")
(define-obsolete-function-alias 'avi-goto-subword-0 'avy-goto-subword-0 "0.1.0")
(define-obsolete-function-alias 'avi-goto-word-1 'avy-goto-word-1 "0.1.0")
(define-obsolete-function-alias 'avi-goto-line 'avy-goto-line "0.1.0")
(define-obsolete-function-alias 'avi-copy-line 'avy-copy-line "0.1.0")
(define-obsolete-function-alias 'avi-move-line 'avy-move-line "0.1.0")
(define-obsolete-function-alias 'avi-copy-region 'avy-copy-region "0.1.0")
(define-obsolete-function-alias 'avi--regex-candidates 'avy--regex-candidates "0.1.0")
(provide 'avy-jump)
;;; avy-jump.el ends here

View File

@ -66,7 +66,3 @@
(108 (97 leaf . 8) (108 (97 leaf . 8)
(115 leaf . 9) (115 leaf . 9)
(100 leaf . 10)))))) (100 leaf . 10))))))
(provide 'avy-test)
;;; avy-test.el ends here

2156
avy.el

File diff suppressed because it is too large Load Diff

View File

@ -1,498 +0,0 @@
* 0.3.0
** Fixes
*** Candidate window reversal
See [[https://github.com/abo-abo/avy/issues/27][#27]].
*** Jumping to newlines with =at-full= style
See [[https://github.com/abo-abo/avy/issues/5][#5]].
*** Stop =at-full= style from shifting text sometimes
See [[https://github.com/abo-abo/avy/issues/5][#5]].
*** Fix =at-full= interaction with tabs
When at a tab, visualize it using =tab-width= spaces.
See [[https://github.com/abo-abo/avy/issues/43][#43]].
*** Fix overlay issue when the same buffer is in two windows
See [[https://github.com/abo-abo/avy/issues/47][#47]] and http://debbugs.gnu.org/cgi/bugreport.cgi?bug=20607.
*** Quote punctuation chars
See [[https://github.com/abo-abo/avy/issues/63][#63]].
*** Update screenshot for =avy-goto-char= in README.md
Use ~C-:~ as the new suggested binding instead of the pi char.
See [[https://github.com/abo-abo/avy/issues/64][#64]].
** New Features
*** =avy-goto-line= can now break into =goto-line=
Just enter a digit and you'll be transferred into =goto-line= prompt
with that digit already entered. This means that you can just bind
~M-g g~ to =avy-goto-line= without losing anything.
See [[https://github.com/abo-abo/avy/issues/29][#29]].
*** =avy-goto-line= now works with all kinds of overlay styles
Any of the following do something different now:
#+begin_src elisp
(setq avy-styles-alist
'((avy-goto-line . post)))
(setq avy-styles-alist
'((avy-goto-line . at)))
(setq avy-styles-alist
'((avy-goto-line . at-full)))
(setq avy-styles-alist
'((avy-goto-line . pre)))
#+end_src
See [[https://github.com/abo-abo/ace-link/issues/17][#17]].
*** New defcustom =avy-case-fold-search=
Non-nil when searches should ignore case, so e.g. =avy-goto-char= "b"
will match both "b" and "B". On by default. Use this to turn off this
behavior:
#+begin_src elisp
(setq avy-case-fold-search nil)
#+end_src
See [[https://github.com/abo-abo/avy/issues/34][#34]].
*** New command =avy-goto-word-or-subword-1=
Enter one char, and select a visible word or subword that starts with
it, depending on =subword-mode=. Move the point there.
See [[https://github.com/abo-abo/avy/issues/33][#33]].
*** =avy-move-line= should remove empty line after original one is moved
See [[https://github.com/abo-abo/avy/issues/40][#40]].
*** =avy-move-line= now takes a prefix arg
Use e.g. ~M-3~ before =avy-move-line= to move 3 lines at once.
*** Most commands can be used non-interactively
Example:
#+begin_src elisp
(defun avy-goto-lp ()
(interactive)
(avy-goto-char ?\())
#+end_src
This command only goes to the "(" character. This is actually very
similar to [[http://oremacs.com/lispy/#lispy-ace-paren][=lispy-ace-paren=]], except the implementation is only one
line.
See [[https://github.com/abo-abo/avy/issues/44][#44]].
*** (almost) all defcustoms are explained on the wiki
See [[https://github.com/abo-abo/avy/wiki/defcustom][the defcustom wiki page]].
*** Allow all operations to work across frames
You have to customize =avy-all-windows= for this. By default, it's set
to work on all windows on the current frame.
To make it work only on the current window, use:
#+begin_src elisp
(setq avy-all-windows nil)
#+end_src
To make it work on all frames, use:
#+begin_src elisp
(setq avy-all-windows 'all-frames)
#+end_src
*** New command =avy-goto-char-in-line=
This is =avy-goto-char= reduced only to the current line. Few
candidates means very short decision chars path.
See [[https://github.com/abo-abo/avy/issues/49][#49]].
*** New overlay style =de-bruijn=
How to use it:
#+begin_src elisp
(setq avy-style 'de-bruijn)
#+end_src
What it does: when your leading chars are clumped up together, it's
impossible to overlay the decision path without shifting the buffer
text a bit. For example, with the word "buffer", you =avy-goto-char= "b", and:
- the path for the first "f" is "aj"
- the path for the second "f" is "ak"
It's not possible to overlay 4 characters over "ff" in "buffer". But
to with =de-bruijn= style, which results in the path being "aj" and
"jk". It's possible to overlay "ajk" just fine.
Pros and cons of =de-bruijn= over other styles:
- a pro is that it's possible to display the full decision path for
clumped up chars, which is truncated for other styles
- a con is that the decision path is of the same length (e.g. 2 or 3)
for all candidates, while with other styles it's possible to have a
few candidates with a shorter path.
See [[https://github.com/abo-abo/avy/issues/51][#51]] and [[https://github.com/abo-abo/avy/issues/5][#5]].
*** New defcustom =avy-ignored-modes=
This is meant for visual modes like =doc-view-mode= or =image-mode=
that can have a huge number of chars in a single window. Which results
in a huge number of candidates even in other windows.
Current setting:
#+begin_src elisp
(setq avy-ignored-modes '(image-mode doc-view-mode pdf-view-mode))
#+end_src
See [[https://github.com/abo-abo/avy/issues/57][#57]].
*** New tutorial on writing custom commands
See the [[https://github.com/abo-abo/avy/wiki/custom-commands][the custom-commands wiki page]] and [[https://github.com/abo-abo/avy/issues/55][#55]].
*** New face setup
New variable =avy-lead-faces= will determine the faces used to color
the current decision depth you're in. For example, if to select a
particular candidate you need to press "abc":
- "a" will be highlighted with a face that corresponds to depth 3
- "b" will be highlighted with a face that corresponds to depth 2
- "c" will be highlighted with a face that corresponds to depth 1
But if another candidate needs "ef":
- "e" will be highlighted with a face that corresponds to depth 2
- "f" will be highlighted with a face that corresponds to depth 1
See [[https://github.com/abo-abo/avy/issues/53][#53]].
*** New variable =avy-translate-char-function=
You can use this, for example, to interpret one character as another in =avy-keys=.
Example:
#+begin_src elisp
(setq avy-translate-char-function
(lambda (c) (if (= c 32) ?a c)))
#+end_src
This will translate ~SPC~ (32) into ~a~. So you can press either ~a~ or ~SPC~ to mean "a".
*** =avy-isearch= works for different styles
See [[https://github.com/abo-abo/avy/issues/61][#61]].
*** Switch the default style from =pre= to =at-full=
I've come to like =at-full= more than =pre= over time. The difference
is that =pre= hides no chars in your buffer, while =at-full= doesn't
shift text.
Use this to restore the previous default behavior:
#+begin_src elisp
(setq avy-style 'pre)
#+end_src
* 0.4.0
** Fixes
*** =avy-goto-char-timer= obeys =avy-styles-alist=
See [[https://github.com/abo-abo/avy/issues/67][#67]].
*** Add =de-bruijn= to the defcustom of =avy-styles-alist=
See [[https://github.com/abo-abo/avy/issues/73][#73]].
*** Respect the current input method for target chars
See [[https://github.com/abo-abo/avy/issues/76][#76]].
*** =avy-goto-subword-0= shouldn't offer invisible chars
See [[https://github.com/abo-abo/avy/issues/90][#90]].
*** Better =case-fold-search= handling
See [[https://github.com/abo-abo/avy/issues/87][#87]].
*** Add misc punctuation to subword commands
See [[https://github.com/abo-abo/avy/issues/93][#93]].
*** Add padding for wide-width chars (ex. Japanese and Chinese)
See [[https://github.com/abo-abo/avy/issues/96][#96]].
*** =avy-goto-line=
**** Push mark for numeric line
See [[https://github.com/abo-abo/avy/issues/74][#74]].
**** Allow numeric prefix arg
The old behavior remains for ARG 1 or 4. For all other ARG, simply go
to that line.
See [[https://github.com/abo-abo/avy/issues/86][#86]].
**** Work for =visual-line-mode=
See [[https://github.com/abo-abo/avy/issues/91][#91]].
**** Don't error on end of buffer
See [[https://github.com/abo-abo/avy/issues/91][#91]].
**** Obey =avy-background=
See [[https://github.com/abo-abo/avy/issues/94][#94]].
**** Fix for narrowed regions
See [[https://github.com/abo-abo/avy/issues/122][#122]], [[https://github.com/abo-abo/avy/issues/123][#123]].
**** Don't modify =avy-action=
See [[https://github.com/abo-abo/avy/issues/124][#124]].
*** =avy-goto-char-timer=
**** May read as many chars as you want
See [[https://github.com/abo-abo/avy/issues/97][#97]].
**** Highlight matches while reading chars
See [[https://github.com/abo-abo/avy/issues/98][#98]].
**** Highlight depending on =avy-all-windows=
See [[https://github.com/abo-abo/avy/issues/104][#104]].
**** Make faster for =org-mode=
See [[https://github.com/abo-abo/avy/issues/100][#100]].
**** Add case fold search
See [[https://github.com/abo-abo/avy/issues/128][#128]].
*** =avy-copy-region=
**** Keep the same selectors for the second pass
See [[https://github.com/abo-abo/avy/issues/120][#120]], [[https://github.com/abo-abo/avy/issues/121][#121]].
**** Copy/move to initial window
See [[https://github.com/abo-abo/avy/issues/131][#131]].
*** Search only in the visible region
See [[https://github.com/abo-abo/avy/issues/108][#108]], [[https://github.com/abo-abo/avy/issues/109][#109]].
*** Fix jumping to the last char of a folded Org outline
See [[https://github.com/abo-abo/avy/issues/108][#108]].
*** Fix for both =org-indent-mode= and =visual-line-mode=
See [[https://github.com/abo-abo/avy/issues/110][#110]].
*** Beep when there are no matches
See [[https://github.com/abo-abo/avy/issues/111][#111]].
*** Simplify overlay code
Most functions reuse =avy--overlay= now.
*** Fix de-bruijn "no catch for tag"
See [[https://github.com/abo-abo/avy/issues/116][#116]].
*** Fix overlays at =point-max=
See [[https://github.com/abo-abo/avy/issues/125][#125]].
*** Improve =case-fold-search= condition
See [[https://github.com/abo-abo/avy/issues/126][#126]].
*** Don't shorten selector string for =visual-line-mode= and =bolp=
See [[https://github.com/abo-abo/avy/issues/129][#129]].
*** Fix interaction with =goto-address-mode=
** New Features
*** Allow non-printing keys in =avy-keys=
Now you can set avy-keys also to the arrow keys and page up/down, e.g.
#+begin_src elisp
(setq avy-keys '(left right up down prior next))
#+end_src
and those will be displayed as ▲, ▼, ◀, ▶, △, ▽ in the overlays. The
display is controlled by the variable =avy-key-to-char-alist=.
See [[https://github.com/abo-abo/avy/issues/77][#77]].
*** Allow to switch action midway from goto to kill/mark/copy
For example, suppose you have:
#+begin_src elisp
(global-set-key (kbd "M-t") 'avy-goto-word-1)
#+end_src
- To jump to a certain word starting with "w" (e.g. first one on
screen): ~M-t w a~
- To copy the word instead of jumping to it: ~M-t w na~.
- To mark the word after jumping to it: ~M-t w ma~.
- To kill the word after jumping to it: ~M-t w xa~.
You can customize =avy-dispatch-alist= to modify these actions.
See [[https://github.com/abo-abo/avy/issues/78][#78]].
*** New command =avy-pop-mark=
Goes back to the last location of =push-mark=:
- has its own history,
- handles multiple frames.
See [[https://github.com/abo-abo/avy/issues/81][#81]] [[https://github.com/abo-abo/avy/issues/88][#88]] [[https://github.com/abo-abo/avy/issues/69][#69]].
*** New commands =avy-goto-line-above= and =avy-goto-line-below=
See [[https://github.com/abo-abo/avy/issues/106][#106]].
*** New defcustom =avy-line-insert-style=
Allows to modify the behavior of =avy-copy-line=, =avy-move-line=, and =avy-copy-region=.
See [[https://github.com/abo-abo/avy/issues/117][#117]].
*** New defcustom =avy-all-windows-alt=
Allows to customize the behavior of =universal-argument= modifying
=avy-all-windows=.
See [[https://github.com/abo-abo/avy/issues/118][#118]].
*** New defcustom =avy-subword-extra-word-chars=
Allows to customize the behavior of =avy-goto-subword-0= and
=avy-goto-subword-1= by adding extra chars that should match as word
constituents.
See [[https://github.com/abo-abo/avy/issues/116][#116]].
* 0.5.0
** Fixes
*** el:avy-action-copy
Save selected window and frame. See [[https://github.com/abo-abo/avy/issues/133][#133]].
Copy line for el:avy-goto-line. See [[https://github.com/abo-abo/avy/issues/191][#191]].
*** el:avy-read
Make ~C-g~ and ~ESC~ fail silently when reading char. See [[https://github.com/abo-abo/avy/issues/137][#137]].
Display error message on mouse clicks. See [[https://github.com/abo-abo/avy/issues/226][#226]].
Update el:avy-current-path before returning. See [[https://github.com/abo-abo/avy/issues/226][#226]].
Quit on ~ESC~. See [[https://github.com/abo-abo/avy/issues/249][#249]].
Fix for el:org-toggle-link-display. See [[https://github.com/abo-abo/avy/issues/261][#261]].
Fix for el:buffer-invisibility-spec being t. See [[https://github.com/abo-abo/avy/issues/264][#264]].
Allow "invisible" 'org-link. See [[https://github.com/abo-abo/avy/issues/269][#269]].
*** el:avy-goto-word-1
Works for "^A"-"^Z", see [[https://github.com/abo-abo/avy/issues/167][#167]].
*** el:avy-goto-subword-0
Add char at window start if empty, See [[https://github.com/abo-abo/avy/issues/145][#145]].
Add option to limit scope. See [[https://github.com/abo-abo/avy/issues/235][#235]].
*** el:avy-goto-subword-1
Check el:char-after. See [[https://github.com/abo-abo/avy/issues/163][#163]].
*** el:avy-isearch
Escape regex. See [[https://github.com/abo-abo/avy/issues/147][#147]].
*** el:avy-goto-char-2
Translate ~RET~ to ~C-j~. See [[https://github.com/abo-abo/avy/issues/153][#153]].
*** el:avy-action-goto
Add el:raise-frame.
*** el:avy-goto-char-timer
Allow ~C-h~ to delete. See [[https://github.com/abo-abo/avy/issues/193][#193]].
Obey el:avy-background for the initial search. See [[https://github.com/abo-abo/avy/issues/259][#259]].
*** el:avy-goto-line
Fix for empty buffer. See [[https://github.com/abo-abo/avy/issues/238][#238]].
Add ability to display candidates from bottom to top. See [[https://github.com/abo-abo/avy/issues/236][#236]].
*** el:avy--overlay-at-full
More consistent face order.
See [[https://github.com/abo-abo/avy/issues/270][#270]].
*** documentation
See [[https://github.com/abo-abo/avy/issues/223][#223]], [[https://github.com/abo-abo/avy/issues/226][#226]], [[https://github.com/abo-abo/avy/issues/218][#218]], [[https://github.com/abo-abo/avy/issues/245][#245]], [[https://github.com/abo-abo/avy/issues/262][#262]].
** New Features
*** API
New functions have been added as drop-in replacements of double-dash (private) avy
functions that were used in other packages and configs. Please replace the references to
the obsolete functions.
**** el:avy-jump
New API function to replace el:avy--generic-jump. See [[https://github.com/abo-abo/avy/issues/265][#265]], [[https://github.com/abo-abo/avy/issues/267][#267]].
**** el:avy-process
New API function to replace el:avy--process. See [[https://github.com/abo-abo/avy/issues/266][#266]].
*** New actions
**** el:avy-action-kill-stay
Kill a word with el:avy-goto-char without moving there.
Bound to ~X~.
**** el:avy-action-ispell
Auto-correct word at point. See [[https://github.com/abo-abo/avy/issues/142][#142]], [[https://github.com/abo-abo/avy/issues/160][#160]], [[https://github.com/abo-abo/avy/issues/161][#161]].
Bound to ~i~.
**** el:avy-action-yank
Yank sexp starting at selected point at the current point. See [[https://github.com/abo-abo/avy/issues/183][#183]].
Bound to ~y~.
**** el:avy-action-teleport
Kill sexp starting on selected point and yank into the current location. See [[https://github.com/abo-abo/avy/issues/207][#207]].
Bound to ~t~.
**** el:avy-action-zap-to-char
Kill from point up to selected point. See [[https://github.com/abo-abo/avy/issues/234][#234]].
Bound to ~z~.
*** New defcustoms
**** New el:avy-style setting: 'words
Use this setting:
#+begin_src elisp
(setq avy-style 'words)
#+end_src
And you'll see overlays like "by", "if", "is", "it", "my" for 2-letter sequences, and
"can", "car", "cog" for 3-letter sequences. You might find them easier to type than "hla",
"lls" and "jhl". But you will have to adjust your el:avy-dispatch-alist, e.g. to use only
upper case characters.
See [[https://github.com/abo-abo/avy/issues/210][#210]], [[https://github.com/abo-abo/avy/issues/219][#219]].
**** el:avy-orders-alist
Use it to customize the order of candidates with relation to point. The default is for
el:avy-goto-char to have the shortest overlay for candidates closest to point.
See [[https://github.com/abo-abo/avy/issues/242][#242]].
**** el:avy-indent-line-overlay
When non-nil el:avy-goto-line will display the line overlay next to the first
non-whitespace character of each line. See [[https://github.com/abo-abo/avy/issues/244][#244]].
**** el:avy-single-candidate-jump
When non-nil, and there is only one candidate, jump there. See [[https://github.com/abo-abo/avy/issues/250][#250]].
**** el:avy-del-last-char-by
Customize keys which delete the last read char. The defaults are ~C-h~ and ~DEL~. See [[https://github.com/abo-abo/avy/issues/251][#251]].
**** el:avy-goto-word-0-regexp
Customize el:avy-goto-word-0. See [[https://github.com/abo-abo/avy/issues/136][#136]], [[https://github.com/abo-abo/avy/issues/156][#156]].
**** el:avy-pre-action
Function to all before el:avy-action. See [[https://github.com/abo-abo/avy/issues/260][#260]].
**** el:avy-enter-times-out
When non-nil (the default), ~RET~ exists el:avy-goto-char-timer early.
When nil, it matches a newline.
See [[https://github.com/abo-abo/avy/issues/220][#220]], [[https://github.com/abo-abo/avy/issues/225][#225]].
*** New commands
**** el:avy-move-region
Select two lines and move the text between them above the current line.
See [[https://github.com/abo-abo/avy/issues/75][#75]], [[https://github.com/abo-abo/avy/issues/187][#187]], [[https://github.com/abo-abo/avy/issues/188][#188]].
**** el:avy-goto-end-of-line
Call el:avy-goto-line and move to the end of the line. See [[https://github.com/abo-abo/avy/issues/240][#240]].
**** el:avy-linum-mode
Minor mode that uses avy hints for el:linum-mode.
**** el:avy-resume
Holds last command avy command after user input. This is a quick way to bring back the
same markers after a jump. See [[https://github.com/abo-abo/avy/issues/157][#157]], [[https://github.com/abo-abo/avy/issues/165][#165]].
**** el:avy-next
Go to the next candidate after el:avy-read.
Example config:
#+begin_src elisp
(defhydra hydra-avy-cycle ()
("j" avy-next "next")
("k" avy-prev "prev")
("q" nil "quit"))
(global-set-key (kbd "C-M-'") 'hydra-avy-cycle/body)
#+end_src
After e.g. el:avy-goto-char or el:avy-goto-char-timer, use the above hydra to cycle
between the last candidates. See [[https://github.com/abo-abo/avy/issues/254][#254]].
**** *-above and *-below variants
Command versions restricted to matches before or after the point.
See [[https://github.com/abo-abo/avy/issues/148][#148]]:
- el:avy-goto-char-2-above
- el:avy-goto-char-2-below
See [[https://github.com/abo-abo/avy/issues/151][#151]]:
- el:avy-goto-word-1-above
- el:avy-goto-word-1-below
See [[https://github.com/abo-abo/avy/issues/156][#156]]:
- el:avy-goto-symbol-1-above
- el:avy-goto-symbol-1-below
See [[https://github.com/abo-abo/avy/issues/186][#186]]:
- el:avy-goto-word-0-below
- el:avy-goto-word-0-above
**** kill and save region functionality
New avy-enabled commands:
- el:avy-kill-whole-line
- el:avy-kill-region
- el:avy-kill-ring-save-whole-line
- el:avy-kill-ring-save-region
See [[https://github.com/abo-abo/avy/issues/158][#158]].
**** org-mode functionality
New avy-enabled commands:
- el:avy-org-refile-as-child
- el:avy-org-goto-heading-timer
See [[https://github.com/abo-abo/avy/issues/214][#214]], [[https://github.com/abo-abo/avy/issues/258][#258]].
*** el:avy-goto-char-timer
Show the number of matches so far in the prompt. See [[https://github.com/abo-abo/avy/issues/253][#253]].
*** el:avy-read
Ignore mistyping when no candidates are available. See [[https://github.com/abo-abo/avy/issues/256][#256]].
When the overlays are shown, press ~?~ to get dispatch help.

View File

@ -1,2 +0,0 @@
(checkdoc-file "avy-test.el")
(checkdoc-file "avy.el")