如何制作描述功能" C-h f"不区分大小写

时间:2014-10-10 04:50:24

标签: emacs case-insensitive

在搜索我记忆中的名字的函数时,我使用 Ch f 来调用describe-function,输入*part-of-function-name,然后点击 TAB 。但我现在意识到这种搜索不是不区分大小写的。

例如:

C-h f info TAB

列出以info开头的所有函数,但不包括以Info开头的函数,而

C-h f Info TAB

列出以Info开头的所有功能,但不包括以info开头的功能。

另一个例子:

C-h f *nfc TAB

给我*nfc [No match],而

C-h f *NFC TAB

给了我ucs-normalize-HFS-NFC-region

如何使用describe-function文件中的某些配置默认情况下init.el不区分大小写?

3 个答案:

答案 0 :(得分:3)

在命令的completion-ignore-case规范中添加tinteractive的绑定。这样做的好处是:(a)它只影响describe-functionC-h f)和(b)您可以轻松地打开/关闭它(与任何Emacs建议一样)。

(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))))))

答案 1 :(得分:1)

(setq completion-ignore-case t)应该做到你想要的,而不仅仅是C-h f

答案 2 :(得分:1)

这是我用来代替describe-function的自定义功能。 它使用ido完成。

(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))))))