From: Alan Mackenzie <acm@muc.de>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: Glenn Morris <rgm@gnu.org>, 23425@debbugs.gnu.org, emacs-devel@gnu.org
Subject: Re: bug#23425: master branch: `message' wrongly corrupts ' to curly quote.
Date: Mon, 5 Jun 2017 16:27:37 +0000 [thread overview]
Message-ID: <20170605162737.GA30946@acm.fritz.box> (raw)
In-Reply-To: <a9ab013f-9f46-d1c8-44f9-8094a7d7ce74@cs.ucla.edu>
Hello, Paul.
On Sun, Jun 04, 2017 at 14:01:42 -0700, Paul Eggert wrote:
> Alan Mackenzie wrote:
> > We have moved from a state where everybody knew what
> > `message' did (in Emacs 24), to one with wild special characters which
> > only apply sometimes, and necessitate crazy prolix formulations to work
> > around unwanted translations of quote characters.
> This exaggerates somewhat. We moved from Emacs 24 where only % is special, to
> Emacs 25 where %, ` and ' are special.
Yes. We moved from regularity (where %x, for varying x, and nothing
else was special) to a ragbag (where there are 3 special characters,
with the two "new" ones being syntactically totally different from %).
> Although some people don't know that ` and ' are special, that's also
> true for %.
No. _Anybody_ who's used `message' knows that %s is how you print out
an arbitrary sexp. Anybody who's used printf in C knows this, too. It
is very easy not to know that ` and ' are special, and horribly easy to
get caught out by it, as happened to me.
> And although it can be annoying to write (message "%s" STR) to avoid
> unwanted translation of STR, that annoyance was already present for %.
It is not merely annoying, it is hideously irregular. Having to write
(message "%s" (format "...." arg1 arg2 ....)) screams out "we didn't
think this through properly". A call to message should only need one
format string. The change I am proposing would achieve this.
This was never the case for %. It is and always was trivially easy to
cause a literal % sign to be output by message, and there was never
danger of confusion in this.
We also have `format' and `format-message' which handle format strings
inconsistently. (Yes, I know, `format-message' was introduced
deliberately to create this inconsistency, because `format' was no
longer able to cope on its own.)
> > it makes sense to shift this burden over to the use cases where the
> > programmers need quote translation, and hence will be aware of it.
> When text-quoting-style specifies translation, most instances of ` and ' in
> Emacs messages are better off translated. So it also makes sense to translate by
> default in this situation, with a way to avoid translation in the rare cases
> where translation isn't wanted.
I disagree with this, of course. Translating behind people's backs is
not a friendly thing to do. Translation should only be done where it is
specifically specified.
> The question is about which approach makes more sense, not whether one
> approach is sensible and the other nonsense.
OK.
> >> although it simplifies ‘message’ (obviously), this is at the price of
> >> complicating everything else.
> > What is the "everything else" that gets thus complicated?
> I was referring to the hassle of going through hundreds or thousands of message
> strings or calls, deciding which instances of ` and ' should be replaced with %`
> and %', and replacing the instances accordingly.
Yes. There are quite a lot, but not an unmanageable number.
> It's also possible that at times we'll need two format strings instead
> of one, complicating the code.
We need two strings instead of one at the moment, with (message "%s"
(format "..." .....)). With %` and %' we'd only need one string in each
message invocation. This is simplification.
Can you give an example of something which might need two strings?
> > There are around 17,000 occurrances of "message" in our Lisp
> > sources, and probably a few in our C sources. Only (some of) those
> > containing the quote characters in the format string would need
> > amendment. These will comprise a tiny portion of these ~17,000
> How many lines do you think will be in that "tiny portion"? No matter how you
> count them, it'll be quite a few changes.
By searching for
"(\\(message\\|error\\)\\s +\\([^\"]\\|\"\\(\\\\.\\|[^\"\\]\\)*[`']\\)"
, i.e. an invocation of message or error followed by either something
which isn't a literal string, or a literal string containing ` or ', I
get 2745 matches in our Lisp sources. There'll be a smaller number also
in our C sources. I would have to enhance that regexp to recognise
comments, and maybe a few other things, but 2745 is a good first
approximation.
A very great number of these are "(error ..." handlers in condition-case
forms. A great number of those remaining could be simply and
mechanically translated, for example "don't", "can't", "couldn't", etc.,
and a lot of "`%s'"s and "`%S'"s.
I estimate there will be a few hundred forms remaining which need
decision making to adapt them. For example, where message is used in
macros, and the format string is a macro parameter.
> > and can be found easily enough with a script
> I'm afraid not, because in many cases the string is not a simple literal
> constant argument to the message function. For starters, there's also the error
> function; that's another 14,000 text matches in the Elisp source -- many of them
> false alarms of course, but not all of them.
See above.
> I'm not saying this sort of change is impossible. It's just that it'd be quite a
> bit of work, work that someone would need to volunteer to do. Is this really the
> best use of our limited resources?
Clearly, that someone would have to be me. The consequences of
surreptitious unwanted translation are so severe that I think this would
indeed be a good use of resources.
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2017-06-05 16:27 UTC|newest]
Thread overview: 123+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-02 14:55 bug#23425: master branch: `message' wrongly corrupts ' to curly quote Alan Mackenzie
2016-05-02 16:25 ` Lars Ingebrigtsen
2016-05-02 16:41 ` Drew Adams
2016-05-02 17:53 ` Paul Eggert
2016-05-02 19:10 ` Alan Mackenzie
2016-05-03 15:17 ` Paul Eggert
2016-05-03 16:36 ` Drew Adams
2016-05-03 16:59 ` Eli Zaretskii
2016-05-03 15:38 ` Eli Zaretskii
2016-05-03 16:27 ` Alan Mackenzie
2016-05-03 16:55 ` Eli Zaretskii
2016-05-03 20:03 ` Alan Mackenzie
2016-05-03 20:49 ` Paul Eggert
2016-05-04 15:32 ` Eli Zaretskii
2016-05-04 16:48 ` Alan Mackenzie
2016-05-04 17:03 ` Eli Zaretskii
2016-05-04 17:37 ` Josh
2016-05-04 19:05 ` Eli Zaretskii
2016-05-04 18:04 ` Alan Mackenzie
2016-05-04 18:39 ` Paul Eggert
2016-05-04 18:57 ` Alan Mackenzie
2016-05-04 19:02 ` John Wiegley
2016-05-04 21:34 ` Paul Eggert
2016-05-04 21:50 ` Paul Eggert
2016-05-04 23:49 ` Paul Eggert
2016-05-05 15:51 ` Eli Zaretskii
2016-05-10 14:41 ` Paul Eggert
2017-05-31 1:07 ` Glenn Morris
2017-05-31 1:42 ` Paul Eggert
2017-05-31 21:24 ` Alan Mackenzie
2017-05-31 23:26 ` Paul Eggert
2017-06-02 21:02 ` Alan Mackenzie
2017-06-02 21:15 ` Dmitry Gutov
2017-06-03 21:10 ` Alan Mackenzie
2017-06-03 21:32 ` Dmitry Gutov
2017-06-03 21:32 ` Dmitry Gutov
2017-06-03 21:10 ` Alan Mackenzie
2017-06-02 21:47 ` Paul Eggert
2017-06-03 0:13 ` Glenn Morris
2017-06-03 21:01 ` Alan Mackenzie
2017-06-03 21:01 ` Alan Mackenzie
2017-06-03 20:53 ` Alan Mackenzie
2017-06-03 20:53 ` Alan Mackenzie
2017-06-04 21:01 ` Paul Eggert
2017-06-05 16:27 ` Alan Mackenzie
2017-06-05 16:27 ` Alan Mackenzie [this message]
2017-06-05 18:19 ` Paul Eggert
2017-06-05 18:19 ` Paul Eggert
2017-06-05 18:31 ` Andreas Schwab
2017-06-05 18:31 ` Andreas Schwab
2017-06-05 20:37 ` Alan Mackenzie
2017-06-05 20:37 ` Alan Mackenzie
2017-06-05 21:05 ` Clément Pit-Claudel
2017-06-07 16:50 ` Alan Mackenzie
2017-06-07 19:29 ` Clément Pit-Claudel
2017-06-07 19:29 ` Clément Pit-Claudel
2017-06-06 0:14 ` Paul Eggert
2017-06-06 8:21 ` Andreas Schwab
2017-06-06 8:21 ` Andreas Schwab
2017-06-06 12:24 ` Clément Pit-Claudel
2017-06-06 13:55 ` Yuri Khan
2017-06-06 13:55 ` Yuri Khan
2017-06-06 18:21 ` Clément Pit-Claudel
2017-06-06 18:59 ` Yuri Khan
2017-06-06 18:59 ` Yuri Khan
2017-06-06 19:39 ` Clément Pit-Claudel
2017-06-07 4:57 ` Eli Zaretskii
2017-06-07 4:57 ` Eli Zaretskii
2017-06-06 19:39 ` Clément Pit-Claudel
2017-06-06 12:24 ` Clément Pit-Claudel
2017-06-06 23:09 ` Paul Eggert
2017-06-07 7:44 ` Andreas Schwab
2017-06-07 18:17 ` Paul Eggert
2017-06-08 8:04 ` Andreas Schwab
2017-06-07 13:27 ` Drew Adams
2017-06-07 13:27 ` Drew Adams
2017-06-07 19:13 ` Alan Mackenzie
2017-06-07 19:27 ` Clément Pit-Claudel
2017-06-07 19:27 ` Clément Pit-Claudel
2017-06-07 19:33 ` Dmitry Gutov
2017-06-07 19:33 ` Dmitry Gutov
2017-06-07 19:51 ` Alan Mackenzie
2017-06-07 19:51 ` Alan Mackenzie
2017-06-07 20:33 ` Alan Mackenzie
2017-06-07 20:33 ` Alan Mackenzie
2017-06-07 20:56 ` Drew Adams
2017-06-07 22:05 ` `message' with quotes [was: bug#23425: `message' wrongly corrupts ' to curly quote] Drew Adams
2017-06-08 17:49 ` Alan Mackenzie
2017-06-07 23:28 ` bug#23425: master branch: `message' wrongly corrupts ' to curly quote Paul Eggert
2017-06-08 17:34 ` Alan Mackenzie
2017-06-08 20:17 ` Paul Eggert
2017-06-09 19:41 ` Alan Mackenzie
2017-06-09 20:17 ` Drew Adams
2017-06-09 20:38 ` Alan Mackenzie
2017-06-09 21:05 ` Drew Adams
2017-06-09 21:44 ` Paul Eggert
2017-06-09 22:51 ` Drew Adams
2017-06-10 0:20 ` Paul Eggert
2017-06-10 10:01 ` Alan Mackenzie
2017-06-10 10:52 ` David Engster
2017-06-10 11:48 ` Eli Zaretskii
2017-06-10 13:01 ` Alan Mackenzie
2017-06-10 13:39 ` Eli Zaretskii
2017-06-11 10:03 ` Alan Mackenzie
2017-06-11 14:37 ` Eli Zaretskii
2017-06-10 15:28 ` Dmitry Gutov
2017-06-01 16:56 ` Glenn Morris
2017-06-03 21:07 ` Alan Mackenzie
2017-06-03 21:07 ` Alan Mackenzie
2016-05-04 18:46 ` John Wiegley
2016-05-04 20:23 ` Dmitry Gutov
2016-05-04 21:15 ` John Wiegley
2016-05-04 22:19 ` Lars Ingebrigtsen
2016-05-05 7:12 ` Andreas Schwab
2016-05-05 17:05 ` Eli Zaretskii
2016-05-05 8:06 ` Alan Mackenzie
2016-05-05 17:06 ` Eli Zaretskii
2016-05-05 23:46 ` John Wiegley
2016-05-06 8:54 ` Nicolas Petton
2016-05-04 19:08 ` Eli Zaretskii
2016-05-04 21:49 ` Andreas Schwab
2017-06-09 20:31 ` Glenn Morris
2017-06-10 7:08 ` Eli Zaretskii
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170605162737.GA30946@acm.fritz.box \
--to=acm@muc.de \
--cc=23425@debbugs.gnu.org \
--cc=eggert@cs.ucla.edu \
--cc=emacs-devel@gnu.org \
--cc=rgm@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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.