From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: MON KEY Newsgroups: gmane.emacs.devel Subject: functions which read by prompting should not add additional chars to prompt string Date: Sat, 22 Jan 2011 15:38:25 -0500 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: dough.gmane.org 1295728904 23397 80.91.229.12 (22 Jan 2011 20:41:44 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 22 Jan 2011 20:41:44 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jan 22 21:41:40 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PgkHB-00078L-4e for ged-emacs-devel@m.gmane.org; Sat, 22 Jan 2011 21:41:37 +0100 Original-Received: from localhost ([127.0.0.1]:55039 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PgkHA-0001bN-Ft for ged-emacs-devel@m.gmane.org; Sat, 22 Jan 2011 15:41:36 -0500 Original-Received: from [140.186.70.92] (port=44531 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PgkFL-0000WE-9a for emacs-devel@gnu.org; Sat, 22 Jan 2011 15:40:45 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PgkE8-0002rd-4a for emacs-devel@gnu.org; Sat, 22 Jan 2011 15:39:42 -0500 Original-Received: from mail-wy0-f169.google.com ([74.125.82.169]:43225) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PgkE7-0002rF-Qr for emacs-devel@gnu.org; Sat, 22 Jan 2011 15:38:28 -0500 Original-Received: by wyj26 with SMTP id 26so3216827wyj.0 for ; Sat, 22 Jan 2011 12:38:26 -0800 (PST) Original-Received: by 10.216.186.144 with SMTP id w16mr2092872wem.13.1295728705807; Sat, 22 Jan 2011 12:38:25 -0800 (PST) Original-Received: by 10.216.70.212 with HTTP; Sat, 22 Jan 2011 12:38:25 -0800 (PST) X-Google-Sender-Auth: 43l7pnqzc6QrNg0l1epzQft1uk8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:134852 Archived-At: Lisp functions which read user input and accept a PROMPT arg should not append additional characters to the supplied PROMPT string esp. when no additional arguments are supplied. --- `read-regexp' lisp/replace.el When read-regexp's optional arg DEFAULT-VALUE is not true, why are a colon (char 58) and space (char 32) tacked onto end of PROMPT? e.g.: (if default-value (format "%s (default %s): " prompt (query-replace-descr default-value)) (format "%s: " prompt)) ^ This should be: (format "%s" prompt) For a `read-*' style function, the behaviour of `read-regexp' is annoying b/c its name suggest that it is the public interface for reading regexps. esp. Indeed, there are regexp readers in other packages which don't use the `read-regexp' interface, instead rolling their own readers, e.g.: `dired-read-regexp' `ad-read-regexp' `grep-read-regexp' As such, I would suggest that the `read-regexp' interface might be adjusted to offer a more conformant behaviour without too much trouble. There are eight functions in ./lisp which directly call `read-regexp'. Of the eight only four supply have provision for a DEFAULT-VALUE: `hi-lock-line-face-buffer' `hi-lock-face-buffer', `hi-lock-face-phrase-buffer' `occur-read-primary-arg' Each of the above rely on the value of (car regexp-history) for DEFAULT-VALUE. IOW, even where callers do supply DEFAULT-VALUE there is no guarantee that the car of `regexp-history' isn't null. A good fix might be to adjust the existing semantics of `read-regexp's DEFAULT-VALUE to accept a boolean which when t defaults to whatever is at the head `regexp-history' e.g.: (and (eq default-value t) (setq default-value (car regexp-history))) Following enumerates the eight functions in ./lisp which rgrep shows as direct callers of `read-regexp'. I've indicated their PROPMT and supply annotation as to which provide a DEFAULT-VALUE. - lisp/replace.el No defaulting behaviour: `keep-lines-read-args' ;--> (read-regexp prompt) With DEFAULT-VALUE supplied but regexp-history may may be nil: `occur-read-primary-arg' ;--> (read-regexp "List lines matching regexp" (car regexp-history)) - lisp/faces.el No defaulting behaviour: `list-faces-display' ;--> (read-regexp "List faces matching regexp") - lisp/hi-lock.el Each supplies a DEFAULT-VAULUE, but regexp-history may may be nil: `hi-lock-line-face-buffer' ;--> (read-regexp "Regexp to highlight line" (car regexp-history)) `hi-lock-face-buffer' ;--> (read-regexp "Regexp to highlight" (car regexp-history)) `hi-lock-face-phrase-buffer' ;--> (read-regexp "Phrase to highlight" (car regexp-history)) - lisp/misearch.el No defaulting behavior: `multi-isearch-read-matching-buffers' ;--> (read-regexp "Search in buffers whose names match regexp") `multi-isearch-read-matching-files' ;--> (read-regexp "Search in files whose names match wildcard") --- Following two functions, `read-face-name' and `read-quoted-char' both step on the supplied PROMPT and should be fixed: (read-face-name "face ") (read-quoted-char "char ") `read-quoted-char' behaves has doubly bad by tacking on a "-". Why? --- `read-buffer' may step on the PROMPT string only when DEF is non-nil: (read-buffer "buffer ") However her buddy `read-buffer-to-switch' has non-standard prompt string defaulting behavior similiar to that of `read-regexp'. Though, unlike `read-regexp' which is implemented in lisp, `read-buffer-to-switch' is a lisp wrapper around the C primitive `read-buffer' defined in src/minibuf.c `read-buffer' will acknowledge `read-buffer-function' when non-nil and allows callers to override its own non standard prompt string defaulting. (read-buffer-to-switch "switch to buffer ") --- For comparsion, following is a list of "reading" functions which do not not step on a supplied PROMPT string by tacking on additional characters: (read-minibuffer "lispy thing ") (read-from-minibuffer "string ") (read-string "string ") (read-no-blanks-input "no spaces please ") (read-number "number ") (read-passwd "password ") (read-event "event ") (read-key-sequence "key sequence ") (read-key-sequence-vector "key sequence ") (read-variable "variable ") (read-command "command ") (read-file-name "file ") (read-directory-name "directory ") (read-color "color ") (read-envvar-name "envvar ") (read-shell-command "shell-command ") (read-char "char ") (read-char-by-name "char-name ") (read-char-exclusive "char ") (read-charset "charset ") (read-file-modes "modes ") (read-multilingual-string "string ") (read-non-nil-coding-system "coding system ") (read-input-method-name "input method ") (read-language-name 'documentation "lang ") (read-coding-system "coding sytem ") -- /s_P\