branch: master commit 8212110101bd080481840dda027e8b007dfef9d2 Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
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