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

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

[elpa] master 24c95b7 018/399: ivy.el (ivy-thing-at-point): Extend


From: Oleh Krehel
Subject: [elpa] master 24c95b7 018/399: ivy.el (ivy-thing-at-point): Extend
Date: Sat, 20 Jul 2019 14:56:39 -0400 (EDT)

branch: master
commit 24c95b7361ac834bb6bb501eb8c3c7a070d487c1
Author: Nathan Moreau <address@hidden>
Commit: Oleh Krehel <address@hidden>

    ivy.el (ivy-thing-at-point): Extend
    
    Fixes #1871
---
 ivy.el | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/ivy.el b/ivy.el
index 064e561..184acf4 100644
--- a/ivy.el
+++ b/ivy.el
@@ -474,20 +474,25 @@ the restoring themselves.")
   "Return a string that corresponds to the current thing at point."
   (substring-no-properties
    (cond
-    ((thing-at-point 'url))
-    ((and (eq (ivy-state-collection ivy-last) #'read-file-name-internal)
-          (let ((inhibit-message t))
-            (ignore-errors
-              (ffap-file-at-point)))))
-    ((let ((s (thing-at-point 'symbol)))
-       (and (stringp s)
-            (if (string-match "\\`[`']?\\(.*?\\)'?\\'" s)
-                (match-string 1 s)
-              s))))
-    ((looking-at "(+\\(\\(?:\\sw\\|\\s_\\)+\\)\\_>")
-     (match-string-no-properties 1))
-    (t
-     ""))))
+     ((use-region-p)
+      (let* ((beg (region-beginning))
+             (end (region-end))
+             (eol (save-excursion (goto-char beg) (line-end-position))))
+        (buffer-substring-no-properties beg (min end eol))))
+     ((thing-at-point 'url))
+     ((and (eq (ivy-state-collection ivy-last) #'read-file-name-internal)
+           (let ((inhibit-message t))
+             (ignore-errors
+               (ffap-file-at-point)))))
+     ((let ((s (thing-at-point 'symbol)))
+        (and (stringp s)
+             (if (string-match "\\`[`']?\\(.*?\\)'?\\'" s)
+                 (match-string 1 s)
+               s))))
+     ((looking-at "(+\\(\\(?:\\sw\\|\\s_\\)+\\)\\_>")
+      (match-string-no-properties 1))
+     (t
+      ""))))
 
 (defvar ivy-history nil
   "History list of candidates entered in the minibuffer.



reply via email to

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