unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: read-regexp
Date: Sat, 18 Oct 2008 19:19:45 +0300	[thread overview]
Message-ID: <87iqrp7wgm.fsf@jurta.org> (raw)
In-Reply-To: <uiqrqkrc8.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 18 Oct 2008 14:41:59 +0200")

> This function accepts an optional argument DEFAULT, but it does not
> add its value to the list of defaults it passes to
> read-from-minibuffer.  Is that intentional, and if so, what is the
> reason for this behavior?
>
> Also, it sounds like DEFAULT must be a single string or nil, it cannot
> be a list of strings, as in other functions that read from the
> minibuffer.  Again, is that on purpose?
>
> (Btw, it would be good if the doc string gave answers to these
> questions.)

The problem is in the ambiguous name of the argument DEFAULT.
It was intended to provide exactly the same functionality as the
argument STRING-DESCRIBING-DEFAULT of the function `read-face-name',
i.e. to display in the minibuffer prompt what default the function
will use if the user types RET.

I thought that the name STRING-DESCRIBING-DEFAULT is too long and clumsy
but had no better idea.  Unless you want to propose a better name, I will
rename the argument DEFAULT of `read-regexp' to the same name
STRING-DESCRIBING-DEFAULT as below with docstring fixes:

Index: lisp/replace.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/replace.el,v
retrieving revision 1.276
diff -c -r1.276 replace.el
*** lisp/replace.el	12 Sep 2008 00:37:41 -0000	1.276
--- lisp/replace.el	18 Oct 2008 16:17:48 -0000
***************
*** 522,532 ****
  Maximum length of the history list is determined by the value
  of `history-length', which see.")
  
! (defun read-regexp (prompt &optional default)
    "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 string argument DEFAULT
! provides the basic default value, that is returned on typing RET.
  Additional defaults are the string at point, the last isearch regexp,
  the last isearch string, and the last replacement regexp."
    (let* ((defaults
--- 526,537 ----
  Maximum length of the history list is determined by the value
  of `history-length', which see.")
  
! (defun read-regexp (prompt &optional string-describing-default)
    "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 STRING-DESCRIBING-DEFAULT
! provides the value to display in the minibuffer prompt that is
! returned if the user just types RET.
  Additional defaults are the string at point, the last isearch regexp,
  the last isearch string, and the last replacement regexp."
    (let* ((defaults
***************
*** 544,555 ****
  	 (history-add-new-input nil)
  	 (input
  	  (read-from-minibuffer
! 	   (if default
! 	       (format "%s (default %s): " prompt (query-replace-descr default))
  	     (format "%s: " prompt))
  	   nil nil nil 'regexp-history defaults t)))
      (if (equal input "")
! 	default
        (prog1 input
  	(add-to-history 'regexp-history input)))))
  
--- 549,561 ----
  	 (history-add-new-input nil)
  	 (input
  	  (read-from-minibuffer
! 	   (if string-describing-default
! 	       (format "%s (default %s): " prompt
! 		       (query-replace-descr string-describing-default))
  	     (format "%s: " prompt))
  	   nil nil nil 'regexp-history defaults t)))
      (if (equal input "")
! 	string-describing-default
        (prog1 input
  	(add-to-history 'regexp-history input)))))
  
-- 
Juri Linkov
http://www.jurta.org/emacs/




  reply	other threads:[~2008-10-18 16:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-18 12:41 read-regexp Eli Zaretskii
2008-10-18 16:19 ` Juri Linkov [this message]
2008-10-18 19:13   ` read-regexp Stefan Monnier
2008-10-18 19:55     ` read-regexp Juri Linkov
2008-10-18 21:47       ` read-regexp Stefan Monnier
2008-10-18 23:29         ` read-regexp Juri Linkov
2008-10-18 19:21   ` read-regexp Eli Zaretskii
2008-10-18 19:59     ` read-regexp Juri Linkov
2008-10-18 16:23 ` Word Delimited Query Replace (was: read-regexp) Juri Linkov
2008-10-18 19:21   ` Word Delimited Query Replace Stefan Monnier
2008-10-18 19:52     ` Juri Linkov
2008-10-18 21:37       ` Stefan Monnier
2008-10-18 23:29         ` Juri Linkov
2008-10-19  2:08           ` Stefan Monnier
2008-10-19 22:48             ` 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

  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=87iqrp7wgm.fsf@jurta.org \
    --to=juri@jurta.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@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 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).