[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors
From: |
Paul Eggert |
Subject: |
bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors |
Date: |
Thu, 04 Jun 2015 08:43:50 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 |
Alan Mackenzie wrote:
a typical use of Q would look like this:
error ("Buffer name " Q(%s) " is in use", SDATA (name));
I'm afraid that's not sufficient, as sometimes we have code like this:
insert_string ("\nUses keymap `");
with unbalanced quotes. We can fix this by using another macro, uLSQM in the
originally proposed patch:
insert_string ("\nUses keymap "uLSQM);
though this is starting to get ugly.
The more serious problem, though is that neither approach will work well in the
Elisp code, which is where the vast majority of these quotes live. It would be
quite painful to change this:
(format "Parsing `%s': expected %s `%s', got `%s'." a b c d)
to this:
(format (concat "Parsing " (q "%s") ": expected %s " (q "%s")
", got " (q "%s") ".")
a b c)
I considered changing 'format' so that it automatically curves quotes in the
format string. But that would mishandle common cases like this:
(format "\\`%s" path-separator)
where 'format' is being used to compose a regular expression containing '\`'.
More reasonable would be to add a new function, 'format-message', that behaves
like 'format' except it also curves quotes, and to change functions like
'message' and 'error' to use 'format-message' instead of plain 'format'. But
even here we have lots of examples like this:
(y-or-n-p (format "File `%s' exists; overwrite? " filename))
where we'd have to change 'format' to 'format-message'.
We could go the GCC route and add a new format flag 'q', so that the above
examples could be written like this:
(format "Parsing %qs: expected %s %qs, got %qs." a b c d)
(y-or-n-p (format "File %qs exists; overwrite? " filename))
This approach would make sense if 8-bit environments were still common, as they
were when GCC added the 'q' flag to its message formatter. However, nowadays
8-bit environments are obsolescent (sorry) and so this approach seems like
overkill now. If we are bothering to go through code to fix quotes, it's better
to change the above examples to:
(format "Parsing ‘%s’: expected %s ‘%s’, got ‘%s’." a b c d)
(y-or-n-p (format "File ‘%s’ exists; overwrite? " filename))
for two reasons. First, unlike %qs the resulting code will work on older Emacs
implementations and thus will make the code more backward-compatible. Second,
it's easier to read and maintain quote marks that you can see.
- bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors, (continued)
- bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors, Paul Eggert, 2015/06/01
- bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors, Alan Mackenzie, 2015/06/01
- bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors, Paul Eggert, 2015/06/01
- bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors, Alan Mackenzie, 2015/06/02
- bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors, Drew Adams, 2015/06/02
- bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors, Paul Eggert, 2015/06/02
- bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors, Dmitry Gutov, 2015/06/02
- bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors, Paul Eggert, 2015/06/02
- bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors, Alan Mackenzie, 2015/06/02
- bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors, Alan Mackenzie, 2015/06/02
- bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors,
Paul Eggert <=
- bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors, Alan Mackenzie, 2015/06/06
- bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors, Paul Eggert, 2015/06/06
- bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors, Alan Mackenzie, 2015/06/06
- bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors, Paul Eggert, 2015/06/06
- bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors, Alan Mackenzie, 2015/06/08
- bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors, Paul Eggert, 2015/06/09
- bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors, Alan Mackenzie, 2015/06/09
- bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors, Paul Eggert, 2015/06/09
- bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors, Alan Mackenzie, 2015/06/09
- bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors, Paul Eggert, 2015/06/09