Subject: Re: bug#21588: 25.0.50: Single quotes becoming curvy quotes in message function

From: Kaushal Modi <[email-masked]>
Date: Wed, 30 Sep 2015 23:54:02 -0400

> This shouldn't happen if your ~/.emacs has (setq text-quoting-style
'grave) or (setq text-quoting-style 'straight), so I assume the issue came
up because your text-quoting-style is ‘curve’ or defaults to ‘curve’.

Correct,
​
`text-quoting-style` was default (nil) and with that, (message "'Hey'") got
displayed as
​
​​
’Hey’.
Now I need to set
​
`text-quoting-style` to 'grave so that apostrophes stay apostrophes and
grave quotes remain grave quotes; no surprising quote conversions. I would
vote for this to be the default.

> I missed some instances and so some minor display glitches remain, but
they can be fixed as they turn up.

Thanks, I am having difficulty grepping for an expression that has both
single and double quotes. But as I find such cases, I will report them or
submit a patch.

> To get typewriter-style straight quoting in your own code, independent of
text-quoting-style, you can write (message "%s" "'Hey'").

That is good to know, thank you!

Summary:
- Can the default be changed to 'grave?
- For the message forms that I or anyone else writes in future, is it
correct if I says that you must always use `Hey' format instead of 'Hey'
format? If so, we need to update the documentation that warns the user to
use the correct style.

​Discussion:
​

As per "C-h i g (emacs) Quotation Marks" (excerpt below), we have
contradicting information.

One common way to quote is the typewriter convention, which quotes using
straight apostrophes 'like this' or double-quotes "like this".  Another
common way is the curved quote convention, which uses left and right
single or double quotation marks ‘like this’ or “like this”.  Typewriter
quotes are simple and portable; curved quotes are less ambiguous and
typically look nicer.

On one hand, the default text-quoting-style value of nil will render
(message 'like this') as
​​
’like this’.
On the other hand, it is mentioned that typewriter quotes are simple and
portable.

I agree
​that the typewriter
 quotes
​(straight quotes or apostrophes as I have been referring in my emails) ​
being simple and portable; the user does not need to think of whether to
enter ` or '. But then the default value of text-quoting-style as 'grave
makes more sense.
​ We would not want unwarned people using (message "'Hey'") in default
emacs sessions be faced with ​the
​
’Hey’
​ with unbalanced quotes.​

If we want to keep the default of text-quoting-style as nil (or 'curve),
more logic needs to be added that decides whether left curly quote or right
curly quote should be used, which might have some performance impact as we
then need to check what the previous character is, what the next character
is, etc to decide if the current apostrophe needs to be replaced with a
left or a right quote.

Here
​are
 few common cases that I can think of
:
​
​CASE 1: 'Hey' ->
​
​
‘Hey’
CASE 2: it's awesome -> ​
​it
’
​s awesome
CASE 3: my sisters' weddings -> ​
sisters
’
​ weddings
​CASE 4: He said 'It's awesome!' ->
He said ‘It’s awesome!’    (It should have rather been -- He said "It's
awesome!" (use of double quotes). But I am just putting here all the
apostrophe cases I can think of..)

Based on above cases,

​The apostrophe is replaced with left quote if,

(AND there's a non-space character after the apostrophe
        (OR the apostrophe is first character in the line
               there's white space before the apostrophe)) ​

The apostrophe is replaced with right quote if​,​​

​​
there's a non-space character
​before
 the apostrophe

OR, probably..

If ​
there's a non-space character
​before
 the apostrophe, replace it with right quote, else use left quote.

​I am by no means a literature or typography expert. So I am sure that the
above 4 cases are not enough to define the rules for left/right quotes. I
just wanted to emphasize that we need more intelligence in deciding which
quote to use if we want to keep the 'curly or nil as the default value of
text-quoting-style.​

--
Kaushal Modi