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#13687: /srv/bzr/emacs/trunk r111878: * lisp/replace.el(read-regexp): Let-bind `default' to the first Date: Sun, 10 Mar 2013 20:28:14 +0200 Organization: JURTA Message-ID: <87li9vruup.fsf@mail.jurta.org> References: <877glsyecw.fsf@gmail.com> <87621cfhff.fsf@mail.jurta.org> <87zjykygjk.fsf@mail.jurta.org> <87vc92gi37.fsf@gmail.com> <1751CEB23B214A3AADCCFD9F007425DE@us.oracle.com> <87li9xer9u.fsf@mail.jurta.org> <8738w5n3rg.fsf@gmail.com> <87d2v9rmcl.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1362940336 26057 80.91.229.3 (10 Mar 2013 18:32:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 10 Mar 2013 18:32:16 +0000 (UTC) Cc: 13687@debbugs.gnu.org To: Jambunathan K Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Mar 10 19:32:40 2013 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 1UEl31-00087X-Ue for geb-bug-gnu-emacs@m.gmane.org; Sun, 10 Mar 2013 19:32:40 +0100 Original-Received: from localhost ([::1]:55320 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UEl2f-0006aT-OP for geb-bug-gnu-emacs@m.gmane.org; Sun, 10 Mar 2013 14:32:17 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:32943) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UEl2c-0006aF-74 for bug-gnu-emacs@gnu.org; Sun, 10 Mar 2013 14:32:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UEl2a-0002zm-Nr for bug-gnu-emacs@gnu.org; Sun, 10 Mar 2013 14:32:14 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:40204) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UEl2a-0002zi-Ks for bug-gnu-emacs@gnu.org; Sun, 10 Mar 2013 14:32:12 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UEl3O-0003DA-AO for bug-gnu-emacs@gnu.org; Sun, 10 Mar 2013 14:33: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: Sun, 10 Mar 2013 18:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13687 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 13687-submit@debbugs.gnu.org id=B13687.136294037112311 (code B ref 13687); Sun, 10 Mar 2013 18:33:02 +0000 Original-Received: (at 13687) by debbugs.gnu.org; 10 Mar 2013 18:32:51 +0000 Original-Received: from localhost ([127.0.0.1]:44308 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UEl3D-0003CV-ES for submit@debbugs.gnu.org; Sun, 10 Mar 2013 14:32:51 -0400 Original-Received: from ps18281.dreamhost.com ([69.163.218.105]:53739 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UEl39-0003CC-Tr for 13687@debbugs.gnu.org; Sun, 10 Mar 2013 14:32:49 -0400 Original-Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 7B70E258B92900; Sun, 10 Mar 2013 11:31:55 -0700 (PDT) In-Reply-To: <87d2v9rmcl.fsf@gmail.com> (Jambunathan K.'s message of "Sat, 09 Mar 2013 14:17:22 +0530") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.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.x 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:72300 Archived-At: > EXPERIMENTAL and ABANDONED PATCH I think your patch is useful, please don't abandon it except its `this-command' part. As you already noted `this-command' is very fragile and flaky. Removing everything related to `this-command' would leave other useful parts of your patch that adds a new defcustom `read-regexp-defaults' and especially this part: + (choice :tag "Function to retrieve the regexp" + (const :tag "Use no defaults" nil) + (radio + (function-item find-tag-default-as-regexp) + (function-item find-tag-default) + (function-item :tag "Regexp history" + (lambda nil + "Use regexp history." + (car regexp-history))) + function))))) and a new function `read-regexp-defaults'. Instead of using `this-command', look for ideas to other similar features. For example, many invocations of minibuffer functions specify their HISTORY argument as a symbol that divides history variables into groups. The DEFAULTS argument could use a similar grouping, i.e. when `read-regexp' uses the symbol `regexp-history' in a call like: (read-regexp "Regexp to highlight" (car regexp-history) 'regexp-history) This could be changed to specify DEFAULTS as the symbol `read-regexp-defaults': (read-regexp "Regexp to highlight" 'read-regexp-defaults 'regexp-history) where `read-regexp-defaults' is a symbol name of the function that uses the value of the defcustom `read-regexp-defaults' the get the default value or returns nil. We could add as many additional default-providing functions as the number of places that call `read-regexp'. But I think it should be enough to have just two functions: (defun read-regexp-defaults-or-history () (or (read-regexp-defaults) (car regexp-history))) (defun read-regexp-defaults-or-tag () (or (read-regexp-defaults) (find-tag-default-as-regexp))) These two functions are necessary to keep the current status quo where some commands traditionally provide the last history element as the default (`highlight-regexp', `occur-read-primary-args', `how-many', `flush-lines', `keep-lines'), and other commands provide the tag at point (`rgrep', `query-replace', `multi-occur-in-matching-buffers'). This is an artificial division existing solely for historical reasons. These functions could be used e.g. in `occur-read-primary-args' as: (read-regexp "List lines matching regexp" 'read-regexp-defaults-or-history 'regexp-history) and e.g. in `grep-read-regexp': (read-regexp "Search for" 'read-regexp-defaults-or-tag 'regexp-history) This implementation will satisfy three goals: 1. Backward compatibility for the current traditional defaults, 2. Allow easy customization in one place (defcustom `read-regexp-defaults'), 3. Allow fine-tuning with function redefinitions, i.e. when the users will ask for more specific functions they could be added as: (defun occur-read-regexp-defaults () (read-regexp-defaults-or-history)) (defun grep-read-regexp-defaults () (read-regexp-defaults-or-tag)) and can be used in `occur-read-primary-args': (read-regexp "List lines matching regexp" 'occur-read-regexp-defaults 'regexp-history) and in `grep-read-regexp': (read-regexp "Search for" 'grep-read-regexp-defaults 'regexp-history)