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.
Asked
Active
Viewed 110 times
3

Marius Hofert
- 6,546
- 10
- 48
- 102
1 Answers
2
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.
-
1ahh... good! Is it possible to bind it to `find-dired` itself [no renaming]? [or, if not possible, bind it to `M-x find`] – Marius Hofert Jan 30 '13 at 11:36
-
Can you explain why you need binding without renaming? It isn't usual way. – artscan Jan 30 '13 at 11:53
-
I don't really need to name it `find-dired` as well, I was just interested in how one would do it without redefining the whole function. Something which would be more practical would be to have it work on the shorter `M-x find` (which isn't used for anything as far as I see). But when I start the definition with `defun find ()`, I only get TAB completion to other functions such as find-*. – Marius Hofert Jan 30 '13 at 12:02
-
You should use `(interactive)` in your definition `(defun foo () (interactive) ..)` then it appears in `M-x`. Also, function `find` is traditionally defined in `cl-seq.el`. You can use your personal name, e.g. `name/find`. See EDIT. – artscan Jan 30 '13 at 12:26
-
Is your first chunk `(defadvice...)` complete? It does not work in my case, I just get the original definition of `find-dired`. Concerning `(interactive)`: I had this. Indeed, I used exactly the second chunk as posted in the answer you link to and replaced `marius/find-dired` by `find`. – Marius Hofert Jan 30 '13 at 12:39
-
Sorry, it should work with "before", but it doesn't. With "after" it works this way: after executing `find-dired` variable `find-args` becomes `'("-iname '**'" . 10)`. And next time you get what you want. – artscan Jan 30 '13 at 12:50
-
let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/23633/discussion-between-artscan-and-marius-hofert) – artscan Jan 30 '13 at 12:52