Search code examples
emacsdired

dired: M-x find-dired: disable history?


I set (setq find-args "-iname ") so that M-x find-dired gives me ... "Run find (with args): -iname " as default. However, it seems to remember its history. Is there a way to disable the history and always start with the default argument "-iname"? I tried to modify find-args-history without success.


Solution

  • You have to use the function marius/find-dired each time instead of find-dired, as it is showed in answer. E.g. setup something like this (global-set-key (kbd "C-x g") 'marius/find-dired). It calls (setq find-args "-iname ...") each time before calling find-grep.

    EDIT: without renaming:

    (setq find-args '("-iname '**'" . 10))
    (defadvice find-dired (after eab-find-dired activate)
      (setq find-args '("-iname '**'" . 10)))
    

    for deactivate:

    (ad-remove-advice 'find-dired 'after 'eab-find-dired)
    (ad-deactivate 'find-dired)
    

    EDIT2: We use after-advice here, see comments.