From: Noam Postavsky <npostavs@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Lars Ingebrigtsen <larsi@gnus.org>,
Shigeru Fukaya <shigeru.fukaya@gmail.com>,
15998@debbugs.gnu.org
Subject: bug#15998: 24.3; forward-sexp (scan-sexps) doesn't do well with some SEXPs
Date: Sat, 06 Jul 2019 22:08:39 -0400 [thread overview]
Message-ID: <875zoe4mvs.fsf@gmail.com> (raw)
In-Reply-To: <jwvtvccqo5s.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Wed, 26 Jun 2019 13:06:22 -0400")
[-- Attachment #1: Type: text/plain, Size: 268 bytes --]
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> But do we want to implement a brand new forward-sexp just for Emacs Lisp?
>
> No, but I think syntax-propertize can take care of those things.
The patch below seems to work, no new sexp movement commands needed?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1977 bytes --]
From 463f98c55ff7d6bde576a9538d3ae3a33a576cf5 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Sat, 6 Jul 2019 21:55:03 -0400
Subject: [PATCH] Handle elisp #-syntax better (Bug#15998)
* elisp-mode.el (elisp-mode-syntax-propertize): New function.
(emacs-lisp-mode): Set it as syntax-propertize-function.
---
lisp/progmodes/elisp-mode.el | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index cb1b17b447..c86277a309 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -213,6 +213,20 @@ emacs-lisp-macroexpand
(if (bolp) (delete-char -1))
(indent-region start (point)))))
+(defun elisp-mode-syntax-propertize (start end)
+ (goto-char start)
+ (funcall
+ (syntax-propertize-rules
+ ("##" (0 (unless (nth 8 (syntax-ppss)) ; Empty symbol.
+ (string-to-syntax "_"))))
+ ((rx "#" (or (seq (group-n 1 (+ digit) "=")) ; Object label.
+ (seq (group-n 1 "&" (+ digit)) ?\") ; Bool-vector.
+ (seq (group-n 1 "s") "(") ; Record.
+ (seq (group-n 1 (+ "^")) "["))) ; Char-table.
+ (1 (unless (save-excursion (nth 8 (syntax-ppss (match-beginning 0))))
+ (string-to-syntax "'")))))
+ start end))
+
(defcustom emacs-lisp-mode-hook nil
"Hook run when entering Emacs Lisp mode."
:options '(eldoc-mode imenu-add-menubar-index checkdoc-minor-mode)
@@ -242,6 +256,7 @@ emacs-lisp-mode
#'elisp-eldoc-documentation-function)
(add-hook 'xref-backend-functions #'elisp--xref-backend nil t)
(setq-local project-vc-external-roots-function #'elisp-load-path-roots)
+ (setq-local syntax-propertize-function #'elisp-mode-syntax-propertize)
(add-hook 'completion-at-point-functions
#'elisp-completion-at-point nil 'local)
(add-hook 'flymake-diagnostic-functions #'elisp-flymake-checkdoc nil t)
--
2.11.0
next prev parent reply other threads:[~2019-07-07 2:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-29 14:45 bug#15998: 24.3; forward-sexp (scan-sexps) doesn't do well with some SEXPs Shigeru Fukaya
2013-11-29 17:12 ` Stefan Monnier
2013-12-01 20:08 ` Shigeru Fukaya
2013-12-01 20:44 ` Stefan Monnier
2013-12-03 9:47 ` Shigeru Fukaya
2013-12-03 17:09 ` Stefan Monnier
2019-06-26 15:23 ` Lars Ingebrigtsen
2019-06-26 17:06 ` Stefan Monnier
2019-06-27 10:30 ` Lars Ingebrigtsen
2019-07-07 2:08 ` Noam Postavsky [this message]
2019-07-07 13:28 ` Stefan Monnier
2019-07-07 13:47 ` Noam Postavsky
2022-05-06 15:50 ` bug#30132: 27.0.50; scan-sexps and ## Lars Ingebrigtsen
2022-05-06 16:30 ` bug#15998: " Lars Ingebrigtsen
2022-05-07 0:08 ` Michael Heerdegen
2022-05-07 4:05 ` bug#15998: " Michael Heerdegen
2022-05-07 10:17 ` Lars Ingebrigtsen
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=875zoe4mvs.fsf@gmail.com \
--to=npostavs@gmail.com \
--cc=15998@debbugs.gnu.org \
--cc=larsi@gnus.org \
--cc=monnier@iro.umontreal.ca \
--cc=shigeru.fukaya@gmail.com \
/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).