unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@users.sourceforge.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: "Michael Heerdegen" <michael_heerdegen@web.de>,
	"Clément Pit-Claudel" <cpitclaudel@gmail.com>,
	"Alan Third" <alan@idiocy.org>,
	"Drew Adams" <drew.adams@oracle.com>,
	"Emacs developers" <emacs-devel@gnu.org>
Subject: Re: Change of Lisp syntax for "fancy" quotes in Emacs 27?
Date: Sun, 4 Feb 2018 16:31:11 -0500	[thread overview]
Message-ID: <CAM-tV--tK8+qLpfWWMfV1-2Ha6VorLCRaMBbGBKumJ_ozN43-g@mail.gmail.com> (raw)
In-Reply-To: <837ersac6f.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 804 bytes --]

On Sun, Feb 4, 2018 at 12:37 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
>> Date: Sun, 4 Feb 2018 10:36:49 -0500
>>
>> > The middle line would require Emacs to do a fuzzy search for similar
>> > symbols, which may be too much.
>>
>> OCaml does this (but at compile time).  Do we have a way to delay the fuzzy search to the point when the error message is displayed?  Otherwise we'll pay the price of the search even if the error is then swallowed by a condition-case.
>
> Isn't this premature optimization?

I think the check fits nicely into command-error-default-function
though. Attaching a quick proof-of-concept (handles only a single
curved quote at the beginning of symbol name). We would want something
also for the byte-compiler.

[-- Attachment #2: v1-0001-sketch-Catch-strange-quotes-on-error-time.patch --]
[-- Type: text/x-diff, Size: 3166 bytes --]

From c9d1e761cea56e94d9ad3d783c8ed7fcf448b082 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Sun, 4 Feb 2018 16:20:32 -0500
Subject: [PATCH v1] [sketch] Catch strange quotes on error time

* src/keyboard.c (Fcommand_error_default_function): Check for RIGHT
SINGLE QUOTATION MARK and give a more detailed message.  TODO: check
for other confusables.
* src/lread.c (read1): Don't signal error on strange quotes.
* src/eval.c (Fsetq): Pass full arglist in error data.  TODO: the same
for all the other Qwrong_number_of_arguments cases.
---
 src/eval.c     |  3 ++-
 src/keyboard.c | 20 ++++++++++++++++++++
 src/lread.c    |  7 -------
 3 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/src/eval.c b/src/eval.c
index 7db4dbcf18..db61c0421f 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -507,7 +507,8 @@ DEFUN ("setq", Fsetq, Ssetq, 0, UNEVALLED, 0,
       Lisp_Object sym = XCAR (tail), lex_binding;
       tail = XCDR (tail);
       if (!CONSP (tail))
-	xsignal2 (Qwrong_number_of_arguments, Qsetq, make_number (nargs + 1));
+        xsignal3 (Qwrong_number_of_arguments, Qsetq,
+                  make_number (nargs + 1), args);
       Lisp_Object arg = XCAR (tail);
       tail = XCDR (tail);
       val = eval_sub (arg);
diff --git a/src/keyboard.c b/src/keyboard.c
index 4324991da4..24c5f66934 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1047,6 +1047,26 @@ DEFUN ("command-error-default-function", Fcommand_error_default_function,
       bitch_at_user ();
 
       print_error_message (data, Qt, SSDATA (context), signal);
+
+      Lisp_Object errname = Fcar (data);
+      /* TODO: Add arglist to Qwrong_number_of_arguments errors, and
+         check those too.  */
+      if (EQ (errname, Qvoid_variable))
+        {
+          Lisp_Object void_symname = Fsymbol_name (Fnth (make_number (1), data));
+          if (SCHARS (void_symname) > 0 &&
+              /* TODO: check all confusables.  */
+              EQ (Faref (void_symname, make_number (0)), make_number (0x2019)))
+            {
+              Lisp_Object msg = CALLN
+                (Fformat_message,
+                 build_string ("\nSymbol has with `%c' (%s) at character 0,"
+                               " did you mean `%c' (%s)"),
+                 make_number (0x2019), build_string ("RIGHT SINGLE QUOTATION MARK"),
+                 make_number ('\''), build_string ("APOSTROPHE"));
+              Fprinc (msg, Qt);
+            }
+        }
     }
   return Qnil;
 }
diff --git a/src/lread.c b/src/lread.c
index 3b0a17c90b..ee08902f81 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3470,13 +3470,6 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
 	    if (! NILP (result))
 	      return unbind_to (count, result);
 	  }
-        if (!quoted && multibyte)
-          {
-            int ch = STRING_CHAR ((unsigned char *) read_buffer);
-            if (confusable_symbol_character_p (ch))
-              xsignal2 (Qinvalid_read_syntax, build_string ("strange quote"),
-                        CALLN (Fstring, make_number (ch)));
-          }
 	{
 	  Lisp_Object result;
 	  ptrdiff_t nbytes = p - read_buffer;
-- 
2.11.0


  reply	other threads:[~2018-02-04 21:31 UTC|newest]

Thread overview: 98+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-02 22:24 Change of Lisp syntax for "fancy" quotes in Emacs 27? Noam Postavsky
2018-02-02 22:52 ` Paul Eggert
2018-02-03  0:00   ` Drew Adams
2018-02-03  0:09     ` Paul Eggert
2018-02-03  0:39       ` Drew Adams
2018-02-03  8:33 ` Eli Zaretskii
2018-02-03 16:16   ` Drew Adams
2018-02-03 17:05     ` Eli Zaretskii
2018-02-04  1:16       ` Michael Heerdegen
2018-02-04  1:25         ` Clément Pit-Claudel
2018-02-04  2:05           ` Drew Adams
2018-02-04  2:06           ` Michael Heerdegen
2018-02-04 10:34           ` Alan Third
2018-02-04 15:36             ` Clément Pit-Claudel
2018-02-04 17:37               ` Eli Zaretskii
2018-02-04 21:31                 ` Noam Postavsky [this message]
2018-02-04 11:15         ` Alan Mackenzie
2018-02-04 15:54           ` Drew Adams
2018-02-04 14:47         ` Noam Postavsky
2018-02-04  1:55       ` Drew Adams
2018-02-04  2:10         ` Noam Postavsky
2018-02-05  1:06       ` Why "symbol's value" error about a list? Richard Stallman
2018-02-05 20:35         ` Alan Mackenzie
2018-02-05 21:46           ` Drew Adams
2018-02-06  4:13             ` Eli Zaretskii
2018-02-06  7:32               ` Tim Cross
2018-02-06  7:40                 ` Eli Zaretskii
2018-02-06 15:45                 ` Drew Adams
2018-02-06 15:45               ` Drew Adams
2018-02-06 19:17                 ` Eli Zaretskii
2018-02-06 14:51           ` Richard Stallman
2018-02-06 11:27         ` Noam Postavsky
2018-02-06 14:53           ` Richard Stallman
2018-02-06 18:59             ` Eli Zaretskii
2018-02-07  2:40               ` Richard Stallman
2018-02-07  3:42                 ` Eli Zaretskii
2018-02-06 18:52           ` Eli Zaretskii
2018-02-05  1:06       ` Change of Lisp syntax for "fancy" quotes in Emacs 27? Richard Stallman
2018-02-03 18:13 ` Aaron Ecay
2018-02-04  2:05   ` Drew Adams
2018-02-04  4:51   ` Paul Eggert
2018-02-04  9:47     ` Andreas Schwab
2018-02-04 15:04     ` Noam Postavsky
2018-02-04 17:33       ` Eli Zaretskii
2018-02-04 19:36         ` Paul Eggert
2018-02-04 19:55           ` Philipp Stephani
2018-02-04 20:10           ` Eli Zaretskii
2018-02-04 20:36             ` Eli Zaretskii
2018-02-04 20:48               ` Paul Eggert
2018-02-04 20:59                 ` Clément Pit-Claudel
2018-10-05  0:03 ` Noam Postavsky
2018-10-05  1:01   ` Paul Eggert
2018-10-05  8:43     ` Eli Zaretskii
2018-10-05 23:02       ` Paul Eggert
2018-10-06  0:20         ` Drew Adams
2018-10-06  9:14           ` Alan Mackenzie
2018-10-06 14:34             ` Stefan Monnier
2018-10-06 14:57             ` Drew Adams
2018-10-06 15:42               ` Garreau, Alexandre
2018-10-06 16:10             ` Paul Eggert
2018-10-06 16:17           ` Paul Eggert
2018-10-07  1:13             ` Drew Adams
2018-10-08  3:51             ` Richard Stallman
2018-10-06 10:11         ` Eli Zaretskii
2018-10-06 15:51           ` Paul Eggert
2018-10-06 16:45             ` Eli Zaretskii
2018-10-06 18:03               ` Paul Eggert
2018-10-06 18:29                 ` Eli Zaretskii
2018-10-06 19:18                   ` Paul Eggert
2018-10-06 19:30                   ` Paul Eggert
2018-10-06 19:32                   ` Garreau, Alexandre
2018-10-06 11:22         ` Garreau, Alexandre
2018-10-06 11:50           ` Eli Zaretskii
2018-10-06 12:10             ` Garreau, Alexandre
2018-10-06 14:00               ` Eli Zaretskii
2018-10-24 22:25                 ` Noam Postavsky
2018-10-06 13:15             ` Unicode security-issues workarounds elsewhere [Was: Re: Change of Lisp syntax for "fancy" quotes in Emacs 27?] Garreau, Alexandre
2018-10-06 14:01               ` Eli Zaretskii
2018-10-06 16:24           ` Change of Lisp syntax for "fancy" quotes in Emacs 27? Paul Eggert
2018-10-06 16:40             ` Stefan Monnier
2018-10-09 14:43         ` Noam Postavsky
2018-10-09 15:30           ` Paul Eggert
2018-10-09 16:13             ` Eli Zaretskii
2018-10-09 17:07               ` Paul Eggert
2018-10-09 19:18                 ` Andreas Schwab
2018-10-10  9:39                   ` Aaron Ecay
2018-10-10 11:18                     ` Garreau, Alexandre
2018-10-10 14:31                       ` Eli Zaretskii
2018-10-10 15:18                   ` Eli Zaretskii
2018-10-10 15:43                     ` Drew Adams
2018-10-10 16:08                     ` Yuri Khan
2018-10-15 20:30                       ` Juri Linkov
2018-10-10  3:58                 ` Richard Stallman
2018-10-10  3:57           ` Richard Stallman
2018-10-10 14:41             ` Eli Zaretskii
2018-10-11  5:01               ` Richard Stallman
2018-10-06 15:40   ` eval-last-sexp / C-x C-e, and punctuation like `?’' [Was: Re: Change of Lisp syntax for "fancy" quotes in Emacs 27?)] Garreau, Alexandre
2018-10-16 12:48   ` Change of Lisp syntax for "fancy" quotes in Emacs 27? Garreau, Alexandre

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAM-tV--tK8+qLpfWWMfV1-2Ha6VorLCRaMBbGBKumJ_ozN43-g@mail.gmail.com \
    --to=npostavs@users.sourceforge.net \
    --cc=alan@idiocy.org \
    --cc=cpitclaudel@gmail.com \
    --cc=drew.adams@oracle.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=michael_heerdegen@web.de \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).