[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode c97dacc 044/495: do not change the indentation of
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode c97dacc 044/495: do not change the indentation of multiline comments |
Date: |
Sat, 7 Aug 2021 09:04:40 -0400 (EDT) |
branch: elpa/go-mode
commit c97dacc0ecc2b5ba24e09ff3db750409e48624be
Author: Dominik Honnef <dominikh@fork-bomb.org>
Commit: Dominik Honnef <dominikh@fork-bomb.org>
do not change the indentation of multiline comments
---
go-mode.el | 46 ++++++++++++++++++----------------
indentation_tests/multiline_comment.go | 11 ++++++++
2 files changed, 35 insertions(+), 22 deletions(-)
diff --git a/go-mode.el b/go-mode.el
index f597dfe..039607b 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -196,28 +196,30 @@ built-ins, functions, and some types.")
(defun go-mode-indent-line ()
(interactive)
- (let ((indent (go-indentation-at-point (point)))
- shift-amt
- end
- (pos (- (point-max) (point)))
- (beg (progn (beginning-of-line) (point))))
- (back-to-indentation)
- (if (looking-at "case .+:\\|default:")
- (setq indent (- indent tab-width)))
- (beginning-of-line)
- (if (and (looking-at "^[[:space:]]*[[:word:]]+:\\([[:space:]]*/.+\\)?$")
- (not (looking-at "^[[:space:]]*default:")))
- (setq indent 0))
- (skip-chars-forward " \t")
- (setq shift-amt (- indent (current-column)))
- (if (zerop shift-amt)
- nil
- (delete-region beg (point))
- (indent-to indent))
- ;; If initial point was within line's indentation,
- ;; position after the indentation. Else stay at same point in text.
- (if (> (- (point-max) pos) (point))
- (goto-char (- (point-max) pos)))))
+ (beginning-of-line)
+ (if (not (go-in-comment-p))
+ (let ((indent (go-indentation-at-point (point)))
+ shift-amt
+ end
+ (pos (- (point-max) (point)))
+ (beg (progn (beginning-of-line) (point))))
+ (back-to-indentation)
+ (if (looking-at "case .+:\\|default:")
+ (setq indent (- indent tab-width)))
+ (beginning-of-line)
+ (if (and (looking-at
"^[[:space:]]*[[:word:]]+:\\([[:space:]]*/.+\\)?$")
+ (not (looking-at "^[[:space:]]*default:")))
+ (setq indent 0))
+ (skip-chars-forward " \t")
+ (setq shift-amt (- indent (current-column)))
+ (if (zerop shift-amt)
+ nil
+ (delete-region beg (point))
+ (indent-to indent))
+ ;; If initial point was within line's indentation,
+ ;; position after the indentation. Else stay at same point in text.
+ (if (> (- (point-max) pos) (point))
+ (goto-char (- (point-max) pos))))))
(defun go-beginning-of-defun (&optional count)
(unless count (setq count 1))
diff --git a/indentation_tests/multiline_comment.go
b/indentation_tests/multiline_comment.go
new file mode 100644
index 0000000..002f60c
--- /dev/null
+++ b/indentation_tests/multiline_comment.go
@@ -0,0 +1,11 @@
+package multilinecomment
+
+/* Some comment here
+ with my very own
+ indentation as it pleases me */
+
+func main() {
+ if true {
+ // code
+ }
+}
- [nongnu] elpa/go-mode 445d10d 032/495: do not use goto-line but forward-line instead, (continued)
- [nongnu] elpa/go-mode 445d10d 032/495: do not use goto-line but forward-line instead, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 7751f22 040/495: add test cases for indentation, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 27f6fb0 047/495: improve indentation routine by jumping around less, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 73137ff 002/495: remove autoload cookies, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 1357916 005/495: go-beginning-of-defun does not need to be interactive, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 55def23 008/495: more descriptive messages in go-goto-imports, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode ccd95ee 016/495: rename some internal functions, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 5c8a47c 030/495: use (forward-line -1) instead of (previous-line), ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 4c5493b 036/495: also load diff-mode during compilation, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode faafd90 038/495: add autoload cookies, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode c97dacc 044/495: do not change the indentation of multiline comments,
ELPA Syncer <=
- [nongnu] elpa/go-mode 5fbf6bd 048/495: remove unnecessary progns, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 8065408 051/495: formatting, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode c14eb13 061/495: more test cases, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 5dc94e8 069/495: Remove enclosing quotes in go-import-add, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 426d2df 050/495: Improve indentation speed by not trying to indent unnested lines, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode d10c4bc 020/495: use /= instead of (not (=)), ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 37181ae 021/495: add feature for removing unused imports, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode cf557a3 024/495: Merge branch 'fix/gh-2', ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 4372f5d 026/495: teach go-import-add how to uncomment imports, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 22427ec 028/495: update documentation, ELPA Syncer, 2021/08/07