GNU bug report logs -
#13480
24.3.50; `C-w' from Isearch should translate newlines to spaces
Previous Next
Reported by: Dani Moncayo <dmoncayo <at> gmail.com>
Date: Thu, 17 Jan 2013 20:41:02 UTC
Severity: normal
Tags: moreinfo
Found in version 24.3.50
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #26 received at 13480 <at> debbugs.gnu.org (full text, mbox):
> 1. It loses information that may be useful. In the future we could
> want to implement a feature whereby the user can toggle the
> lax-whitespace-matching behavior during an Isearch session. In fact I
> think it would be a good feature (and ISTR that Drew proposed some
> time ago).
We already have this feature with `M-SPC'.
> That feature would not be possible if we change the text
> that the user supplies to search for.
Yes, there is no way to restore the original text in the search string
and to un-translate a space back to the newline.
> 2. It is less surprising and more clean to me to see in the echo area
> exactly the text I'm supplying, without translations of any kind.
Then this is possible to not translate newlines to a space
in the search string but process it internally with this code:
(defun search-whitespace-regexp (string)
"Return a regexp which ignores whitespace.
Uses the value of the variable `search-whitespace-regexp'."
(if (or (not (stringp search-whitespace-regexp))
(null (if isearch-regexp
isearch-regexp-lax-whitespace
isearch-lax-whitespace)))
string
;; FIXME: this is not strictly correct implementation because it ignores
;; `subregexp-context-p' and replaces spaces inside char set group like
;; in `C-M-s M-s SPC [ ]', it converts it to ["\\(\\s-\\|\n\\)+"] !
(replace-regexp-in-string
search-whitespace-regexp ;; " "
search-whitespace-regexp
string nil t)))
(defun search-forward-lax-whitespace (string &optional bound noerror count)
(re-search-forward (search-whitespace-regexp (regexp-quote string)) bound noerror count))
(defun search-backward-lax-whitespace (string &optional bound noerror count)
(re-search-backward (search-whitespace-regexp (regexp-quote string)) bound noerror count))
(defun re-search-forward-lax-whitespace (regexp &optional bound noerror count)
(re-search-forward (search-whitespace-regexp regexp) bound noerror count))
(defun re-search-backward-lax-whitespace (regexp &optional bound noerror count)
(re-search-backward (search-whitespace-regexp regexp) bound noerror count))
This bug report was last modified 3 years and 86 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.