GNU bug report logs - #24759
25.1.50; electric-quote-mode

Previous Next

Package: emacs;

Reported by: Dani Moncayo <dmoncayo <at> gmail.com>

Date: Fri, 21 Oct 2016 19:39:02 UTC

Severity: minor

Found in version 25.1.50

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 24759 in the body.
You can then email your comments to 24759 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#24759; Package emacs. (Fri, 21 Oct 2016 19:39:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dani Moncayo <dmoncayo <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 21 Oct 2016 19:39:02 GMT) Full text and rfc822 format available.

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

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: bug-gnu-emacs <bug-gnu-emacs <at> gnu.org>
Subject: 25.1.50; electric-quote-mode
Date: Fri, 21 Oct 2016 21:38:43 +0200
Hello,

I may be missing something, but electric-quote-mode does not seem to
work here.

From `emacs -Q', if I create a new text-mode buffer

  C-x b foo
  M-x text-mode

then I enable electric quoting in that buffer

  M-x electric-quote-local-mode

and then I type [``foo''] or [`foo'], no quote conversion takes place.

Am I missing something?

TIA

In GNU Emacs 25.1.50.1 (i686-pc-mingw32)
 of 2016-10-19 built on LEG570
Repository revision: 8988327d548db7b69f30ea15496ccb0726fa4502
Windowing system distributor 'Microsoft Corp.', version 10.0.14393
Configured using:
 'configure --host=i686-pc-mingw32'

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB
TOOLKIT_SCROLL_BARS

Important settings:
  value of $LANG: ENU
  locale-coding-system: cp1252

Major mode: Text

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-quote-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t


Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message dired format-spec rfc822 mml
mml-sec password-cache epg epg-config gnus-util mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils misearch
multi-isearch cl-extra help-fns help-mode easymenu cl-loaddefs pcase
cl-lib time-date mule-util tooltip eldoc electric uniquify ediff-hook
vc-hooks lisp-float-type mwheel dos-w32 ls-lisp disp-table w32-win
w32-vars term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese charscript case-table epa-hook jka-cmpr-hook help
simple abbrev minibuffer cl-preloaded nadvice loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
w32notify w32 multi-tty make-network-process emacs)

Memory information:
((conses 8 91051 7113)
 (symbols 32 19702 0)
 (miscs 32 185 237)
 (strings 16 15931 4229)
 (string-bytes 1 430123)
 (vectors 8 12502)
 (vector-slots 4 438930 5422)
 (floats 8 165 224)
 (intervals 28 384 92)
 (buffers 516 21))

-- 
Dani Moncayo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24759; Package emacs. (Fri, 21 Oct 2016 20:00:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dani Moncayo <dmoncayo <at> gmail.com>, Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 24759 <at> debbugs.gnu.org
Subject: Re: bug#24759: 25.1.50; electric-quote-mode
Date: Fri, 21 Oct 2016 22:58:59 +0300
> From: Dani Moncayo <dmoncayo <at> gmail.com>
> Date: Fri, 21 Oct 2016 21:38:43 +0200
> 
> I may be missing something, but electric-quote-mode does not seem to
> work here.
> 
> >From `emacs -Q', if I create a new text-mode buffer
> 
>   C-x b foo
>   M-x text-mode
> 
> then I enable electric quoting in that buffer
> 
>   M-x electric-quote-local-mode
> 
> and then I type [``foo''] or [`foo'], no quote conversion takes place.

I guess your buffer-file-coding-system is neither 'undecided' nor
anything that can encode the curved quotes.  Try

  C-x RET f utf-8 RET

and then type the above again.

Paul, I think this condition:

  (defun electric--insertable-p (string)
    (or (not buffer-file-coding-system)
	(eq (coding-system-base buffer-file-coding-system) 'undecided)
	(not (unencodable-char-position nil nil buffer-file-coding-system
					nil string))))

should also accept a coding-system that is the default-value of
buffer-file-coding-system, because that's how buffers are created.
When the file is saved, Emacs will ask for a proper encoding, which is
not a catastrophe.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24759; Package emacs. (Fri, 21 Oct 2016 20:27:01 GMT) Full text and rfc822 format available.

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

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Paul Eggert <eggert <at> cs.ucla.edu>, 24759 <at> debbugs.gnu.org
Subject: Re: bug#24759: 25.1.50; electric-quote-mode
Date: Fri, 21 Oct 2016 22:26:13 +0200
> I guess your buffer-file-coding-system is neither 'undecided' nor
> anything that can encode the curved quotes.  Try
>
>   C-x RET f utf-8 RET
>
> and then type the above again.

Your guess is right.  After doing the above, the electric quote
conversion works.

> Paul, I think this condition:
>
>   (defun electric--insertable-p (string)
>     (or (not buffer-file-coding-system)
>         (eq (coding-system-base buffer-file-coding-system) 'undecided)
>         (not (unencodable-char-position nil nil buffer-file-coding-system
>                                         nil string))))
>
> should also accept a coding-system that is the default-value of
> buffer-file-coding-system, because that's how buffers are created.
> When the file is saved, Emacs will ask for a proper encoding, which is
> not a catastrophe.

I have no opinion on that but I think that, if this minor mode isn't
going to work with every possible buffer-file-coding-system, that
limitation should be explained somehow in the *Help* text of the minor
mode, to avoid confusing some users.

Thanks.

-- 
Dani Moncayo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24759; Package emacs. (Fri, 21 Oct 2016 21:02:01 GMT) Full text and rfc822 format available.

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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Dani Moncayo <dmoncayo <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 24759 <at> debbugs.gnu.org
Subject: Re: bug#24759: 25.1.50; electric-quote-mode
Date: Fri, 21 Oct 2016 14:01:26 -0700
[Message part 1 (text/plain, inline)]
On 10/21/2016 01:26 PM, Dani Moncayo wrote:
> hat
> limitation should be explained somehow in the*Help*  text of the minor
> mode,

Sure, that's easy enough. I installed the attached into emacs-25.

[0001-lisp-electric.el-electric-quote-mode-Improve-doc-Bug.patch (application/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24759; Package emacs. (Fri, 21 Oct 2016 21:06:01 GMT) Full text and rfc822 format available.

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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Eli Zaretskii <eliz <at> gnu.org>, Dani Moncayo <dmoncayo <at> gmail.com>
Cc: 24759 <at> debbugs.gnu.org
Subject: Re: bug#24759: 25.1.50; electric-quote-mode
Date: Fri, 21 Oct 2016 14:04:56 -0700
On 10/21/2016 12:58 PM, Eli Zaretskii wrote:
> I think this condition:
>
>    (defun electric--insertable-p (string)
>      (or (not buffer-file-coding-system)
> 	(eq (coding-system-base buffer-file-coding-system) 'undecided)
> 	(not (unencodable-char-position nil nil buffer-file-coding-system
> 					nil string))))
>
> should also accept a coding-system that is the default-value of
> buffer-file-coding-system, because that's how buffers are created.
> When the file is saved, Emacs will ask for a proper encoding, which is
> not a catastrophe.

Wouldn't this lead to problems? If I use electric quoting in a unibyte 
French locale, where I the default is an ISO 8859 encoding and 
buffer-file-coding-system is something like iso-latin-1-unix, when I 
later save the file Emacs will say "Select coding system (default 
chinese-iso-8bit): ". This is hardly user-friendly, even if we improve 
Emacs to guess UTF-8, as there may be a long interval between typing ` 
and saving the buffer.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24759; Package emacs. (Sat, 22 Oct 2016 06:50:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 24759 <at> debbugs.gnu.org, dmoncayo <at> gmail.com
Subject: Re: bug#24759: 25.1.50; electric-quote-mode
Date: Sat, 22 Oct 2016 09:49:00 +0300
> Cc: 24759 <at> debbugs.gnu.org
> From: Paul Eggert <eggert <at> cs.ucla.edu>
> Date: Fri, 21 Oct 2016 14:04:56 -0700
> 
> On 10/21/2016 12:58 PM, Eli Zaretskii wrote:
> > I think this condition:
> >
> >    (defun electric--insertable-p (string)
> >      (or (not buffer-file-coding-system)
> > 	(eq (coding-system-base buffer-file-coding-system) 'undecided)
> > 	(not (unencodable-char-position nil nil buffer-file-coding-system
> > 					nil string))))
> >
> > should also accept a coding-system that is the default-value of
> > buffer-file-coding-system, because that's how buffers are created.
> > When the file is saved, Emacs will ask for a proper encoding, which is
> > not a catastrophe.
> 
> Wouldn't this lead to problems? If I use electric quoting in a unibyte 
> French locale, where I the default is an ISO 8859 encoding and 
> buffer-file-coding-system is something like iso-latin-1-unix, when I 
> later save the file Emacs will say "Select coding system (default 
> chinese-iso-8bit): ". This is hardly user-friendly, even if we improve 
> Emacs to guess UTF-8, as there may be a long interval between typing ` 
> and saving the buffer.

This is standard Emacs behavior.  Emacs never makes any tests of the
current buffer-file-coding-system when you insert characters.  You
will see the same at save-buffer time if you insert the curved quotes
with, e.g., "C-x 8 [", where we insert the character no matter what is
the current buffer-file-coding-system.  Users who use
electric-quote-mode and don't have UTF-8 as their default encoding
will get accustomed to this prompt soon enough.

So I actually question the need for any test in electric--insertable-p.
What bad things, besides the prompt at save-buffer time, will happen
if we remove the test, and insert the characters unconditionally?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24759; Package emacs. (Sat, 22 Oct 2016 07:48:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: eggert <at> cs.ucla.edu
Cc: 24759 <at> debbugs.gnu.org
Subject: Re: bug#24759: 25.1.50; electric-quote-mode
Date: Sat, 22 Oct 2016 10:47:03 +0300
> Date: Sat, 22 Oct 2016 09:49:00 +0300
> From: Eli Zaretskii <eliz <at> gnu.org>
> Cc: 24759 <at> debbugs.gnu.org
> 
> So I actually question the need for any test in electric--insertable-p.
> What bad things, besides the prompt at save-buffer time, will happen
> if we remove the test, and insert the characters unconditionally?

And if electric-quote-mode wants to be more user-friendly, it could
ask, upon the first insertion of any electric quote character into a
buffer, whether the user would like to her buffer-file-coding-system
switched to UTF-8.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24759; Package emacs. (Sat, 22 Oct 2016 08:17:01 GMT) Full text and rfc822 format available.

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

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Paul Eggert <eggert <at> cs.ucla.edu>, 24759 <at> debbugs.gnu.org
Subject: Re: bug#24759: 25.1.50; electric-quote-mode
Date: Sat, 22 Oct 2016 10:16:35 +0200
>> So I actually question the need for any test in electric--insertable-p.
>> What bad things, besides the prompt at save-buffer time, will happen
>> if we remove the test, and insert the characters unconditionally?
>
> And if electric-quote-mode wants to be more user-friendly, it could
> ask, upon the first insertion of any electric quote character into a
> buffer, whether the user would like to her buffer-file-coding-system
> switched to UTF-8.

I'd like such a feature, but I'd rather make it general (not specific
to electric-quote-mode).  That is, whenever a buffer gets a character
(whether typed, yanked, electrically inserted, ...) which is not
representable in the current buffer-file-coding-system, Emacs could
offer the user to switch the coding system to UTF-8 (or another one
which can represent all the characters currently present in the
buffer), like happens when the buffer is about to be saved to a file.

-- 
Dani Moncayo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24759; Package emacs. (Sat, 22 Oct 2016 09:11:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dani Moncayo <dmoncayo <at> gmail.com>
Cc: eggert <at> cs.ucla.edu, 24759 <at> debbugs.gnu.org
Subject: Re: bug#24759: 25.1.50; electric-quote-mode
Date: Sat, 22 Oct 2016 12:10:33 +0300
> From: Dani Moncayo <dmoncayo <at> gmail.com>
> Date: Sat, 22 Oct 2016 10:16:35 +0200
> Cc: Paul Eggert <eggert <at> cs.ucla.edu>, 24759 <at> debbugs.gnu.org
> 
> > And if electric-quote-mode wants to be more user-friendly, it could
> > ask, upon the first insertion of any electric quote character into a
> > buffer, whether the user would like to her buffer-file-coding-system
> > switched to UTF-8.
> 
> I'd like such a feature, but I'd rather make it general (not specific
> to electric-quote-mode).  That is, whenever a buffer gets a character
> (whether typed, yanked, electrically inserted, ...) which is not
> representable in the current buffer-file-coding-system, Emacs could
> offer the user to switch the coding system to UTF-8 (or another one
> which can represent all the characters currently present in the
> buffer), like happens when the buffer is about to be saved to a file.

IMO, this would be too annoying and detrimental to performance in many
cases.  I think you underestimate how much 'insert' is used in Emacs,
without the user knowing anything about that.  In most such cases, the
buffer into which the character is entered will never be saved to any
file.

My proposal was specifically for the case where keyboard input caused
these characters be inserted after conversion by electric-quote-mode,
which hopefully restricts the applicable use cases to those where the
user is typing at the keyboard.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24759; Package emacs. (Sat, 22 Oct 2016 10:37:02 GMT) Full text and rfc822 format available.

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

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Paul Eggert <eggert <at> cs.ucla.edu>, 24759 <at> debbugs.gnu.org
Subject: Re: bug#24759: 25.1.50; electric-quote-mode
Date: Sat, 22 Oct 2016 12:36:38 +0200
>> > And if electric-quote-mode wants to be more user-friendly, it could
>> > ask, upon the first insertion of any electric quote character into a
>> > buffer, whether the user would like to her buffer-file-coding-system
>> > switched to UTF-8.
>>
>> I'd like such a feature, but I'd rather make it general (not specific
>> to electric-quote-mode).  That is, whenever a buffer gets a character
>> (whether typed, yanked, electrically inserted, ...) which is not
>> representable in the current buffer-file-coding-system, Emacs could
>> offer the user to switch the coding system to UTF-8 (or another one
>> which can represent all the characters currently present in the
>> buffer), like happens when the buffer is about to be saved to a file.
>
> IMO, this would be too annoying and detrimental to performance in many
> cases.  I think you underestimate how much 'insert' is used in Emacs,
> without the user knowing anything about that.  In most such cases, the
> buffer into which the character is entered will never be saved to any
> file.
>
> My proposal was specifically for the case where keyboard input caused
> these characters be inserted after conversion by electric-quote-mode,
> which hopefully restricts the applicable use cases to those where the
> user is typing at the keyboard.

OK.  In that case I withdraw my general approach.

> Date: Sat, 22 Oct 2016 09:49:00 +0300
> From: Eli Zaretskii <eliz <at> gnu.org>
> Cc: 24759 <at> debbugs.gnu.org
>
> So I actually question the need for any test in electric--insertable-p.
> What bad things, besides the prompt at save-buffer time, will happen
> if we remove the test, and insert the characters unconditionally?

FWIW: I'd also prefer to remove that check from electric-quote-mode,
so that the quote conversion would always happen (if the minor mode is
enabled in the current buffer), regardless of
buffer-file-coding-system.

Thanks.

-- 
Dani Moncayo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24759; Package emacs. (Sat, 22 Oct 2016 18:49:01 GMT) Full text and rfc822 format available.

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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 24759 <at> debbugs.gnu.org, dmoncayo <at> gmail.com
Subject: Re: bug#24759: 25.1.50; electric-quote-mode
Date: Sat, 22 Oct 2016 11:47:58 -0700
Eli Zaretskii wrote:
>> when I
>> > later save the file Emacs will say "Select coding system (default
>> > chinese-iso-8bit): ". This is hardly user-friendly, even if we improve
>> > Emacs to guess UTF-8, as there may be a long interval between typing `
>> > and saving the buffer.
> This is standard Emacs behavior.

If it is, then the standard behavior is wrong. For starters, Emacs should not 
default to chinese-iso-8bit in a unibyte French-language environment merely 
because the buffer has a curved quote. That can't be what a typical French user 
wants.

The problem can be reproduced without electric-quote mode, as follows:

LC_ALL=fr_FR.iso88591 emacs -Q newfile
C-x 8 [ RET
C-x C-s


More generally, if I type any character that won't be saved, I should be 
notified when I type it, not ages later when I save the buffer. This should be 
done independently of whether electric-quote mode is in use.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24759; Package emacs. (Sat, 22 Oct 2016 19:05:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 24759 <at> debbugs.gnu.org, dmoncayo <at> gmail.com
Subject: Re: bug#24759: 25.1.50; electric-quote-mode
Date: Sat, 22 Oct 2016 22:04:28 +0300
> Cc: dmoncayo <at> gmail.com, 24759 <at> debbugs.gnu.org
> From: Paul Eggert <eggert <at> cs.ucla.edu>
> Date: Sat, 22 Oct 2016 11:47:58 -0700
> 
> Eli Zaretskii wrote:
> >> when I
> >> > later save the file Emacs will say "Select coding system (default
> >> > chinese-iso-8bit): ". This is hardly user-friendly, even if we improve
> >> > Emacs to guess UTF-8, as there may be a long interval between typing `
> >> > and saving the buffer.
> > This is standard Emacs behavior.
> 
> If it is, then the standard behavior is wrong.

It was like that since Emacs 20.1.  I don't see what changed now that
it's suddenly a problem.  I guess you are simply unused to see these
prompts due to your locale, that's all.

> For starters, Emacs should not default to chinese-iso-8bit in a
> unibyte French-language environment merely because the buffer has a
> curved quote.

Emacs collects all the encodings that can handle all of the
characters, then sorts them; chinese-iso-8bit is just the one that
comes up first in the sorted order.  If you are hinting that UTF-8
should come up first, we should just change the sorting order, that's
all.

> That can't be what a typical French user wants.

We have no idea what the user might want.  We can guess at best, and
offer the list of the alternatives from which to choose.  Which is
what we do.

> More generally, if I type any character that won't be saved, I should be 
> notified when I type it, not ages later when I save the buffer.

I disagree.  Most buffers will never be saved.  And even if they will
be, the user could delete the character by the time she saves it.

I don't see how we can do better here than we already do, except by
making the first alternative more suitable for today's world.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24759; Package emacs. (Sat, 22 Oct 2016 19:21:02 GMT) Full text and rfc822 format available.

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

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 24759 <at> debbugs.gnu.org
Subject: Re: bug#24759: 25.1.50; electric-quote-mode
Date: Sat, 22 Oct 2016 21:20:31 +0200
On Okt 22 2016, Paul Eggert <eggert <at> cs.ucla.edu> wrote:

> If it is, then the standard behavior is wrong. For starters, Emacs should
> not default to chinese-iso-8bit in a unibyte French-language environment
> merely because the buffer has a curved quote. That can't be what a typical
> French user wants.

A typical French user will use a utf-8 locale.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24759; Package emacs. (Sat, 22 Oct 2016 19:36:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: eggert <at> cs.ucla.edu
Cc: 24759 <at> debbugs.gnu.org
Subject: Re: bug#24759: 25.1.50; electric-quote-mode
Date: Sat, 22 Oct 2016 22:34:50 +0300
> Date: Sat, 22 Oct 2016 22:04:28 +0300
> From: Eli Zaretskii <eliz <at> gnu.org>
> Cc: 24759 <at> debbugs.gnu.org
> 
> > For starters, Emacs should not default to chinese-iso-8bit in a
> > unibyte French-language environment merely because the buffer has a
> > curved quote.
> 
> Emacs collects all the encodings that can handle all of the
> characters, then sorts them; chinese-iso-8bit is just the one that
> comes up first in the sorted order.  If you are hinting that UTF-8
> should come up first, we should just change the sorting order, that's
> all.
> 
> > That can't be what a typical French user wants.
> 
> We have no idea what the user might want.  We can guess at best, and
> offer the list of the alternatives from which to choose.  Which is
> what we do.

Please also note that by the time this prompt is displayed, Emacs has
already tried to see whether several default encodings corresponding
to the user locale and preferences can encode the text, and the answer
was NO (this information is included in the buffer popped up to the
user).  If one of the default encodings could encode the text, Emacs
would have used it without asking any questions.

Once we have tried all those defaults, and found they cannot do the
job, we've exhausted our potential of guessing "what the user wants"
reliably, so we must now ask the user to tell us that.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24759; Package emacs. (Sun, 23 Oct 2016 03:56:02 GMT) Full text and rfc822 format available.

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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 24759 <at> debbugs.gnu.org
Subject: Re: bug#24759: 25.1.50; electric-quote-mode
Date: Sat, 22 Oct 2016 20:55:25 -0700
Andreas Schwab wrote:
> A typical French user will use a utf-8 locale.

Yes, and to some extent this subthread is a tempest in a teapot, since typical 
French users now either use a UTF-8 locale, or perhaps the C locale, and Emacs 
works fine in both these cases. That is, when I run this:

LC_ALL=C emacs -Q newfile
C-x 8 [ RET
C-x C-s

on Fedora 24, Emacs saves the file using UTF-8 without prompting the user for an 
encoding - basically, it is bypassing the locale settings for this file, which 
is a reasonable thing to do.

As I understand it, this subthread is about what Emacs should do in a unibyte 
locale that isn't the C locale. It's not clear to me why these locales (which 
are no longer that important) should be treated differently from a unibyte C 
locale for this sort of situation.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24759; Package emacs. (Sun, 23 Oct 2016 04:11:02 GMT) Full text and rfc822 format available.

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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 24759 <at> debbugs.gnu.org
Subject: Re: bug#24759: 25.1.50; electric-quote-mode
Date: Sat, 22 Oct 2016 21:10:08 -0700
Eli Zaretskii wrote:
> Once we have tried all those defaults, and found they cannot do the
> job, we've exhausted our potential of guessing "what the user wants"
> reliably, so we must now ask the user to tell us that.

It is odd that Emacs uses UTF-8 without questions in the C locale, but prompts 
and suggest a Chinese encoding in a unibyte French locale.

> It was like that since Emacs 20.1.  I don't see what changed now that
> it's suddenly a problem.

Emacs is now more likely to have non-unibyte text, partly due to its fancier 
quoting and partly because Unicode is more ubiquitous than it was in 1997 when 
Emacs 20.1 was released. So the problem is more likely to occur now.

> If you are hinting that UTF-8 should come up first

UTF-8 should be the most-preferred multibyte encoding nowadays, unless there is 
a reasonable indication that the user prefers something else. In a unibyte 
European locale, UTF-8 should be the first-listed multibyte encoding by default.

> Most buffers will never be saved.

For buffers that don't correspond to files, we needn't bother with any of this 
checking. But for buffers that correspond to files with restrictive encodings, 
it would be helpful to warn users earlier rather than later about this sort of 
problem.

It's a bit like spelling checking. Many users prefer checking spelling on the 
fly, rather than checking only when you save the file.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24759; Package emacs. (Sun, 23 Oct 2016 07:01:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 24759 <at> debbugs.gnu.org, schwab <at> linux-m68k.org
Subject: Re: bug#24759: 25.1.50; electric-quote-mode
Date: Sun, 23 Oct 2016 10:00:28 +0300
> Cc: Eli Zaretskii <eliz <at> gnu.org>, 24759 <at> debbugs.gnu.org
> From: Paul Eggert <eggert <at> cs.ucla.edu>
> Date: Sat, 22 Oct 2016 20:55:25 -0700
> 
> As I understand it, this subthread is about what Emacs should do in a unibyte 
> locale that isn't the C locale. It's not clear to me why these locales (which 
> are no longer that important) should be treated differently from a unibyte C 
> locale for this sort of situation.

Because a C locale basically means you have no non-trivial default
encoding.  IOW, your default is 'undecided'.  In such cases, we prefer
UTF-8 automatically if it can do the job (and it usually can), since
the user doesn't have any specific preferences.

So I think we should indeed remove the electric--insertable-p test in
electric-quote-mode, on the emacs-25 branch.

A related change (which IMO should be done on master) is to make UTF-8
be the first encoding in the sorted list of encodings Emacs offers
when the defaults cannot cope with some characters in a buffer about
to be saved or sent to a subprocess.  But this related change is not a
prerequisite for removing the electric--insertable-p test, as it is a
general improvement in the Emacs guesswork, not something specific to
the issue at hand in this bug report.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24759; Package emacs. (Sun, 23 Oct 2016 07:14:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 24759 <at> debbugs.gnu.org
Subject: Re: bug#24759: 25.1.50; electric-quote-mode
Date: Sun, 23 Oct 2016 10:13:20 +0300
> Cc: 24759 <at> debbugs.gnu.org
> From: Paul Eggert <eggert <at> cs.ucla.edu>
> Date: Sat, 22 Oct 2016 21:10:08 -0700
> 
> Eli Zaretskii wrote:
> > Once we have tried all those defaults, and found they cannot do the
> > job, we've exhausted our potential of guessing "what the user wants"
> > reliably, so we must now ask the user to tell us that.
> 
> It is odd that Emacs uses UTF-8 without questions in the C locale, but prompts 
> and suggest a Chinese encoding in a unibyte French locale.

I tried to explain the logic behind this in another message.

> > It was like that since Emacs 20.1.  I don't see what changed now that
> > it's suddenly a problem.
> 
> Emacs is now more likely to have non-unibyte text, partly due to its fancier 
> quoting and partly because Unicode is more ubiquitous than it was in 1997 when 
> Emacs 20.1 was released. So the problem is more likely to occur now.

I'm not sure you are right (the original Emacs 20.x m17n was heavily
biased towards ISO-2022 encodings, which are multibyte), but I don't
think it matters.

> > If you are hinting that UTF-8 should come up first
> 
> UTF-8 should be the most-preferred multibyte encoding nowadays, unless there is 
> a reasonable indication that the user prefers something else.

What kind of indication do you have in mind?

> In a unibyte European locale, UTF-8 should be the first-listed
> multibyte encoding by default.

Why not list it the first always?  That sounds simpler to me, because
it doesn't require any guesswork about the user preferences beyond
what we do already.  The encoding we offer as the first alternative
now has nothing to do with user preferences, so why would we introduce
such preferences?

> > Most buffers will never be saved.
> 
> For buffers that don't correspond to files, we needn't bother with any of this 
> checking. But for buffers that correspond to files with restrictive encodings, 
> it would be helpful to warn users earlier rather than later about this sort of 
> problem.

First, buffers that correspond to files are not the only case where
this encoding prompt can pop up.  Text sent to a subprocess or to the
network (like this email message I'm typing) is another.

And second, I think you underestimate the annoyance that would result
from such prompting.  If the single prompt we now issue already annoys
you, it hardly makes sense to do the same multiple times.  It is
better to try to minimize the prompts by silently doing TRT whenever
we can.

> It's a bit like spelling checking.

It's not.  A mis-spelled buffer can be saved, but we cannot save a
buffer without knowing how to encode it.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24759; Package emacs. (Sun, 23 Oct 2016 08:16:01 GMT) Full text and rfc822 format available.

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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 24759 <at> debbugs.gnu.org, schwab <at> linux-m68k.org
Subject: Re: bug#24759: 25.1.50; electric-quote-mode
Date: Sun, 23 Oct 2016 01:15:47 -0700
[Message part 1 (text/plain, inline)]
Eli Zaretskii wrote:
> So I think we should indeed remove the electric--insertable-p test in
> electric-quote-mode, on the emacs-25 branch.

OK, done with the attached.
[0001-electric-quote-mode-no-longer-worries-about-coding.patch (text/x-diff, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24759; Package emacs. (Sun, 23 Oct 2016 08:25:02 GMT) Full text and rfc822 format available.

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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 24759 <at> debbugs.gnu.org
Subject: Re: bug#24759: 25.1.50; electric-quote-mode
Date: Sun, 23 Oct 2016 01:24:15 -0700
Eli Zaretskii wrote:

>> UTF-8 should be the most-preferred multibyte encoding nowadays, unless there is
>> a reasonable indication that the user prefers something else.
>
> What kind of indication do you have in mind?

A locale that uses some non-UTF-8 multibyte encoding.

>> In a unibyte European locale, UTF-8 should be the first-listed
>> multibyte encoding by default.
>
> Why not list it the first always?

I wouldn't object. People who prefer non-UTF-8 multibyte locales might not like 
it (I'm not such a person so I can't say).

> If the single prompt we now issue already annoys
> you, it hardly makes sense to do the same multiple times.

It's not merely the prompt that annoys me. It's that the prompt can occur long 
after the problem it diagnoses.

We could suppress the prompt in later occurrences if the user doesn't want to 
see it again.

>> It's a bit like spelling checking.
>
> It's not.  A mis-spelled buffer can be saved, but we cannot save a
> buffer without knowing how to encode it.

A bit like, not exactly like. The point is that users often find it more 
convenient to see problems right away. For example, although an 
improperly-parenthesized Lisp buffer can be saved, it's still nice to have 
parenthesis-matching enabled as I type, so that I can see and fix parenthesis 
problems while they're still fresh in my mind.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24759; Package emacs. (Sun, 23 Oct 2016 08:53:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 24759 <at> debbugs.gnu.org
Subject: Re: bug#24759: 25.1.50; electric-quote-mode
Date: Sun, 23 Oct 2016 11:51:50 +0300
> Cc: 24759 <at> debbugs.gnu.org
> From: Paul Eggert <eggert <at> cs.ucla.edu>
> Date: Sun, 23 Oct 2016 01:24:15 -0700
> 
> > What kind of indication do you have in mind?
> 
> A locale that uses some non-UTF-8 multibyte encoding.

It isn't clear that this will help.  If that locale's encoding can
encode the offending characters, Emacs will already use it silently
without any prompts.  Beyond that, inferring a preference for some
non-UTF-8 encoding from the fact that the locale's encoding is
multibyte and not UTF-8 sounds far-fetched to me.

> >> In a unibyte European locale, UTF-8 should be the first-listed
> >> multibyte encoding by default.
> >
> > Why not list it the first always?
> 
> I wouldn't object. People who prefer non-UTF-8 multibyte locales might not like 
> it (I'm not such a person so I can't say).

I don't think we should do this as the first approximation; we should
just make sure UTF-8 is the first in the list.  If later users will
complain about this, we could introduce a defcustom for such a "second
best" encoding, perhaps with a suitably guessed default value.  But I
wouldn't go there without specific requests and use cases.

> > If the single prompt we now issue already annoys
> > you, it hardly makes sense to do the same multiple times.
> 
> It's not merely the prompt that annoys me. It's that the prompt can occur long 
> after the problem it diagnoses.

But the buffer we pop up clearly shows the problematic characters, and
also describes which of them couldn't be encoded with what
coding-systems that were tried.  So I think this provides enough
information for the user to decide what to do, and the fact that the
insertion happened much earlier doesn't matter, because the
information is not lost.  In particular, one of the valid reactions to
the prompt is to type C-g, then go to the buffer and delete/replace
the offending characters, and then try saving again.

> We could suppress the prompt in later occurrences if the user doesn't want to 
> see it again.

We could, but it's not a yes/no kind of answer, because the user might
not want to see another prompt for characters that require an encoding
she already saw, but might still want prompts for characters that
require other encodings.

For example, if I insert a Latin-1 character, I will be prompted and
decode I don't want to see prompts about any other characters that are
encodable with ISO-8859-1.  But if I later insert a character that
cannot be encoded with ISO-8859-1, I might still want to see the
prompt.

So I think this is a lot of hassle for something that works well in
practice for the past several years.  Changing it will most probably
open a can of worms (the current situation took several iterations to
get right).  So I'd rather we invest our efforts in silently doing TRT
in more use cases.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24759; Package emacs. (Sun, 23 Oct 2016 08:56:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Paul Eggert <eggert <at> cs.ucla.edu>, Dani Moncayo <dmoncayo <at> gmail.com>
Cc: 24759 <at> debbugs.gnu.org
Subject: Re: bug#24759: 25.1.50; electric-quote-mode
Date: Sun, 23 Oct 2016 11:55:20 +0300
> Cc: schwab <at> linux-m68k.org, 24759 <at> debbugs.gnu.org
> From: Paul Eggert <eggert <at> cs.ucla.edu>
> Date: Sun, 23 Oct 2016 01:15:47 -0700
> 
> Eli Zaretskii wrote:
> > So I think we should indeed remove the electric--insertable-p test in
> > electric-quote-mode, on the emacs-25 branch.
> 
> OK, done with the attached.

Thanks, I think this bug can be closed now.  Dani, any objections?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24759; Package emacs. (Sun, 23 Oct 2016 09:16:02 GMT) Full text and rfc822 format available.

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

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Paul Eggert <eggert <at> cs.ucla.edu>, 24759 <at> debbugs.gnu.org
Subject: Re: bug#24759: 25.1.50; electric-quote-mode
Date: Sun, 23 Oct 2016 11:15:36 +0200
On Sun, Oct 23, 2016 at 10:55 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>> Cc: schwab <at> linux-m68k.org, 24759 <at> debbugs.gnu.org
>> From: Paul Eggert <eggert <at> cs.ucla.edu>
>> Date: Sun, 23 Oct 2016 01:15:47 -0700
>>
>> Eli Zaretskii wrote:
>> > So I think we should indeed remove the electric--insertable-p test in
>> > electric-quote-mode, on the emacs-25 branch.
>>
>> OK, done with the attached.
>
> Thanks, I think this bug can be closed now.  Dani, any objections?

No, none.  Thanks to both of you.

-- 
Dani Moncayo




Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Sun, 23 Oct 2016 09:30:03 GMT) Full text and rfc822 format available.

Notification sent to Dani Moncayo <dmoncayo <at> gmail.com>:
bug acknowledged by developer. (Sun, 23 Oct 2016 09:30:03 GMT) Full text and rfc822 format available.

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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Dani Moncayo <dmoncayo <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 24759-done <at> debbugs.gnu.org
Subject: Re: bug#24759: 25.1.50; electric-quote-mode
Date: Sun, 23 Oct 2016 02:28:58 -0700
Dani Moncayo wrote:
> On Sun, Oct 23, 2016 at 10:55 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:

>> Thanks, I think this bug can be closed now.  Dani, any objections?
>
> No, none.  Thanks to both of you.
>

You're welcome. Closing the bug.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 20 Nov 2016 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 151 days ago.

Previous Next


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