대문 최근에 바뀐 글 새소식 찾기 하우투 문제 제안

Icicles - Dired Enhancements

최근 편집

추가됨:

> * You can use the [[multi-completion]] [[multi-command]]s
> '''`icicle-visit-marked-file-of-content'''' and
> '''`icicle-visit-marked-file-of-content-other-window'''' to visit
> marked files whose ''names'' and/or whose ''content'' matches your
> minibuffer input. See [[Icicles - Multi-Completions#icicle-visit-marked-file-of-content|Icicles - Multi-Completions]].


iciclesimage
Previous: Icicles - Shell-Command EnhancementsIciclesIciclesIndexNext: Icicles - Info Enhancements

Icicles Dired Enhancements

Icicles can help with DiredMode in these ways:

Search-and-Replace Marked Files

If you also use library Dired+ then ‘M-s M-s m’ (‘icicle-search-dired-marked-recursive’) in Dired uses Icicles search (and on-demand replace) on the marked files.

Each marked subdirectory is handled recursively in the same way: If it has a Dired buffer then its marked files are searched, or all of its files if none are marked. If a marked directory at any level has no Dired buffer then all of its files are searched. With a prefix argument the Dired markings are ignored; all files are searched.

Because you might not be aware of existing Dired buffers for some marked directories, you are asked to confirm searching their marked files. If you do not confirm, then all files in marked subdirectories (recursively) are searched, regardless of whether they might have Dired buffers with marked files. That is, Dired buffers are ignored if you do not confirm using them.

Command ‘icicle-search-dired-marked-recursive’ runs ‘icicle-search’, so you have available all of its features, including accessing search hits directly, in any order. To skip a whole file, just match its name with your minibuffer input and then use `C-~’ to remove all of its occurrences from the set of hits.

You can similarly use ‘M-s M-s m’ in Ibuffer or Buffer Menu to search all marked buffers using Icicles search, and in your bookmark list (buffer `*Bookmark List*’) to search all marked bookmark targets (you need library Bookmark+ for this). Also, ‘C-0 M-s M-s M-s’ and `C-0 C-c `’ are bound to the same command. (But you cannot pass a separate prefix arg in those cases, since ‘C-0’ is already used.)

Save Marked Names as Completion Candidates

In Dired with Icicles, you can use `C-M->’ (‘icicle-dired-save-marked’) to save the marked file and subdirectory names as a set of completion candidates, for reuse later (e.g., using `C-M-<’). Similarly, you can use `C->’ to add the marked files to an existing saved set of candidates.

These bindings act similarly to `C-M->’ and `C->’ in the minibuffer: a prefix argument controls whether you save candidates to a variable or a cache file. Also, `C-M-}’ saves to a variable you name, and `C-}’ saves to a cache file – see Marked Files and Dirs as a Project, below.

You can use such a saved set of file and directory names as candidates during file-name completion. They are saved as absolute names, which means you can use them with, say, ‘C-u C-x C-f’. See Absolute File Names and Different Directories.

Save Marked Names Here and Below

Just as ‘M-s M-s m’ acts on the marked names in not only the current Dired buffer but also those in marked subdirectories, recursively (see Search-and-Replace Marked Files), so there are commands to save the marked names at all levels within the current directory. These commands are available only if you use library Dired+.

They have the same key bindings as the non-recursive commands, except that they are on prefix key `M-+’. For example, `M-+ C-M->’ saves the marked names here and below as a set of file-name completion candidates. They are available on Dired menu-bar menu Multiple > Marked Here and Below > Icicles.

Open Dired for a Set of File and Dir Names

In Dired with Icicles you can use `C-M-<’ (‘icicle-dired-chosen-files-other-window’) to open Dired for a set of file or directory names that you choose interactively or that you have previously saved (persistently or not) as completion candidates or as an Emacs fileset.

For example, this opens Dired on all files whose names match the regexp `.*foo.*bar’ (the initial `.*’ is implicit):

  C-M-<  foo.*bar  S-TAB  C-!  C-g

The Dired buffer that is created is named `Icy File Set’ (suffixed with `<1>’, `<2>’, etc. as needed), and it contains only the chosen file names.

The file names are checked to be sure they reference existing files. If any of the names are relative names, those files are checked for existence in the Dired directory. If you use a prefix argument, then you are prompted for the directory to use.

Marked Files and Dirs as a Project

Just as `C-}’ in the minibuffer is a shortcut for `C-u C-M->’, which saves the current set of completion candidates persistently, so `C-}’ in Dired saves the marked file names in a cache file or, with a prefix arg, an Emacs fileset. Similarly, just as `C-{’ in the minibuffer is a shortcut for `C-u C-M-<’, which retrieves candidates from a persistent set, so `C-{’ in Dired retrieves a persistent set of file names and opens them in a separate Dired buffer.

You can think of such persistent file-name sets as projects. `C-}’ is bound to command ‘icicle-dired-save-marked-as-project’ (aka ‘icicle-dired-save-marked-persistently’). `C-{’ is bound to command ‘icicle-dired-project-other-window’.

Again, you can use such a project as a candidate set for file-name completion at any time. In addition, `C-}’ and `C-{’ can be handy in Dired for working with projects even without using completion. The files in a project can be distributed among any directories anywhere. This gives you an easy way to open Dired on just the files you want and operate on them there.

And while in a project in Dired you can use `C-M-<’ to mark a project subset to work on, and then use `C-M->’ to operate on that subset using Icicles completion. And you can have any number of projects – you access each by its name (with completion) and need not remember its cache file name.

Shell Commands On Marked Files

This is an optional feature that is not enabled by default. See also Icicles - Shell-Command Enhancements.

In Icicle mode, `!’ and `&’ in Dired let you complete a shell command. You can optionally use Icicles file-name completion for the shell command, by customizing option `icicle-functions-to-redefine’ to add the shell-related functions ‘dired-read-shell-command’ and ‘read-shell-command’.

If you do that, then Icicle mode will substitute Icicles functions for these standard functions and you will get the Icicles completion described here. This is the same optional program-file completion that is available anywhere when a shell command is read (see Icicles - Shell-Command Enhancements), but in Dired the extra, proxy candidates include commands that Icicles thinks might be particularly appropriate for the marked files.

These proxy candidates are not necessarily only command names. They can include switches (options) that specialize a command. For example, if a PDF file (*.pdf) is marked in Dired, the completion candidates might include `gv -safer’, `pdftotext ? -’, and `xpdf’. The first two of these are not just command names (`-safer’ is a command switch).

Starting with Emacs 23, Icicles uses both of the following methods to guess extra (proxy) candidates that are file type-specific:

Prior to Emacs 23, MIME types are not used. In the example of a PDF file, candidates `gv -safer’ and `pdftotext ? -’ are provided by MIME-type associations, and candidate `xpdf’ is provided by the Dired X rules. Note that you can customize the rules.

Any candidates that are specific to the marked files are Icicles proxy candidates – see Proxy Candidates. These are available regardless of the current default-directory. They are not treated as file-name candidates, even though they are available during file-name completion. Icicles proxy candidates have face ‘icicle-proxy-candidates’ in buffer ‘*Completions*’.

Again, everything that is true for shell-command completion elsewhere is also true for shell-command completion in Dired. See Icicles - Shell-Command Enhancements. This includes adding all commands from your search path as proxy candidates if option `icicle-guess-commands-in-path’ is non-‘nil’, and providing help on individual candidates (shell commands or files) during completion.


See Also:



Discussion

In DiredMode, Q eventually runs ‘tags-query-replace’ and A runs ‘tags-search’. In both cases you can use `M→ M-,’ ( (goto-char (point-max))(tags-loop-continue) ) to skip rest of the file and continue to the next file. – GregChernov

Yes, LucTeirlinck? just pointed that out in the current thread on the topic on emacs-devel (I’ve modified the text above to mention it, and RMS has agreed to mention it in the manual). It would still be good if ‘Q’ and ‘A’ had a key to skip to the next file without leaving the current command. It’s good to make this available as an explicit possibility (in the prompt and the doc).
Wrt Icicles‘Q’ and ‘A’ still don’t give you direct access to any search hit, of course. Within a file, you must still traverse all search hits, in order, or else quit the command, move point, and resume. And they both start with point, rather than operating on the whole file or the active region. – DrewAdams
See the note in the text, above: starting with Emacs 23, you will be able to skip to the next file. – DrewAdams

Previous: Icicles - Shell-Command EnhancementsIciclesIciclesIndexNext: Icicles - Info Enhancements

DrewsElispLibraries referenced here: Lisp:icicles.el

CategoryCommands CategoryHelp CategoryCompletion CategoryRegexp CategoryModes CategoryProgrammerUtils CategoryCode CategorySearchAndReplace CategoryShell