unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Toshi Umehara" <toshi@niceume.com>
To: "Jakub T. Jankiewicz" <jcubic@onet.pl>
Cc: "Stefan Monnier" <monnier@iro.umontreal.ca>,
	emacs-devel@gnu.org, "Eli Zaretskii" <eliz@gnu.org>
Subject: Re: [PATCH] Scheme-mode: Add support for regular expression literal
Date: Thu, 28 Mar 2024 21:40:11 +0900	[thread overview]
Message-ID: <6d79d884-e691-4223-be1b-ada141ad8f37@app.fastmail.com> (raw)
In-Reply-To: <20240328123354.17588d57@jcubic>

The code below, which works in init.el, corresponds to the updated scheme.el .
Could you try it ?

(add-hook
 'scheme-mode-hook
 (lambda ()
   (setq-local
    syntax-propertize-function
    (lambda (beg end)
      (goto-char beg)
      (scheme-syntax-propertize-sexp-comment2 end)
      (scheme-syntax-propertize-regexp end)
      (funcall
       (syntax-propertize-rules
        ("\\(#\\);" (1 (prog1 "< cn"
                         (scheme-syntax-propertize-sexp-comment2 end))))
        ("\\(#\\)/" (1 (when (null (nth 8 (save-excursion
                                            (syntax-ppss
                                             (match-beginning 0)))))
                         (put-text-property
                          (match-beginning 1)
                          (match-end 1)
                          'syntax-table (string-to-syntax "|"))
                         (scheme-syntax-propertize-regexp end)
                         nil)
                       )))
       (point) end)))))

(defun scheme-syntax-propertize-sexp-comment2 (end)
  (let ((state (syntax-ppss)))
    (when (eq 2 (nth 7 state))
      ;; It's a sexp-comment.  Tell parse-partial-sexp where it ends.
      (condition-case nil
          (progn
            (goto-char (+ 2 (nth 8 state)))
            ;; FIXME: this doesn't handle the case where the sexp
            ;; itself contains a #; comment.
            (forward-sexp 1)
            (put-text-property (1- (point)) (point)
                               'syntax-table (string-to-syntax "> cn")))
        (scan-error (goto-char end))))))

(defun scheme-syntax-propertize-regexp (end)
  (let* ((state (syntax-ppss))
         (within-str (nth 3 state))
         (start-delim-pos (nth 8 state)))
    (when (and within-str
               (char-equal ?# (char-after start-delim-pos)))
      (while
          (and
           (re-search-forward "/" end 'move)
           (eq -1
               (% (save-excursion
                    (backward-char)
                    (skip-chars-backward "\\\\")) 2))))
      (when (< (point) end)
        (progn
          (put-text-property
           (match-beginning 0)
           (match-end 0)
           'syntax-table (string-to-syntax "|"))
          )))
    ))




  reply	other threads:[~2024-03-28 12:40 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-23  2:40 [PATCH] Scheme-mode: Add support for regular expression literal Toshi Umehara
2024-03-23 14:28 ` Jakub T. Jankiewicz
2024-03-23 20:57 ` Stefan Monnier
2024-03-24  4:33   ` Toshi Umehara
2024-03-28 11:33     ` Jakub T. Jankiewicz
2024-03-28 12:40       ` Toshi Umehara [this message]
2024-03-28 23:43         ` Jakub T. Jankiewicz
2024-03-29  6:48           ` Eli Zaretskii
2024-03-29 11:09             ` Jakub T. Jankiewicz
2024-03-29 15:02               ` Toshi Umehara
2024-03-29 15:38                 ` Eli Zaretskii
2024-03-30  0:48                   ` Toshi Umehara
2024-04-01  6:17       ` Stefan Monnier
2024-03-30  7:59     ` Eli Zaretskii
2024-04-01  5:31       ` Stefan Monnier
2024-04-01  5:24     ` Stefan Monnier
2024-04-02  8:48       ` Toshi Umehara

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=6d79d884-e691-4223-be1b-ada141ad8f37@app.fastmail.com \
    --to=toshi@niceume.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=jcubic@onet.pl \
    --cc=monnier@iro.umontreal.ca \
    /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).