unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#62611: 30.0.50; Improvements for elixir-ts-mode
@ 2023-04-02  9:33 Wilhelm Kirschbaum
  0 siblings, 0 replies; only message in thread
From: Wilhelm Kirschbaum @ 2023-04-02  9:33 UTC (permalink / raw)
  To: 62611

[-- Attachment #1: Type: text/plain, Size: 137 bytes --]


Hi,

Here are two improvements to elixir-ts-mode.  One improves the 
sigil
fontification and the other improves indentation for lists.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Improve list indentation for elixir-ts-mode --]
[-- Type: text/x-patch, Size: 2567 bytes --]

From f85fa091931712136575c194d8cc19320bb0365f Mon Sep 17 00:00:00 2001
From: Wilhelm H Kirschbaum <wkirschbaum@gmail.com>
Date: Sun, 2 Apr 2023 11:26:02 +0200
Subject: [PATCH 1/2] Improve list indentation for elixir-ts-mode

* lisp/progmodes/elixir-ts-mode.el
(elixir-ts--argument-indent-offset): Add empty line check.
(elixir-ts--argument-indent-anchor): Change ERROR offset.
* test/lisp/progmodes/elixir-ts-mode-resources/indent.erts:
Add test.
---
 lisp/progmodes/elixir-ts-mode.el              | 10 ++++++++--
 .../elixir-ts-mode-resources/indent.erts      | 20 ++++++++++++++++++-
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/elixir-ts-mode.el b/lisp/progmodes/elixir-ts-mode.el
index e462758f0f8..d09beafb77a 100644
--- a/lisp/progmodes/elixir-ts-mode.el
+++ b/lisp/progmodes/elixir-ts-mode.el
@@ -171,7 +171,13 @@ elixir-ts--syntax-table
 
 (defun elixir-ts--argument-indent-offset (node _parent &rest _)
   "Return the argument offset position for NODE."
-  (if (treesit-node-prev-sibling node t) 0 elixir-ts-indent-offset))
+  (if (or (treesit-node-prev-sibling node t)
+          ;; Don't indent if this is the first node or
+          ;; if the line is empty.
+          (save-excursion
+            (beginning-of-line)
+            (looking-at-p "[[:blank:]]*$")))
+      0 elixir-ts-indent-offset))
 
 (defun elixir-ts--argument-indent-anchor (node parent &rest _)
   "Return the argument anchor position for NODE and PARENT."
@@ -266,7 +272,7 @@ elixir-ts--indent-rules
        ;; Handle incomplete maps when parent is ERROR.
        ((n-p-gp "^binary_operator$" "ERROR" nil) parent-bol 0)
        ;; When there is an ERROR, just indent to prev-line.
-       ((parent-is "ERROR") prev-line 0)
+       ((parent-is "ERROR") prev-line ,offset)
        ((node-is "^binary_operator$")
         (lambda (node parent &rest _)
           (let ((top-level
diff --git a/test/lisp/progmodes/elixir-ts-mode-resources/indent.erts b/test/lisp/progmodes/elixir-ts-mode-resources/indent.erts
index ea5d9e62240..9ad604e5198 100644
--- a/test/lisp/progmodes/elixir-ts-mode-resources/indent.erts
+++ b/test/lisp/progmodes/elixir-ts-mode-resources/indent.erts
@@ -1,6 +1,5 @@
 Code:
   (lambda ()
-    (setq indent-tabs-mode nil)
     (elixir-ts-mode)
     (indent-region (point-min) (point-max)))
 
@@ -330,3 +329,22 @@ defmodule Foo do
   end
 end
 =-=-=
+
+Code:
+  (lambda ()
+    (elixir-ts-mode)
+    (newline)
+    (indent-for-tab-command))
+
+Name: New list item
+
+=-=
+[
+  :foo,$
+]
+=-=
+[
+  :foo,
+  $
+]
+=-=-=
-- 
2.40.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: Improve sigil fontification for elixir-ts-mode --]
[-- Type: text/x-patch, Size: 1406 bytes --]

From 1054d917a6dbecc26f3c49e3e1383ee0c26f2a7a Mon Sep 17 00:00:00 2001
From: Wilhelm H Kirschbaum <wkirschbaum@gmail.com>
Date: Sun, 2 Apr 2023 11:28:27 +0200
Subject: [PATCH 2/2] Improve sigil fontification for elixir-ts-mode

lisp/progmodes/elixir-ts-mode.el (elixir-ts--font-lock-settings):
Update sigil queries.
---
 lisp/progmodes/elixir-ts-mode.el | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/lisp/progmodes/elixir-ts-mode.el b/lisp/progmodes/elixir-ts-mode.el
index d09beafb77a..576afd8104f 100644
--- a/lisp/progmodes/elixir-ts-mode.el
+++ b/lisp/progmodes/elixir-ts-mode.el
@@ -457,16 +457,13 @@ elixir-ts--font-lock-settings
    :override t
    `((sigil
       (sigil_name) @elixir-ts-font-sigil-name-face
-      quoted_start: _ @font-lock-string-face
-      quoted_end: _ @font-lock-string-face
-      (:match "^[sSwWpP]$" @elixir-ts-font-sigil-name-face))
+      (:match "^[sSwWpPUD]$" @elixir-ts-font-sigil-name-face))
      @font-lock-string-face
      (sigil
+      "~" @font-lock-string-face
       (sigil_name) @elixir-ts-font-sigil-name-face
-      quoted_start: _ @font-lock-regex-face
-      quoted_end: _ @font-lock-regex-face
       (:match "^[rR]$" @elixir-ts-font-sigil-name-face))
-     @font-lock-regex-face
+     @font-lock-regexp-face
      (sigil
       "~" @font-lock-string-face
       (sigil_name) @elixir-ts-font-sigil-name-face
-- 
2.40.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-02  9:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-02  9:33 bug#62611: 30.0.50; Improvements for elixir-ts-mode Wilhelm Kirschbaum

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