1

I want to use a set of files inside my directory ~/Dokumente to search for changes in title, content. So I saved such a set of file names persistently, using C-} during file-name completion with Icicles.

Later, I can use C-{ to restore that set of file names as completion candidates for a command that prompts for a file name.

But how can I combine this with command icicle-locate (or another command that prompts for a file name)?

Command icicle-locate can used with C-M-j to filter by both file name AND file content. How can I do that and also take advantage of my saved persistent set of file names?

1

This answer is for using command icicle-find-file-absolute, which is similar in most regards to icicle-locate.

But icicle-locate uses a prefix arg differently, passing it to system-command locate. So icicle-locate doesn't handle the use of a prefix arg to make multi-completion candidates include also a last modification-date middle component. (Command icicle-locate-file is more similar to icicle-find-file-absolute than is icicle-locate, which uses system command locate.)

The short, tl;dr, answer to your question is that even when completing to match both file name and file content, the completion candidates shown in *Completions* are just the file names, and it is perfectly OK to use C-{ to retrieve a set of these.


  1. (You already did this.) Use C-} during file-name completion, to save the file names that match your minibuffer pattern persistently. Let's say you saved this in file foo.el, using name set-name foo.

  2. M-x icicle-find-file-absolute (or just C-u C-x C-f).

  3. At the prompt for a file name, use C-{, to restore your saved set of file names. At the prompt, enter the name of the saved set, foo. The saved names are shown as the completion candidates in buffer *Completions*.

  4. Type C-M-j, to say that you are done matching file names and you now want to give a pattern to match file content.

  5. Type a pattern to match file content, e.g., toto.*titi. Use S-TAB to update *Completions*, to show only the names of files whose content matches regexp toto.*titi.


If you want to match also the file last-modification dates, then use a negative prefix arg. In that case, after step 3, use C-M-j and type a pattern that matches the dates you want, then continue with step 4 (a second C-M-j followed by a file-content pattern).


As mentioned, icicle-locate is a bit different, because for it the prefix arg is passed to locate, so you can't use it to include last modification-date matching. But the general approach is the same.


See also:

| improve this answer | |
  • hello, thanks for the answer, but unfortunately it seems, that i'm a little bit too stupid for that. After Step 3 i dont see a Completion Buffer. My Minibuffer shows "File or dir (absolute) (./)". Then i push C-M-j and .* to show all content. S-TAB brings up the Completion Buffer. Unfortunately with files from my home directory. And after a short time emacs complains "Reverting buffer ‘.xsession-errors’." So it seems that i have to switch to the directory i saved. I thought, that the Completions are ONLY from the persistent set. – space_held Jan 24 at 16:11
  • (1) #3 means: at the prompt File or dir (absolute), use C-{. You should see *Completions* with your saved candidates at that point. (2) There's no sense in a content-matching regexp of .* Content-matching is optional - you need not use C-M-j at all, if you aren't filtering the candidate files by content (.* does no real filtering, because it matches all lines of content). (3) The file-name matching for this is absolute name matching. It's up to you to get the directory-matching part right, with your filename input pattern. – Drew Jan 24 at 16:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.