GNU bug report logs - #20545
New minor mode Electric Quote

Previous Next

Package: emacs;

Reported by: Paul Eggert <eggert <at> cs.ucla.edu>

Date: Sun, 10 May 2015 23:57:02 UTC

Severity: wishlist

Tags: patch

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 20545 in the body.
You can then email your comments to 20545 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Sun, 10 May 2015 23:57:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Paul Eggert <eggert <at> cs.ucla.edu>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 10 May 2015 23:57:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Emacs bug reports and feature requests <bug-gnu-emacs <at> gnu.org>
Subject: New minor mode Electric Punct
Date: Sun, 10 May 2015 16:55:42 -0700
[Message part 1 (text/plain, inline)]
Attached are two proposed patches.  The first creates a new minor mode Electric 
Punct that does a variant of "smart quoting" designed for the Emacs tradition of 
using ` and ' as aliases for left and right single quotation marks.  This new 
minor mode is inactive by default, but the user can enable it in certain 
contexts.  The second patch modifies .dir-locals.el to enable the minor mode in 
contexts where it should be useful when editing Emacs itself.

These patches are related to Bug#20385 in that they make it much easier to edit 
doc strings formatted ‘like this’, which is the point of Bug#20385.  (All that 
one needs to do is to type the string "`like this'".)  However, the main idea of 
this patch is independent of the Emacs doc string issue, as Emacs should make it 
easy to quote ‘like this’ when the user prefers this form.

I named this mode "Electric Punct" because I anticipate that there may be a 
similar need to enter em and en dashes, and a few other non-ASCII punctuation 
marks commonly used in text.  Quotes are a good place to start, so that's where 
I started.
[0001-New-minor-mode-Electric-Punct.patch (text/x-patch, attachment)]
[0002-Use-Electric-Punct-when-editing-Emacs-source.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Mon, 11 May 2015 15:02:02 GMT) Full text and rfc822 format available.

Message #8 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 20545 <at> debbugs.gnu.org
Subject: Re: bug#20545: New minor mode Electric Punct
Date: Mon, 11 May 2015 18:00:58 +0300
> Date: Sun, 10 May 2015 16:55:42 -0700
> From: Paul Eggert <eggert <at> cs.ucla.edu>
> 
> Attached are two proposed patches. The first creates a new minor mode Electric Punct that does a variant of "smart quoting" designed for the Emacs tradition of using ` and ' as aliases for left and right single quotation marks. This new minor mode is inactive by default

The documentation patch says it's enabled by default.

> but the user can enable it in certain contexts. The second patch modifies .dir-locals.el to enable the minor mode in contexts where it should be useful when editing Emacs itself.

I don't think we should enable this by default, not even in
.dir-locals.el.  Let users decide whether they want this; as for
Emacs, we didn't yet decide this style to be mandatory, so it's too
early to force it.

> These patches are related to Bug#20385 in that they make it much easier to edit doc strings formatted ‘like this’, which is the point of Bug#20385.

Do we already have a way of displaying ‘..’ on terminals that cannot
display them (notably, some TTYs)?  If not, we should add that before
we install these changes, and those in bug #20385.  I don't think we
can let doc strings have glyphless characters.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Mon, 11 May 2015 15:58:02 GMT) Full text and rfc822 format available.

Message #11 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 20545 <at> debbugs.gnu.org
Subject: Re: bug#20545: New minor mode Electric Punct
Date: Mon, 11 May 2015 11:57:18 -0400
> Attached are two proposed patches.  The first creates a new minor mode
> Electric Punct that does a variant of "smart quoting" designed for the Emacs
> tradition of using ` and ' as aliases for left and right single quotation
> marks.

How does it interact with electric-pair-mode?


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Mon, 11 May 2015 16:49:02 GMT) Full text and rfc822 format available.

Message #14 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Artur Malabarba <bruce.connor.am <at> gmail.com>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 20545 <at> debbugs.gnu.org
Subject: Re: bug#20545: New minor mode Electric Punct
Date: Mon, 11 May 2015 17:48:39 +0100
Not to start bikeshedding here, but electric-punctuation sounds like
something that automatically inserts spaces after punctionation marks,
like comma and fullstop.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Wed, 13 May 2015 07:34:01 GMT) Full text and rfc822 format available.

Message #17 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 20545 <at> debbugs.gnu.org
Subject: Re: bug#20545: New minor mode Electric Punct
Date: Wed, 13 May 2015 00:33:29 -0700
Stefan Monnier wrote:
> How does it interact with electric-pair-mode?

Err, it doesn't.  Thanks.  I'll look into that.

Your comment prompted me to find related issues with the patch I proposed in 
Bug#20385, and I just now sent in a revised version of that patch, here:

http://bugs.gnu.org/20385#205




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Wed, 13 May 2015 07:49:02 GMT) Full text and rfc822 format available.

Message #20 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 20545 <at> debbugs.gnu.org
Subject: Re: bug#20545: New minor mode Electric Punct
Date: Wed, 13 May 2015 00:48:13 -0700
Eli Zaretskii wrote:

> The documentation patch says it's enabled by default.

It's enabled, but the variables that configure it make it inactive by default. 
I'll try to make this clearer in the documentation.

> I don't think we should enable this by default, not even in
> .dir-locals.el.

We can certainly hold off on the .dir-locals.el part for a bit, to see how it 
works for developers who want to try it.

> Do we already have a way of displaying ‘..’ on terminals that cannot
> display them (notably, some TTYs)?  If not, we should add that before
> we install these changes, and those in bug #20385.  I don't think we
> can let doc strings have glyphless characters.

I just now configured a terminal to refuse to display curved quotes, and when I 
used it Emacs displayed "‘like this’" as "\u2018like this\u2019" with 
underscores below the "\u2018" and the "\u2019".  I could easily change it to 
display it as "`like this'" with underscores under the "`" and the "'", if you 
think that'd be a win.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Wed, 13 May 2015 13:11:02 GMT) Full text and rfc822 format available.

Message #23 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 20545 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#20545: New minor mode Electric Punct
Date: Wed, 13 May 2015 09:10:07 -0400
> I just now configured a terminal to refuse to display curved quotes, and
> when I used it Emacs displayed "‘like this’" as "\u2018like this\u2019" with
> underscores below the "\u2018" and the "\u2019".

Hmm... is it really Emacs that displayed it like this?  Or is it the
terminal which did it?  If it's Emacs, then I wonder how it figured it
needed to do that, and if it's the terminal, then I wonder how Emacs
could tell the terminal to...

> ... display it as "`like this'" with underscores under the "`" and the "'",
> if you think that'd be a win.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Wed, 13 May 2015 14:50:05 GMT) Full text and rfc822 format available.

Message #26 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 20545 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#20545: New minor mode Electric Punct
Date: Wed, 13 May 2015 07:49:47 -0700
[Message part 1 (text/plain, inline)]
Stefan Monnier wrote:

> Hmm... is it really Emacs that displayed it like this?  Or is it the
> terminal which did it?  If it's Emacs, then I wonder how it figured it
> needed to do that

I haven't looked at the details, but I expect Emacs looks at the locale and 
discovers that it's unibyte.  At least, that's how I did it: by starting xterm 
in an Ubuntu 15.04 environment where LC_ALL=en_US.iso885915, and then running 
emacs -nw under xterm.  In this situation, the attached patch to Emacs (which 
would have to be improved before installing) has the behavior of using 
underlined ` and ' to render curved single quotes.

[patch.diff (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Wed, 13 May 2015 16:39:02 GMT) Full text and rfc822 format available.

Message #29 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 20545 <at> debbugs.gnu.org
Subject: Re: bug#20545: New minor mode Electric Punct
Date: Wed, 13 May 2015 19:38:13 +0300
> Date: Wed, 13 May 2015 00:48:13 -0700
> From: Paul Eggert <eggert <at> cs.ucla.edu>
> CC: 20545 <at> debbugs.gnu.org
> 
>     Do we already have a way of displaying ‘..’ on terminals that cannot
>     display them (notably, some TTYs)?  If not, we should add that before
>     we install these changes, and those in bug #20385.  I don't think we
>     can let doc strings have glyphless characters.
> 
> I just now configured a terminal to refuse to display curved quotes, and when I used it Emacs displayed "‘like this’" as "\u2018like this\u2019" with underscores below the "\u2018" and the "\u2019".

Yes, that's what I see, too.

> I could easily change it to display it as "`like this'" with underscores under the "`" and the "'", if you think that'd be a win.

I think we should indeed display that `like this' (when the curved
quotes cannot be displayed), but do we really need the underscores?
What would be their purpose?

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Wed, 13 May 2015 16:55:03 GMT) Full text and rfc822 format available.

Message #32 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 20545 <at> debbugs.gnu.org, eggert <at> cs.ucla.edu
Subject: Re: bug#20545: New minor mode Electric Punct
Date: Wed, 13 May 2015 19:54:30 +0300
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: Eli Zaretskii <eliz <at> gnu.org>,  20545 <at> debbugs.gnu.org
> Date: Wed, 13 May 2015 09:10:07 -0400
> 
> > I just now configured a terminal to refuse to display curved quotes, and
> > when I used it Emacs displayed "‘like this’" as "\u2018like this\u2019" with
> > underscores below the "\u2018" and the "\u2019".
> 
> Hmm... is it really Emacs that displayed it like this?  Or is it the
> terminal which did it?

Emacs.  That's how we display "glyphless" characters on a TTY.

> If it's Emacs, then I wonder how it figured it needed to do that,

By checking whether the character belongs to one of the charsets
supported by the terminal.  We call char_charset with the list of
charsets supported by the terminal frame; that charset list is set by
set-terminal-coding-system-internal.  See the end of
term.c:produce_glyphs.

> and if it's the terminal, then I wonder how Emacs could tell the
> terminal to...
> 
> > ... display it as "`like this'" with underscores under the "`" and the "'",
> > if you think that'd be a win.

We could discover this in advance (e.g., using char-displayable-p) and
use a display table, for example.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Wed, 13 May 2015 16:57:01 GMT) Full text and rfc822 format available.

Message #35 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 20545 <at> debbugs.gnu.org
Subject: Re: bug#20545: New minor mode Electric Punct
Date: Wed, 13 May 2015 09:56:12 -0700
Eli Zaretskii wrote:
> do we really need the underscores?
> What would be their purpose?

To tell the user that the characters are not really "`" and "'", but are 
something else.  It's the same reason we underline the "\u2018" and the "\u2019".




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Wed, 13 May 2015 17:06:02 GMT) Full text and rfc822 format available.

Message #38 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 20545 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
Subject: Re: bug#20545: New minor mode Electric Punct
Date: Wed, 13 May 2015 20:05:28 +0300
> Date: Wed, 13 May 2015 07:49:47 -0700
> From: Paul Eggert <eggert <at> cs.ucla.edu>
> CC: Eli Zaretskii <eliz <at> gnu.org>, 20545 <at> debbugs.gnu.org
> 
> In this situation, the attached patch to Emacs (which would have to
> be improved before installing) has the behavior of using underlined
> ` and ' to render curved single quotes.
> 
> diff --git a/src/term.c b/src/term.c
> index d2a9c3d..86ca4d8 100644
> --- a/src/term.c
> +++ b/src/term.c
> @@ -1867,6 +1867,10 @@ produce_glyphless_glyph (struct it *it, Lisp_Object acronym)
>  			  : it->c <= MAX_UNICODE_CHAR ? "\\U%06X"
>  			  : "\\x%06X"),
>  			 it->c + 0u);
> +	  if (it->c == 0x2018)
> +	    buf[0] = '`', len = 1;
> +	  else if (it->c == 0x2019)
> +	    buf[0] = '\'', len = 1;

I think we should use a display table here, like we do with other
special characters.  Hard-coding the replacements sounds un-Emacsy.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Wed, 13 May 2015 17:17:02 GMT) Full text and rfc822 format available.

Message #41 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 20545 <at> debbugs.gnu.org
Subject: Re: bug#20545: New minor mode Electric Punct
Date: Wed, 13 May 2015 20:16:23 +0300
> Date: Wed, 13 May 2015 09:56:12 -0700
> From: Paul Eggert <eggert <at> cs.ucla.edu>
> CC: 20545 <at> debbugs.gnu.org
> 
> Eli Zaretskii wrote:
> > do we really need the underscores?
> > What would be their purpose?
> 
> To tell the user that the characters are not really "`" and "'", but are 
> something else.

I fear it will just be a source of confusion.  FWIW, when Texinfo's
Info reader makes similar replacements, it doesn't mark them in any
way, so the user really doesn't know the characters were replaced.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Wed, 13 May 2015 18:11:03 GMT) Full text and rfc822 format available.

Message #44 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: eggert <at> cs.ucla.edu
Cc: 20545 <at> debbugs.gnu.org
Subject: Re: bug#20545: New minor mode Electric Punct
Date: Wed, 13 May 2015 21:10:43 +0300
> Date: Wed, 13 May 2015 20:16:23 +0300
> From: Eli Zaretskii <eliz <at> gnu.org>
> Cc: 20545 <at> debbugs.gnu.org
> 
> > Date: Wed, 13 May 2015 09:56:12 -0700
> > From: Paul Eggert <eggert <at> cs.ucla.edu>
> > CC: 20545 <at> debbugs.gnu.org
> > 
> > Eli Zaretskii wrote:
> > > do we really need the underscores?
> > > What would be their purpose?
> > 
> > To tell the user that the characters are not really "`" and "'", but are 
> > something else.
> 
> I fear it will just be a source of confusion.  FWIW, when Texinfo's
> Info reader makes similar replacements, it doesn't mark them in any
> way, so the user really doesn't know the characters were replaced.

If you still think we should highlight these characters, then let's at
least do that in the same manner as we do with non-ASCII hyphen,
conditioned on nobreak-char-display (see xdisp.c around line 6900 for
the details).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Thu, 14 May 2015 03:53:02 GMT) Full text and rfc822 format available.

Message #47 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 20545 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#20545: New minor mode Electric Punct
Date: Wed, 13 May 2015 23:52:35 -0400
> discovers that it's unibyte.  At least, that's how I did it: by starting
> xterm in an Ubuntu 15.04 environment where LC_ALL=en_US.iso885915, and then

Oh, but that's the easy case.  The real test is when the environment
uses utf-8 but the terminal's font fails to include the glyphs.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Thu, 14 May 2015 06:34:02 GMT) Full text and rfc822 format available.

Message #50 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 20545 <at> debbugs.gnu.org
Subject: Re: bug#20545: New minor mode Electric Punct
Date: Wed, 13 May 2015 23:32:57 -0700
[Message part 1 (text/plain, inline)]
Eli Zaretskii wrote:
> I fear it will just be a source of confusion.

Well, 8-bit terminals are no longer that common (at least when developing Emacs) 
so it's no big deal either way, and as it's easier to do it without highlighting 
let's try it that way.  A proposed patch is attached; it worked for me.

Stefan Monnier wrote:
> The real test is when the environment
> uses utf-8 but the terminal's font fails to include the glyphs.

That can easily happen with other characters, but in practice nowadays I think 
everybody has glyphs for curved quotes.  This is in part due to Microsoft 
Windows putting curved quotes in their most-popular 8-bit character set starting 
with MS-Windows 1.0 in 1985.  This put a lot of pressure on everybody else to 
support these glyphs one way or another, and it has been thirty years now....
[0001-Work-better-on-terminals-sans-curved-single-quotes.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Thu, 14 May 2015 14:55:03 GMT) Full text and rfc822 format available.

Message #53 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 20545 <at> debbugs.gnu.org, eggert <at> cs.ucla.edu
Subject: Re: bug#20545: New minor mode Electric Punct
Date: Thu, 14 May 2015 17:54:16 +0300
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: Eli Zaretskii <eliz <at> gnu.org>,  20545 <at> debbugs.gnu.org
> Date: Wed, 13 May 2015 23:52:35 -0400
> 
> > discovers that it's unibyte.  At least, that's how I did it: by starting
> > xterm in an Ubuntu 15.04 environment where LC_ALL=en_US.iso885915, and then
> 
> Oh, but that's the easy case.  The real test is when the environment
> uses utf-8 but the terminal's font fails to include the glyphs.

IOW, the terminal supports UTF-8, but the font it uses doesn't have
these characters covered?

Is that something that is likely to happen in real life?  I was under
the impression that the General Punctuation block was well covered in
UTF-8 locales in general, and in fonts used for the default text when
UTF-8 encoding is supported, in particular.  But if that's not the
case, we could provide a user option to forcibly use the display table
with ASCII glyphs for these characters, even if char-displayable-p
says they can be displayed.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Sat, 16 May 2015 21:21:04 GMT) Full text and rfc822 format available.

Message #56 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 20545 <at> debbugs.gnu.org
Subject: Re: bug#20545: New minor mode Electric Punct
Date: Sat, 16 May 2015 14:20:39 -0700
[Message part 1 (text/plain, inline)]
Paul Eggert wrote:
> A proposed patch is attached; it worked for me.

On further thought, the code affects global settings so it should be done only 
if FRAME is nil.  Also, it should treat double-quotes like single-quotes, and 
the ASCII approximations should use straight quotes.  This code is separable 
from Bug#20545, and is also separable from the issue of how to quote in doc 
strings, as the code is useful whenever text with English quotes appears on an 
obsolescent display lacking them.  So I installed the attached patch.
[0001-ASCIIfy-curved-quotes-on-displays-lacking-them.txt (text/plain, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Sun, 17 May 2015 14:34:02 GMT) Full text and rfc822 format available.

Message #59 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 20545 <at> debbugs.gnu.org
Subject: Re: bug#20545: New minor mode Electric Punct
Date: Sun, 17 May 2015 17:33:40 +0300
> Date: Sat, 16 May 2015 14:20:39 -0700
> From: Paul Eggert <eggert <at> cs.ucla.edu>
> CC: 20545 <at> debbugs.gnu.org
> 
> On further thought, the code affects global settings so it should be done only if FRAME is nil. Also, it should treat double-quotes like single-quotes, and the ASCII approximations should use straight quotes. This code is separable from Bug#20545, and is also separable from the issue of how to quote in doc strings, as the code is useful whenever text with English quotes appears on an obsolescent display lacking them. So I installed the attached patch. 

Yes, this global effect is not a Good Thing.  It means that a buffer
with these characters that is displayed on a TTY frame and on a GUI
frame will use the substitutes on both.

Btw, is set-locale-environment called when a new frame is created?  If
not, then this is not a proper place to install the display table, as
it won't DTRT when a new TTY frame is created in a running Emacs
session, and that frame displays on a terminal that doesn't support
these characters.

I think it would be better to install this as a window-specific
display table, using set-window-display-table, as part of setting up
the window showing the *Help* buffer.  WDYT?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Sun, 17 May 2015 17:00:07 GMT) Full text and rfc822 format available.

Message #62 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 20545 <at> debbugs.gnu.org
Subject: Re: bug#20545: New minor mode Electric Punct
Date: Sun, 17 May 2015 09:58:52 -0700
Eli Zaretskii wrote:

> is set-locale-environment called when a new frame is created?

Yes, but in that case FRAME is non-nil, so this new code isn't executed.  It's 
executed only during startup.

> I think it would be better to install this as a window-specific
> display table, using set-window-display-table, as part of setting up
> the window showing the*Help*  buffer.  WDYT?

Having it be window-specific, or better yet frame-specific, would be an 
improvement, but it shouldn't be limited to *Help* buffers, as other kinds of 
buffers can have curved quotes.

I'm not sure I'd worry about it.  First, the kind of user likely to be running 
multidisplay is not the kind of user likely to be starting up in an obsolescent 
8-bit locale.  Second, if someone really does both things, they'll probably run 
into other problems anyway.  Third, this particular problem, for the rare user 
who runs into it, will be just a minor glitch.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Sun, 17 May 2015 19:05:02 GMT) Full text and rfc822 format available.

Message #65 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 20545 <at> debbugs.gnu.org
Subject: Re: bug#20545: New minor mode Electric Punct
Date: Sun, 17 May 2015 22:04:30 +0300
> Date: Sun, 17 May 2015 09:58:52 -0700
> From: Paul Eggert <eggert <at> cs.ucla.edu>
> CC: 20545 <at> debbugs.gnu.org
> 
> I'm not sure I'd worry about it.  First, the kind of user likely to be running 
> multidisplay is not the kind of user likely to be starting up in an obsolescent 
> 8-bit locale.  Second, if someone really does both things, they'll probably run 
> into other problems anyway.  Third, this particular problem, for the rare user 
> who runs into it, will be just a minor glitch.

I guess we can always wait and see if we get complaints about this ;-)




Changed bug title to 'New minor mode Electric Quote' from 'New minor mode Electric Punct' Request was from Paul Eggert <eggert <at> cs.ucla.edu> to control <at> debbugs.gnu.org. (Tue, 26 May 2015 11:11:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Tue, 26 May 2015 11:25:02 GMT) Full text and rfc822 format available.

Message #70 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: 20545 <at> debbugs.gnu.org
Cc: Eli Zaretskii <eliz <at> gnu.org>, Stefan Monnier <monnier <at> iro.umontreal.ca>,
 Artur Malabarba <bruce.connor.am <at> gmail.com>
Subject: New minor mode Electric Quote
Date: Tue, 26 May 2015 04:24:12 -0700
[Message part 1 (text/plain, inline)]
Attached is a revised patch that should address the comments raised:

* The new minor mode is now disabled by default.

* The patch doesn't affect .dir-locals.el.

* The new minor mode is now (less ambitiously) called Electric Quote mode, not 
Electric Punct mode.

* Electric Quote mode combines well with Electric Pair mode's pairings of ` and 
', turning them into electric ‘ and ’.  I did not implement the electric quote 
pairing of “ and ”, as it would be trickier to add and anyway any such pairing 
is considerably lower priority for Elisp.

Plus another issue I found while testing:

* Electric quoting is now inactive in buffers whose coding systems can't 
represent curved quotes.
[0001-New-minor-mode-Electric-Quote.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Wed, 27 May 2015 14:26:02 GMT) Full text and rfc822 format available.

Message #73 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 20545 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca, bruce.connor.am <at> gmail.com
Subject: Re: New minor mode Electric Quote
Date: Wed, 27 May 2015 17:24:23 +0300
> Date: Tue, 26 May 2015 04:24:12 -0700
> From: Paul Eggert <eggert <at> cs.ucla.edu>
> CC: Eli Zaretskii <eliz <at> gnu.org>, 
>  Stefan Monnier <monnier <at> iro.umontreal.ca>,
>  Artur Malabarba <bruce.connor.am <at> gmail.com>
> 
> Attached is a revised patch that should address the comments raised:

Thanks.  Please allow me a comment about the documentation:

> --- a/doc/emacs/modes.texi
> +++ b/doc/emacs/modes.texi
> @@ -200,6 +200,15 @@ Auto Save mode saves the buffer contents periodically to reduce the
>  amount of work you can lose in case of a crash.  @xref{Auto Save}.
>  
>  @item
> +@cindex Electric Quote mode
> +@cindex mode, Electric Quote
> +@findex electric-quote-mode
> +Electric Quote mode automatically converts quotation marks.  For
> +example, it requotes text typed @t{`like this'} to text @t{‘like
> +this’}.  You can control what kind of text it operates in, and you can
> +disable it entirely in individual buffers.  @xref{Quotation Marks}.
> [...]
> --- a/doc/emacs/text.texi
> +++ b/doc/emacs/text.texi
> @@ -404,6 +405,43 @@ that separates pages (@pxref{Regexps}).  The normal value of this
>  variable is @code{"^\f"}, which matches a formfeed character at the
>  beginning of a line.
>  
> +@node Quotation Marks
> +@section Quotation Marks
> +@cindex Quotation marks
> +@cindex Electric Quote mode
> +@cindex mode, Electric Quote
> +  One common way to quote is the typewriter convention, which quotes

As you see, you have identical index entries in 2 different places.
That is generally not useful, because they get converted to something
like "foo" and "foo <1>", and the reader will have no way of knowing
which one does she want.

In this case, I would simply drop the first set of entries (and move
the "electric-quote-mode" one to the second set), to where the actual
description of this mode lives.  There's no need to index a place that
just mentions the mode in passing and sends the reader to the real
description.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Wed, 27 May 2015 15:28:02 GMT) Full text and rfc822 format available.

Message #76 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 20545 <at> debbugs.gnu.org
Subject: Re: New minor mode Electric Quote
Date: Wed, 27 May 2015 08:27:16 -0700
[Message part 1 (text/plain, inline)]
Thanks for the review.  I'll fold in the attached further patch before 
installing.  As you may be able to tell, I don't use the manual indexes and so 
my indexing can be a bit random.


[doc.txt (text/plain, attachment)]

bug closed, send any further explanations to 20545 <at> debbugs.gnu.org and Paul Eggert <eggert <at> cs.ucla.edu> Request was from Paul Eggert <eggert <at> cs.ucla.edu> to control <at> debbugs.gnu.org. (Sat, 30 May 2015 19:16:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Mon, 01 Jun 2015 03:07:02 GMT) Full text and rfc822 format available.

Message #81 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 20545 <at> debbugs.gnu.org
Subject: Re: bug#20545: Transliterating curved to straight quotes in 8-bit
 environments
Date: Sun, 31 May 2015 20:06:16 -0700
[Message part 1 (text/plain, inline)]
Eli Zaretskii wrote:
> I guess we can always wait and see if we get complaints about this ;-)

In trying out a few new things I did run into a problem in batch mode, because 
(print FOO) can generate improperly encoded output if FOO contains characters 
outside the system locale.  For example, if the file t.el uses UTF-8 encoding 
and contains this:

;; -*- coding: utf-8 -*-
(print "‘x’ “y” `z'")

and Emacs is in an 8-bit locale, the command 'emacs --batch -l t.el' will output 
the string "‘x’ “y” `z'" to stdout in a UTF-8 encoding, which is an encoding 
error for this environment.

Although this problem can occur with any non-ASCII character, diagnostics 
containing curved quotes will make it more likely.  I installed the attached 
patch to fix this, using the same technique for standard output that Emacs is 
already using for standard display.
[0001-Treat-batch-stdout-stderr-like-standard-display.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20545; Package emacs. (Mon, 01 Jun 2015 14:33:02 GMT) Full text and rfc822 format available.

Message #84 received at 20545 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 20545 <at> debbugs.gnu.org
Subject: Re: bug#20545: Transliterating curved to straight quotes in 8-bit
 environments
Date: Mon, 01 Jun 2015 17:31:42 +0300
> Date: Sun, 31 May 2015 20:06:16 -0700
> From: Paul Eggert <eggert <at> cs.ucla.edu>
> CC: 20545 <at> debbugs.gnu.org
> 
> In trying out a few new things I did run into a problem in batch mode, because 
> (print FOO) can generate improperly encoded output if FOO contains characters 
> outside the system locale.  For example, if the file t.el uses UTF-8 encoding 
> and contains this:
> 
> ;; -*- coding: utf-8 -*-
> (print "‘x’ “y” `z'")
> 
> and Emacs is in an 8-bit locale, the command 'emacs --batch -l t.el' will output 
> the string "‘x’ “y” `z'" to stdout in a UTF-8 encoding, which is an encoding 
> error for this environment.
> 
> Although this problem can occur with any non-ASCII character, diagnostics 
> containing curved quotes will make it more likely.  I installed the attached 
> patch to fix this, using the same technique for standard output that Emacs is 
> already using for standard display.

It sounds strange to use display tables for batch-mode output, but
maybe it's just a matter of getting used to.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 30 Jun 2015 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 274 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.