bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#2967: smart quotes in .emacs


From: npostavs
Subject: bug#2967: smart quotes in .emacs
Date: Tue, 06 Jun 2017 23:46:48 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux)

Glenn Morris <rgm@gnu.org> writes:

> I assume the OP means something like:
>
> (set 'foo t)
>
> where the quote character is actually U+2019 "RIGHT SINGLE QUOTATION MARK"
> rather than a plain old-ASCII apostrophe.
>
> This leads to errors like:
>
>   Symbol's value as variable is void: 'foo

Adding Alan to Cc, I think this is relevant also to the scenario in
Bug#23425.

I propose making these funny quotes give a read syntax error in symbol
name contexts.  Theoretically this breaks backwards compability with
code that uses variables containing them, but probably no such code
exists.

Something like this (not sure if this is the best way to test for them):

--- i/src/lread.c
+++ w/src/lread.c
@@ -3349,6 +3349,15 @@ read1 (Lisp_Object readcharfun, int *pch, bool 
first_in_list)
             ? multibyte_chars_in_text ((unsigned char *) read_buffer,
                                        nbytes)
             : nbytes);
+        if (!quoted && multibyte)
+          {
+            switch (STRING_CHAR ((unsigned char *) read_buffer))
+              {
+              case 0x2018:      /* LEFT SINGLE QUOTATION MARK */
+              case 0x2019:      /* RIGHT SINGLE QUOTATION MARK */
+                invalid_syntax ("strange quote");
+              }
+          }
        Lisp_Object name = ((uninterned_symbol && ! NILP (Vpurify_flag)
                             ? make_pure_string : make_specified_string)
                            (read_buffer, nchars, nbytes, multibyte));

We then get the following error from evaluating (read (format-message "'foo")):

Debugger entered--Lisp error: (invalid-read-syntax "strange quote")
  read("’foo")
  eval((read (format-message "'foo")) nil)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]