all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Gideon Stupp <gideon.stupp@gmail.com>
To: Juri Linkov <juri@jurta.org>
Cc: emacs-devel@gnu.org
Subject: Re: [EXPERIMENTAL PATCH] Extending Isearch-repeat-forward/backward to support a prefix argument following suggesion by Juri Linkov
Date: Tue, 31 Jan 2012 13:52:58 +0200	[thread overview]
Message-ID: <CAJzWQ4fWXrZ_xBJ6_ieq8XwCDzeTsC4dV-v3bhnBkXPRiZhm=Q@mail.gmail.com> (raw)
In-Reply-To: <87wr88lt1i.fsf@mail.jurta.org>

[-- Attachment #1: Type: text/plain, Size: 605 bytes --]

On 1/31/12, Juri Linkov <juri@jurta.org> wrote:
>> So how about the following behavior (for brevity I will describe only
>> isearch-repeat-forward): (1) if you use isearch-repeat-forward then at
>> the end of the operation you must be in a search-forward state; (2)
>> the numerical value decides how many searches are done and (3) the
>> sign defines the direction.
>
> Thanks.  I agree that these rules are reasonable.
>
Hi Juri,
Please see attached patch. Note that I decided to stop the repeated
search at wraparound and any other case where the search fails (eq
isearch-sucess nil).

Thanks, Gideon.

[-- Attachment #2: isearch_repeat_prefix_arg_support.patch --]
[-- Type: text/x-patch, Size: 2157 bytes --]

diff --git a/lisp/isearch.el b/lisp/isearch.el
index ce75911..04f29ba 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -1340,15 +1340,60 @@ 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
+      (let ((narg (prefix-numeric-value arg)))
+	(if (< narg 0)
+	    ;; Go backward.
+	    (progn
+	      ;; Switch direction if necessary
+	      (if isearch-forward (isearch-repeat 'backward))
+	      ;; Go back narg times
+	      (while (and isearch-success (< narg 0))
+		(isearch-repeat 'backward)
+		(setq narg (1+ narg)))
+	      ;; Switch back to forward search
+	      (isearch-repeat 'forward))
+	  ;; Go forward
+	  (progn
+	    ;; Switch direction if necessary
+	    (or isearch-forward (isearch-repeat 'forward))
+	    ;; Go forward narg times
+	    (while (and isearch-success (> narg 0))
+	      (isearch-repeat 'forward)
+	      (setq narg (1- narg))))))
+    ;; No argument
+    (isearch-repeat 'forward)))
+
+(defun isearch-repeat-backward (&optional arg)
   "Repeat incremental search backwards."
-  (interactive)
-  (isearch-repeat 'backward))
+  (interactive "P")
+  (if arg
+    (let ((narg (prefix-numeric-value arg)))
+     (if (< narg 0)
+	 ;; Go forward.
+	 (progn
+	   ;; Switch direction if necessary
+	   (or isearch-forward (isearch-repeat 'forward))
+	   ;; Go back narg times
+	   (while (and isearch-success(< narg 0))
+	     (isearch-repeat 'forward)
+	     (setq narg (1+ narg)))
+	   ;; Switch back to backward search
+	   (isearch-repeat 'backward))
+       ;; Go backward
+       (progn
+	 ;; Switch direction if necessary
+	 (if isearch-forward (isearch-repeat 'backward))
+	 ;; Go backward narg times
+	 (while (and isearch-success (> narg 0))
+	   (isearch-repeat 'backward)
+	   (setq narg (1- narg))))))
+    ;; No argument
+    (isearch-repeat 'backward)))
+
 
 (defun isearch-toggle-regexp ()
   "Toggle regexp searching on or off."

  reply	other threads:[~2012-01-31 11:52 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-26 17:27 bug#10614: [EXPERIMENTAL PATCH] Extending Isearch-repeat-forward/backward to support a prefix argument following suggesion by Juri Linkov Gideon Stupp
2012-01-26 18:36 ` Tassilo Horn
2012-01-26 18:46   ` Tassilo Horn
2012-01-26 19:00   ` Re: [EXPERIMENTAL PATCH] Extending Isearch-repeat-forward/backward to support a prefix argument gideon.stupp
2012-01-26 19:10     ` Re: Re: [EXPERIMENTAL PATCH] Extending Isearch-repeat-forward/backward to support a prefix argum gideon.stupp
2012-01-26 19:32       ` Glenn Morris
2012-01-26 19:11   ` [EXPERIMENTAL PATCH] Extending Isearch-repeat-forward/backward to support a prefix argument following suggesion by Juri Linkov Tassilo Horn
2012-01-26 19:28     ` bug#10614: " Jérémy Compostella
2012-01-26 19:28     ` Jérémy Compostella
2012-01-26 21:43   ` bug#10614: [EXPERIMENTAL PATCH] ExtendingIsearch-repeat-forward/backward to support a prefix argumentfollowing " Drew Adams
2012-01-26 21:43   ` Drew Adams
2012-01-27  1:44 ` [EXPERIMENTAL PATCH] Extending Isearch-repeat-forward/backward to support a prefix argument following " Juri Linkov
2012-01-27  6:17   ` Gideon Stupp
2012-01-27 12:07     ` Juri Linkov
2012-01-27 17:05       ` [EXPERIMENTAL PATCH] Extending Isearch-repeat-forward/backward tosupport " Drew Adams
2012-01-28 12:40         ` RE: [EXPERIMENTAL PATCH] Extending Isearch-repeat-forward/backward tosupport a prefix argument f gideon.stupp
2012-01-28 12:31       ` Re: [EXPERIMENTAL PATCH] Extending Isearch-repeat-forward/backward to support a prefix argument gideon.stupp
2012-01-29 16:11       ` [EXPERIMENTAL PATCH] Extending Isearch-repeat-forward/backward to support a prefix argument following suggesion by Juri Linkov Gideon Stupp
2012-01-30  0:38         ` Juri Linkov
2012-01-30  9:53           ` Gideon Stupp
2012-01-30 22:53             ` Juri Linkov
2012-01-31 11:52               ` Gideon Stupp [this message]
2012-01-31 20:18                 ` Juri Linkov
2016-02-25  6:06 ` bug#10614: " Lars Ingebrigtsen
2016-02-25  6:06 ` Lars Ingebrigtsen
2016-02-29 23:44   ` Juri Linkov
2016-03-01  0:43     ` Lars Ingebrigtsen
2019-06-27 15:36       ` Lars Ingebrigtsen
2016-03-01  0:43     ` Lars Ingebrigtsen
2016-02-29 23:44   ` Juri Linkov

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='CAJzWQ4fWXrZ_xBJ6_ieq8XwCDzeTsC4dV-v3bhnBkXPRiZhm=Q@mail.gmail.com' \
    --to=gideon.stupp@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=juri@jurta.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.