1

I want to map describe-symbol to shortcut, but I constantly have to press additional enter for show describe on found default suggestion. Is there a way to force emacs to newer ask for confirmation with enter on describe-symbol call?

P.S. Maybe there's a way to do this from elisp function call? I use that wrapper function to get symbol under cursor description, how shoult I tweak it to make it works as I wish?

(defun sandric/hydra-dash (arg)
  "Hydra help dash"
  (interactive "P")
  (call-interactively 'describe-symbol arg))
1

I have no idea how to modify or even re-use the interactive spec, but making a new function is very easy:

(defun describe-symbol-at-point ()
  (interactive)
  (describe-symbol (or (symbol-at-point) (error "No symbol-at-point"))))

BTW, describe-symbol is on C-h o by default, alongside with C-h f (describe-function) and C-h v (describe-variable).

1

Something like this:

(defun my-describe-symbol (symbol)
  "..."
  (interactive
   (let* ((v-or-f (symbol-at-point))
          (found  (if v-or-f (cl-some (lambda (x) (funcall (nth 1 x) v-or-f))
                                      describe-symbol-backends)))
          (v-or-f (if found v-or-f (function-called-at-point)))
          (found  (or found v-or-f))
          (enable-recursive-minibuffers t)
          (val    (if found
                      (format "%s" v-or-f)
                    (completing-read
                     "Describe symbol: " obarray
                     (lambda (vv) (cl-some (lambda (x) (funcall (nth 1 x) vv))
                                      describe-symbol-backends))
                     t nil nil (if found (symbol-name v-or-f))))))
     (list (if (equal val "") v-or-f (intern val)))))
  (describe-symbol symbol))

That just reproduces the interactive spec from describe-symbol, modifying it slightly to use the default value, when present.

  • Thanks, that works, although mb there's cleaner solution so I'll wait a little before marking as best answer. – sandric Nov 14 '17 at 19:33
  • FWIW, I would not have coded the interactive spec that way - it's not my style. I tried to keep it as close as possible to the original in describe-symbol, so you can easily see the change I made to it. – Drew Nov 15 '17 at 3:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.