From: Richard Stallman <rms@gnu.org>
Subject: spaces in isearch
Date: Sat, 20 Nov 2004 20:10:22 -0500 [thread overview]
Message-ID: <E1CVgFC-00006L-G2@fencepost.gnu.org> (raw)
I wrote these changes to isearch.el that take advantage of the new
search feature I just installed. It fixes the bug, but has a
drawback: C-q SPC would no longer work as a way to search for a
literal space. One would need to write [ ]. This is actually more
logical, but some users might be accustomed to C-q SPC. What do
people think?
*** isearch.el 12 Oct 2004 04:45:09 -0400 1.242
--- isearch.el 20 Nov 2004 09:22:33 -0500
***************
*** 112,117 ****
--- 112,119 ----
(defcustom search-whitespace-regexp "\\(?:\\s-+\\)"
"*If non-nil, regular expression to match a sequence of whitespace chars.
This applies to regular expression incremental search.
+ When you put a space or spaces in the incremental regexp, it stands for
+ this, unless it is inside of a regexp construct such as [...] or *, + or ?.
You might want to use something like \"\\\\(?:[ \\t\\r\\n]+\\\\)\" instead.
In the Customization buffer, that is `\\(?:[' followed by a space,
a tab, a carriage return (control-M), a newline, and `]+\\)'."
***************
*** 260,267 ****
(define-key map "\r" 'isearch-exit)
(define-key map "\C-j" 'isearch-printing-char)
(define-key map "\t" 'isearch-printing-char)
- (define-key map " " 'isearch-whitespace-chars)
- (define-key map [?\S-\ ] 'isearch-whitespace-chars)
(define-key map "\C-w" 'isearch-yank-word-or-char)
(define-key map "\M-\C-w" 'isearch-del-char)
--- 262,267 ----
***************
*** 485,491 ****
Do incremental search forward for regular expression.
With a prefix argument, do a regular string search instead.
Like ordinary incremental search except that your input
! is treated as a regexp. See \\[isearch-forward] for more info."
(interactive "P\np")
(isearch-mode t (null not-regexp) nil (not no-recursive-edit)))
--- 485,496 ----
Do incremental search forward for regular expression.
With a prefix argument, do a regular string search instead.
Like ordinary incremental search except that your input
! is treated as a regexp. See \\[isearch-forward] for more info.
!
! In regexp incremental searches, a space or spaces normally matches
! any whitespace (the variable `search-whitespace-regexp' controls
! precisely what that means). If you want to search for a literal space
! and nothing else, enter `[ ]'."
(interactive "P\np")
(isearch-mode t (null not-regexp) nil (not no-recursive-edit)))
***************
*** 1704,1725 ****
(isearch-process-search-multibyte-characters char)
(isearch-process-search-char char)))))
- (defun isearch-whitespace-chars ()
- "Match all whitespace chars, if in regexp mode.
- If you want to search for just a space, type \\<isearch-mode-map>\\[isearch-quote-char] SPC."
- (interactive)
- (if isearch-regexp
- (if (and search-whitespace-regexp (not isearch-within-brackets)
- (not isearch-invalid-regexp))
- (isearch-process-search-string search-whitespace-regexp " ")
- (isearch-printing-char))
- (progn
- ;; This way of doing word search doesn't correctly extend current search.
- ;; (setq isearch-word t)
- ;; (setq isearch-adjusted t)
- ;; (goto-char isearch-barrier)
- (isearch-printing-char))))
-
(defun isearch-process-search-char (char)
;; Append the char to the search string, update the message and re-search.
(isearch-process-search-string
--- 1709,1714 ----
***************
*** 1960,1965 ****
--- 1949,1955 ----
(let ((inhibit-point-motion-hooks search-invisible)
(inhibit-quit nil)
(case-fold-search isearch-case-fold-search)
+ (search-spaces-regexp search-whitespace-regexp)
(retry t))
(if isearch-regexp (setq isearch-invalid-regexp nil))
(setq isearch-within-brackets nil)
***************
*** 2373,2379 ****
(defun isearch-lazy-highlight-search ()
"Search ahead for the next or previous match, for lazy highlighting.
Attempt to do the search exactly the way the pending isearch would."
! (let ((case-fold-search isearch-case-fold-search))
(funcall (isearch-search-fun)
isearch-string
(if isearch-forward
--- 2363,2370 ----
(defun isearch-lazy-highlight-search ()
"Search ahead for the next or previous match, for lazy highlighting.
Attempt to do the search exactly the way the pending isearch would."
! (let ((case-fold-search isearch-case-fold-search)
! (search-spaces-regexp search-whitespace-regexp))
(funcall (isearch-search-fun)
isearch-string
(if isearch-forward
next reply other threads:[~2004-11-21 1:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-21 1:10 Richard Stallman [this message]
2004-11-21 2:43 ` spaces in isearch Juri Linkov
2004-11-21 11:08 ` Alex Schroeder
2004-11-21 17:09 ` Juri Linkov
2004-11-22 0:35 ` Stefan Monnier
2004-11-22 14:07 ` Richard Stallman
2004-11-22 18:39 ` Kevin Rodgers
2004-11-23 6:07 ` Harald Maier
2004-11-23 6:52 ` Juri Linkov
2004-11-24 5:37 ` Harald Maier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1CVgFC-00006L-G2@fencepost.gnu.org \
--to=rms@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.