From: Juri Linkov <juri@jurta.org>
To: Jambunathan K <kjambunathan@gmail.com>
Cc: 13687@debbugs.gnu.org
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 [thread overview]
Message-ID: <87li9vruup.fsf@mail.jurta.org> (raw)
In-Reply-To: <87d2v9rmcl.fsf@gmail.com> (Jambunathan K.'s message of "Sat, 09 Mar 2013 14:17:22 +0530")
> 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)
next prev parent reply other threads:[~2013-03-10 18:28 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <E1UA5QC-0006Vm-Qb@vcs.savannah.gnu.org>
[not found] ` <877glsyecw.fsf@gmail.com>
2013-02-28 18:12 ` bug#13687: /srv/bzr/emacs/trunk r111878: * lisp/replace.el (read-regexp): Let-bind `default' to the first Juri Linkov
2013-03-03 9:31 ` Juri Linkov
2013-03-06 18:00 ` Jambunathan K
2013-03-08 13:02 ` Jambunathan K
2013-03-08 15:29 ` bug#13687: /srv/bzr/emacs/trunk r111878: * lisp/replace.el(read-regexp): " Drew Adams
2013-03-08 16:53 ` Jambunathan K
2013-03-08 17:10 ` Drew Adams
2013-03-08 17:27 ` Jambunathan K
2013-03-08 17:28 ` Juri Linkov
2013-03-08 18:16 ` Drew Adams
2013-03-08 18:30 ` Jambunathan K
2013-03-08 18:53 ` Drew Adams
2013-03-08 19:03 ` Jambunathan K
2013-03-08 21:08 ` Drew Adams
2013-03-09 8:47 ` Jambunathan K
2013-03-09 15:08 ` Drew Adams
2013-03-09 16:21 ` Jambunathan K
2013-03-09 16:37 ` Drew Adams
2013-03-09 16:59 ` Jambunathan K
2013-03-09 17:14 ` Drew Adams
2013-03-09 17:25 ` Jambunathan K
2013-03-09 17:55 ` Drew Adams
2013-03-10 18:28 ` Juri Linkov [this message]
2013-03-18 7:24 ` Jambunathan K
2013-03-04 5:46 ` bug#13687: /srv/bzr/emacs/trunk r111878: * lisp/replace.el (read-regexp): " Jambunathan K
2013-03-04 9:28 ` Juri Linkov
2013-03-06 18:03 ` Jambunathan K
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87li9vruup.fsf@mail.jurta.org \
--to=juri@jurta.org \
--cc=13687@debbugs.gnu.org \
--cc=kjambunathan@gmail.com \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).