[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#7567: Please add a history argument to read-regexp
From: |
Juri Linkov |
Subject: |
bug#7567: Please add a history argument to read-regexp |
Date: |
Thu, 20 Sep 2012 11:30:35 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (x86_64-pc-linux-gnu) |
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.
- bug#7567: Please add a history argument to read-regexp,
Juri Linkov <=