From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#7567: Please add a history argument to read-regexp Date: Thu, 20 Sep 2012 11:30:35 +0300 Organization: JURTA Message-ID: <87vcf941u7.fsf@mail.jurta.org> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1348130568 12318 80.91.229.3 (20 Sep 2012 08:42:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 20 Sep 2012 08:42:48 +0000 (UTC) To: 7567@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Sep 20 10:42:52 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TEcLM-0004zJ-UO for geb-bug-gnu-emacs@m.gmane.org; Thu, 20 Sep 2012 10:42:45 +0200 Original-Received: from localhost ([::1]:58344 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEcLI-0005eG-4o for geb-bug-gnu-emacs@m.gmane.org; Thu, 20 Sep 2012 04:42:40 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:49272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEcLC-0005di-Go for bug-gnu-emacs@gnu.org; Thu, 20 Sep 2012 04:42:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TEcLB-0004HB-44 for bug-gnu-emacs@gnu.org; Thu, 20 Sep 2012 04:42:34 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:34968) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEcLB-0004H5-0O for bug-gnu-emacs@gnu.org; Thu, 20 Sep 2012 04:42:33 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TEcMc-0002CR-V1 for bug-gnu-emacs@gnu.org; Thu, 20 Sep 2012 04:44:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 20 Sep 2012 08:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7567 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 7567-submit@debbugs.gnu.org id=B7567.13481306048393 (code B ref 7567); Thu, 20 Sep 2012 08:44:02 +0000 Original-Received: (at 7567) by debbugs.gnu.org; 20 Sep 2012 08:43:24 +0000 Original-Received: from localhost ([127.0.0.1]:44513 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TEcLz-0002BJ-5J for submit@debbugs.gnu.org; Thu, 20 Sep 2012 04:43:23 -0400 Original-Received: from ps18281.dreamhost.com ([69.163.218.105]:45366 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TEcLt-0002Ay-73 for 7567@debbugs.gnu.org; Thu, 20 Sep 2012 04:43:19 -0400 Original-Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id DE30A451CCBC for <7567@debbugs.gnu.org>; Thu, 20 Sep 2012 01:41:45 -0700 (PDT) In-Reply-To: (Lennart Borgman's message of "Mon, 6 Dec 2010 03:24:01 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:64637 Archived-At: 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.