How to make description-function "Ch f" case insensitive by default
When looking for a function that I partially remember the name I use C-h fto call describe-function
, enter *part-of-function-name
and press TAB. But now I understand that this search is not case sensitive.
For example:
C-h f info
TAB
lists all functions starting with info
but does not include those starting with info
, whereas
C-h f info
TAB
lists all functions starting with info
, but excludes those starting with info
.
Another example:
C-h f *nfc
TAB
gives me *nfc [No match]
, whereas
C-h f *nfc
TAB
gives me ucs-normalize-HFS-NFC-region
.
How can I do the describe-function
case insensitive default using some configuration in the file init.el
?
source to share
Add a binding completion-ignore-case
to t
in the interactive
command specification . This has the advantage that (a) it only affects describe-function
( C-h f
) and (b) you can easily toggle it on / off (as with any Emacs advice).
(defadvice describe-function (before ignore-case activate)
"Make it case-insensitive."
(interactive
(let ((completion-ignore-case t) ; <============= ADDED BINDING
(fn (function-called-at-point))
(enable-recursive-minibuffers t)
val)
(setq val (completing-read
(if fn
(format "Describe function (default %s): " fn)
"Describe function: ")
obarray 'fboundp t nil nil (and fn (symbol-name fn))))
(list (if (equal val "") fn (intern val))))))
source to share
Here's a custom function that I'm using instead describe-function
. It uses ido completion.
(defvar functions-cache nil) ;;;###autoload (defun refresh-functions-cache () (interactive) (setq functions-cache nil) (mapatoms (lambda (symbol) (when (fboundp symbol) (push (symbol-name symbol) functions-cache)))) (setq functions-cache (sort functions-cache #'string<))) ;;;###autoload (defun describe-function-ex (function) "Display the full documentation of FUNCTION (a symbol)." (interactive (let ((fn (function-called-at-point)) (enable-recursive-minibuffers t) val) (unless functions-cache (refresh-functions-cache)) (setq val (ido-completing-read (if fn (format "Describe function (default %s): " fn) "Describe function: ") functions-cache nil t nil nil (and fn (symbol-name fn)))) (list (if (equal val "") fn (intern val))))) (if (null function) (message "You didn't specify a function") (help-setup-xref (list #'describe-function function) (called-interactively-p 'interactive)) (save-excursion (with-help-window (help-buffer) (prin1 function) (princ " is ") (describe-function-1 function) (with-current-buffer standard-output ;; Return the text we displayed. (buffer-string))))))
source to share