> <tt>[[isearch+.el]]</tt> Features:
> <tt>[[isearch-prop.el]]</tt> Features:
This page is about Isearch+, that is, library isearch+.el and its companion library isearch-prop.el. These libraries extend standard Emacs library
isearch.el, which provides IncrementalSearch. (Neither of these extension libraries requires the other. They are complementary, but they enhance each other.)
‘isearchp-restrict-to-region-flag’. Deactivation of the active region, controlled by option
‘isearchp-deactivate-region-flag’. Both of these are available for Emacs 24.3 and later. You can use
‘isearchp-toggle-region-restriction’) during search to toggle
‘query-replace’). The main job of that library is to show information about the active region in the mode line. And whenever you invoke a replacement command or Isearch for the active region, that region information is highlighted specially. See ModeLinePosition for screenshots and more info.
‘nil’means automatically set the region around the last search target.
‘isearchp-toggle-set-region’, bound to
‘C-SPC’during isearch – toggle
‘set-region-around-search-target’– manually set the region around the last search target.
‘isearchp-act-on-demand’– Emacs 22+ only) to invoke the action function that is the value of option
‘isearchp-on-demand-action-function’. That function is passed the current search-hit string and its start and end positions in the buffer. Search moves to the next hit in the same search direction, so just repeating
‘C-M-RET’carries out the action on subsequent hits.
‘isearchp-replace-on-demand’, which replaces the search hit. This means that you can replace (or delete) chosen search hits on demand. By default, the replacement string is empty, so with no prefix argument the action is to delete the search hit (replace it with nothing).
‘C-M-RET’) prompts for the replacement, which is used thereafter until you again use a prefix arg. Since you can use a prefix arg at any time, you can provide different replacements for different search hits. When prompted, if you clear the minibuffer and hit
‘RET’, hit replacement just becomes search-hit deletion. [NOTE: To use a prefix arg within Isearch, you must set
‘isearch-allow-prefix’(if available) or
‘C-u’) or a numeric prefix arg of value 1 (e.g.
‘isearchp-replace-on-demand’replaces only the current search hit.
‘isearchp-replace-on-demand’changes searching so that it also replaces. That is, the search key (e.g.,
‘C-s’) then acts the same as
‘C-M-RET’. (You can cancel this by using a non-negative prefix arg or by quitting and restarting Isearch.)
‘isearchp-replace-on-demand’replaces N search hits (but it stops at the search limit, if reached).
‘isearchp-replace-on-demand’replaces all remaining search hits (up to the search limit).
‘C-M-RET’) the replacement text can be either inserted literally, as is, or interpreted as in
‘query-replace-regexp’. In the latter case, you can use `
\,’ and `
`\(e\)\|a'and a replacement pattern of
`\,(if \1 "a" "e")'. Each
‘C-M-RET’will then swap
‘a’and vice versa.
‘Regexp Replace’of the Emacs manual for more information.
\?’ is supported, but it is not very useful in this context, because it prompts you to edit the result each time you hit
‘C-M-RET’. Instead, use
‘C-u C-M-RET’whenever you want to change (edit) the replacement pattern.)
‘isearchp-toggle-literal-replacement’) anytime during Isearch to toggle whether replacement text is used literally or interpreted per the special regexp-replacement constructs.
\&’ and so on is to use `
‘isearchp-noprompt-action-function’is a function that is invoked automatically, after you visit each search hit. The function is called with no arguments. It cannot use the minibuffer, but it can modify buffer contents. The variable is reset to
‘nil’when you quit Isearch. As an example of use, command
‘isearchp-replace-on-demand’with a negative prefix arg sets this to
‘isearchp-replace-match’, which causes automatic replacement each time you visit a search hit.
‘isearchp-nomodify-action-hook’(Emacs 22+ only) is also run after each search visit. Its functions also must accept the same arguments as
‘isearchp-act-on-demand’. The functions can use the minibuffer, but they must not update the buffer text (in a way noticeable by Isearch), or else that will likely lead to a call-stack overflow. This is because they are called with Isearch suspended during
‘isearch-update’(which can itself be invoked by the action…).
‘isearchp-regexp-quote-yank-flag’) and command (
‘isearchp-toggle-regexp-quote-yank’, bound to `
C-`’) to toggle quoting (escaping) of regexp special characters. With escaping turned off, you can yank text such as
^\*.*without it being transformed to
‘isearchp-retrieve-last-quit-search’) yanks the last successful search string (regexp or plain) from when you last hit
‘C-g’in Isearch. Sometimes you search for something but abandon the search — you just want to check the locations of something, without staying at any of them. Afterward, if you want to find them again, use
‘M-g’. This yanks that search string, so you can append it to whatever you are already searching for.
‘C-x r g’(
‘isearchp-append-register’) appends the contents of a register to the search string. You are prompted for the register to use. This is the same key that is bound globally to
‘insert-register’. If you want this key to instead exit Isearch and insert the register in the buffer, then define this key in
‘isearch-mode-map’as `nil` (i.e., unbind it), and optionally bind
‘isearchp-append-register’to a different key in
‘isearch-yank-secondary’) yanks the secondary selection onto the search string, if you also use library second-sel.el (see secondary selection enhancements).
‘isearchp-yank-char’) yanks successive characters onto the search string.
‘isearchp-yank-symbol-or-char’) yanks successive symbols (or words or subwords or chars) onto the search string.
‘isearchp-yank-sexp-symbol-or-char’) yanks successive sexps (or symbols or words or subwords or chars) onto the search string.
‘isearchp-kill-ring-save’) copies the current search string to the kill ring. You can then, for example, use
‘C-s M-y’to search for the same thing in another Emacs session. (I use this all the time, but you might not use multiple Emacs sessions.) Note that if you did not have this feature then you would need to select the search-string text (in the text buffer or in the
‘M-e’Isearch edit buffer) and copy it to the kill ring. (Note:
‘M-w’used to toggle word search, but
‘C-y’(in addition to any other Isearch bindings):
C-y C-_ isearchp-yank-symbol-or-char C-y C-( isearchp-yank-sexp-symbol-or-char C-y C-2 isearch-yank-secondary C-y C-c isearchp-yank-char C-y C-e isearchp-yank-line C-y C-w isearchp-yank-word-or-char C-y C-y isearch-yank-kill C-y M-y isearch-yank-pop
‘isearch-yank-pop’) by just repeating the last key. For example:
‘C-y C-e C-e C-e’adds the text up to the end of three lines.
‘C-x 8 RET’(
‘isearch-char-by-name’) reads the name of a Unicode character with completion and appends it to the search string. Same thing when editing the search string (i.e., after
‘M-e’). This is part of GnuEmacs starting with Emacs 24.4.
‘isearchp-open-recursive-edit’) opens a recursive editing session, where you can do anything you like (including search for something different). Using
‘C-M-c’closes the recursive editing session and resumes the search (from the current position when you hit
‘C-g’, or removed/replaced automatically if you use
‘M-k’(see next). I added this feature to GnuEmacs 23.1.
‘C-g’after successfully finding matches restores not only the original position but also its relative position in the window. IOW, you get back to what you saw before searching. Fixes GnuEmacs bug #12253 for Isearch.
‘isearchp-cycle-mismatch-removal’) cycles automatic removal or replacement of the input portion that does not match. The behavior is controlled by the value of option
‘replace-last’– Your current input replaces the last mismatched text. You can always see your last input, even if it is a mismatch. And it is available for editing using
‘nil’– Your current input is appended, even if the previous input has a mismatched portion.
‘isearchp-toggle-option-flag’, which you can toggle using
‘isearchp-toggle-option-toggle’), determines whether commands that toggle behavior also toggle an associated user option. For such commands, a prefix argument flips the behavior, as if
‘isearchp-toggle-option-flag’were toggled temporarily. Currently this feature applies to toggles
‘M-s i’(matching hidden text).
‘isearch-toggle-case-fold’) toggles case sensitivity. If option
‘nil’then it toggles option
‘isearchp-case-fold’to change the sensitivity from now on. Otherwise, the option value is not changed, so the effect is for the current search only.
‘isearch-toggle-invisible’) toggles invisible-text sensitivity. If option
‘nil’then it toggles option
‘search-invisible’to change the sensitivity from now on. Otherwise, the option value is not changed, so the effect is for the current search only.
‘isearchp-toggle-invisible’) toggles the value of option
‘search-invisible’. The effect is like that of
‘M-s i’with no prefix argument and with non-
‘prior’repeat the last Isearch forward and backward (easier than using the chords
‘C-end’– go to the longest line. Repeat to go to the longest line following that one in the buffer. As usual,
‘C-g’puts you back where you started. This binding is made only if you also use library misc-cmds.el. See Find Long Lines.
‘C-h’provides help on Isearch while searching. Library isearch+.el also redefines
‘isearch-mode-help’so that it lists all Isearch bindings and ends Isearch properly.
‘isearch-edit-string’) automatically puts the cursor at the first mismatch position in the search string, for easy editing. Whereas
‘M-k’) removes all of the mismatch, this feature lets you change or insert a character or two, without losing the rest of the search string.
‘isearchp-initiate-edit-commands’, that specifies commands whose keys will not exit Isearch but will instead initiate editing of the search string. For example, if
‘backward-char’is included in the list then
‘left’will just move the cursor backward over the search string so you can change, delete, or insert chars in the middle somewhere. This makes the search string more minibuffer-like.
‘C-s’etc. to search for it. This is controlled by user option
‘face’text property with a value of
‘font-lock-string-face’. Search overlays or text properties. From within Isearch:
‘C-M-t’for regexp search). First time, or with a prefix argument, you are prompted for the property and its values. See the doc string of command
‘face’and other text properties for use with
‘C-t’, you can use command
‘isearchp-put-prop-on-region’(outside of Isearch) to add a text property to a zone of text. By default, it applies the last property and value whose zones you searched using
‘C-t’, but a prefix argument lets you specify the property and value to apply. This gives you an interactive way to set up zones for text-property search (
‘C-t’). For property
‘face’, empty input removes all faces from the region.
‘isearchp-dim-non-prop-zones-flag’controls whether such dimming occurs. You can toggle it anytime during Isearch, using
‘isearchp-dimming-color’defines the dimming behavior. It specifies a given background color to use always, or it specifies that the current background color is to be dimmed a given amount.
‘isearchp-thing’. This is equivalent to using command
‘isearchp-thing-define-contexts’, which marks such zones with a text property, and then using
‘isearchp-previous-visible-thing’. For best results I recommend that you also use library thingatpt+.el. It enhances the vanilla treatment of THINGS and fixes various vanilla thing-at-point bugs.
‘isearchp-imenu-non-interactive-function’. Since ImenuMode is based on regexps that recognize definitions, these commands are based on the behavior of
‘isearchp-remove-all-properties’. By default, the latter removes only properties whose names begin with
‘isearchp-’. These are the properties inserted automatically by the commands of library isearch-prop.el, when you do not specify a property.
‘isearchp-toggle-hiding-comments’). You can toggle ignoring comments during Isearch, using `
‘query-replace’. In particular, the ability to select (put the region around) the last replacement.
In Emacs 24.2.1, and maybe other versions, if you use IsearchPlus with Ido Ubiquitous (see: InteractivelyDoThings) enabled, you find that you can’t search for unicode charaters and if you try an error is generated. In Emacs 24.2.1 the solution is to disable Ido’s advice around
‘isearchp-read-unicode-char’ is called. This can be done by putting:
in your .emacs file. When I first did this, I evaluated the form interactively and it didn’t seem to fix the problem - I don’t know why - but it worked next time I started up Emacs. — Bernard Hurley
Good to know, for Ido users. If you investigate a bit more and figure out why it sometimes does not work, would this be something that should be done automatically in Isearch+? Or do you think some users would not want it done (in which case perhaps it should be an option or an Isearch toggle)? Would you like to try patching
isearch+.el to DTRT? Seems like we should be able to take care of this kind of thing automatically, so users do not need to do anything. – DrewAdams
Ido seems to work by advising
‘completing-read’ and advising various functions that call it. Ido code doesn’t look very clear to me, but I think that’s what it does. It also turns off this advice for functions that the Ido developers know about but haven’t got round to advising. This is obviously going to cause problems if you write a function that calls
‘completing-read’, as yours does, and are returned an unexpected value. I can’t imagine any users not wanting this fixed automatically. My own thoughts are that since Ido makes this quite radical change to a core Emacs function, it’s better if it’s done automatically in that package. I have emailed the developers to gently suggest this. However I will look farther into it in case they don’t want to do so. – Bernard Hurley
Thanks for the update. FYI, I renamed
‘isearchp-insert-char-by-name’ in keeping with an updated definition and an expectation that Emacs 24.4 might include this (as
I still have the same question as above:
Please let me know, when you can. It would be good to take care of this problem automatically, if that is appropriate. Thx – DrewAdams
Since searching for unicode characters in isearch+ is virtually impossible without the fix, I think it should be done automatically. Ido users might be a bit surprised not to get an Ido search at this point but Ido isn’t guaranteed to work everywhere, so I can’t see why anyone shouldn’t want the fix. – Bernard Hurley
OK, thanks. Can you provide a patch? Note that the same feature might well be added to Emacs — see this thread: http://lists.gnu.org/archive/html/emacs-devel/2012-12/msg00234.html. So you might want to bring JuriLinkov into the loop about fixing this wrt Ido. He might also have a suggestion. Please cc me if you do so by email. Thx – DrewAdams