Skip to content

Commit 82d9306

Browse files
committed
Reabsorb ivy-avy into ivy
For some discussion, see the following threads: https://lists.gnu.org/r/emacs-devel/2021-02/msg01935.html https://lists.gnu.org/r/emacs-devel/2021-03/msg00490.html * ivy-avy.el: Move contents to ivy.el. Bump package versions to 0.13.5. Mention deprecation in Commentary and warning message. * ivy.el: Bump package version to 0.13.5. (ivy-define-key): Use function-put in place of put. (ivy-minibuffer-map): Bind ivy-avy. (ivy-avy-style): Moved from ivy-avy.el. Add a nil option for falling through to the default avy-styles-alist or avy-style. (ivy--avy-candidates, ivy--avy-action, ivy--avy-handler-function) (ivy-avy): Moved from ivy-avy.el with some cleanups. * swiper.el: Bump package versions to 0.13.5. Localize external variable and function declarations. (swiper-avy): Fix error message and docstring. * counsel.el: * ivy-hydra.el * doc/ivy.org: Bump package versions to 0.13.5. * doc/ivy.texi: Regenerate. * Makefile (compile): Don't byte-compile ivy-avy.el. * ivy-test.el (ivy-avy): * targets/plain.el: Don't load ivy-avy.el. Closes #2574, closes #2583.
1 parent 1c6b3da commit 82d9306

10 files changed

Lines changed: 127 additions & 114 deletions

File tree

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ checkdoc:
1515
$(emacs) -batch -l targets/checkdoc.el
1616

1717
compile:
18-
$(emacs) -batch -l elpa.el -L . -f batch-byte-compile colir.el ivy-faces.el ivy-overlay.el ivy.el ivy-avy.el swiper.el counsel.el
18+
$(emacs) -batch -l elpa.el -L . -f batch-byte-compile \
19+
colir.el ivy-faces.el ivy-overlay.el ivy.el swiper.el counsel.el
1920

2021
plain:
2122
$(emacs) --version

counsel.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
;; Author: Oleh Krehel <[email protected]>
66
;; URL: https://github.com/abo-abo/swiper
7-
;; Version: 0.13.4
8-
;; Package-Requires: ((emacs "24.5") (ivy "0.13.4") (swiper "0.13.4"))
7+
;; Version: 0.13.5
8+
;; Package-Requires: ((emacs "24.5") (ivy "0.13.5") (swiper "0.13.5"))
99
;; Keywords: convenience, matching, tools
1010

1111
;; This file is part of GNU Emacs.

doc/ivy.org

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ ivy-ox.el then ~C-c C-e i t~ in the ivy.org buffer.
5858
:CUSTOM_ID: copying
5959
:END:
6060
#+TEXINFO: @ifnottex
61-
Ivy manual, version 0.13.4
61+
Ivy manual, version 0.13.5
6262

6363
Ivy is an interactive interface for completion in Emacs. Emacs uses
6464
completion mechanism in a variety of contexts: code, menus, commands,

doc/ivy.texi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
@copying
1010
@ifnottex
11-
Ivy manual, version 0.13.4
11+
Ivy manual, version 0.13.5
1212

1313
Ivy is an interactive interface for completion in Emacs. Emacs uses
1414
completion mechanism in a variety of contexts: code, menus, commands,

ivy-avy.el

Lines changed: 18 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
;; Author: Oleh Krehel <[email protected]>
66
;; URL: https://github.com/abo-abo/swiper
7-
;; Version: 0.13.4
8-
;; Package-Requires: ((emacs "24.5") (ivy "0.13.4") (avy "0.5.0"))
7+
;; Version: 0.13.5
8+
;; Package-Requires: ((ivy "0.13.5") (avy "0.5.0"))
99
;; Keywords: convenience
1010

1111
;; This program is free software; you can redistribute it and/or modify
@@ -22,90 +22,28 @@
2222
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
2323

2424
;;; Commentary:
25+
26+
;; *N.B.:* This package has been absorbed, and is therefore made
27+
;; obsolete, by the `ivy' package, version 0.13.5.
28+
;;
29+
;; If you maintain a package that depends on `ivy-avy', then you
30+
;; should change that to instead depend on `ivy' version 0.13.5, and
31+
;; remove all references to `ivy-avy'.
2532
;;
26-
;; This package adds a "C-'" binding to Ivy minibuffer that uses Avy.
33+
;; If you use any packages that depend on `ivy-avy', either directly
34+
;; or indirectly, then you will have to wait until all of them have
35+
;; transitioned away from it before you can uninstall it.
2736

2837
;;; Code:
2938

30-
(require 'ivy)
3139
(require 'avy)
40+
(require 'ivy)
3241

33-
(defcustom ivy-avy-style 'pre
34-
"The `avy-style' setting for `ivy-avy'."
35-
:type '(choice
36-
(const :tag "Pre" pre)
37-
(const :tag "At" at)
38-
(const :tag "At Full" at-full)
39-
(const :tag "Post" post)
40-
(const :tag "De Bruijn" de-bruijn)
41-
(const :tag "Words" words))
42-
:group 'ivy)
43-
44-
(defun ivy-avy--candidates ()
45-
"List of candidates for `ivy-avy'."
46-
(let (candidates)
47-
(save-excursion
48-
(save-restriction
49-
(narrow-to-region
50-
(window-start)
51-
(window-end))
52-
(goto-char (point-min))
53-
(forward-line)
54-
(while (< (point) (point-max))
55-
(push
56-
(cons (point)
57-
(selected-window))
58-
candidates)
59-
(forward-line))))
60-
(nreverse candidates)))
61-
62-
(defun ivy-avy--action (pt)
63-
"Select the candidate represented by PT."
64-
(when (number-or-marker-p pt)
65-
(let ((bnd (ivy--minibuffer-index-bounds
66-
ivy--index ivy--length ivy-height)))
67-
(ivy--done
68-
(substring-no-properties
69-
(nth (+ (car bnd) (- (line-number-at-pos pt) 2)) ivy--old-cands))))))
70-
71-
(defun ivy-avy--handler-function (char)
72-
"Handle CHAR that's not on `avy-keys'."
73-
(let (cmd)
74-
(cond ((memq char '(?\C-\[ ?\C-g))
75-
;; exit silently
76-
(throw 'done 'abort))
77-
((memq (setq cmd (lookup-key ivy-minibuffer-map (vector char)))
78-
'(ivy-scroll-up-command
79-
ivy-scroll-down-command))
80-
(funcall cmd)
81-
(ivy--exhibit)
82-
(throw 'done 'exit))
83-
;; ignore wrong key
84-
(t
85-
(throw 'done 'restart)))))
86-
87-
(defun ivy-avy ()
88-
"Jump to one of the current ivy candidates."
89-
(interactive)
90-
(if (= (minibuffer-depth) 0)
91-
(user-error
92-
"This command is intended to be called from within `ivy-read'")
93-
(let* ((avy-all-windows nil)
94-
(avy-keys (or (cdr (assq 'ivy-avy avy-keys-alist))
95-
avy-keys))
96-
(avy-style (or (cdr (assq 'ivy-avy avy-styles-alist))
97-
avy-style))
98-
(avy-action #'identity)
99-
(avy-handler-function #'ivy-avy--handler-function)
100-
res)
101-
(while (eq (setq res (avy-process (ivy-avy--candidates))) t))
102-
(when res
103-
(ivy-avy--action res)))))
104-
105-
(put 'ivy-avy 'no-counsel-M-x t)
106-
(unless (lookup-key ivy-minibuffer-map (kbd "C-'"))
107-
(define-key ivy-minibuffer-map (kbd "C-'") 'ivy-avy))
108-
(add-to-list 'avy-styles-alist `(ivy-avy . ,ivy-avy-style))
42+
(eval-and-compile
43+
(let ((msg "Package ivy-avy is obsolete; use ivy 0.13.5 instead"))
44+
(if (and noninteractive (fboundp 'byte-compile-warn))
45+
(byte-compile-warn msg)
46+
(message "%s" msg))))
10947

11048
(provide 'ivy-avy)
11149

ivy-hydra.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
;; Author: Oleh Krehel <[email protected]>
66
;; URL: https://github.com/abo-abo/swiper
77
;; Version: 0.13.5
8-
;; Package-Requires: ((emacs "24.5") (ivy "0.13.4") (hydra "0.14.0"))
8+
;; Package-Requires: ((emacs "24.5") (ivy "0.13.5") (hydra "0.14.0"))
99
;; Keywords: convenience
1010

1111
;; This file is part of GNU Emacs.

ivy-test.el

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1590,7 +1590,6 @@ a buffer visiting a file."
15901590

15911591
(ert-deftest ivy-avy ()
15921592
(skip-unless (require 'avy nil t))
1593-
(require 'ivy-avy)
15941593
(let ((enable-recursive-minibuffers t)
15951594
(read-numbers '(ivy-read "test: " (mapcar #'number-to-string
15961595
(number-sequence 1 100)))))

ivy.el

Lines changed: 82 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
;; Author: Oleh Krehel <[email protected]>
66
;; URL: https://github.com/abo-abo/swiper
7-
;; Version: 0.13.4
7+
;; Version: 0.13.5
88
;; Package-Requires: ((emacs "24.5"))
99
;; Keywords: matching
1010

@@ -303,8 +303,8 @@ action functions.")
303303
(require 'delsel)
304304
(defun ivy-define-key (keymap key def)
305305
"Forward to (`define-key' KEYMAP KEY DEF).
306-
Remove DEF from `counsel-M-x' list."
307-
(put def 'no-counsel-M-x t)
306+
Remove DEF (a function symbol) from `counsel-M-x' completion."
307+
(function-put def 'no-counsel-M-x t)
308308
(define-key keymap key def))
309309

310310
(defvar ivy-minibuffer-map
@@ -353,6 +353,7 @@ Remove DEF from `counsel-M-x' list."
353353
(ivy-define-key map [remap kill-whole-line] 'ivy-kill-whole-line)
354354
(ivy-define-key map (kbd "S-SPC") 'ivy-restrict-to-matches)
355355
(ivy-define-key map [remap kill-ring-save] 'ivy-kill-ring-save)
356+
(ivy-define-key map (kbd "C-'") 'ivy-avy)
356357
(ivy-define-key map (kbd "C-M-a") 'ivy-read-action)
357358
(ivy-define-key map (kbd "C-c C-o") 'ivy-occur)
358359
(ivy-define-key map (kbd "C-c C-a") 'ivy-toggle-ignore)
@@ -1710,6 +1711,84 @@ This string is inserted into the minibuffer."
17101711
ivy-format-function-arrow-line)
17111712
(function :tag "Custom function"))))
17121713

1714+
(defcustom ivy-avy-style 'pre
1715+
"The `avy-style' setting for `ivy-avy'."
1716+
:type '(choice
1717+
(const :tag "Pre" pre)
1718+
(const :tag "At" at)
1719+
(const :tag "At Full" at-full)
1720+
(const :tag "Post" post)
1721+
(const :tag "De Bruijn" de-bruijn)
1722+
(const :tag "Words" words)
1723+
(const :tag "Default" nil)))
1724+
1725+
(defun ivy--avy-candidates ()
1726+
"List of candidates for `ivy-avy'."
1727+
(let (candidates)
1728+
(save-excursion
1729+
(save-restriction
1730+
(narrow-to-region (window-start) (window-end))
1731+
(goto-char (point-min))
1732+
(forward-line)
1733+
(while (< (point) (point-max))
1734+
(push (cons (point) (selected-window))
1735+
candidates)
1736+
(forward-line))))
1737+
(nreverse candidates)))
1738+
1739+
(defun ivy--avy-action (pt)
1740+
"Select the candidate represented by PT."
1741+
(when (number-or-marker-p pt)
1742+
(let ((bnd (ivy--minibuffer-index-bounds
1743+
ivy--index ivy--length ivy-height)))
1744+
(ivy--done
1745+
(substring-no-properties
1746+
(nth (+ (car bnd) (- (line-number-at-pos pt) 2)) ivy--old-cands))))))
1747+
1748+
(defun ivy--avy-handler-function (char)
1749+
"Handle CHAR that's not on `avy-keys'."
1750+
(cond ((memql char '(?\C-\[ ?\C-g))
1751+
;; Exit silently.
1752+
(throw 'done 'abort))
1753+
((let ((cmd (lookup-key ivy-minibuffer-map (vector char))))
1754+
(when (memq cmd '(ivy-scroll-up-command
1755+
ivy-scroll-down-command))
1756+
(funcall cmd)
1757+
(ivy--exhibit)
1758+
(throw 'done 'exit))))
1759+
;; Ignore wrong key.
1760+
((throw 'done 'restart))))
1761+
1762+
(defun ivy-avy ()
1763+
"Jump to one of the current `ivy' candidates with `avy'."
1764+
(interactive)
1765+
(unless (require 'avy nil t)
1766+
(user-error "Package `avy' is not installed"))
1767+
(when (zerop (minibuffer-depth))
1768+
(user-error
1769+
"Command `ivy-avy' is intended to be called from within `ivy-read'"))
1770+
(defvar avy-action)
1771+
(defvar avy-all-windows)
1772+
(defvar avy-handler-function)
1773+
(defvar avy-keys)
1774+
(defvar avy-keys-alist)
1775+
(defvar avy-style)
1776+
(defvar avy-styles-alist)
1777+
(declare-function avy-process "avy"
1778+
(candidates &optional overlay-fn cleanup-fn))
1779+
(let ((avy-all-windows nil)
1780+
(avy-keys (or (cdr (assq #'ivy-avy avy-keys-alist))
1781+
avy-keys))
1782+
(avy-style (or ivy-avy-style
1783+
(cdr (assq #'ivy-avy avy-styles-alist))
1784+
avy-style))
1785+
(avy-action #'identity)
1786+
(avy-handler-function #'ivy--avy-handler-function)
1787+
res)
1788+
(while (eq (setq res (avy-process (ivy--avy-candidates))) t))
1789+
(when res
1790+
(ivy--avy-action res))))
1791+
17131792
(defun ivy-sort-file-function-default (x y)
17141793
"Compare two files X and Y.
17151794
Prioritize directories."

swiper.el

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
;; Author: Oleh Krehel <[email protected]>
66
;; URL: https://github.com/abo-abo/swiper
7-
;; Version: 0.13.4
8-
;; Package-Requires: ((emacs "24.5") (ivy "0.13.4"))
7+
;; Version: 0.13.5
8+
;; Package-Requires: ((emacs "24.5") (ivy "0.13.5"))
99
;; Keywords: matching
1010

1111
;; This file is part of GNU Emacs.
@@ -262,21 +262,6 @@ If the input is empty, select the previous history element instead."
262262
(set-window-configuration wnd-conf))))))))
263263
(put 'swiper-all-query-replace 'no-counsel-M-x t)
264264

265-
(defvar avy-all-windows)
266-
(defvar avy-style)
267-
(defvar avy-keys)
268-
(declare-function avy--overlay-post "ext:avy")
269-
(declare-function avy-action-goto "ext:avy")
270-
(declare-function avy-candidate-beg "ext:avy")
271-
(declare-function avy--done "ext:avy")
272-
(declare-function avy--make-backgrounds "ext:avy")
273-
(declare-function avy-window-list "ext:avy")
274-
(declare-function avy-read "ext:avy")
275-
(declare-function avy-read-de-bruijn "ext:avy")
276-
(declare-function avy-tree "ext:avy")
277-
(declare-function avy-push-mark "ext:avy")
278-
(declare-function avy--remove-leading-chars "ext:avy")
279-
280265
(defun swiper--avy-candidates ()
281266
(let* (
282267
;; We'll have overlapping overlays, so we sort all the
@@ -317,6 +302,18 @@ If the input is empty, select the previous history element instead."
317302
cands))))))
318303

319304
(defun swiper--avy-candidate ()
305+
(defvar avy-all-windows)
306+
(defvar avy-keys)
307+
(defvar avy-style)
308+
(declare-function avy--done "ext:avy" ())
309+
(declare-function avy--make-backgrounds "ext:avy" (wnd-list))
310+
(declare-function avy--overlay-post "ext:avy" (path leaf))
311+
(declare-function avy--remove-leading-chars "ext:avy" ())
312+
(declare-function avy-push-mark "ext:avy" ())
313+
(declare-function avy-read "ext:avy" (tree display-fn cleanup-fn))
314+
(declare-function avy-read-de-bruijn "ext:avy" (lst keys))
315+
(declare-function avy-tree "ext:avy" (lst keys))
316+
(declare-function avy-window-list "ext:avy" ())
320317
(let ((candidates (swiper--avy-candidates))
321318
(avy-all-windows nil))
322319
(unwind-protect
@@ -351,6 +348,8 @@ If the input is empty, select the previous history element instead."
351348
-2)))))
352349

353350
(defun swiper--avy-goto (candidate)
351+
(declare-function avy-action-goto "ext:avy" (pt))
352+
(declare-function avy-candidate-beg "ext:avy" (leaf))
354353
(cond ((let ((win (cdr-safe candidate)))
355354
(and win (window-minibuffer-p win)))
356355
(setq ivy--index (swiper--avy-index (car candidate)))
@@ -364,10 +363,10 @@ If the input is empty, select the previous history element instead."
364363

365364
;;;###autoload
366365
(defun swiper-avy ()
367-
"Jump to one of the current swiper candidates with `avy'."
366+
"Jump to one of the current `swiper' candidates with `avy'."
368367
(interactive)
369368
(unless (require 'avy nil 'noerror)
370-
(user-error "Package avy isn't installed"))
369+
(user-error "Package `avy' is not installed"))
371370
(cl-case (length ivy-text)
372371
(0
373372
(user-error "Need at least one char of input"))

targets/plain.el

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,5 @@
1010
(global-set-key (kbd "<f2> j") 'counsel-set-variable)
1111
(global-set-key (kbd "C-c s") 'isearch-forward-regexp)
1212
(setq ivy-use-virtual-buffers t)
13-
(condition-case nil
14-
(require 'ivy-avy)
15-
(error
16-
(require 'targets/install-deps)
17-
(require 'ivy-avy)))
13+
(unless (require 'avy nil t)
14+
(require 'targets/install-deps))

0 commit comments

Comments
 (0)