unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#15909: 24.3.50; please fix `read-face-name' brain-dead PROMPT handling
@ 2013-11-15 22:12 Drew Adams
  2013-11-15 22:49 ` Drew Adams
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Drew Adams @ 2013-11-15 22:12 UTC (permalink / raw)
  To: 15909

In Emacs 20, the PROMPT arg was just passed to `completing-read'.  So
you used ": " at the end.  As usual in Emacs.  Simple.  Sure.  No
nonsense.

In Emacs 22, `read-face-name' decided to become "smart": It required
callers NOT to end the PROMPT with a space.  Dumb.

In Emacs 24, `read-face-name' decided to become even "smarter": It
requires callers NOT to end the PROMPT with EITHER a space or a colon.
It systematically adds ": " to PROMPT.  Dumber.

This is silly.  It means that any 3rd-party code that passes a prompt to
`read-face-name' has to fiddle with it to get the desired result for
different Emacs versions.  To what end?  What good is accomplished by
this silliness?

Please add some code similar to the following to `read-face-name', so it
DTRT.

 (when (save-match-data (string-match ": $" prompt))
   (setq prompt  (substring prompt 0 -2)))

Feel free to make this code even smarter - make it accommodate prompts
of all sorts, adding ": " or ":" or " " ONLY AS NEEDED, not
systematically.  After a decade or so of silliness, we should be able to
get this right finally.

If there were no silly history, the right approach would of course be to
have callers include ": " in the PROMPT arg, as usual in Emacs.
`read-face-name' (or some utility function it calls) could massage the
prompt to fiddle with default values or whatever.

It's not too late to make that the new interface.  But we still need to
fix the problem of callers that must work across Emacs versions.

So please update the behavior (and the doc string) to expect PROMPT to
have its own ": ", but still accommodate PROMPTs that do not have it by
adding ": ", ":", or " " as needed.  Yes, this is a mess.  And a
gratuitous one, to boot.


In GNU Emacs 24.3.50.1 (i686-pc-mingw32)
 of 2013-11-12 on LEG570
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --enable-checking 'CFLAGS=-O0 -g3' CPPFLAGS=-DGLYPH_DEBUG=1'





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#15909: 24.3.50; please fix `read-face-name' brain-dead PROMPT handling
  2013-11-15 22:12 bug#15909: 24.3.50; please fix `read-face-name' brain-dead PROMPT handling Drew Adams
@ 2013-11-15 22:49 ` Drew Adams
  2014-02-08  3:14 ` Lars Ingebrigtsen
  2016-04-29 14:42 ` Lars Ingebrigtsen
  2 siblings, 0 replies; 5+ messages in thread
From: Drew Adams @ 2013-11-15 22:49 UTC (permalink / raw)
  To: 15909

> Please add some code similar to the following to `read-face-name',
> so it DTRT.
>  (when (save-match-data (string-match ": $" prompt))
>    (setq prompt  (substring prompt 0 -2)))

To be clearer about that part.  Below is code I use to counteract
the current `read-face-name' behavior.  Incorporating a reasonable
fix into `read-face-name' would do something akin to the opposite.

(defun my-read-face-name (prompt)
  "Read a face name using completion.  Return its face symbol.
Accommodate vanilla Emacs PROMPT arg across Emacs versions."
  (save-match-data
    (when (and (> emacs-major-version 21)
               (string-match "\\(:\\s *$\\|:?\\s +$\\)" prompt))
      (setq prompt
            (substring prompt 0
                       (- (length (match-string 0 prompt)))))))
  (read-face-name prompt))





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#15909: 24.3.50; please fix `read-face-name' brain-dead PROMPT handling
  2013-11-15 22:12 bug#15909: 24.3.50; please fix `read-face-name' brain-dead PROMPT handling Drew Adams
  2013-11-15 22:49 ` Drew Adams
@ 2014-02-08  3:14 ` Lars Ingebrigtsen
  2014-02-08 23:08   ` Drew Adams
  2016-04-29 14:42 ` Lars Ingebrigtsen
  2 siblings, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2014-02-08  3:14 UTC (permalink / raw)
  To: Drew Adams; +Cc: 15909

Drew Adams <drew.adams@oracle.com> writes:

> In Emacs 20, the PROMPT arg was just passed to `completing-read'.  So
> you used ": " at the end.  As usual in Emacs.  Simple.  Sure.  No
> nonsense.
>
> In Emacs 22, `read-face-name' decided to become "smart": It required
> callers NOT to end the PROMPT with a space.  Dumb.
>
> In Emacs 24, `read-face-name' decided to become even "smarter": It
> requires callers NOT to end the PROMPT with EITHER a space or a colon.
> It systematically adds ": " to PROMPT.  Dumber.
>
> This is silly.  It means that any 3rd-party code that passes a prompt to
> `read-face-name' has to fiddle with it to get the desired result for
> different Emacs versions.  To what end?  What good is accomplished by
> this silliness?

Is there any third-party code that calls that function?

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#15909: 24.3.50; please fix `read-face-name' brain-dead PROMPT handling
  2014-02-08  3:14 ` Lars Ingebrigtsen
@ 2014-02-08 23:08   ` Drew Adams
  0 siblings, 0 replies; 5+ messages in thread
From: Drew Adams @ 2014-02-08 23:08 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 15909

> Is there any third-party code that calls that function?

Of course.  Why wouldn't there be?  Take a look:

http://lmgtfy.com/?q=%22read-face-name%22+-debbugs+-bug-gnu-emacs





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#15909: 24.3.50; please fix `read-face-name' brain-dead PROMPT handling
  2013-11-15 22:12 bug#15909: 24.3.50; please fix `read-face-name' brain-dead PROMPT handling Drew Adams
  2013-11-15 22:49 ` Drew Adams
  2014-02-08  3:14 ` Lars Ingebrigtsen
@ 2016-04-29 14:42 ` Lars Ingebrigtsen
  2 siblings, 0 replies; 5+ messages in thread
From: Lars Ingebrigtsen @ 2016-04-29 14:42 UTC (permalink / raw)
  To: Drew Adams; +Cc: 15909

Drew Adams <drew.adams@oracle.com> writes:

> In Emacs 20, the PROMPT arg was just passed to `completing-read'.  So
> you used ": " at the end.  As usual in Emacs.  Simple.  Sure.  No
> nonsense.
>
> In Emacs 22, `read-face-name' decided to become "smart": It required
> callers NOT to end the PROMPT with a space.  Dumb.
>
> In Emacs 24, `read-face-name' decided to become even "smarter": It
> requires callers NOT to end the PROMPT with EITHER a space or a colon.
> It systematically adds ": " to PROMPT.  Dumber.
>
> This is silly.  It means that any 3rd-party code that passes a prompt to
> `read-face-name' has to fiddle with it to get the desired result for
> different Emacs versions.  To what end?  What good is accomplished by
> this silliness?

I've now pushed a fix for this to the trunk.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-04-29 14:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-15 22:12 bug#15909: 24.3.50; please fix `read-face-name' brain-dead PROMPT handling Drew Adams
2013-11-15 22:49 ` Drew Adams
2014-02-08  3:14 ` Lars Ingebrigtsen
2014-02-08 23:08   ` Drew Adams
2016-04-29 14:42 ` Lars Ingebrigtsen

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).