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

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

[elpa] master 8212110 15/90: Handle symbol-at-point better in non-Elisp


From: Oleh Krehel
Subject: [elpa] master 8212110 15/90: Handle symbol-at-point better in non-Elisp buffers
Date: Tue, 30 Jun 2015 07:28:06 +0000

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

    Handle symbol-at-point better in non-Elisp buffers
    
    * counsel.el (counsel-symbol-at-point): New defun.
    (counsel-describe-variable): Update.
    (counsel-describe-function): Update.
    
    Fixes #126
---
 counsel.el |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/counsel.el b/counsel.el
index f27095e..6be445f 100644
--- a/counsel.el
+++ b/counsel.el
@@ -80,6 +80,14 @@
 (defvar counsel-describe-symbol-history nil
   "History for `counsel-describe-variable' and `counsel-describe-function'.")
 
+(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))))
+
 (defun counsel-describe-variable ()
   "Forward to `describe-variable'."
   (interactive)
@@ -94,7 +102,7 @@
             (push (symbol-name vv) cands))))
        cands)
      :keymap counsel-describe-map
-     :preselect (thing-at-point 'symbol)
+     :preselect (counsel-symbol-at-point)
      :history 'counsel-describe-symbol-history
      :require-match t
      :sort t
@@ -114,7 +122,7 @@
                      (push (symbol-name x) cands))))
                 cands)
               :keymap counsel-describe-map
-              :preselect (thing-at-point 'symbol)
+              :preselect (counsel-symbol-at-point)
               :history 'counsel-describe-symbol-history
               :require-match t
               :sort t



reply via email to

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