From: Juri Linkov <juri@jurta.org>
To: 7567@debbugs.gnu.org
Subject: bug#7567: Please add a history argument to read-regexp
Date: Thu, 20 Sep 2012 11:30:35 +0300 [thread overview]
Message-ID: <87vcf941u7.fsf@mail.jurta.org> (raw)
In-Reply-To: <AANLkTik-PEdh+Z7SQ--ipdOrLJvuHfcmUihvXoWnqope@mail.gmail.com> (Lennart Borgman's message of "Mon, 6 Dec 2010 03:24:01 +0100")
This patch fixes bug#7567 by adding a history argument to `read-regexp':
=== modified file 'lisp/replace.el'
--- lisp/replace.el 2012-09-09 22:15:24 +0000
+++ lisp/replace.el 2012-09-20 08:28:05 +0000
@@ -574,12 +575,14 @@ (defvar regexp-history nil
(defvar occur-collect-regexp-history '("\\1")
"History of regexp for occur's collect operation")
-(defun read-regexp (prompt &optional default-value)
+(defun read-regexp (prompt &optional default-value history)
"Read regexp as a string using the regexp history and some useful defaults.
Prompt for a regular expression with PROMPT (without a colon and
space) in the minibuffer. The optional argument DEFAULT-VALUE
provides the value to display in the minibuffer prompt that is
returned if the user just types RET.
+Non-nil HISTORY is a symbol to use as the history list.
+If HISTORY is nil, `regexp-history' is used.
Values available via M-n are the string at point, the last isearch
regexp, the last isearch string, and the last replacement regexp."
(let* ((defaults
@@ -603,11 +606,11 @@ (defun read-regexp (prompt &optional def
(format "%s (default %s): " prompt
(query-replace-descr default-value))
(format "%s: " prompt)))
- nil nil nil 'regexp-history defaults t)))
+ nil nil nil (or history 'regexp-history) defaults t)))
(if (equal input "")
(or default-value input)
(prog1 input
- (add-to-history 'regexp-history input)))))
+ (add-to-history (or history 'regexp-history) input)))))
This allows more functions to use `read-regexp' with other history lists
as was discussed here in bug#7567 a year ago.
=== modified file 'lisp/replace.el'
--- lisp/replace.el 2012-09-09 22:15:24 +0000
+++ lisp/replace.el 2012-09-20 08:28:05 +0000
@@ -128,20 +128,21 @@ (defun query-replace-read-from (prompt r
(if query-replace-interactive
(car (if regexp-flag regexp-search-ring search-ring))
(let* ((history-add-new-input nil)
+ (prompt
+ (if query-replace-defaults
+ (format "%s (default %s -> %s): " prompt
+ (query-replace-descr (car query-replace-defaults))
+ (query-replace-descr (cdr query-replace-defaults)))
+ (format "%s: " prompt)))
(from
;; The save-excursion here is in case the user marks and copies
;; a region in order to specify the minibuffer input.
;; That should not clobber the region for the query-replace itself.
(save-excursion
- (read-from-minibuffer
- (if query-replace-defaults
- (format "%s (default %s -> %s): " prompt
- (query-replace-descr (car query-replace-defaults))
- (query-replace-descr (cdr query-replace-defaults)))
- (format "%s: " prompt))
- nil nil nil
- query-replace-from-history-variable
- nil t))))
+ (if regexp-flag
+ (read-regexp prompt nil query-replace-from-history-variable)
+ (read-from-minibuffer
+ prompt nil nil nil query-replace-from-history-variable nil t)))))
(if (and (zerop (length from)) query-replace-defaults)
(cons (car query-replace-defaults)
(query-replace-compile-replacement
@@ -1130,9 +1135,9 @@ (defun occur-read-primary-args ()
"\\&"
;; Get the regexp for collection pattern.
(let ((default (car occur-collect-regexp-history)))
- (read-string
+ (read-regexp
(format "Regexp to collect (default %s): " default)
- nil 'occur-collect-regexp-history default)))
+ default 'occur-collect-regexp-history)))
;; Otherwise normal occur takes numerical prefix argument.
(when current-prefix-arg
(prefix-numeric-value current-prefix-arg))))))
@@ -1219,14 +1224,11 @@ (defun multi-occur-in-matching-buffers (
(cons
(let* ((default (car regexp-history))
(input
- (read-from-minibuffer
+ (read-regexp
(if current-prefix-arg
"List lines in buffers whose names match regexp: "
"List lines in buffers whose filenames match regexp: ")
- nil
- nil
- nil
- 'regexp-history)))
+ nil 'regexp-history)))
(if (equal input "")
default
input))
=== modified file 'lisp/isearch.el'
--- lisp/isearch.el 2012-09-09 22:15:24 +0000
+++ lisp/isearch.el 2012-09-20 08:23:25 +0000
@@ -1649,9 +1681,9 @@ (defun isearch-occur (regexp &optional n
(isearch-done nil t)
(isearch-clean-overlays)
(let ((default (car occur-collect-regexp-history)))
- (read-string
+ (read-regexp
(format "Regexp to collect (default %s): " default)
- nil 'occur-collect-regexp-history default)))
+ default 'occur-collect-regexp-history)))
;; Otherwise normal occur takes numerical prefix argument.
(when current-prefix-arg
(prefix-numeric-value current-prefix-arg))))))
=== modified file 'lisp/progmodes/grep.el'
--- lisp/progmodes/grep.el 2012-04-20 08:48:50 +0000
+++ lisp/progmodes/grep.el 2012-09-20 08:24:55 +0000
@@ -817,11 +831,11 @@ (defun grep-expand-template (template &o
(defun grep-read-regexp ()
"Read regexp arg for interactive grep."
(let ((default (grep-tag-default)))
- (read-string
+ (read-regexp
(concat "Search for"
(if (and default (> (length default) 0))
(format " (default \"%s\"): " default) ": "))
- nil 'grep-regexp-history default)))
+ default 'grep-regexp-history)))
(defun grep-read-files (regexp)
"Read files arg for interactive grep."
=== modified file 'lisp/dired.el'
--- lisp/dired.el 2012-09-18 23:40:39 +0000
+++ lisp/dired.el 2012-09-20 08:21:11 +0000
@@ -3178,8 +3196,8 @@ (defun dired-toggle-marks ()
(defvar dired-regexp-history nil
"History list of regular expressions used in Dired commands.")
-(defun dired-read-regexp (prompt)
- (read-from-minibuffer prompt nil nil nil 'dired-regexp-history))
+(defun dired-read-regexp (prompt &optional default history)
+ (read-regexp prompt default (or history 'dired-regexp-history)))
(defun dired-mark-files-regexp (regexp &optional marker-char)
"Mark all files matching REGEXP for use in later commands.
PS: The problems related to other arguments (PROMPT and DEFAULT-VALUE)
of `read-regexp' are about to be fixed in bug#12321.
next prev parent reply other threads:[~2012-09-20 8:30 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-06 2:24 bug#7567: Please add a history variable to read-regexp Lennart Borgman
2010-12-06 22:43 ` Lennart Borgman
2010-12-06 22:57 ` Drew Adams
2010-12-06 23:00 ` Lennart Borgman
2010-12-06 23:11 ` Drew Adams
2010-12-06 23:23 ` Lennart Borgman
2010-12-07 0:31 ` Drew Adams
2010-12-07 4:09 ` Drew Adams
2010-12-08 1:51 ` Juri Linkov
2010-12-08 3:03 ` Drew Adams
2010-12-06 23:03 ` Juri Linkov
2010-12-06 23:46 ` Lennart Borgman
2010-12-08 1:44 ` Juri Linkov
2010-12-07 3:48 ` Stefan Monnier
2010-12-08 1:57 ` Juri Linkov
2010-12-08 2:19 ` Lennart Borgman
2010-12-09 1:25 ` Juri Linkov
2010-12-08 3:10 ` Drew Adams
2010-12-09 14:31 ` Stefan Monnier
2010-12-09 16:14 ` Drew Adams
2010-12-10 3:09 ` Stefan Monnier
2010-12-09 14:28 ` Stefan Monnier
2010-12-09 17:43 ` Drew Adams
2010-12-10 3:06 ` Stefan Monnier
2010-12-10 3:46 ` Drew Adams
2010-12-10 20:10 ` Stefan Monnier
2010-12-08 3:32 ` Lennart Borgman
2012-09-20 8:30 ` Juri Linkov [this message]
2012-09-20 21:59 ` bug#7567: Please add a history argument " 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=87vcf941u7.fsf@mail.jurta.org \
--to=juri@jurta.org \
--cc=7567@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.