emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/graphql-mode 92136cf9b5 4/4: Merge pull request #50 from f


From: ELPA Syncer
Subject: [nongnu] elpa/graphql-mode 92136cf9b5 4/4: Merge pull request #50 from flooose/feature/better-indent-in-polymode
Date: Sat, 16 Jul 2022 04:58:34 -0400 (EDT)

branch: elpa/graphql-mode
commit 92136cf9b5a4dcd8c202c8dba9064b497776d2f7
Merge: daeb5557a9 5975f0dd5c
Author: David Vázquez Púa <davazp@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #50 from flooose/feature/better-indent-in-polymode
    
    Basic support for better indenting in polymode
---
 graphql-mode.el | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/graphql-mode.el b/graphql-mode.el
index c5e0d4bf58..4a85fa18a1 100644
--- a/graphql-mode.el
+++ b/graphql-mode.el
@@ -157,10 +157,8 @@ Please install it and try again."))
 (defun graphql-beginning-of-query ()
   "Move the point to the beginning of the current query."
   (interactive)
-  (while (and (> (point) (point-min))
-              (or (> (current-indentation) 0)
-                  (> (car (syntax-ppss)) 0)))
-    (forward-line -1)))
+  (goto-char (syntax-ppss-toplevel-pos (syntax-ppss (point-at-bol))))
+  (back-to-indentation))
 
 (defun graphql-end-of-query ()
   "Move the point to the end of the current query."
@@ -312,7 +310,12 @@ Please install it and try again."))
 (defun graphql-indent-line ()
   "Indent GraphQL schema language."
   (let ((position (point))
+        (column)
         (indent-pos))
+    (save-excursion
+      (graphql-beginning-of-query)
+      (setq column (current-column)))
+
     (save-excursion
       (let ((level (car (syntax-ppss (point-at-bol)))))
 
@@ -320,7 +323,7 @@ Please install it and try again."))
         (when (looking-at "\\s-*\\s)")
           (setq level (1- level)))
 
-        (indent-line-to (* graphql-indent-level level))
+        (indent-line-to (+ column (* graphql-indent-level level)))
         (setq indent-pos (point))))
 
     (when (< position indent-pos)



reply via email to

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