help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dynamic completion-ignored-extensions


From: Kevin Ryde
Subject: Re: dynamic completion-ignored-extensions
Date: Thu, 24 Jul 2008 10:43:10 +1000
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.2 (gnu/linux)

Kevin Rodgers <address@hidden> writes:
>
> (defun my-read-file-name (&rest args)
>   "Tweak `completion-ignored-extensions' before calling `read-file-name'."
>   (let ((read-file-name-function nil)
>       (completion-ignored-extensions (your-code-here)))
>     (apply 'read-file-name args)))

Yes, close, though I had the idea of ignores depending on the name
entered so-far too.  I get some joy from munging deeper down like below.
I guess there's 3 or 4 other completion funcs too, but tab's the only
one I normally press.  (I wouldn't be surprised if there was a cleaner
way too ...)


(defadvice minibuffer-complete (around my-ignore activate)
  (if minibuffer-completing-file-name
      (let ((completion-ignored-extensions completion-ignored-extensions))
        (my-dynamic-ignored)
        ad-do-it)
    ad-do-it))

(defun my-dynamic-ignored ()
  (let* ((contents (minibuffer-contents-no-properties))
         (dir      (file-name-directory contents)))

    (if (file-expand-wildcards (concat contents "*.xs"))
        (add-to-list 'completion-ignored-extensions ".c"))

    (if (or (file-exists-p (concat dir "Makefile.am"))
            (file-exists-p (concat dir "Makefile.PL")))
        (add-to-list 'completion-ignored-extensions "Makefile"))

    (if (file-exists-p (concat dir "Build.PL"))
        (add-to-list 'completion-ignored-extensions "Build"))))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]