From: Juri Linkov <juri@jurta.org>
Cc: emacs-devel@gnu.org
Subject: Re: isearch-query-replace-regexp and stuff
Date: Sat, 03 Jul 2004 09:59:14 +0300 [thread overview]
Message-ID: <87n02h374e.fsf@mail.jurta.org> (raw)
In-Reply-To: <x5fz8au9kq.fsf@lola.goethe.zz> (David Kastrup's message of "02 Jul 2004 09:55:49 +0200")
David Kastrup <dak@gnu.org> writes:
> The other thing that might make sense is to just define M-% and use it
> to start regexp replacements in regexp searches, and non-regexp
> replaced in normal isearch. It might be confusing. OTOH, the C-s
> binding during searches already has this sort of split personality.
Yes, it makes sense to use M-% to start regexp replacements in regexp
search. I often mistakenly type M-% even if I want to start regexp
replacements, and then cancel it and retype C-M-%. Using M-% to start
regexp replacements in regexp isearch will reduce such mistakes. If
users have switched to regexp search mode there is a high probability
than they want regexp replacements and mistyped M-% instead of C-M-%.
>> We could use a prefix argument of M-r to implement these things
>> instead of adding a new key binding.
>
> No, we couldn't. Prefix arguments exit the search.
Prefix arguments don't exit the search. IIRC, this is a relatively
recent change in isearch.el.
> It might make sense when switching to use the respective search
> history's last entry _if_ it happens to match at point.
This is useless. It's possible to type M-p just after switching
the search mode to use the respective search history's last entry.
But the current non-intrusive behavior of M-r is much better
for users who use it to switch the search type invoked by mistake
(`C-s' instead of `C-M-s') or by other reasons (e.g. want to add
regexp constructs to the current search string).
BTW, M-p currently does not work right. When typing it after starting
isearch mode (i.e. `C-s M-p') it uses not the most recent item in the
search ring, but the second history item. The patch below fixes this
problem. It makes M-p to start visiting previous search strings from
the index 0 instead of 1. And in those places where the last search
string is reused after typing `C-s C-s' it calls `isearch-ring-adjust1'
to adjust the isearch ring to the first element to prepare the correct
index for further M-p and M-n commands.
Index: lisp/isearch.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.230
diff -u -w -b -r1.230 isearch.el
--- lisp/isearch.el 1 Jul 2004 09:54:51 -0000 1.230
+++ lisp/isearch.el 3 Jul 2004 07:32:43 -0000
@@ -911,6 +911,7 @@
;; Empty isearch-string means use default.
(if (= 0 (length isearch-string))
+ (progn
(setq isearch-string (or (car (if isearch-regexp
regexp-search-ring
search-ring))
@@ -919,6 +920,7 @@
isearch-message
(mapconcat 'isearch-text-char-description
isearch-string ""))
+ (isearch-ring-adjust1 nil))
;; This used to set the last search string,
;; but I think it is not right to do that here.
;; Only the string actually used should be saved.
@@ -989,6 +991,7 @@
;; C-s in forward or C-r in reverse.
(if (equal isearch-string "")
;; If search string is empty, use last one.
+ (progn
(setq isearch-string
(or (if isearch-regexp
(car regexp-search-ring)
@@ -998,6 +1001,7 @@
(mapconcat 'isearch-text-char-description
isearch-string "")
isearch-case-fold-search isearch-last-case-fold-search)
+ (isearch-ring-adjust1 nil))
;; If already have what to search for, repeat it.
(or isearch-success
(progn
@@ -1650,11 +1654,10 @@
()
(set yank-pointer-name
(setq yank-pointer
- (mod (+ (or yank-pointer 0)
+ (mod (+ (or yank-pointer (if advance 0 -1))
(if advance -1 1))
length)))
(setq isearch-string (nth yank-pointer ring)
@@ -1693,13 +1695,11 @@
()
(set yank-pointer-name
(setq yank-pointer
- (mod (- (or yank-pointer 0) n)
+ (mod (- (or yank-pointer (if (> n 0) 0 -1)) n)
length)))
(delete-field)
(insert (nth yank-pointer ring))
--
Juri Linkov
http://www.jurta.org/emacs/
next prev parent reply other threads:[~2004-07-03 6:59 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-01 23:18 isearch-query-replace-regexp and stuff David Kastrup
2004-07-02 0:05 ` David Kastrup
2004-07-02 17:51 ` Richard Stallman
2004-07-02 6:55 ` Juri Linkov
2004-07-02 7:55 ` David Kastrup
2004-07-02 13:44 ` Stefan
2004-07-03 6:59 ` Juri Linkov [this message]
2004-07-03 18:20 ` Richard Stallman
2004-07-05 19:07 ` David Kastrup
2004-07-06 9:59 ` Juri Linkov
2004-07-06 11:20 ` David Kastrup
2004-07-06 16:36 ` Juri Linkov
2004-07-06 17:29 ` David Kastrup
2004-07-07 5:08 ` Juri Linkov
2004-07-07 9:29 ` David Kastrup
2004-07-07 18:29 ` Juri Linkov
2004-07-07 19:33 ` David Kastrup
2004-07-08 16:45 ` Juri Linkov
2004-07-08 18:12 ` David Kastrup
2004-07-09 20:54 ` Juri Linkov
2004-07-08 23:17 ` Richard Stallman
2004-07-06 22:00 ` Richard Stallman
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=87n02h374e.fsf@mail.jurta.org \
--to=juri@jurta.org \
--cc=emacs-devel@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.