all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: 14563@debbugs.gnu.org
Subject: bug#14563: Add prefix arg to more isearch commands
Date: Thu, 06 Jun 2013 09:30:40 +0300	[thread overview]
Message-ID: <87obbj699r.fsf@mail.jurta.org> (raw)

Severity: wishlist
Tags: patch

Since bug#9706 to allow a prefix arg pass to isearch commands
is done now more isearch commands can support prefix args.

bug#10614 and bug#10638 deals with adding a prefix arg to
`isearch-repeat-forward' and `isearch-repeat-backward'.

And the following patch adds a prefix arg to
`isearch-quote-char' (to use the same args as in `quoted-insert'),
`isearch-printing-char' (to use the same args as in `insert-char'),
`isearch-process-search-char' and
`isearch-process-search-multibyte-characters':

=== modified file 'lisp/isearch.el'
--- lisp/isearch.el	2013-06-05 20:57:09 +0000
+++ lisp/isearch.el	2013-06-06 06:28:07 +0000
@@ -2381,9 +2585,11 @@ (defun isearch-other-meta-char (&optiona
           (t;; otherwise nil
 	   (isearch-process-search-string key key)))))
 
-(defun isearch-quote-char ()
-  "Quote special characters for incremental search."
-  (interactive)
+(defun isearch-quote-char (&optional count)
+  "Quote special characters for incremental search.
+With argument, add COUNT copies of the character."
+  (interactive "p")
   (let ((char (read-quoted-char (isearch-message t))))
     ;; Assume character codes 0200 - 0377 stand for characters in some
     ;; single-byte character set, and convert them to Emacs
@@ -2391,24 +2597,27 @@ (defun isearch-quote-char ()
     (if (and isearch-regexp isearch-regexp-lax-whitespace (= char ?\s))
 	(if (subregexp-context-p isearch-string (length isearch-string))
 	    (isearch-process-search-string "[ ]" " ")
-	  (isearch-process-search-char char))
+	  (isearch-process-search-char char count))
       (and enable-multibyte-characters
 	   (>= char ?\200)
 	   (<= char ?\377)
 	   (setq char (unibyte-char-to-multibyte char)))
-      (isearch-process-search-char char))))
+      (isearch-process-search-char char count))))
 
-(defun isearch-printing-char ()
-  "Add this ordinary printing character to the search string and search."
-  (interactive)
-  (let ((char last-command-event))
+(defun isearch-printing-char (&optional char count)
+  "Add this ordinary printing CHAR to the search string and search.
+With argument, add COUNT copies of the character."
+  (interactive (list last-command-event
+		     (prefix-numeric-value current-prefix-arg)))
+  (let ((char (or char last-command-event)))
     (if (= char ?\S-\ )
 	(setq char ?\s))
     (if current-input-method
-	(isearch-process-search-multibyte-characters char)
-      (isearch-process-search-char char))))
+	(isearch-process-search-multibyte-characters char count)
+      (isearch-process-search-char char count))))
 
-(defun isearch-process-search-char (char)
+(defun isearch-process-search-char (char &optional count)
   ;; * and ? are special in regexps when not preceded by \.
   ;; } and | are special in regexps when preceded by \.
   ;; Nothing special for + because it matches at least once.
@@ -2417,12 +2627,15 @@ (defun isearch-process-search-char (char
    ((eq   char ?\})      (isearch-fallback t t))
    ((eq   char ?|)       (isearch-fallback t nil t)))
 
-  ;; Append the char to the search string, update the message and re-search.
-  (isearch-process-search-string
-   (char-to-string char)
-   (if (>= char ?\200)
-       (char-to-string char)
-     (isearch-text-char-description char))))
+  ;; Append the char(s) to the search string,
+  ;; update the message and re-search.
+  (let* ((string (if (and (integerp count) (> count 1))
+		     (make-string count char)
+		   (char-to-string char)))
+	 (message (if (>= char ?\200)
+		      string
+		    (mapconcat 'isearch-text-char-description string ""))))
+    (isearch-process-search-string string message)))
 
 (defun isearch-process-search-string (string message)
   (setq isearch-string (concat isearch-string string)

=== modified file 'lisp/international/isearch-x.el'
--- lisp/international/isearch-x.el	2013-01-01 09:11:05 +0000
+++ lisp/international/isearch-x.el	2013-06-06 06:29:51 +0000
@@ -94,7 +94,7 @@ (defun isearch-with-input-method ()
     (exit-minibuffer)))
 
 ;;;###autoload
-(defun isearch-process-search-multibyte-characters (last-char)
+(defun isearch-process-search-multibyte-characters (last-char &optional count)
   (if (eq this-command 'isearch-printing-char)
       (let ((overriding-terminal-local-map nil)
 	    (prompt (isearch-message-prefix))
@@ -136,8 +136,11 @@ (defun isearch-process-search-multibyte-
 
 	(if (and str (> (length str) 0))
 	    (let ((unread-command-events nil))
-	      (isearch-process-search-string str str))
+	      (if (and (integerp count) (> count 1))
+		  (let ((strs (mapconcat 'identity (make-list count str) "")))
+		    (isearch-process-search-string strs strs))
+		(isearch-process-search-string str str)))
 	  (isearch-update)))
-    (isearch-process-search-char last-char)))
+    (isearch-process-search-char last-char count)))
 
 ;;; isearch-x.el ends here





             reply	other threads:[~2013-06-06  6:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-06  6:30 Juri Linkov [this message]
2013-06-09 20:35 ` bug#14563: Add prefix arg to more isearch commands Juri Linkov
2013-06-13 21:12   ` Juri Linkov
2013-06-14 22:30     ` Juri Linkov
2018-11-20 23:45       ` 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=87obbj699r.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=14563@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 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.