* bug#66183: elixir-ts-mode test failure
@ 2023-09-24 16:53 john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-25 3:12 ` Yuan Fu
0 siblings, 1 reply; 13+ messages in thread
From: john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-24 16:53 UTC (permalink / raw)
To: 66183; +Cc: Yuan Fu
The change in 5cba5ee8905 caused an elixir test to start failing. The
white space at the start of the test is now in a heex range so pressing
tab there matches a heex rule instead of the elixir one. Moving the
dummy range to the end fixes the test.
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -722,7 +722,7 @@ treesit-update-ranges
;; language, set it's range to a dummy (1
;; . 1), otherwise it would be set to the
;; whole buffer, which is not what we want.
- `((,(point-min) . ,(point-min))))))))))))
+ `((,(point-max) . ,(point-max))))))))))))
Running 1 tests (2023-09-24 11:52:17-0500, selector ‘t’)
Test elixir-ts-mode-test-indentation backtrace:
signal(ert-test-failed (("Mismatch in test \"Basic modules\", file /
ert-fail(("Mismatch in test \"Basic modules\", file /home/jm/src/ema
ert-test--erts-test(((dummy . t) (code)) "/home/jm/src/emacs/test/li
ert-test-erts-file("/home/jm/src/emacs/test/lisp/progmodes/elixir-ts
(closure (t) nil (let ((value-4 (gensym "ert-form-evaluation-aborted
ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
ert-run-test(#s(ert-test :name elixir-ts-mode-test-indentation :docu
ert-run-or-rerun-test(#s(ert--stats :selector t :tests [#s(ert-test
ert-run-tests(t #f(compiled-function (event-type &rest event-args) #
ert-run-tests-batch(nil)
ert-run-tests-batch-and-exit()
command-line-1(("-l" "ert" "-l" "/home/jm/src/emacs/lisp/progmodes/e
command-line()
normal-top-level()
Test elixir-ts-mode-test-indentation condition:
(ert-test-failed
("Mismatch in test \"Basic modules\", file /home/jm/src/emacs/test/lisp/progmodes/elixir-ts-mode-resources/indent.erts"
#(
" defmodule Foobar do\n def bar() do\n \"one\"\n end\n end\n"
0 65 (fontified nil))
"defmodule Foobar do\n def bar() do\n \"one\"\n end\nend\n"))
FAILED 1/1 elixir-ts-mode-test-indentation (0.053512 sec) at ../../src/emacs/test/lisp/progmodes/elixir-ts-mode-tests.el:26
Ran 1 tests, 0 results as expected, 1 unexpected (2023-09-24 11:52:17-0500, 0.118489 sec)
1 unexpected results:
FAILED elixir-ts-mode-test-indentation
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#66183: elixir-ts-mode test failure
2023-09-24 16:53 bug#66183: elixir-ts-mode test failure john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-09-25 3:12 ` Yuan Fu
2023-09-25 16:01 ` john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-26 16:30 ` Wilhelm Kirschbaum
0 siblings, 2 replies; 13+ messages in thread
From: Yuan Fu @ 2023-09-25 3:12 UTC (permalink / raw)
To: john muhl; +Cc: 66183
[-- Attachment #1: Type: text/plain, Size: 1086 bytes --]
> On Sep 24, 2023, at 9:53 AM, john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors <bug-gnu-emacs@gnu.org> wrote:
>
> The change in 5cba5ee8905 caused an elixir test to start failing. The
> white space at the start of the test is now in a heex range so pressing
> tab there matches a heex rule instead of the elixir one. Moving the
> dummy range to the end fixes the test.
Thank you. I’ll make sure to remember also running elixir tests when I make a change.
I looked around and found elixir-mode’s language-at-point function works in a way that isn’t what tree-sitter functions expect. Tree-sitter functions expect the major mode to derive language at point by querying the host language and do some pattern matching, rather than using language parser’s range. I took a quick look at elixir’s grammar and came up with this version for a POC. You probably need to adjust it but the idea is there.
With the new language-at-point definition, treesit-language-at can return the correct language, and the test passes again.
Yuan
[-- Attachment #2: example.diff --]
[-- Type: application/octet-stream, Size: 1325 bytes --]
diff --git a/lisp/progmodes/elixir-ts-mode.el b/lisp/progmodes/elixir-ts-mode.el
index 7175fe4bff8..31a25ccadcf 100644
--- a/lisp/progmodes/elixir-ts-mode.el
+++ b/lisp/progmodes/elixir-ts-mode.el
@@ -510,21 +510,13 @@ elixir-ts--treesit-anchor-grand-parent-bol
(defun elixir-ts--treesit-language-at-point (point)
"Return the language at POINT."
- (let* ((range nil)
- (language-in-range
- (cl-loop
- for parser in (treesit-parser-list)
- do (setq range
- (cl-loop
- for range in (treesit-parser-included-ranges parser)
- if (and (>= point (car range)) (<= point (cdr range)))
- return parser))
- if range
- return (treesit-parser-language parser))))
- (if (null language-in-range)
- (when-let ((parser (car (treesit-parser-list))))
- (treesit-parser-language parser))
- language-in-range)))
+ (let* ((node (treesit-node-at point 'elixir)))
+ (if (and (equal (treesit-node-type node) "quoted_content")
+ (string-match-p
+ (rx bos (or "H" "F") eos)
+ (treesit-node-text (treesit-node-prev-sibling node))))
+ 'heex
+ 'elixir)))
(defun elixir-ts--defun-p (node)
"Return non-nil when NODE is a defun."
^ permalink raw reply related [flat|nested] 13+ messages in thread
* bug#66183: elixir-ts-mode test failure
2023-09-25 3:12 ` Yuan Fu
@ 2023-09-25 16:01 ` john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-26 6:18 ` Wilhelm Kirschbaum
2023-09-26 16:30 ` Wilhelm Kirschbaum
1 sibling, 1 reply; 13+ messages in thread
From: john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-25 16:01 UTC (permalink / raw)
To: Yuan Fu; +Cc: Wilhelm H Kirschbaum, 66183
Yuan Fu <casouri@gmail.com> writes:
>> On Sep 24, 2023, at 9:53 AM, john muhl via Bug reports for GNU
>> Emacs, the Swiss army knife of text editors <bug-gnu-emacs@gnu.org>
>> wrote:
>>
>> The change in 5cba5ee8905 caused an elixir test to start failing. The
>> white space at the start of the test is now in a heex range so pressing
>> tab there matches a heex rule instead of the elixir one. Moving the
>> dummy range to the end fixes the test.
>
> Thank you. I’ll make sure to remember also running elixir tests when I
> make a change.
>
> I looked around and found elixir-mode’s language-at-point function
> works in a way that isn’t what tree-sitter functions expect.
> Tree-sitter functions expect the major mode to derive language at
> point by querying the host language and do some pattern matching,
> rather than using language parser’s range. I took a quick look at
> elixir’s grammar and came up with this version for a POC. You probably
> need to adjust it but the idea is there.
Thanks for checking. Actually I was just looking at why the tests were
failing but now see that I forgot to include the elixir mode maintainer.
> With the new language-at-point definition, treesit-language-at can
> return the correct language, and the test passes again.
Wilhelm could you have a look?
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#66183: elixir-ts-mode test failure
2023-09-25 16:01 ` john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-09-26 6:18 ` Wilhelm Kirschbaum
0 siblings, 0 replies; 13+ messages in thread
From: Wilhelm Kirschbaum @ 2023-09-26 6:18 UTC (permalink / raw)
To: john muhl; +Cc: 66183, Yuan Fu
[-- Attachment #1: Type: text/plain, Size: 319 bytes --]
On Mon, Sep 25, 2023 at 9:04 PM john muhl <jm@pub.pink> wrote:
> Yuan Fu <casouri@gmail.com> writes:
>
> > With the new language-at-point definition, treesit-language-at can
> > return the correct language, and the test passes again.
>
> Wilhelm could you have a look?
>
I will have a look later today.
[-- Attachment #2: Type: text/html, Size: 624 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#66183: elixir-ts-mode test failure
2023-09-25 3:12 ` Yuan Fu
2023-09-25 16:01 ` john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-09-26 16:30 ` Wilhelm Kirschbaum
2023-09-26 18:00 ` Yuan Fu
1 sibling, 1 reply; 13+ messages in thread
From: Wilhelm Kirschbaum @ 2023-09-26 16:30 UTC (permalink / raw)
To: Yuan Fu; +Cc: 66183, jm
Yuan Fu <casouri@gmail.com> writes:
>> On Sep 24, 2023, at 9:53 AM, john muhl via Bug reports for GNU
>> Emacs, the Swiss army knife of text editors
>> <bug-gnu-emacs@gnu.org>
>> wrote:
>>
>> The change in 5cba5ee8905 caused an elixir test to start
>> failing. The
>> white space at the start of the test is now in a heex range so
>> pressing
>> tab there matches a heex rule instead of the elixir one. Moving
>> the
>> dummy range to the end fixes the test.
>
> Thank you. I’ll make sure to remember also running elixir tests
> when I make a change.
>
> I looked around and found elixir-mode’s language-at-point
> function
> works in a way that isn’t what tree-sitter functions
> expect. Tree-sitter functions expect the major mode to derive
> language
> at point by querying the host language and do some pattern
> matching,
> rather than using language parser’s range. I took a quick look
> at
> elixir’s grammar and came up with this version for a POC. You
> probably
Sorry about that. I had absolutely no idea how it was expected to
work.
> need to adjust it but the idea is there.
>
> With the new language-at-point definition, treesit-language-at
> can
> return the correct language, and the test passes again.
>
> Yuan
>
> [2. text/x-patch; example.diff]...
This seems to work if you set named on: treesit-node-prev-sibling,
otherwise it just tries to match the \"\"\" against H or F.
(let* ((node (treesit-node-at point 'elixir)))
(if (and (equal (treesit-node-type node) "quoted_content")
(string-match-p
(rx bos (or "H" "F") eos)
- (treesit-node-text (treesit-node-prev-sibling
node))))
+ (treesit-node-text (treesit-node-prev-sibling node
t))))
'heex
'elixir)))
I will spend some time in the next couple of hours to catch up to
all
the changes.
Wilhelm
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#66183: elixir-ts-mode test failure
2023-09-26 16:30 ` Wilhelm Kirschbaum
@ 2023-09-26 18:00 ` Yuan Fu
2023-09-26 20:26 ` Wilhelm Kirschbaum
2023-09-29 11:14 ` Eli Zaretskii
0 siblings, 2 replies; 13+ messages in thread
From: Yuan Fu @ 2023-09-26 18:00 UTC (permalink / raw)
To: Wilhelm Kirschbaum; +Cc: 66183, jm
> On Sep 26, 2023, at 9:30 AM, Wilhelm Kirschbaum <wkirschbaum@gmail.com> wrote:
>
>
> Yuan Fu <casouri@gmail.com> writes:
>
>>> On Sep 24, 2023, at 9:53 AM, john muhl via Bug reports for GNU
>>> Emacs, the Swiss army knife of text editors <bug-gnu-emacs@gnu.org>
>>> wrote:
>>> The change in 5cba5ee8905 caused an elixir test to start failing. The
>>> white space at the start of the test is now in a heex range so pressing
>>> tab there matches a heex rule instead of the elixir one. Moving the
>>> dummy range to the end fixes the test.
>>
>> Thank you. I’ll make sure to remember also running elixir tests when I make a change.
>>
>> I looked around and found elixir-mode’s language-at-point function
>> works in a way that isn’t what tree-sitter functions
>> expect. Tree-sitter functions expect the major mode to derive language
>> at point by querying the host language and do some pattern matching,
>> rather than using language parser’s range. I took a quick look at
>> elixir’s grammar and came up with this version for a POC. You probably
>
> Sorry about that. I had absolutely no idea how it was expected to work.
It’s absolutely my fault :-) Several people have had confusion about it, because the docstring wasn’t clear enough. I’ve updated the docstring so hopefully this confusion won’t occur in the future.
>
>> need to adjust it but the idea is there.
>>
>> With the new language-at-point definition, treesit-language-at can
>> return the correct language, and the test passes again.
>>
>> Yuan
>>
>> [2. text/x-patch; example.diff]...
>
> This seems to work if you set named on: treesit-node-prev-sibling,
> otherwise it just tries to match the \"\"\" against H or F.
>
> (let* ((node (treesit-node-at point 'elixir)))
> (if (and (equal (treesit-node-type node) "quoted_content")
> (string-match-p
> (rx bos (or "H" "F") eos)
> - (treesit-node-text (treesit-node-prev-sibling node))))
> + (treesit-node-text (treesit-node-prev-sibling node t))))
> 'heex
> 'elixir)))
>
> I will spend some time in the next couple of hours to catch up to all
> the changes.
Ah, right. I’ll leave the specifics to you. As long as the language is derived from the node at point rather than parser range, it will be fine. Also, there’s no rush.
Yuan
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#66183: elixir-ts-mode test failure
2023-09-26 18:00 ` Yuan Fu
@ 2023-09-26 20:26 ` Wilhelm Kirschbaum
2023-09-27 6:46 ` Yuan Fu
2023-09-29 11:14 ` Eli Zaretskii
1 sibling, 1 reply; 13+ messages in thread
From: Wilhelm Kirschbaum @ 2023-09-26 20:26 UTC (permalink / raw)
To: Yuan Fu; +Cc: 66183, jm
[-- Attachment #1: Type: text/plain, Size: 1367 bytes --]
>>> need to adjust it but the idea is there.
>>>
>>> With the new language-at-point definition, treesit-language-at
>>> can
>>> return the correct language, and the test passes again.
>>>
>>> Yuan
>>>
>>> [2. text/x-patch; example.diff]...
>>
>> This seems to work if you set named on:
>> treesit-node-prev-sibling,
>> otherwise it just tries to match the \"\"\" against H or F.
>>
>> (let* ((node (treesit-node-at point 'elixir)))
>> (if (and (equal (treesit-node-type node) "quoted_content")
>> (string-match-p
>> (rx bos (or "H" "F") eos)
>> - (treesit-node-text (treesit-node-prev-sibling
>> node))))
>> + (treesit-node-text (treesit-node-prev-sibling
>> node t))))
>> 'heex
>> 'elixir)))
>>
>> I will spend some time in the next couple of hours to catch up
>> to all
>> the changes.
>
> Ah, right. I’ll leave the specifics to you. As long as the
> language is derived from the node at point rather than parser
> range, it will be fine. Also, there’s no rush.
>
Hi Yuan,
With the new changes I had to update some indentation rules as
well.
The following patch was tested against a couple of elixir files.
There is another indentation issue with HEEx embeds, but think its
unrelated to this issue and will have a look this weekend.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Fix treesit-language-at-point for elixir-ts-mode --]
[-- Type: text/x-patch, Size: 3540 bytes --]
From 046950eb63b5499ab7f60434c5ebd0bbe5ada274 Mon Sep 17 00:00:00 2001
From: Wilhelm H Kirschbaum <wkirschbaum@gmail.com>
Date: Tue, 26 Sep 2023 21:32:40 +0200
Subject: [PATCH] Fix treesit-langauge-at-point for elixir-ts-mode.
The treesit-language-at-point function is only suppose to query the
host language.
* lisp/progmodes/elixir-ts-mode.el
(elixir-ts--indent-rules): Add missing rules.
(elixir-ts--treesit-language-at-point): Update function to only query
the host language.
* test/lisp/progmodes/elixir-ts-mode-resources/indent.erts: Add test
for inline docs.
---
lisp/progmodes/elixir-ts-mode.el | 35 ++++++++++---------
.../elixir-ts-mode-resources/indent.erts | 16 +++++++++
2 files changed, 35 insertions(+), 16 deletions(-)
diff --git a/lisp/progmodes/elixir-ts-mode.el b/lisp/progmodes/elixir-ts-mode.el
index 7175fe4bff8..fd4400c6c53 100644
--- a/lisp/progmodes/elixir-ts-mode.el
+++ b/lisp/progmodes/elixir-ts-mode.el
@@ -312,7 +312,16 @@ elixir-ts--indent-rules
((parent-is "^catch_block$") parent ,offset)
((parent-is "^keywords$") parent-bol 0)
((node-is "^call$") parent-bol ,offset)
- ((node-is "^comment$") parent-bol ,offset)))))
+ ((node-is "^comment$") parent-bol ,offset)
+ ((node-is "\"\"\"") parent-bol 0)
+ ;; Handle quoted_content indentation on the last
+ ;; line before the closing \"\"\", where it might
+ ;; see it as no-node outside a HEEx tag.
+ (no-node (lambda (_n _p _bol)
+ (treesit-node-start
+ (treesit-node-parent
+ (treesit-node-at (point) 'elixir))))
+ 0)))))
(defvar elixir-ts--font-lock-settings
(treesit-font-lock-rules
@@ -510,21 +519,15 @@ elixir-ts--treesit-anchor-grand-parent-bol
(defun elixir-ts--treesit-language-at-point (point)
"Return the language at POINT."
- (let* ((range nil)
- (language-in-range
- (cl-loop
- for parser in (treesit-parser-list)
- do (setq range
- (cl-loop
- for range in (treesit-parser-included-ranges parser)
- if (and (>= point (car range)) (<= point (cdr range)))
- return parser))
- if range
- return (treesit-parser-language parser))))
- (if (null language-in-range)
- (when-let ((parser (car (treesit-parser-list))))
- (treesit-parser-language parser))
- language-in-range)))
+ (let ((node (treesit-node-at point 'elixir)))
+ (if (and (equal (treesit-node-type node) "quoted_content")
+ (let ((prev-sibling (treesit-node-prev-sibling node t)))
+ (when (treesit-node-p prev-sibling)
+ (string-match-p
+ (rx bos (or "H" "F") eos)
+ (treesit-node-text (treesit-node-prev-sibling node t))))))
+ 'heex
+ 'elixir)))
(defun elixir-ts--defun-p (node)
"Return non-nil when NODE is a defun."
diff --git a/test/lisp/progmodes/elixir-ts-mode-resources/indent.erts b/test/lisp/progmodes/elixir-ts-mode-resources/indent.erts
index 1f855d3c977..fe09a37a32b 100644
--- a/test/lisp/progmodes/elixir-ts-mode-resources/indent.erts
+++ b/test/lisp/progmodes/elixir-ts-mode-resources/indent.erts
@@ -330,6 +330,22 @@ Name: Long tuple
"October", "November", "December"}
=-=-=
+Name: Doc
+
+=-=
+defmodule Foo do
+"""
+ bar
+ """
+end
+=-=
+defmodule Foo do
+ """
+ bar
+ """
+end
+=-=-=
+
Name: Embedded HEEx
=-=
--
2.42.0
[-- Attachment #3: Type: text/plain, Size: 14 bytes --]
Wilhelm
^ permalink raw reply related [flat|nested] 13+ messages in thread
* bug#66183: elixir-ts-mode test failure
2023-09-26 20:26 ` Wilhelm Kirschbaum
@ 2023-09-27 6:46 ` Yuan Fu
2023-09-27 7:17 ` Wilhelm Kirschbaum
0 siblings, 1 reply; 13+ messages in thread
From: Yuan Fu @ 2023-09-27 6:46 UTC (permalink / raw)
To: Wilhelm Kirschbaum; +Cc: 66183, jm, 66183-done
[-- Attachment #1: Type: text/plain, Size: 1422 bytes --]
> On Sep 26, 2023, at 1:26 PM, Wilhelm Kirschbaum <wkirschbaum@gmail.com> wrote:
>
>>>> need to adjust it but the idea is there.
>>>> With the new language-at-point definition, treesit-language-at can
>>>> return the correct language, and the test passes again.
>>>> Yuan
>>>> [2. text/x-patch; example.diff]...
>>> This seems to work if you set named on: treesit-node-prev-sibling,
>>> otherwise it just tries to match the \"\"\" against H or F.
>>> (let* ((node (treesit-node-at point 'elixir)))
>>> (if (and (equal (treesit-node-type node) "quoted_content")
>>> (string-match-p
>>> (rx bos (or "H" "F") eos)
>>> - (treesit-node-text (treesit-node-prev-sibling node))))
>>> + (treesit-node-text (treesit-node-prev-sibling node t))))
>>> 'heex
>>> 'elixir)))
>>> I will spend some time in the next couple of hours to catch up to all
>>> the changes.
>>
>> Ah, right. I’ll leave the specifics to you. As long as the language is derived from the node at point rather than parser range, it will be fine. Also, there’s no rush.
>>
>
> Hi Yuan,
>
> With the new changes I had to update some indentation rules as well.
> The following patch was tested against a couple of elixir files.
>
> There is another indentation issue with HEEx embeds, but think its
> unrelated to this issue and will have a look this weekend.
>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-treesit-langauge-at-point-for-elixir-ts-mode.patch --]
[-- Type: text/x-patch; x-unix-mode=0644; name="0001-Fix-treesit-langauge-at-point-for-elixir-ts-mode.patch", Size: 3642 bytes --]
From 046950eb63b5499ab7f60434c5ebd0bbe5ada274 Mon Sep 17 00:00:00 2001
From: Wilhelm H Kirschbaum <wkirschbaum@gmail.com>
Date: Tue, 26 Sep 2023 21:32:40 +0200
Subject: [PATCH] Fix treesit-langauge-at-point for elixir-ts-mode.
The treesit-language-at-point function is only suppose to query the
host language.
* lisp/progmodes/elixir-ts-mode.el
(elixir-ts--indent-rules): Add missing rules.
(elixir-ts--treesit-language-at-point): Update function to only query
the host language.
* test/lisp/progmodes/elixir-ts-mode-resources/indent.erts: Add test
for inline docs.
---
lisp/progmodes/elixir-ts-mode.el | 35 ++++++++++---------
.../elixir-ts-mode-resources/indent.erts | 16 +++++++++
2 files changed, 35 insertions(+), 16 deletions(-)
diff --git a/lisp/progmodes/elixir-ts-mode.el b/lisp/progmodes/elixir-ts-mode.el
index 7175fe4bff8..fd4400c6c53 100644
--- a/lisp/progmodes/elixir-ts-mode.el
+++ b/lisp/progmodes/elixir-ts-mode.el
@@ -312,7 +312,16 @@ elixir-ts--indent-rules
((parent-is "^catch_block$") parent ,offset)
((parent-is "^keywords$") parent-bol 0)
((node-is "^call$") parent-bol ,offset)
- ((node-is "^comment$") parent-bol ,offset)))))
+ ((node-is "^comment$") parent-bol ,offset)
+ ((node-is "\"\"\"") parent-bol 0)
+ ;; Handle quoted_content indentation on the last
+ ;; line before the closing \"\"\", where it might
+ ;; see it as no-node outside a HEEx tag.
+ (no-node (lambda (_n _p _bol)
+ (treesit-node-start
+ (treesit-node-parent
+ (treesit-node-at (point) 'elixir))))
+ 0)))))
(defvar elixir-ts--font-lock-settings
(treesit-font-lock-rules
@@ -510,21 +519,15 @@ elixir-ts--treesit-anchor-grand-parent-bol
(defun elixir-ts--treesit-language-at-point (point)
"Return the language at POINT."
- (let* ((range nil)
- (language-in-range
- (cl-loop
- for parser in (treesit-parser-list)
- do (setq range
- (cl-loop
- for range in (treesit-parser-included-ranges parser)
- if (and (>= point (car range)) (<= point (cdr range)))
- return parser))
- if range
- return (treesit-parser-language parser))))
- (if (null language-in-range)
- (when-let ((parser (car (treesit-parser-list))))
- (treesit-parser-language parser))
- language-in-range)))
+ (let ((node (treesit-node-at point 'elixir)))
+ (if (and (equal (treesit-node-type node) "quoted_content")
+ (let ((prev-sibling (treesit-node-prev-sibling node t)))
+ (when (treesit-node-p prev-sibling)
+ (string-match-p
+ (rx bos (or "H" "F") eos)
+ (treesit-node-text (treesit-node-prev-sibling node t))))))
+ 'heex
+ 'elixir)))
(defun elixir-ts--defun-p (node)
"Return non-nil when NODE is a defun."
diff --git a/test/lisp/progmodes/elixir-ts-mode-resources/indent.erts b/test/lisp/progmodes/elixir-ts-mode-resources/indent.erts
index 1f855d3c977..fe09a37a32b 100644
--- a/test/lisp/progmodes/elixir-ts-mode-resources/indent.erts
+++ b/test/lisp/progmodes/elixir-ts-mode-resources/indent.erts
@@ -330,6 +330,22 @@ Name: Long tuple
"October", "November", "December"}
=-=-=
+Name: Doc
+
+=-=
+defmodule Foo do
+"""
+ bar
+ """
+end
+=-=
+defmodule Foo do
+ """
+ bar
+ """
+end
+=-=-=
+
Name: Embedded HEEx
=-=
--
2.42.0
[-- Attachment #3: Type: text/plain, Size: 74 bytes --]
>
> Wilhelm
Thanks. I made some minor change and pushed to master.
Yuan
^ permalink raw reply related [flat|nested] 13+ messages in thread
* bug#66183: elixir-ts-mode test failure
2023-09-27 6:46 ` Yuan Fu
@ 2023-09-27 7:17 ` Wilhelm Kirschbaum
0 siblings, 0 replies; 13+ messages in thread
From: Wilhelm Kirschbaum @ 2023-09-27 7:17 UTC (permalink / raw)
To: Yuan Fu; +Cc: 66183, jm, 66183-done
Yuan Fu <casouri@gmail.com> writes:
>> On Sep 26, 2023, at 1:26 PM, Wilhelm Kirschbaum
>> <wkirschbaum@gmail.com> wrote:
>>
>>>>> need to adjust it but the idea is there.
>>>>> With the new language-at-point definition,
>>>>> treesit-language-at can
>>>>> return the correct language, and the test passes again.
>>>>> Yuan
>>>>> [2. text/x-patch; example.diff]...
>>>> This seems to work if you set named on:
>>>> treesit-node-prev-sibling,
>>>> otherwise it just tries to match the \"\"\" against H or F.
>>>> (let* ((node (treesit-node-at point 'elixir)))
>>>> (if (and (equal (treesit-node-type node) "quoted_content")
>>>> (string-match-p
>>>> (rx bos (or "H" "F") eos)
>>>> - (treesit-node-text (treesit-node-prev-sibling
>>>> node))))
>>>> + (treesit-node-text (treesit-node-prev-sibling
>>>> node t))))
>>>> 'heex
>>>> 'elixir)))
>>>> I will spend some time in the next couple of hours to catch
>>>> up to all
>>>> the changes.
>>>
>>> Ah, right. I’ll leave the specifics to you. As long as the
>>> language
>>> is derived from the node at point rather than parser range, it
>>> will
>>> be fine. Also, there’s no rush.
>>>
>>
>> Hi Yuan,
>>
>> With the new changes I had to update some indentation rules as
>> well.
>> The following patch was tested against a couple of elixir
>> files.
>>
>> There is another indentation issue with HEEx embeds, but think
>> its
>> unrelated to this issue and will have a look this weekend.
>>
>
> [2. text/x-patch;
> 0001-Fix-treesit-langauge-at-point-for-elixir-ts-mode.patch]...
>
>>
>> Wilhelm
>
> Thanks. I made some minor change and pushed to master.
>
> Yuan
Fantastic, thanks!
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#66183: elixir-ts-mode test failure
2023-09-26 18:00 ` Yuan Fu
2023-09-26 20:26 ` Wilhelm Kirschbaum
@ 2023-09-29 11:14 ` Eli Zaretskii
2023-10-05 7:18 ` Eli Zaretskii
1 sibling, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2023-09-29 11:14 UTC (permalink / raw)
To: Yuan Fu; +Cc: wkirschbaum, 66183, jm
> Cc: 66183@debbugs.gnu.org, jm@pub.pink
> From: Yuan Fu <casouri@gmail.com>
> Date: Tue, 26 Sep 2023 11:00:23 -0700
>
> > On Sep 26, 2023, at 9:30 AM, Wilhelm Kirschbaum <wkirschbaum@gmail.com> wrote:
> >
> >
> > Yuan Fu <casouri@gmail.com> writes:
> >
> >>> On Sep 24, 2023, at 9:53 AM, john muhl via Bug reports for GNU
> >>> Emacs, the Swiss army knife of text editors <bug-gnu-emacs@gnu.org>
> >>> wrote:
> >>> The change in 5cba5ee8905 caused an elixir test to start failing. The
> >>> white space at the start of the test is now in a heex range so pressing
> >>> tab there matches a heex rule instead of the elixir one. Moving the
> >>> dummy range to the end fixes the test.
> >>
> >> Thank you. I’ll make sure to remember also running elixir tests when I make a change.
> >>
> >> I looked around and found elixir-mode’s language-at-point function
> >> works in a way that isn’t what tree-sitter functions
> >> expect. Tree-sitter functions expect the major mode to derive language
> >> at point by querying the host language and do some pattern matching,
> >> rather than using language parser’s range. I took a quick look at
> >> elixir’s grammar and came up with this version for a POC. You probably
> >
> > Sorry about that. I had absolutely no idea how it was expected to work.
>
> It’s absolutely my fault :-) Several people have had confusion about it, because the docstring wasn’t clear enough. I’ve updated the docstring so hopefully this confusion won’t occur in the future.
Should this doc-string fix be cherry-picked to the release branch?
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#66183: elixir-ts-mode test failure
2023-09-29 11:14 ` Eli Zaretskii
@ 2023-10-05 7:18 ` Eli Zaretskii
2023-10-07 8:44 ` Wilhelm Kirschbaum
0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2023-10-05 7:18 UTC (permalink / raw)
To: casouri; +Cc: wkirschbaum, 66183, jm
Ping!
> Cc: wkirschbaum@gmail.com, 66183@debbugs.gnu.org, jm@pub.pink
> Date: Fri, 29 Sep 2023 14:14:44 +0300
> From: Eli Zaretskii <eliz@gnu.org>
>
> > Cc: 66183@debbugs.gnu.org, jm@pub.pink
> > From: Yuan Fu <casouri@gmail.com>
> > Date: Tue, 26 Sep 2023 11:00:23 -0700
> >
> > > On Sep 26, 2023, at 9:30 AM, Wilhelm Kirschbaum <wkirschbaum@gmail.com> wrote:
> > >
> > >
> > > Yuan Fu <casouri@gmail.com> writes:
> > >
> > >>> On Sep 24, 2023, at 9:53 AM, john muhl via Bug reports for GNU
> > >>> Emacs, the Swiss army knife of text editors <bug-gnu-emacs@gnu.org>
> > >>> wrote:
> > >>> The change in 5cba5ee8905 caused an elixir test to start failing. The
> > >>> white space at the start of the test is now in a heex range so pressing
> > >>> tab there matches a heex rule instead of the elixir one. Moving the
> > >>> dummy range to the end fixes the test.
> > >>
> > >> Thank you. I’ll make sure to remember also running elixir tests when I make a change.
> > >>
> > >> I looked around and found elixir-mode’s language-at-point function
> > >> works in a way that isn’t what tree-sitter functions
> > >> expect. Tree-sitter functions expect the major mode to derive language
> > >> at point by querying the host language and do some pattern matching,
> > >> rather than using language parser’s range. I took a quick look at
> > >> elixir’s grammar and came up with this version for a POC. You probably
> > >
> > > Sorry about that. I had absolutely no idea how it was expected to work.
> >
> > It’s absolutely my fault :-) Several people have had confusion about it, because the docstring wasn’t clear enough. I’ve updated the docstring so hopefully this confusion won’t occur in the future.
>
> Should this doc-string fix be cherry-picked to the release branch?
>
>
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#66183: elixir-ts-mode test failure
2023-10-05 7:18 ` Eli Zaretskii
@ 2023-10-07 8:44 ` Wilhelm Kirschbaum
2023-10-07 9:05 ` Eli Zaretskii
0 siblings, 1 reply; 13+ messages in thread
From: Wilhelm Kirschbaum @ 2023-10-07 8:44 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 66183, casouri, jm
>> > It’s absolutely my fault :-) Several people have had
>> > confusion
>> > about it, because the docstring wasn’t clear enough. I’ve
>> > updated
>> > the docstring so hopefully this confusion won’t occur in the
>> > future.
>>
>> Should this doc-string fix be cherry-picked to the release
>> branch?
>>
I don't see why not, because the elixir-ts-mode patch works on
29.1 as well.
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#66183: elixir-ts-mode test failure
2023-10-07 8:44 ` Wilhelm Kirschbaum
@ 2023-10-07 9:05 ` Eli Zaretskii
0 siblings, 0 replies; 13+ messages in thread
From: Eli Zaretskii @ 2023-10-07 9:05 UTC (permalink / raw)
To: Wilhelm Kirschbaum; +Cc: 66183, casouri, jm
> From: Wilhelm Kirschbaum <wkirschbaum@gmail.com>
> Cc: casouri@gmail.com, 66183@debbugs.gnu.org, jm@pub.pink
> Date: Sat, 07 Oct 2023 10:44:12 +0200
>
>
>
> >> > It’s absolutely my fault :-) Several people have had
> >> > confusion
> >> > about it, because the docstring wasn’t clear enough. I’ve
> >> > updated
> >> > the docstring so hopefully this confusion won’t occur in the
> >> > future.
> >>
> >> Should this doc-string fix be cherry-picked to the release
> >> branch?
> >>
>
> I don't see why not, because the elixir-ts-mode patch works on
> 29.1 as well.
Done.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2023-10-07 9:05 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-24 16:53 bug#66183: elixir-ts-mode test failure john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-25 3:12 ` Yuan Fu
2023-09-25 16:01 ` john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-26 6:18 ` Wilhelm Kirschbaum
2023-09-26 16:30 ` Wilhelm Kirschbaum
2023-09-26 18:00 ` Yuan Fu
2023-09-26 20:26 ` Wilhelm Kirschbaum
2023-09-27 6:46 ` Yuan Fu
2023-09-27 7:17 ` Wilhelm Kirschbaum
2023-09-29 11:14 ` Eli Zaretskii
2023-10-05 7:18 ` Eli Zaretskii
2023-10-07 8:44 ` Wilhelm Kirschbaum
2023-10-07 9:05 ` Eli Zaretskii
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.