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

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

[nongnu] elpa/julia-mode c87949315f 02/22: Remove hack for indentation i


From: ELPA Syncer
Subject: [nongnu] elpa/julia-mode c87949315f 02/22: Remove hack for indentation in strings
Date: Thu, 4 May 2023 11:00:51 -0400 (EDT)

branch: elpa/julia-mode
commit c87949315f81f8744d4ddef821a92bc56b61224b
Author: Adam Beckmeyer <adam_gpg@thebeckmeyers.xyz>
Commit: Adam Beckmeyer <adam_gpg@thebeckmeyers.xyz>

    Remove hack for indentation in strings
---
 julia-mode.el | 78 +++++++++++++++++++++++++++--------------------------------
 1 file changed, 35 insertions(+), 43 deletions(-)

diff --git a/julia-mode.el b/julia-mode.el
index cbd6f39112..b15b182486 100644
--- a/julia-mode.el
+++ b/julia-mode.el
@@ -365,6 +365,12 @@ As a result, it is true inside \"foo\", `foo` and 'f'."
      ;; of overlapping triple-quotes with first escaped
      ((backward-char 2)))))
 
+(defun julia-in-multiline-string (&optional syntax-pps)
+  "Return non-nil if point is inside multi-line string using SYNTAX-PPS."
+  (and (julia-in-string syntax-pps)
+       (save-excursion (beginning-of-line)
+                       (julia-in-string syntax-pps))))
+
 (defun julia-in-brackets ()
   "Return non-nil if point is inside square brackets."
   (let ((start-pos (point))
@@ -573,19 +579,6 @@ only comments."
             ;; above
             (+ julia-indent-offset prev-indent)))))))
 
-(defun julia-indent-in-string ()
-  "Indentation inside strings with newlines is \"manual\",
-meaning always increase indent on TAB and decrease on S-TAB."
-  (save-excursion
-    (beginning-of-line)
-    (when (julia-in-string)
-      (if (member this-command '(julia-latexsub-or-indent
-                                 ess-indent-or-complete))
-          (+ julia-indent-offset (current-indentation))
-        ;; return the current indentation to prevent other functions from
-        ;; indenting inside strings
-        (current-indentation)))))
-
 (defun julia-indent-import-export-using ()
   "Indent offset for lines that follow `import` or `export`, otherwise nil."
   (when (julia-following-import-export-using)
@@ -594,37 +587,36 @@ meaning always increase indent on TAB and decrease on 
S-TAB."
 (defun julia-indent-line ()
   "Indent current line of julia code."
   (interactive)
-  (let* ((point-offset (- (current-column) (current-indentation))))
-    (indent-line-to
-     (or
-      ;; note: if this first function returns nil the beginning of the line
-      ;; cannot be in a string
-      (julia-indent-in-string)
-      ;; indent due to hanging operators (lines ending in an operator)
-      (julia-indent-hanging)
-      ;; indent for import and export
-      (julia-indent-import-export-using)
-      ;; use julia-paren-indent along with block indentation
-      (let ((paren-indent (or (julia-paren-indent) 0)))
-        ;; Indent according to how many nested blocks we are in.
-        (save-excursion
-          (beginning-of-line)
-          ;; jump out of any comments
-          (let ((state (syntax-ppss)))
-            (when (nth 4 state)
-              (goto-char (nth 8 state))))
-          (forward-to-indentation 0)
-          (let ((endtok (julia-at-keyword julia-block-end-keywords))
+  (if (julia-in-multiline-string)
+      'noindent
+    (let* ((point-offset (- (current-column) (current-indentation))))
+      (indent-line-to
+       (or
+        ;; indent due to hanging operators (lines ending in an operator)
+        (julia-indent-hanging)
+        ;; indent for import and export
+        (julia-indent-import-export-using)
+        ;; use julia-paren-indent along with block indentation
+        (let ((paren-indent (or (julia-paren-indent) 0)))
+          ;; Indent according to how many nested blocks we are in.
+          (save-excursion
+            (beginning-of-line)
+            ;; jump out of any comments
+            (let ((state (syntax-ppss)))
+              (when (nth 4 state)
+                (goto-char (nth 8 state))))
+            (forward-to-indentation 0)
+            (let ((endtok (julia-at-keyword julia-block-end-keywords))
                 (last-open-block (julia-last-open-block (- (point) 
julia-max-block-lookback))))
-            (max paren-indent (- (or last-open-block paren-indent)
-                                 ;; subtract indentation if we're at the end 
of a block
-                                 (if (or endtok
-                                         (julia-at-keyword 
julia-block-start-keywords-no-indent))
-                                     julia-indent-offset 0))))))))
-    ;; Point is now at the beginning of indentation, restore it
-    ;; to its original position (relative to indentation).
-    (when (>= point-offset 0)
-      (move-to-column (+ (current-indentation) point-offset)))))
+              (max paren-indent (- (or last-open-block paren-indent)
+                                   ;; subtract indentation if we're at the end 
of a block
+                                   (if (or endtok
+                                           (julia-at-keyword 
julia-block-start-keywords-no-indent))
+                                       julia-indent-offset 0))))))))
+      ;; Point is now at the beginning of indentation, restore it
+      ;; to its original position (relative to indentation).
+      (when (>= point-offset 0)
+        (move-to-column (+ (current-indentation) point-offset))))))
 
 
 ;;; Navigation



reply via email to

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