unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Dani Moncayo <dmoncayo@gmail.com>
Cc: 13480@debbugs.gnu.org
Subject: bug#13480: 24.3.50; `C-w' from Isearch should translate newlines to spaces
Date: Sat, 19 Jan 2013 11:59:22 +0200	[thread overview]
Message-ID: <87bocl7av5.fsf@mail.jurta.org> (raw)
In-Reply-To: <CAH8Pv0j7SDcdR6yRjDa8iMM8=O9sV3EZSj80++GgJ0h3dvbfBg@mail.gmail.com> (Dani Moncayo's message of "Sat, 19 Jan 2013 09:05:19 +0100")

> 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))





  parent reply	other threads:[~2013-01-19  9:59 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-17 20:39 bug#13480: 24.3.50; `C-w' from Isearch should translate newlines to spaces Dani Moncayo
2013-01-17 21:27 ` Juri Linkov
2013-01-17 23:10   ` Dani Moncayo
2013-01-17 23:54     ` Dani Moncayo
2013-01-18 21:59       ` Juri Linkov
2013-01-19  8:05         ` Dani Moncayo
2013-01-19  9:56           ` Dani Moncayo
2013-01-19 10:07             ` Juri Linkov
2013-01-19 10:40               ` Dani Moncayo
2013-01-19 10:57                 ` Juri Linkov
2013-01-19 12:11                   ` Dani Moncayo
2013-01-19 15:45                     ` Drew Adams
2013-01-19 15:43                   ` Drew Adams
2013-01-19 17:20                     ` Stefan Monnier
2013-01-19 23:30                       ` Juri Linkov
2013-01-20  9:41                         ` Dani Moncayo
2013-01-20 12:27                           ` Dani Moncayo
2022-04-22 12:28                         ` Lars Ingebrigtsen
2022-04-24 15:46                           ` Juri Linkov
2022-04-25  7:26                             ` Lars Ingebrigtsen
2013-01-19 15:01             ` Drew Adams
2013-01-19  9:59           ` Juri Linkov [this message]
2013-08-03 17:09 ` Dani Moncayo

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bocl7av5.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=13480@debbugs.gnu.org \
    --cc=dmoncayo@gmail.com \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).