[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ivy-hydra 6a576cb 293/395: ivy-avy.el: Extract
From: |
Basil L. Contovounesios |
Subject: |
[elpa] externals/ivy-hydra 6a576cb 293/395: ivy-avy.el: Extract |
Date: |
Thu, 25 Feb 2021 08:32:23 -0500 (EST) |
branch: externals/ivy-hydra
commit 6a576cba564ab8860142f9ec343b13ec89cc2440
Author: Oleh Krehel <ohwoeowho@gmail.com>
Commit: Oleh Krehel <ohwoeowho@gmail.com>
ivy-avy.el: Extract
---
ivy-avy.el | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ivy-test.el | 2 +-
ivy.el | 87 ---------------------------------------------------
3 files changed, 102 insertions(+), 88 deletions(-)
diff --git a/ivy-avy.el b/ivy-avy.el
new file mode 100644
index 0000000..8939da5
--- /dev/null
+++ b/ivy-avy.el
@@ -0,0 +1,101 @@
+;;; ivy-avy.el --- Avy integration for Ivy -*- lexical-binding: t -*-
+
+;; Copyright (C) 2020 Free Software Foundation, Inc.
+
+;; Author: Oleh Krehel <ohwoeowho@gmail.com>
+;; Keywords: convenience
+
+;; This program 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 of the License, 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.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+(require 'ivy)
+(require 'avy)
+
+(defcustom ivy-avy-style 'pre
+ "The `avy-style' setting for `ivy-avy'."
+ :type '(choice
+ (const :tag "Pre" pre)
+ (const :tag "At" at)
+ (const :tag "At Full" at-full)
+ (const :tag "Post" post)
+ (const :tag "De Bruijn" de-bruijn)
+ (const :tag "Words" words))
+ :group 'ivy)
+
+(defun ivy--avy-candidates ()
+ (let (candidates)
+ (save-excursion
+ (save-restriction
+ (narrow-to-region
+ (window-start)
+ (window-end))
+ (goto-char (point-min))
+ (forward-line)
+ (while (< (point) (point-max))
+ (push
+ (cons (point)
+ (selected-window))
+ candidates)
+ (forward-line))))
+ (nreverse candidates)))
+
+(defun ivy--avy-action (pt)
+ (when (number-or-marker-p pt)
+ (let ((bnd (ivy--minibuffer-index-bounds
+ ivy--index ivy--length ivy-height)))
+ (ivy--done
+ (substring-no-properties
+ (nth (+ (car bnd) (- (line-number-at-pos pt) 2)) ivy--old-cands))))))
+
+(defun ivy--avy-handler-function (char)
+ (let (cmd)
+ (cond ((memq char '(?\C-\[ ?\C-g))
+ ;; exit silently
+ (throw 'done 'abort))
+ ((memq (setq cmd (lookup-key ivy-minibuffer-map (vector char)))
+ '(ivy-scroll-up-command
+ ivy-scroll-down-command))
+ (funcall cmd)
+ (ivy--exhibit)
+ (throw 'done 'exit))
+ ;; ignore wrong key
+ (t
+ (throw 'done 'restart)))))
+
+(defun ivy-avy ()
+ "Jump to one of the current ivy candidates."
+ (interactive)
+ (if (= (minibuffer-depth) 0)
+ (user-error
+ "This command is intended to be called from within `ivy-read'")
+ (let* ((avy-all-windows nil)
+ (avy-keys (or (cdr (assq 'ivy-avy avy-keys-alist))
+ avy-keys))
+ (avy-style (or (cdr (assq 'ivy-avy avy-styles-alist))
+ avy-style))
+ (avy-action #'identity)
+ (avy-handler-function #'ivy--avy-handler-function)
+ res)
+ (while (eq (setq res (avy-process (ivy--avy-candidates))) t))
+ (when res
+ (ivy--avy-action res)))))
+
+(put 'ivy-avy 'no-counsel-M-x t)
+(define-key ivy-minibuffer-map (kbd "C-'") 'ivy-avy)
+(add-to-list 'avy-styles-alist `(ivy-avy . ,ivy-avy-style))
+
+(provide 'ivy-avy)
diff --git a/ivy-test.el b/ivy-test.el
index 3d1a5cb..88243cf 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -1529,7 +1529,7 @@ a buffer visiting a file."
'("one" "two"))))
(ert-deftest ivy-avy ()
- (when (require 'avy nil t)
+ (when (require 'ivy-avy nil t)
(let ((enable-recursive-minibuffers t)
(read-numbers '(ivy-read "test: " (mapcar #'number-to-string
(number-sequence 1 100)))))
(should (string= (ivy-with read-numbers "C-' a") "1"))
diff --git a/ivy.el b/ivy.el
index 8587a79..05bed29 100644
--- a/ivy.el
+++ b/ivy.el
@@ -457,7 +457,6 @@ action functions.")
(define-key map [remap kill-whole-line] 'ivy-kill-whole-line)
(define-key map (kbd "S-SPC") 'ivy-restrict-to-matches)
(define-key map [remap kill-ring-save] 'ivy-kill-ring-save)
- (define-key map (kbd "C-'") 'ivy-avy)
(define-key map (kbd "C-M-a") 'ivy-read-action)
(define-key map (kbd "C-c C-o") 'ivy-occur)
(define-key map (kbd "C-c C-a") 'ivy-toggle-ignore)
@@ -1808,15 +1807,6 @@ minibuffer."
(cl-rotatef ivy--regex-function ivy--regexp-quote)
(setq ivy-regex (funcall ivy--regex-function ivy-text)))
-(defvar avy-all-windows)
-(defvar avy-action)
-(defvar avy-keys)
-(defvar avy-keys-alist)
-(defvar avy-style)
-(defvar avy-styles-alist)
-(declare-function avy-process "ext:avy")
-(declare-function avy--style-fn "ext:avy")
-
(defcustom ivy-format-functions-alist
'((t . ivy-format-function-default))
"An alist of functions that transform the list of candidates into a string.
@@ -1830,83 +1820,6 @@ This string is inserted into the minibuffer."
(const :tag "Full line" ivy-format-function-line)
(function :tag "Custom function"))))
-(defcustom ivy-avy-style 'pre
- "The `avy-style' setting for `ivy-avy'."
- :type '(choice
- (const :tag "Pre" pre)
- (const :tag "At" at)
- (const :tag "At Full" at-full)
- (const :tag "Post" post)
- (const :tag "De Bruijn" de-bruijn)
- (const :tag "Words" words)))
-
-(with-eval-after-load 'avy
- (add-to-list 'avy-styles-alist `(ivy-avy . ,ivy-avy-style)))
-
-(defun ivy--avy-candidates ()
- (let (candidates)
- (save-excursion
- (save-restriction
- (narrow-to-region
- (window-start)
- (window-end))
- (goto-char (point-min))
- (forward-line)
- (while (< (point) (point-max))
- (push
- (cons (point)
- (selected-window))
- candidates)
- (forward-line))))
- (nreverse candidates)))
-
-(defun ivy--avy-action (pt)
- (when (number-or-marker-p pt)
- (let ((bnd (ivy--minibuffer-index-bounds
- ivy--index ivy--length ivy-height)))
- (ivy--done
- (substring-no-properties
- (nth (+ (car bnd) (- (line-number-at-pos pt) 2)) ivy--old-cands))))))
-
-(defun ivy--avy-handler-function (char)
- (let (cmd)
- (cond ((memq char '(?\C-\[ ?\C-g))
- ;; exit silently
- (throw 'done 'abort))
- ((memq (setq cmd (lookup-key ivy-minibuffer-map (vector char)))
- '(ivy-scroll-up-command
- ivy-scroll-down-command))
- (funcall cmd)
- (ivy--exhibit)
- (throw 'done 'exit))
- ;; ignore wrong key
- (t
- (throw 'done 'restart)))))
-
-(defvar avy-handler-function)
-
-(defun ivy-avy ()
- "Jump to one of the current ivy candidates."
- (interactive)
- (cond ((not (require 'avy nil 'noerror))
- (error "Package avy isn't installed"))
- ((= (minibuffer-depth) 0)
- (user-error
- "This command is intended to be called from within `ivy-read'"))
- (t
- (let* ((avy-all-windows nil)
- (avy-keys (or (cdr (assq 'ivy-avy avy-keys-alist))
- avy-keys))
- (avy-style (or (cdr (assq 'ivy-avy avy-styles-alist))
- avy-style))
- (avy-action #'identity)
- (avy-handler-function #'ivy--avy-handler-function)
- res)
- (while (eq (setq res (avy-process (ivy--avy-candidates))) t))
- (when res
- (ivy--avy-action res))))))
-(put 'ivy-avy 'no-counsel-M-x t)
-
(defun ivy-sort-file-function-default (x y)
"Compare two files X and Y.
Prioritize directories."
- [elpa] externals/ivy-hydra 6369139 271/395: ivy.el (ivy--update-history): Behave more like completing-read-default, (continued)
- [elpa] externals/ivy-hydra 6369139 271/395: ivy.el (ivy--update-history): Behave more like completing-read-default, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra c0dc909 277/395: ivy.el (ivy-resume): Support multiple ivy sessions, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 8989ed1 276/395: ivy.el (ivy--update-minibuffer): don't filter while there's input, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra d790e53 278/395: doc/ivy.org: Mention multiple-session ivy-resume, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra fb8804d 280/395: ivy.el (ivy--call-marked): Extract, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 489bc57 284/395: counsel.el (counsel-rg-base-command): Make the default a list, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 7fd0662 285/395: counsel.el (counsel-grep-like-occur): Fix for marked files in dired, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra f1c57a1 292/395: counsel.el (counsel-async-command-delay): Set the default to 0.0, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra fb73bfe 288/395: counsel.el (counsel--rg-targets): Fix regression, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 2b26f83 289/395: counsel.el (counsel--sync-sentinel-on-exit): Don't reset index, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 6a576cb 293/395: ivy-avy.el: Extract,
Basil L. Contovounesios <=
- [elpa] externals/ivy-hydra e42e0b3 295/395: ivy-hydra.el (ivy-minibuffer-grow): Move, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 9fddf44 297/395: ivy-faces.el: Extract, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra a33af9b 356/395: Unset yank-undo-function in counsel-yank-pop, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 98c61de 299/395: ivy.el (ivy-set-display-transformer): Mark obsolete, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 177d7e0 325/395: Fix definition of ‘counsel--browse-history’., Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra a877961 330/395: ivy.el (ivy-call): Don't modify default-directory, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 39ede5f 324/395: targets/plain.el: Require ivy-avy, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra d951004 336/395: doc: Conflate installation description, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 3a2c5b2 300/395: counsel.el: Mark obsolete the functions that can be replaced by complete-symbol, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 3ecf828 344/395: ivy.el (ivy-switch-buffer): Don't lose the current index, Basil L. Contovounesios, 2021/02/25