emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master ca1ca04 14/17: Add avy-goto-subword-1


From: Oleh Krehel
Subject: [elpa] master ca1ca04 14/17: Add avy-goto-subword-1
Date: Fri, 08 May 2015 13:42:14 +0000

branch: master
commit ca1ca0464796de5cf31be7ff31f4bca45d8cd02f
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    Add avy-goto-subword-1
    
    Fixes #8
---
 avy-jump.el |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/avy-jump.el b/avy-jump.el
index 520011a..60b9160 100644
--- a/avy-jump.el
+++ b/avy-jump.el
@@ -329,9 +329,13 @@ The window scope is determined by `avy-all-windows' (ARG 
negates it)."
 (declare-function subword-backward "subword")
 
 ;;;###autoload
-(defun avy-goto-subword-0 (&optional arg)
+(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)."
+
+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)
   (let ((avy-keys (number-sequence ?a ?z))
@@ -343,11 +347,23 @@ The window scope is determined by `avy-all-windows' (ARG 
negates it)."
           (goto-char (window-end (selected-window) t))
           (subword-backward)
           (while (> (point) ws)
-            (push (cons (point) (selected-window)) candidates)
+            (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-goto-word-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")
+  (let ((char (downcase (read-char "char: "))))
+    (avy-goto-subword-0
+     arg (lambda () (eq (downcase (char-after)) char)))))
+
 (defun avy--line (&optional arg)
   "Select line in current window."
   (let ((avy-background nil)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]