[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#13480: 24.3.50; `C-w' from Isearch should translate newlines to spac
From: |
Juri Linkov |
Subject: |
bug#13480: 24.3.50; `C-w' from Isearch should translate newlines to spaces |
Date: |
Sat, 19 Jan 2013 11:59:22 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) |
> 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))
- bug#13480: 24.3.50; `C-w' from Isearch should translate newlines to spaces, (continued)
- bug#13480: 24.3.50; `C-w' from Isearch should translate newlines to spaces, Drew Adams, 2013/01/19
- bug#13480: 24.3.50; `C-w' from Isearch should translate newlines to spaces, Stefan Monnier, 2013/01/19
- bug#13480: 24.3.50; `C-w' from Isearch should translate newlines to spaces, Juri Linkov, 2013/01/19
- bug#13480: 24.3.50; `C-w' from Isearch should translate newlines to spaces, Dani Moncayo, 2013/01/20
- bug#13480: 24.3.50; `C-w' from Isearch should translate newlines to spaces, Dani Moncayo, 2013/01/20
- bug#13480: 24.3.50; `C-w' from Isearch should translate newlines to spaces, Drew Adams, 2013/01/19
- bug#13480: 24.3.50; `C-w' from Isearch should translate newlines to spaces,
Juri Linkov <=