]> code.delx.au - gnu-emacs-elpa/commitdiff
Rename counsel-symbol-at-point to ivy-thing-at-point
authorOleh Krehel <ohwoeowho@gmail.com>
Mon, 22 Feb 2016 15:27:47 +0000 (16:27 +0100)
committerOleh Krehel <ohwoeowho@gmail.com>
Mon, 22 Feb 2016 15:27:47 +0000 (16:27 +0100)
* 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
ivy.el

index d4bc4690214dd13ce19da6fa17689c8345878b15..57b7a33f42054384805a68b054d716cbfa1df869 100644 (file)
@@ -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 c762a6ba525989c77632a59c16abb1dec4b4e163..396d5894fc9621d59d7cff47c645b50b476c5223 100644 (file)
--- 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)