我寫了一些代碼,應該做你想做的。基本思想是設置變量'completion-ignored-extensions
以匹配要跳過的擴展名,但僅當存在.tex
文件時。這段代碼是這樣做的。
(defadvice find-file-read-args (around find-file-read-args-limit-choices activate)
"set some stuff up for controlling extensions when tab completing"
(let ((completion-ignored-extensions completion-ignored-extensions)
(find-file-limit-choices t))
ad-do-it))
(defadvice minibuffer-complete (around minibuffer-complete-limit-choices nil activate)
"When in find-file, check for files of extension .tex, and if they're found, ignore .log .pdf .bbl .aux"
(let ((add-or-remove
(if (and (boundp 'find-file-limit-choices) find-file-limit-choices
(save-excursion
(let ((b (progn (beginning-of-line) (point)))
(e (progn (end-of-line) (point))))
(directory-files (file-name-directory (buffer-substring-no-properties b e)) nil "\\.tex$"))))
'add-to-list
'remove)))
(mapc (lambda (e) (setq completion-ignored-extensions
(funcall add-or-remove 'completion-ignored-extensions e)))
'(".log" ".pdf" ".bbl" ".aux")))
ad-do-it)
享受。
我收到'mapcq'的未定義函數錯誤 - 是由我應該加載的elisp包提供的嗎? – 2009-04-28 19:55:09