Skip to content

counsel "find-X" commands worse at default guessing than the corresponding builtins #1088

Description

@stepnem

I would expect the counsel replacements to be at least as smart as the builtin commands they purport to supersede, but they're not (in this respect at least).

E.g., the builtin find-function guesses the right default anywhere inside the function call. Counsel had better make use of the preexisting and well-tried builtin guessing functions, e.g. the patch below seems to fix the find-function case. There are equivalents for find-variable, find-library...

diff --git a/counsel.el b/counsel.el
index 6bd25a7..3ec8c6e 100644
--- a/counsel.el
+++ b/counsel.el
@@ -524,7 +524,8 @@ (defun counsel-describe-function ()
                      (push (symbol-name x) cands))))
                 cands)
               :keymap counsel-describe-map
-              :preselect (ivy-thing-at-point)
+              :preselect (when-let (fn (function-called-at-point))
+                           (symbol-name fn))
               :history 'counsel-describe-symbol-history
               :require-match t
               :sort t

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions