emacs-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Scheme-mode: Add support for regular expression literal


From: Jakub T. Jankiewicz
Subject: Re: [PATCH] Scheme-mode: Add support for regular expression literal
Date: Fri, 29 Mar 2024 00:43:23 +0100

Yes, I can confirm it works. The comments works after a delay, it first
highlight single line immediately and after a second i highlight whole
expression.

On Thu, 28 Mar 2024 21:40:11 +0900
"Toshi Umehara" <toshi@niceume.com> wrote:

> 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 "|"))
>           )))
>     ))
> 

--
Jakub T. Jankiewicz, Senior Front-End Developer
https://jcubic.pl/me
https://lips.js.org
https://koduj.org



reply via email to

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