@@ -1286,8 +1286,8 @@ that defines it./
12861286
12871287 As always, inspect the generated code (via ~macrostep-expand~) to see that it does what you expect:
12881288 #+begin_src emacs-lisp :tangle no
1289- (use-package annotation :commands annotation-annotate )
1290- ≈ (autoload (function annotation-annotate ) "annotation " nil t)
1289+ (use-package helpful :commands helpful-callable )
1290+ ≈ (autoload (function helpful-callable ) "helpful " nil t)
12911291 #+end_src
12921292
12931293** Emacs Package Manager
@@ -5726,40 +5726,46 @@ Let's use a helpful Emacs /documentation/ system that cleanly shows a lot of
57265726contextual information ---then let's /extend/ that to work as we want it to:
57275727~C-h o~ to describe the symbol at point.
57285728#+begin_src emacs-lisp
5729- (use-package helpful)
5729+ (use-package helpful
5730+ :commands (helpful-callable helpful-symbol)
5731+ :bind (("C-h k" . #'helpful-key)
5732+ ("C-h o" . #'my/describe-symbol)))
57305733
57315734(defun my/describe-symbol (symbol)
5732- "A “C-h o” replacement using “helpful”:
5733- If there's a thing at point, offer that as default search item.
5734-
5735- If a prefix is provided, i.e., “C-u C-h o” then the built-in
5736- “describe-symbol” command is used.
5737-
5738- ⇨ Pretty docstrings, with links and highlighting.
5739- ⇨ Source code of symbol.
5740- ⇨ Callers of function symbol.
5741- ⇨ Key bindings for function symbol.
5742- ⇨ Aliases.
5743- ⇨ Options to enable tracing, dissable, and forget/unbind the symbol!
5744- "
5745- (interactive "p")
5746- (let* ((thing (symbol-at-point))
5747- (val (completing-read
5748- (format "Describe symbol (default %s): " thing)
5749- (vconcat (list thing) obarray)
5750- (lambda (vv)
5751- (cl-some (lambda (x) (funcall (nth 1 x) vv))
5752- describe-symbol-backends))
5753- t nil nil))
5754- (it (intern val)))
5755- (cond
5756- (current-prefix-arg (funcall #'describe-symbol it))
5757- ((or (functionp it) (macrop it) (commandp it)) (helpful-callable it))
5758- (t (helpful-symbol it)))))
5735+ "A “C-h o” replacement using “helpful”.
5736+
5737+ If there's a thing at point, offer that as default search item.
57595738
5760- ;; Keybindings.
5761- (global-set-key (kbd "C-h o") #'my/describe-symbol)
5762- (global-set-key (kbd "C-h k") #'helpful-key)
5739+ If a prefix is provided, i.e., “C-u C-h o” then the built-in
5740+ “describe-symbol” command is used.
5741+
5742+ ⇨ Pretty docstrings, with links and highlighting.
5743+ ⇨ Source code of symbol.
5744+ ⇨ Callers of function symbol.
5745+ ⇨ Key bindings for function symbol.
5746+ ⇨ Aliases.
5747+ ⇨ Options to enable tracing, dissable, and forget/unbind the symbol!"
5748+ (interactive "P")
5749+ (let* ((sym-at-pt (symbol-at-point))
5750+ (default (and (symbolp sym-at-pt) (symbol-name sym-at-pt)))
5751+ (prompt (if default
5752+ (format "Describe symbol (default %s): " default)
5753+ "Describe symbol: "))
5754+ (pred (lambda (sym) ; SYM is a symbol when COLLECTION is an obarray
5755+ (cl-some (lambda (x) (funcall (cadr x) sym))
5756+ describe-symbol-backends)))
5757+ (name (completing-read prompt
5758+ obarray ; ← use obarray directly
5759+ pred
5760+ t ; require-match
5761+ nil nil
5762+ default)) ; ← default goes here
5763+ (sym (intern name)))
5764+ (if current-prefix-arg
5765+ (describe-symbol sym) ; C-u C-h o → built-in
5766+ (if (or (functionp sym) (macrop sym) (commandp sym))
5767+ (helpful-callable sym)
5768+ (helpful-symbol sym)))))
57635769#+END_SRC
57645770
57655771I like [[https://github.com/Wilfred/helpful][helpful]] and wanted it to have the same behaviour as ~C-h o~, which
0 commit comments