1

I recently upgraded from Windows Emacs 19.x to Windows 26.3.1 and have a problem.

in the old version 19 if I did a search forward for a space, (C-s) it skipped forward to the FIRST space character and stopped there. If I typed a second space character, the search became a search for two space characters in a row, and would find the first instance of two spaces, and point to the second character. I have dozens of functions and macros which depend upon this operation and now none of them work.

What I'm seeing with version 26.3.1 is that when I search for a space, if it finds multiple spaces in a row, it positions on the LAST space, which is (1) not what I want and (2) really strange behavior and (3) breaks all my functions.

I need the behavior for any and all forward searches in any and all files to be to find the first instance and STAY THERE and NOT move to the last of a series of characters, whitespace, etc.

How do I disable this "feature" where it skips to the LAST of a series of characters, and go back to the way Emacs used to work? Is there something I can put in the default.el file (yeah, another great change I found out about the hard way) so that for EVERY file I open the operation is to find the first space?

1

Set variable isearch-lax-whitespace to nil.

C-h v isearch-lax-whitespace tells you:

isearch-lax-whitespace is a variable defined in isearch.el.

Its value is t

Documentation:

If non-nil, a space will match a sequence of whitespace chars. When you enter a space or spaces in ordinary incremental search, it will match any sequence matched by the regexp defined by the variable search-whitespace-regexp.

If the value is nil, each space you type matches literally, against one space. You can toggle the value of this variable by the command isearch-toggle-lax-whitespace.

There is also variable isearch-regexp-lax-whitespace, which acts similarly for regexp searches.

And command isearch-toggle-lax-whitespace toggles either of these variables (depending on which kind of searching is in progress). The command is bound by default to M-s SPC in Isearch mode. So you can toggle the behavior between what you prefer and the new default behavior just by hitting M-s SPC during Isearch.

  • Thanks Drew! I tried modifying isearch.el, but it didn't seem to have any effect. Does that file need to be recompiled, and if so what is the process? I tried the isearch-toggle-lax-whitespace and it worked interactively, so I put it in my default.el file, and it seems to work, so would that be a better solution than the modification to isearch.el? – John Jun 11 '18 at 22:48
  • Don't modify anything in isearch.el. It works out of the box, even in vanilla Emacs (emacs -Q: no init file). If you want to change the default behavior, just set the variable(s) to nil in your init file. E.g., (setq isearch-lax-whitespace nil). – Drew Jun 11 '18 at 22:50
  • Thanks! Adding (setq isearch-lax-whitespace nil) to my default.el file did the trick! – John Jun 12 '18 at 20:04

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.