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

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

[nongnu] elpa/go-mode a5164ac 055/495: Fix indentation for code after mu


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode a5164ac 055/495: Fix indentation for code after multi-line function signature
Date: Sat, 7 Aug 2021 09:04:42 -0400 (EDT)

branch: elpa/go-mode
commit a5164ac8bd7b7a2b3b7c11831b9c381768fe6653
Author: Dominik Honnef <dominikh@fork-bomb.org>
Commit: Dominik Honnef <dominikh@fork-bomb.org>

    Fix indentation for code after multi-line function signature
    
    Closes gh-15
---
 go-mode.el                 | 12 ++++++++++--
 indentation_tests/gh-15.go |  7 +++++++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/go-mode.el b/go-mode.el
index 4a6cdb5..14410e6 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -149,6 +149,12 @@ built-ins, functions, and some types.")
     (go--backward-irrelevant t)
     (looking-back go-dangling-operators-regexp)))
 
+(defun go-previous-line-has-opening-parenthesis-p ()
+  (save-excursion
+    (beginning-of-line)
+    (go--backward-irrelevant t)
+    (looking-back "(")))
+
 (defun go-indentation-at-point (point)
   (save-excursion
     (let (start-nesting line-begin (outindent 0))
@@ -163,7 +169,7 @@ built-ins, functions, and some types.")
                           (>= (go-paren-level) start-nesting))
                 (skip-chars-backward "^[]{}()")
                 (backward-char))
-              (if (go-previous-line-has-dangling-op-p)
+              (if (or (go-previous-line-has-dangling-op-p) 
(go-previous-line-has-opening-parenthesis-p))
                   (- (current-indentation) tab-width)
                 (current-indentation)))
           (go--backward-irrelevant t)
@@ -185,7 +191,9 @@ built-ins, functions, and some types.")
                       (go--backward-irrelevant)
                       (setq line-begin (line-beginning-position)))))
               (if (< (go-paren-level) start-nesting)
-                  (+ (current-indentation) tab-width (- outindent))
+                  (if (go-previous-line-has-opening-parenthesis-p)
+                      (current-indentation)
+                    (+ (current-indentation) tab-width (- outindent)))
                 (- (current-indentation) outindent)))))))))
 
 (defun go-mode-indent-line ()
diff --git a/indentation_tests/gh-15.go b/indentation_tests/gh-15.go
new file mode 100644
index 0000000..4494ec6
--- /dev/null
+++ b/indentation_tests/gh-15.go
@@ -0,0 +1,7 @@
+package gh15
+
+func somewhatLongFunctionName(
+       arg1 package1.RatherLongTypeName, arg2 package2.AnotherLongTypeName) {
+       return
+}
+



reply via email to

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