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

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

Re: When is a syntax-propertize-function called when parse-sexp-lookup-p


From: Pierre Rouleau
Subject: Re: When is a syntax-propertize-function called when parse-sexp-lookup-properties is t for a current buffer?
Date: Tue, 5 Oct 2021 22:46:11 -0400

On Tue, Oct 5, 2021 at 9:55 PM Stefan Monnier via Users list for the GNU
Emacs text editor <help-gnu-emacs@gnu.org> wrote:

>
> So, IIUC even though the function is called, the relevant char doesn't
> get the corresponding `syntax-table` text property?
>
> Correct.

Maybe the major-mode is getting in the way?
>
> That's what I think.

You can try to use:
>
>       (defun my-syntax-propertize (beg end)
>
        (funcall
>          (syntax-propertize-rules
>            ("\\(<\\)<"
>             (1 (progn
>                  (message "OPEN at %S" (match-beginning 1))
>                  (string-to-syntax "(>")))))
>            (">\\(>\\)"
>             (1 (progn
>                  (message "CLOSE at %S" (match-beginning 1))
>                  (string-to-syntax "(>")))))
>          beg end))
>
> Then check your *Messages* buffer to see where the function placed the
> property, then look at these positions (e.g. with `C-u C-x =`) to see if
> the `syntax-table` text property is still present.
>
> If the property is absent (i.e. has been removed after your function
> added it), then you may want to check your `syntax-propertize-function`
> and search for `syntax-table` in erlong-mode's code to see what might be
> interfering (e.g. maybe this property is added to
> `font-lock-extra-properties`?).
>

I had done something similar and yes the syntax-table properties disappear
from the character.  The erlang.el erlang-mode sets up the syntax for < and
> as
punctuation character with:

(modify-syntax-entry ?< "." table)
(modify-syntax-entry ?> "." table)

It also sets up electric behaviour of >  for the > in '->' sequence to
automatically
insert newline and indent by doing:

;; Also, set up text properties for bit syntax handling.


  (put 'bitsyntax-open-outer  'syntax-table '(4 . ?>))
  (put 'bitsyntax-open-outer  'rear-nonsticky '(category))
  ;;


  (put 'bitsyntax-open-inner  'rear-nonsticky '(category))
  (put 'bitsyntax-close-inner 'rear-nonsticky '(category))
  ;;


  (put 'bitsyntax-close-outer 'syntax-table '(5 . ?<))
  (put 'bitsyntax-close-outer 'rear-nonsticky '(category))

I'm not very familiar yet with all the syntax handling mechanism and that's
why I wanted to know what could interfere and why.  I was looking for some
centralized info on the topic but I guess it's spread across text
properties, syntax , etc..

Thanks for the info, I will check some more things in the code.

-- 
/Pierre


reply via email to

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