Commit 6e8cfc81 authored by Juri Linkov's avatar Juri Linkov
Browse files

Add prefix arg to more isearch commands.

* lisp/isearch.el (isearch-yank-word, isearch-yank-line)
(isearch-char-by-name, isearch-quote-char)
(isearch-printing-char, isearch-process-search-char):
Add optional count prefix arg. 

* lisp/international/isearch-x.el (isearch-process-search-multibyte-characters):
Add optional count prefix arg.

Fixes: debbugs:14563
parent c23d55f4
...@@ -296,6 +296,10 @@ and opens overlays with hidden text when `search-invisible' is `open'. ...@@ -296,6 +296,10 @@ and opens overlays with hidden text when `search-invisible' is `open'.
*** By default, prefix arguments do not now terminate Isearch mode. *** By default, prefix arguments do not now terminate Isearch mode.
Set `isearch-allow-prefix' to nil to restore old behavior. Set `isearch-allow-prefix' to nil to restore old behavior.
*** More Isearch commands accept prefix arguments, namely
`isearch-printing-char', `isearch-quote-char', `isearch-yank-word',
`isearch-yank-line'.
** MH-E has been updated to MH-E version 8.5. ** MH-E has been updated to MH-E version 8.5.
See MH-E-NEWS for details. See MH-E-NEWS for details.
......
2013-06-13 Juri Linkov <juri@jurta.org>
* isearch.el (isearch-yank-word, isearch-yank-line)
(isearch-char-by-name, isearch-quote-char)
(isearch-printing-char, isearch-process-search-char):
Add optional count prefix arg. (Bug#14563)
* international/isearch-x.el
(isearch-process-search-multibyte-characters):
Add optional count prefix arg.
2013-06-13 Stefan Monnier <monnier@iro.umontreal.ca> 2013-06-13 Stefan Monnier <monnier@iro.umontreal.ca>
   
* subr.el (internal-push-keymap, internal-pop-keymap): New functions. * subr.el (internal-push-keymap, internal-pop-keymap): New functions.
...@@ -4667,7 +4678,7 @@ ...@@ -4667,7 +4678,7 @@
* progmodes/grep.el (grep-regexp-alist): Use variable grep-match-face * progmodes/grep.el (grep-regexp-alist): Use variable grep-match-face
instead of hard-coded default face `match'. (Bug#9438) instead of hard-coded default face `match'. (Bug#9438)
   
2012-02-01 Christopher Schmidt <christopher@ch.ristopher.com> 2013-02-01 Christopher Schmidt <christopher@ch.ristopher.com>
   
* vc/vc-arch.el (vc-arch-registered): * vc/vc-arch.el (vc-arch-registered):
* vc/vc-bzr.el (vc-bzr-registered): * vc/vc-bzr.el (vc-bzr-registered):
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
(exit-minibuffer))) (exit-minibuffer)))
;;;###autoload ;;;###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) (if (eq this-command 'isearch-printing-char)
(let ((overriding-terminal-local-map nil) (let ((overriding-terminal-local-map nil)
(prompt (isearch-message-prefix)) (prompt (isearch-message-prefix))
...@@ -136,8 +136,11 @@ ...@@ -136,8 +136,11 @@
(if (and str (> (length str) 0)) (if (and str (> (length str) 0))
(let ((unread-command-events nil)) (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-update)))
(isearch-process-search-char last-char))) (isearch-process-search-char last-char count)))
;;; isearch-x.el ends here ;;; isearch-x.el ends here
...@@ -1919,29 +1919,33 @@ Subword is used when `subword-mode' is activated. " ...@@ -1919,29 +1919,33 @@ Subword is used when `subword-mode' is activated. "
(forward-word 1)) (forward-word 1))
(forward-char 1)) (point)))) (forward-char 1)) (point))))
(defun isearch-yank-word () (defun isearch-yank-word (&optional arg)
"Pull next word from buffer into search string." "Pull next word from buffer into search string."
(interactive) (interactive "p")
(isearch-yank-internal (lambda () (forward-word 1) (point)))) (isearch-yank-internal (lambda () (forward-word arg) (point))))
(defun isearch-yank-line () (defun isearch-yank-line (&optional arg)
"Pull rest of line from buffer into search string." "Pull rest of line from buffer into search string."
(interactive) (interactive "p")
(isearch-yank-internal (isearch-yank-internal
(lambda () (let ((inhibit-field-text-motion t)) (lambda () (let ((inhibit-field-text-motion t))
(line-end-position (if (eolp) 2 1)))))) (line-end-position (if (eolp) (1+ arg) arg))))))
(defun isearch-char-by-name () (defun isearch-char-by-name (&optional count)
"Read a character by its Unicode name and add it to the search string. "Read a character by its Unicode name and add it to the search string.
Completion is available like in `read-char-by-name' used by `insert-char'." Completion is available like in `read-char-by-name' used by `insert-char'.
(interactive) With argument, add COUNT copies of the character."
(interactive "p")
(with-isearch-suspended (with-isearch-suspended
(let ((char (read-char-by-name "Add character to search (Unicode name or hex): "))) (let ((char (read-char-by-name "Add character to search (Unicode name or hex): ")))
(when char (when char
(setq isearch-new-string (concat isearch-string (string char)) (let ((string (if (and (integerp count) (> count 1))
(make-string count char)
(char-to-string char))))
(setq isearch-new-string (concat isearch-string string)
isearch-new-message (concat isearch-message isearch-new-message (concat isearch-message
(mapconcat 'isearch-text-char-description (mapconcat 'isearch-text-char-description
(string char) ""))))))) string ""))))))))
(defun isearch-search-and-update () (defun isearch-search-and-update ()
;; Do the search and update the display. ;; Do the search and update the display.
...@@ -2382,9 +2386,10 @@ Isearch mode." ...@@ -2382,9 +2386,10 @@ Isearch mode."
(t;; otherwise nil (t;; otherwise nil
(isearch-process-search-string key key))))) (isearch-process-search-string key key)))))
(defun isearch-quote-char () (defun isearch-quote-char (&optional count)
"Quote special characters for incremental search." "Quote special characters for incremental search.
(interactive) With argument, add COUNT copies of the character."
(interactive "p")
(let ((char (read-quoted-char (isearch-message t)))) (let ((char (read-quoted-char (isearch-message t))))
;; Assume character codes 0200 - 0377 stand for characters in some ;; Assume character codes 0200 - 0377 stand for characters in some
;; single-byte character set, and convert them to Emacs ;; single-byte character set, and convert them to Emacs
...@@ -2392,24 +2397,26 @@ Isearch mode." ...@@ -2392,24 +2397,26 @@ Isearch mode."
(if (and isearch-regexp isearch-regexp-lax-whitespace (= char ?\s)) (if (and isearch-regexp isearch-regexp-lax-whitespace (= char ?\s))
(if (subregexp-context-p isearch-string (length isearch-string)) (if (subregexp-context-p isearch-string (length isearch-string))
(isearch-process-search-string "[ ]" " ") (isearch-process-search-string "[ ]" " ")
(isearch-process-search-char char)) (isearch-process-search-char char count))
(and enable-multibyte-characters (and enable-multibyte-characters
(>= char ?\200) (>= char ?\200)
(<= char ?\377) (<= char ?\377)
(setq char (unibyte-char-to-multibyte char))) (setq char (unibyte-char-to-multibyte char)))
(isearch-process-search-char char)))) (isearch-process-search-char char count))))
(defun isearch-printing-char () (defun isearch-printing-char (&optional char count)
"Add this ordinary printing character to the search string and search." "Add this ordinary printing CHAR to the search string and search.
(interactive) With argument, add COUNT copies of the character."
(let ((char last-command-event)) (interactive (list last-command-event
(prefix-numeric-value current-prefix-arg)))
(let ((char (or char last-command-event)))
(if (= char ?\S-\ ) (if (= char ?\S-\ )
(setq char ?\s)) (setq char ?\s))
(if current-input-method (if current-input-method
(isearch-process-search-multibyte-characters char) (isearch-process-search-multibyte-characters char count)
(isearch-process-search-char char)))) (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 not preceded by \.
;; } and | are special in regexps when preceded by \. ;; } and | are special in regexps when preceded by \.
;; Nothing special for + because it matches at least once. ;; Nothing special for + because it matches at least once.
...@@ -2418,12 +2425,15 @@ Isearch mode." ...@@ -2418,12 +2425,15 @@ Isearch mode."
((eq char ?\}) (isearch-fallback t t)) ((eq char ?\}) (isearch-fallback t t))
((eq char ?|) (isearch-fallback t nil t))) ((eq char ?|) (isearch-fallback t nil t)))
;; Append the char to the search string, update the message and re-search. ;; Append the char(s) to the search string,
(isearch-process-search-string ;; update the message and re-search.
(char-to-string char) (let* ((string (if (and (integerp count) (> count 1))
(if (>= char ?\200) (make-string count char)
(char-to-string char) (char-to-string char)))
(isearch-text-char-description 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) (defun isearch-process-search-string (string message)
(setq isearch-string (concat isearch-string string) (setq isearch-string (concat isearch-string string)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment