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

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

[elpa] master e8f2064 117/272: Rename counsel-symbol-at-point to ivy-thi


From: Oleh Krehel
Subject: [elpa] master e8f2064 117/272: Rename counsel-symbol-at-point to ivy-thing-at-point
Date: Mon, 25 Apr 2016 10:13:20 +0000

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

    Rename counsel-symbol-at-point to ivy-thing-at-point
    
    * ivy.el (ivy-thing-at-point): New defun.
    (ivy--reset-state): Set `ivy--default' to `ivy-thing-at-point'.
    
    * counsel.el (counsel-symbol-at-point): Mark obsolete.
    (counsel-describe-variable):
    (counsel-describe-function): Use `ivy-thing-at-point'.
---
 counsel.el |   13 ++++---------
 ivy.el     |   19 +++++++++++++++----
 2 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/counsel.el b/counsel.el
index d4bc469..57b7a33 100644
--- a/counsel.el
+++ b/counsel.el
@@ -342,13 +342,8 @@ Update the minibuffer with the amount of lines collected 
every
                  (error "Couldn't fild definition of %s"
                         sym))))))))
 
-(defun counsel-symbol-at-point ()
-  "Return current symbol at point as a string."
-  (let ((s (thing-at-point 'symbol)))
-    (and (stringp s)
-         (if (string-match "\\`[`']?\\(.*?\\)'?\\'" s)
-             (match-string 1 s)
-           s))))
+(define-obsolete-function-alias 'counsel-symbol-at-point
+    'ivy-thing-at-point "0.7.0")
 
 (defun counsel-variable-list ()
   "Return the list of all currently bound variables."
@@ -369,7 +364,7 @@ Update the minibuffer with the amount of lines collected 
every
      "Describe variable: "
      (counsel-variable-list)
      :keymap counsel-describe-map
-     :preselect (counsel-symbol-at-point)
+     :preselect (ivy-thing-at-point)
      :history 'counsel-describe-symbol-history
      :require-match t
      :sort t
@@ -397,7 +392,7 @@ Update the minibuffer with the amount of lines collected 
every
                      (push (symbol-name x) cands))))
                 cands)
               :keymap counsel-describe-map
-              :preselect (counsel-symbol-at-point)
+              :preselect (ivy-thing-at-point)
               :history 'counsel-describe-symbol-history
               :require-match t
               :sort t
diff --git a/ivy.el b/ivy.el
index c762a6b..396d589 100644
--- a/ivy.el
+++ b/ivy.el
@@ -280,6 +280,20 @@ This should eventually become a stack so that you could use
 (defsubst ivy-set-action (action)
   (setf (ivy-state-action ivy-last) action))
 
+(defun ivy-thing-at-point ()
+  "Return a string that corresponds to the current thing at point."
+  (or
+   (thing-at-point 'url)
+   (let (s)
+     (cond ((stringp (setq s (thing-at-point 'symbol)))
+            (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.
 
@@ -1401,10 +1415,7 @@ This is useful for recursive `ivy-read'."
               (buffer-substring
                (region-beginning)
                (region-end))
-            (or
-             (thing-at-point 'url)
-             (thing-at-point 'symbol)
-             "")))
+            (ivy-thing-at-point)))
     (setq ivy--prompt
           (cond ((string-match "%.*d" prompt)
                  prompt)



reply via email to

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