From: Paul Eggert <eggert@cs.ucla.edu>
To: Dmitry Gutov <dgutov@yandex.ru>, emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] master 9ce1d38: Use curved quotes in core elisp diagnostics
Date: Mon, 17 Aug 2015 16:55:41 -0700 [thread overview]
Message-ID: <55D2747D.10809@cs.ucla.edu> (raw)
In-Reply-To: <55D22CF4.9030608@yandex.ru>
[-- Attachment #1: Type: text/plain, Size: 1460 bytes --]
Dmitry Gutov wrote:
>> It's a bit more complicated and it would not
>> address all the uses of curved quotes in diagnostics, but it would
>> address many of them.
>
> The other uses, which currently don't employ a formatting sequence, can be
> changed to use %qs as well. It'll just be less of a mechanical conversion.
Do you mean replacing this sort of thing:
(message "Press ‘?’ or ‘h’ for help, ‘q’ to quit")
with this?
(message "Press %qs or %qs for help, %qs to quit" "?" "h" "q")
If so, this doesn't sound like a good idea, as it would make the code harder to
read. Also, it wouldn't suffice for code like this:
(insert (symbol-name type)
(format " is a type (of kind ‘"))
(help-insert-xref-button (symbol-name metatype)
'cl-help-type metatype)
(insert (format "’)"))
which formats the matching quotes separately. Of course in general one could
rewrite even the latter example to use %qs (if only to grab the quote characters
out of the result string and reuse them individually!) but the rewritten version
would be significantly harder to read and maintain.
As we need to support formatting individual curved quotes anyway, there is an
argument for keeping it simple and omitting the attached patch for paired
quotes. With all this in mind, do you still think the complexity of the
attached draft patch is a good idea?
[-- Attachment #2: 0001-New-q-flag-for-format.txt --]
[-- Type: text/plain, Size: 7673 bytes --]
From 39d03d94f95e3ccf148f36ca3bfc1ee85f4dea20 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@Penguin.CS.UCLA.EDU>
Date: Mon, 17 Aug 2015 16:35:06 -0700
Subject: [PATCH] =?UTF-8?q?New=20q=20flag=20for=20=E2=80=98format=E2=80=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* doc/lispref/processes.texi (Sentinels):
Don't hardwire grave quoting style in example.
* doc/lispref/strings.texi (Formatting Strings):
* etc/NEWS:
Document new q flag.
* src/editfns.c (Fformat): Implement it.
---
doc/lispref/processes.texi | 4 +--
doc/lispref/strings.texi | 9 ++++--
etc/NEWS | 13 +++++---
src/editfns.c | 78 +++++++++++++++++++++++++++++++++++++++-------
4 files changed, 84 insertions(+), 20 deletions(-)
diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi
index 2bc6a18..98b3dfb 100644
--- a/doc/lispref/processes.texi
+++ b/doc/lispref/processes.texi
@@ -1720,13 +1720,13 @@ sentinel, the eventual call to the sentinel will use the new one.
@group
(defun msg-me (process event)
(princ
- (format "Process: %s had the event `%s'" process event)))
+ (format "Process: %s had the event ‘%s’" process event)))
(set-process-sentinel (get-process "shell") 'msg-me)
@result{} msg-me
@end group
@group
(kill-process (get-process "shell"))
- @print{} Process: #<process shell> had the event `killed'
+ @print{} Process: #<process shell> had the event ‘killed’
@result{} #<process shell>
@end group
@end smallexample
diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi
index 3093338..8de1473 100644
--- a/doc/lispref/strings.texi
+++ b/doc/lispref/strings.texi
@@ -936,7 +936,7 @@ where curved single quotes stand for themselves:
(format "The name of this buffer is ‘%s’." (buffer-name))
@result{} "The name of this buffer is ‘strings.texi’."
-(format "The buffer object prints as ‘%s’." (current-buffer))
+(format "The buffer object prints as %qs." (current-buffer))
@result{} "The buffer object prints as ‘strings.texi’."
(format "The octal value of %d is %o,
@@ -1011,13 +1011,16 @@ specifier, if any, to be inserted on the right rather than the left.
If both @samp{-} and @samp{0} are present, the @samp{0} flag is
ignored.
+ The flag @samp{q} quotes the printed representation as per the
+variable @samp{text-quoting-style} described below.
+
@example
@group
(format "%06d is padded on the left with zeros" 123)
@result{} "000123 is padded on the left with zeros"
-(format "%-6d is padded on the right" 123)
- @result{} "123 is padded on the right"
+(format "%q-6d is padded on the right" 123)
+ @result{} "‘123 ’ is padded on the right"
(format "The word ‘%-7s’ actually has %d letters in it."
"foo" (length "foo"))
diff --git a/etc/NEWS b/etc/NEWS
index ec3d25c..6058f22 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -912,12 +912,17 @@ create a string, and may return its first argument if the argument
already has the correct value.
+++
+** New ‘format’ flag ‘q’
+The new ‘q’ flag causes ‘format’ to quote the output representation as
+per the value of ‘text quoting-style’. E.g., (format "%qs failed"
+"foo") might return "‘foo’ failed".
+
++++
** substitute-command-keys now replaces quotes.
That is, it converts documentation strings' quoting style as per the
-value of ‘text-quoting-style’ as described above. Doc strings in
-source code can use either curved quotes or grave accent and
-apostrophe. As before, isolated apostrophes and characters preceded
-by \= are output as-is.
+value of ‘text-quoting-style’. Doc strings in source code can use
+either curved quotes or grave accent and apostrophe. As before,
+isolated apostrophes and characters preceded by \= are output as-is.
+++
** The character classes [:alpha:] and [:alnum:] in regular expressions
diff --git a/src/editfns.c b/src/editfns.c
index ed57d8a..0e1b0c8 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -3822,7 +3822,7 @@ specifiers, as follows:
%<flags><width><precision>character
-where flags is [+ #-0]+, width is [0-9]+, and precision is .[0-9]+
+where flags is [+ #-0q]+, width is [0-9]+, and precision is .[0-9]+
The + flag character inserts a + before any positive number, while a
space inserts a space before any positive number; these flags only
@@ -3835,6 +3835,9 @@ The # flag means to use an alternate display form for %o, %x, %X, %e,
for %e, %f, and %g, it causes a decimal point to be included even if
the precision is zero.
+The q flag means to quote the printed representation as per
+‘text-quoting-style’. E.g., "%qs" is equivalent to "‘%s’".
+
The width specifier supplies a lower limit for the length of the
printed representation. The padding, if any, normally goes on the
left, but it goes on the right if the - flag is present. The padding
@@ -3973,11 +3976,12 @@ usage: (format STRING &rest OBJECTS) */)
digits to print after the '.' for floats, or the max.
number of chars to print from a string. */
- bool minus_flag = 0;
- bool plus_flag = 0;
- bool space_flag = 0;
- bool sharp_flag = 0;
- bool zero_flag = 0;
+ bool minus_flag = false;
+ bool plus_flag = false;
+ bool space_flag = false;
+ bool sharp_flag = false;
+ bool zero_flag = false;
+ bool quote_flag = false;
ptrdiff_t field_width;
bool precision_given;
uintmax_t precision = UINTMAX_MAX;
@@ -3988,11 +3992,12 @@ usage: (format STRING &rest OBJECTS) */)
{
switch (*++format)
{
- case '-': minus_flag = 1; continue;
- case '+': plus_flag = 1; continue;
- case ' ': space_flag = 1; continue;
- case '#': sharp_flag = 1; continue;
- case '0': zero_flag = 1; continue;
+ case '-': minus_flag = true; continue;
+ case '+': plus_flag = true; continue;
+ case ' ': space_flag = true; continue;
+ case '#': sharp_flag = true; continue;
+ case '0': zero_flag = true; continue;
+ case 'q': quote_flag = true; continue;
}
break;
}
@@ -4121,6 +4126,20 @@ usage: (format STRING &rest OBJECTS) */)
if (convbytes && multibyte && ! STRING_MULTIBYTE (args[n]))
convbytes = count_size_as_multibyte (SDATA (args[n]), nbytes);
+ if (quote_flag)
+ {
+ convbytes += 2;
+ if (quoting_style == CURVE_QUOTING_STYLE)
+ {
+ if (!multibyte)
+ {
+ multibyte = true;
+ goto retry;
+ }
+ convbytes += 4;
+ }
+ }
+
padding = width < field_width ? field_width - width : 0;
if (max_bufsize - padding <= convbytes)
@@ -4128,6 +4147,27 @@ usage: (format STRING &rest OBJECTS) */)
convbytes += padding;
if (convbytes <= buf + bufsize - p)
{
+
+ if (quote_flag)
+ {
+ switch (quoting_style)
+ {
+ case CURVE_QUOTING_STYLE:
+ memcpy (p, uLSQM, 3);
+ p += 3;
+ break;
+
+ case GRAVE_QUOTING_STYLE:
+ *p++ = '`';
+ break;
+
+ case STRAIGHT_QUOTING_STYLE:
+ *p++ = '\'';
+ break;
+ }
+ nchars++;
+ }
+
if (! minus_flag)
{
memset (p, ' ', padding);
@@ -4157,6 +4197,22 @@ usage: (format STRING &rest OBJECTS) */)
nchars += padding;
}
+ if (quote_flag)
+ {
+ switch (quoting_style)
+ {
+ case CURVE_QUOTING_STYLE:
+ memcpy (p, uRSQM, 3);
+ p += 3;
+ break;
+
+ default:
+ *p++ = '\'';
+ break;
+ }
+ nchars++;
+ }
+
/* If this argument has text properties, record where
in the result string it appears. */
if (string_intervals (args[n]))
--
2.1.0
next prev parent reply other threads:[~2015-08-17 23:55 UTC|newest]
Thread overview: 212+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20150816160149.9416.80132@vcs.savannah.gnu.org>
[not found] ` <E1ZR0NZ-0002SU-SM@vcs.savannah.gnu.org>
2015-08-16 21:44 ` [Emacs-diffs] master 9ce1d38: Use curved quotes in core elisp diagnostics Dmitry Gutov
2015-08-16 22:53 ` Alan Mackenzie
2015-08-16 23:16 ` Drew Adams
2015-08-18 3:40 ` Richard Stallman
2015-08-18 5:20 ` Paul Eggert
2015-08-18 8:56 ` Bastien
2015-08-18 17:34 ` Paul Eggert
2015-08-18 18:05 ` Andreas Schwab
2015-08-18 18:32 ` Chad Brown
2015-08-18 19:42 ` Alan Mackenzie
2015-08-18 20:17 ` Drew Adams
2015-08-24 20:20 ` Richard Stallman
2015-08-25 11:35 ` Dmitry Gutov
2015-08-25 22:11 ` Richard Stallman
2015-08-25 22:16 ` Dmitry Gutov
2015-08-26 18:51 ` Richard Stallman
2015-08-26 22:23 ` Jean-Christophe Helary
2015-08-26 22:39 ` David Kastrup
2015-08-26 22:53 ` Jean-Christophe Helary
2015-08-27 2:44 ` Eli Zaretskii
2015-08-27 3:11 ` Jean-Christophe Helary
2015-08-27 4:43 ` Jean-Christophe Helary
2015-08-27 4:49 ` Werner LEMBERG
2015-08-27 16:27 ` Richard Stallman
2015-08-27 16:27 ` Richard Stallman
2015-08-27 3:10 ` Alexis
2015-08-27 4:48 ` Werner LEMBERG
2015-08-27 4:52 ` Werner LEMBERG
2015-08-27 4:49 ` Paul Eggert
2015-08-27 5:08 ` Werner LEMBERG
2015-08-27 7:33 ` David Kastrup
2015-08-27 8:47 ` Paul Eggert
2015-08-27 8:56 ` Werner LEMBERG
2015-08-27 16:28 ` [TRUNCATED MESSAGE 2408 171455] " Richard Stallman
2015-08-27 17:44 ` Paul Eggert
2015-08-27 11:27 ` Alexis
2015-08-27 16:27 ` Richard Stallman
2015-08-27 17:16 ` Paul Eggert
2015-08-28 1:41 ` Richard Stallman
2015-08-28 2:02 ` Paul Eggert
2015-08-28 7:28 ` Eli Zaretskii
2015-08-28 21:17 ` Richard Stallman
2015-08-28 8:12 ` Rasmus
2015-08-28 8:32 ` Paul Eggert
2015-08-28 8:38 ` Rasmus
2015-08-28 8:47 ` Marcin Borkowski
2015-08-28 9:08 ` Eli Zaretskii
2015-08-28 9:36 ` Marcin Borkowski
2015-08-28 9:05 ` Eli Zaretskii
2015-08-28 9:53 ` Rasmus
2015-08-28 10:05 ` Eli Zaretskii
2015-08-28 10:12 ` Rasmus
2015-08-28 12:45 ` Eli Zaretskii
2015-08-28 15:04 ` Rasmus
2015-08-28 15:31 ` Eli Zaretskii
2015-08-28 9:01 ` Eli Zaretskii
2015-08-28 16:40 ` Stefan Monnier
2015-08-28 19:13 ` Eli Zaretskii
2015-08-29 14:50 ` Stefan Monnier
2015-08-29 16:15 ` Eli Zaretskii
2015-08-30 2:00 ` Stefan Monnier
2015-08-30 14:41 ` Eli Zaretskii
2015-08-30 15:49 ` David Kastrup
2015-08-31 1:33 ` Stefan Monnier
2015-08-31 14:29 ` Eli Zaretskii
2015-08-31 17:36 ` Stefan Monnier
2015-08-31 17:52 ` Eli Zaretskii
2015-09-01 3:33 ` Stefan Monnier
2015-08-28 21:20 ` Richard Stallman
2015-08-28 7:21 ` Eli Zaretskii
2015-08-18 20:53 ` Dmitry Gutov
2015-08-18 21:43 ` Paul Eggert
2015-08-19 1:09 ` Dmitry Gutov
2015-08-19 18:14 ` Richard Stallman
2015-08-20 13:56 ` Dmitry Gutov
2015-08-21 7:51 ` Eli Zaretskii
2015-08-21 12:43 ` Richard Stallman
2015-08-21 12:52 ` David Kastrup
2015-08-22 17:30 ` Richard Stallman
2015-08-21 13:58 ` Ricardo Wurmus
2015-08-21 14:39 ` Marcin Borkowski
2015-08-19 1:22 ` Richard Stallman
2015-08-19 3:52 ` Paul Eggert
2015-08-19 18:15 ` Richard Stallman
2015-08-19 18:52 ` Paul Eggert
2015-08-20 16:54 ` Richard Stallman
2015-08-21 0:48 ` Dmitry Gutov
2015-08-21 1:35 ` Paul Eggert
2015-08-18 20:47 ` Dmitry Gutov
2015-08-19 1:24 ` Richard Stallman
2015-08-19 4:52 ` Paul Eggert
2015-08-24 20:20 ` Richard Stallman
2015-08-17 3:44 ` Paul Eggert
2015-08-17 11:09 ` Bastien Guerry
2015-08-17 16:39 ` Paul Eggert
2015-08-17 16:57 ` Bastien
2015-08-17 17:25 ` Paul Eggert
2015-08-17 17:47 ` Bastien
2015-08-17 11:33 ` Dmitry Gutov
2015-08-17 16:41 ` Paul Eggert
2015-08-17 11:47 ` Dmitry Gutov
2015-08-17 16:42 ` Paul Eggert
2015-08-17 18:11 ` Dmitry Gutov
2015-08-17 18:38 ` Paul Eggert
2015-08-17 18:50 ` Dmitry Gutov
2015-08-17 23:25 ` Artur Malabarba
2015-08-17 23:55 ` Paul Eggert [this message]
2015-08-18 11:31 ` Dmitry Gutov
2015-08-19 6:28 ` Paul Eggert
2015-08-19 13:30 ` Dmitry Gutov
2015-08-19 22:21 ` Paul Eggert
2015-08-19 22:38 ` Dmitry Gutov
2015-08-20 13:55 ` Paul Eggert
2015-08-21 23:47 ` Dmitry Gutov
2015-08-22 0:19 ` Paul Eggert
2015-08-22 12:45 ` Dmitry Gutov
2015-08-24 17:33 ` Paul Eggert
2015-08-25 7:11 ` Paul Eggert
2015-08-25 11:38 ` Dmitry Gutov
2015-08-25 18:03 ` Paul Eggert
2015-08-26 1:25 ` Stefan Monnier
2015-08-26 2:51 ` Paul Eggert
2015-08-20 16:56 ` Richard Stallman
2015-08-20 19:32 ` Paul Eggert
2015-08-22 16:31 ` Dmitry Gutov
2015-08-22 18:48 ` Paul Eggert
2015-08-22 21:09 ` Dmitry Gutov
2015-08-22 22:43 ` Paul Eggert
2015-08-22 23:08 ` Dmitry Gutov
2015-08-22 23:45 ` Paul Eggert
2015-08-23 8:11 ` Dmitry Gutov
2015-08-23 9:48 ` Paul Eggert
2015-08-23 10:45 ` Dmitry Gutov
2015-08-23 10:48 ` Andreas Schwab
2015-08-24 5:47 ` Paul Eggert
2015-08-23 4:30 ` Richard Stallman
2015-08-23 8:13 ` Dmitry Gutov
2015-08-24 0:08 ` Richard Stallman
2015-08-24 1:10 ` Paul Eggert
2015-08-24 20:22 ` Richard Stallman
2015-08-24 20:20 ` Richard Stallman
2015-08-24 22:25 ` Paul Eggert
2015-08-25 22:10 ` Richard Stallman
2015-08-26 6:13 ` Paul Eggert
2015-08-17 12:15 ` Alan Mackenzie
2015-08-17 14:40 ` Drew Adams
2015-08-17 16:53 ` Eli Zaretskii
2015-08-17 19:06 ` Paul Eggert
2015-08-17 19:34 ` Eli Zaretskii
2015-08-17 16:53 ` Paul Eggert
2015-08-17 17:35 ` Alan Mackenzie
2015-08-18 2:55 ` Paul Eggert
2015-08-18 10:39 ` Alan Mackenzie
2015-08-18 16:45 ` Paul Eggert
2015-08-18 17:17 ` Alan Mackenzie
2015-08-18 19:25 ` Paul Eggert
2015-08-18 20:42 ` Alan Mackenzie
2015-08-18 21:40 ` Paul Eggert
2015-08-18 22:44 ` Óscar Fuentes
2015-08-18 23:11 ` Bastien
2015-08-18 23:41 ` Paul Eggert
2015-08-19 0:29 ` Óscar Fuentes
2015-08-19 0:38 ` Óscar Fuentes
2015-08-19 18:15 ` Richard Stallman
2015-08-19 18:40 ` Paul Eggert
2015-08-20 13:37 ` Wolfgang Jenkner
2015-08-20 20:23 ` Paul Eggert
2015-08-21 7:41 ` Eli Zaretskii
2015-08-21 15:27 ` Stephen J. Turnbull
2015-08-22 17:29 ` Richard Stallman
2015-08-19 6:31 ` Stephen J. Turnbull
2015-08-19 6:58 ` Óscar Fuentes
2015-08-19 9:09 ` Stephen J. Turnbull
2015-08-19 9:13 ` Andreas Schwab
2015-08-19 14:05 ` Stephen J. Turnbull
2015-08-19 14:47 ` Andreas Schwab
2015-08-19 16:10 ` Stephen J. Turnbull
2015-08-20 23:46 ` Dmitry Gutov
2015-08-19 14:16 ` Eli Zaretskii
2015-08-19 16:03 ` Stephen J. Turnbull
2015-08-22 17:27 ` Richard Stallman
2015-08-23 0:04 ` Stephen J. Turnbull
2015-08-24 0:05 ` Richard Stallman
2015-08-19 18:16 ` Richard Stallman
2015-08-21 7:17 ` Eli Zaretskii
2015-08-22 17:27 ` Richard Stallman
2015-08-19 18:14 ` Richard Stallman
2015-08-18 23:15 ` Alan Mackenzie
2015-08-19 4:24 ` Paul Eggert
2015-08-19 7:37 ` Óscar Fuentes
2015-08-19 10:10 ` Nicolas Richard
2015-08-19 14:26 ` Marcin Borkowski
2015-08-19 21:53 ` Paul Eggert
2015-08-20 7:20 ` Andreas Schwab
2015-08-20 13:31 ` Óscar Fuentes
2015-08-18 15:09 ` Yuri Khan
2015-08-18 15:24 ` Andreas Schwab
2015-08-18 15:48 ` Yuri Khan
2015-08-18 15:48 ` Alan Mackenzie
2015-08-18 17:08 ` Yuri Khan
2015-08-18 18:12 ` Eli Zaretskii
2015-08-19 4:45 ` Yuri Khan
2015-08-19 14:14 ` Eli Zaretskii
2015-08-19 5:19 ` Stephen J. Turnbull
2015-08-19 14:15 ` Eli Zaretskii
2015-08-19 16:05 ` Stephen J. Turnbull
2015-08-19 1:19 ` Richard Stallman
2015-08-17 18:22 ` Dmitry Gutov
2015-08-18 3:55 ` Stephen J. Turnbull
2015-08-18 10:51 ` Dmitry Gutov
2015-08-18 12:31 ` Óscar Fuentes
2015-08-18 3:44 ` Richard Stallman
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=55D2747D.10809@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=dgutov@yandex.ru \
--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 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.