Icicles - Isearch Enhancements

Last edit

Changed:

< '''`C-M-TAB''''. (Note: For MS Windows, you can use

to

> '''`C-M-TAB''''. (Note: For some versions of MS Windows, you can use


iciclesimage
Previous: Icicles - History EnhancementsIciclesIciclesIndexNext: Icicles - Search Commands, Overview

Isearch Enhancements

Icicles provides two different enhancements for searching:

See Also: Icicles - Support for Projects for information about using ‘grep’ to search all of the files in a project.

Isearch Completion Against the Search History

When you search incrementally (‘C-s’), Emacs lets you use ‘M-TAB’ (‘M-tab’ or ‘C-M-i’, aka ‘ESC-TAB’) to complete your input to a string that you have sought previously, that is, a string in the current search history (‘search-ring’ or ‘regexp-search-ring’). In Icicle mode, this feature is enhanced so that you can use all of the completion enhancements provided by Icicles: ‘M-TAB’ is bound to ‘icicle-isearch-complete’ during Isearch.

Some operating systems grab ‘M-TAB’ for their own use, making it unavailable for Emacs. They normally do not grab ‘ESC TAB’, which in Emacs is typically the same ase ‘M-TAB’. For this reason, Icicles also binds ‘icicle-isearch-complete’ to both ‘ESC TAB’ and ‘C-M-TAB’. (Note: For some versions of MS Windows, you can use (w32-register-hot-key (icicle-kbd "M-tab")) to allow Emacs to use ‘M-TAB’.)

Icicles users are in the habit of using `M-o’ to complete the current minibuffer input against previously entered inputs. Because of the similarity, you can likewise use ‘M-o’ during Isearch to append previous isearch strings to the current string. During Isearch, ‘M-o’ is bound to minibuffer multi-command ‘icicle-isearch-history-insert’.

The keys bound by default to ‘icicle-isearch-complete’ in ‘isearch-mode-map’ are thus ‘M-TAB’, ‘ESC TAB’, and ‘C-M-TAB’, and the only key bound by default to ‘icicle-isearch-history-insert’ is ‘M-o’. But you can change the keys to use for these commands by customizing options `icicle-isearch-complete-keys’ and `icicle-isearch-history-insert-keys’, respectively.

When you use ‘M-o’ (or ‘M-TAB’) while searching, Isearch exits momentarily, giving way to Icicles completion in the minibuffer. You can then use either ‘S-TAB’ or ‘TAB’ to complete your search string. After you finish completing (e.g. by hitting ‘C-g’ or ‘RET’), Isearch resumes with the new, modified search string. It’s pretty seamless, and easier to try than to describe.

Reminder: Using ‘S-TAB’ vs ‘TAB’ for regexp vs non-regexp completion against previous search strings has nothing to do with regexp vs non-regexp incremental searching. You can of course use either kind of searching before or after having used either kind of completion. Isearch uses different search histories (rings) for regexp and non-regexp searching. The kind of search in progress (regexp or not) at the moment you use ‘M-TAB’ or ‘M-o’ determines which search ring provides the candidates for completion.

Content-Matching Pattern as Isearch Regexp

When your multi-completion input for commands such as ‘icicle-buffer’ (‘C-x b’), ‘icicle-file’ (‘C-x C-f’), and ‘icicle-Info-goto-node’ (‘g’ in Info) provides a content-matching pattern for completion against buffer, file, or Info node content, and at least one candidate matches, the pattern is saved to the Isearch regexp history, ‘regexp-search-ring’. If you then visit a matching buffer or file, you can immediately search for each match using ‘C-M-s’ or ‘C-M-r’.

This gives you another way to search a set of buffers, files, or Info nodes. You can use progressive completion to narrow down the search hits, either by container (buffer, file, or node name) or by content.

(This content-searching behavior is available for ‘icicle-file’ starting with Emacs 23, and for ‘icicle-Info-goto-node’ starting with Emacs 22.)

See also Icicles - Searching Named Containers.

Launch Occur using the Isearch Search String

If you use library color-moccur.el or library occur-schroeder.el, then ‘C-o’ is bound during Isearch to ‘isearch-moccur’, which provides an OccurMode buffer interface for search hits. This has nothing per se to do with Icicles, but you might find it useful. (Library color-moccur.el itself binds ‘M-o’ for this, but `M-o’ is used in Icicles for search-string completion.)

Launch Icicles Search using the Isearch Search String

Icicles search is described in section Icicles - Search Commands, Overview.

You can start Icicles search from Isearch: Hit ‘S-TAB’ to choose the Icicles search initial regexp – the default value is the current Isearch search string, but you can edit that. Completion is available for your input – completion against your previous Isearch regexp search strings.

For example, use ‘C-s C-w C-w S-TAB’ to pick up the next two words at the cursor, then type `.*’ before and after them and hit ‘RET’. That puts you in Icicles search with the completion candidates being all of the lines in the buffer that contain that two-word phrase. Type some more text to narrow the candidate lines to those that match what you type. Then use ‘C-next’ to visit search hits.

With Emacs 22 and later, and provided option ‘isearch-allow-scroll’ (a misnomer) is non-‘nil’, you can use a prefix argument with ‘S-TAB’ to change the behavior. You still choose an Isearch search string using completion. But in this case the string does not define the Icicles search contexts. Instead, you are prompted for a search-context regexp to do that. The Isearch string is copied to the ‘kill-ring’, so you can yank it into your minibuffer input anytime, to search for it within each of the search contexts.

The key to initiate Icicles search from Isearch is ‘S-TAB’ only by default. You can change this key by customizing option `icicle-search-from-isearch-keys’.


Previous: Icicles - History EnhancementsIciclesIciclesIndexNext: Icicles - Search Commands, Overview

DrewsElispLibraries referenced here: Lisp:highlight.el, Lisp:icicles.el

CategoryCommands CategoryCompletion CategoryRegexp CategoryRegion CategoryModes CategoryDirectories