[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 14:45:43 -0400 |
Well, it never hurts to get the latest Emacs! I'm on GNU Emacs
> 29.0.50 so that's quite a difference ...
>
I want to make it work on all these platforms and 26.1 is a necessary target
imposed by non-technical constraints out of my control.
> But ... I don't understand 100% what it is you'd like to
> happen? Can you describe it in human terms rather? "When I do
> ... I'd like this to happen ... and not this ..." ?
>
No problem.
I know the following is long, but I think I need to give some context...
I’m trying to add navigation with forward-sexp and backward-sexp
inside erlang-mode buffers to support the Erlang Bit Syntax expressions
(
https://erlang.org/doc/reference_manual/expressions.html#bit-syntax-expressions
).
Currently, with the latest version of erlang.el, the erlang-mode activates
the ability to move to the >> matching the << just after point, but
*only* after you just write the Erlang code.
So let's say you just wrote the following Erlang statement inside an
erlang-mode buffer:
Abc = << <<Bin>> || Bin <- [<<3,7,5,4,7>>] >>
The statement is not complete, the full-stop has not yet been typed.
At this point you can use the backward-sexp command to move the point just
before the first < character on the line. And you can also use
forward-sexp
to come back where you were.
Let's say you just type the full-stop (period) to terminate the statement
and then hit RET to move point to the next line. From then on, if you
place
the point just before the first < or after the last >, forward-sexp and
backward-sexp do not work: they do not move the point to the matching
location.
If you save and re-open the file you also lose the matching ability.
My understanding of the reason why it stops working is because the
erlang.el syntax
table, modified by erlang.el `erlang-ensure-syntax-table-is-initialized'
does not identify
the < and > characters as parens that match another one. The erlang.el
code does this:
(modify-syntax-entry ?< "." table)
(modify-syntax-entry ?> "." table)
It assigns punctuation syntax to these characters instead of doing the
following:
(modify-syntax-entry ?< "(>" table)
(modify-syntax-entry ?> ")<" table)
The reason the last 2 statements are *not* used is because, > and < are
also used, like
many other programming languages as comparison operators and in erlang you
also
have '->', '<-' and '<=' operators. Giving open and closing delimiter
syntax to the < and >
characters would break operations and cause a lot of unbalanced issues.
So, I am trying to syntax propertize << and >> to provide ability to
navigate across the
bit syntax expression by setting the syntax-propertize-function to activate
syntax
properties to the outer characters of << and >>.
To do that I added the following at top level, just before the
(defun erlang-ensure-syntax-table-is-initialized ... ) form:
(defconst erlang-mode-syntax-propertize-function
(syntax-propertize-rules
("\\(<\\)<" (1 "(>"))
(">\\(>\\)" (2 ")<")))
"Syntax properties to activate << >> pairing.")
And I added the following inside of
erlang-ensure-syntax-table-is-initialized
after the code that sets up the syntax table for Erlang :
(setq-local parse-sexp-lookup-properties t)
(setq-local syntax-propertize-function
erlang-mode-syntax-propertize-function)
After byte compilation and testing I was expecting that I'd see the
syntax-table text
property of all outer characters of << and >> bit syntax inside the erlang
buffer to be
activated allowing me to navigate across their edges with forward-sexp and
backward-sexp.
But that does not work: I still cannot navigate with forward-sexp and
backward-sexp
and the outer << and >> characters do not have the text properties I
thought they would have.
I check inside the buffer if parse-sexp-lookup-properies is t and it is.
I also check in the buffer if syntax-propertize-function is set and it is
set to what I expect.
Yet I do not see a change of behaviour from what the non-modified erlang.el
code provides.
Therefore my question as to *when* the syntax-propertize-function should
take effect
and how I can see if it is applied.
--
/Pierre
- When is a syntax-propertize-function called when parse-sexp-lookup-properties is t for a current buffer?, Pierre Rouleau, 2021/10/04
- Re: When is a syntax-propertize-function called when parse-sexp-lookup-properties is t for a current buffer?, Emanuel Berg, 2021/10/05
- Re: When is a syntax-propertize-function called when parse-sexp-lookup-properties is t for a current buffer?, Stefan Monnier, 2021/10/05
- Re: When is a syntax-propertize-function called when parse-sexp-lookup-properties is t for a current buffer?, Pierre Rouleau, 2021/10/05
- Re: When is a syntax-propertize-function called when parse-sexp-lookup-properties is t for a current buffer?, Stefan Monnier, 2021/10/05
- Re: When is a syntax-propertize-function called when parse-sexp-lookup-properties is t for a current buffer?, Pierre Rouleau, 2021/10/05
- Re: When is a syntax-propertize-function called when parse-sexp-lookup-properties is t for a current buffer?, Emanuel Berg, 2021/10/05
- Re: When is a syntax-propertize-function called when parse-sexp-lookup-properties is t for a current buffer?,
Pierre Rouleau <=
- Re: When is a syntax-propertize-function called when parse-sexp-lookup-properties is t for a current buffer?, Emanuel Berg, 2021/10/05
- Re: When is a syntax-propertize-function called when parse-sexp-lookup-properties is t for a current buffer?, Pierre Rouleau, 2021/10/05
- Re: When is a syntax-propertize-function called when parse-sexp-lookup-properties is t for a current buffer?, Stefan Monnier, 2021/10/05
- Message not available
- Fwd: When is a syntax-propertize-function called when parse-sexp-lookup-properties is t for a current buffer?, Pierre Rouleau, 2021/10/05
- Re: When is a syntax-propertize-function called when parse-sexp-lookup-properties is t for a current buffer?, Pierre Rouleau, 2021/10/05
- Re: When is a syntax-propertize-function called when parse-sexp-lookup-properties is t for a current buffer?, Stefan Monnier, 2021/10/05
- Re: When is a syntax-propertize-function called when parse-sexp-lookup-properties is t for a current buffer?, Pierre Rouleau, 2021/10/05