From: Gideon Stupp <gideon.stupp@gmail.com>
To: 10638@debbugs.gnu.org
Subject: bug#10638: [PATCH] Prefix Arg support for 'isearch-repeat-forward' and 'isearch-repeat-backward'
Date: Sun, 29 Jan 2012 17:59:06 +0200 [thread overview]
Message-ID: <CAJzWQ4dWm6y0RLoFkgT4VcfJgV53RN1LRsq9Ek+8JsO06JTomg@mail.gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 333 bytes --]
Package: emacs
Tags: patch
This patch extends 'isearch-repeat-forward' and 'isearch-repeat-backward'
to support a prefix argument so that during search it is possible to press
C-3 C-s for example to repeat the last search three times. Notice that
you need to set `isearch-allow-scroll' to t for the patch to take effect.
Gideon.
[-- Attachment #1.2: Type: text/html, Size: 469 bytes --]
[-- Attachment #2: isearch_repeat_prefix_arg_support.patch --]
[-- Type: text/x-patch, Size: 1400 bytes --]
diff --git a/lisp/isearch.el b/lisp/isearch.el
index ce75911..ce12552 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -1340,15 +1340,37 @@ Use `isearch-exit' to quit without signaling."
(isearch-push-state)
(isearch-update))
-(defun isearch-repeat-forward ()
+(defun isearch-repeat-forward (&optional arg)
"Repeat incremental search forwards."
- (interactive)
- (isearch-repeat 'forward))
-
-(defun isearch-repeat-backward ()
+ (interactive "p")
+ (if (< arg 0)
+ (progn
+ ;; Doesn't do any search, just switches to backward search
+ (isearch-repeat 'backward)
+ (while (< arg 0)
+ (isearch-repeat 'backward)
+ (setq arg (1+ arg)))
+ ;; Now switch back to forward search
+ (isearch-repeat 'forward))
+ (while (> arg 0)
+ (isearch-repeat 'forward)
+ (setq arg (1- arg)))))
+
+(defun isearch-repeat-backward (&optional arg)
"Repeat incremental search backwards."
- (interactive)
- (isearch-repeat 'backward))
+ (interactive "p")
+ (if (< arg 0)
+ (progn
+ ;; Doesn't do any search, just switches to forward search
+ (isearch-repeat 'forward)
+ (while (< arg 0)
+ (isearch-repeat 'forward)
+ (setq arg (1+ arg)))
+ ;; Now switch back to backward search
+ (isearch-repeat 'backward))
+ (while (> arg 0)
+ (isearch-repeat 'backward)
+ (setq arg (1- arg)))))
(defun isearch-toggle-regexp ()
"Toggle regexp searching on or off."
next reply other threads:[~2012-01-29 15:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-29 15:59 Gideon Stupp [this message]
2012-04-10 23:59 ` bug#10638: [PATCH] Prefix Arg support for 'isearch-repeat-forward' and 'isearch-repeat-backward' Lars Magne Ingebrigtsen
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=CAJzWQ4dWm6y0RLoFkgT4VcfJgV53RN1LRsq9Ek+8JsO06JTomg@mail.gmail.com \
--to=gideon.stupp@gmail.com \
--cc=10638@debbugs.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 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).