[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode c94ca2e 064/495: refactor
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode c94ca2e 064/495: refactor |
Date: |
Sat, 7 Aug 2021 09:04:44 -0400 (EDT) |
branch: elpa/go-mode
commit c94ca2e023002f4fe0b4f0dde305dc37429915a8
Author: Dominik Honnef <dominikh@fork-bomb.org>
Commit: Dominik Honnef <dominikh@fork-bomb.org>
refactor
---
go-mode.el | 69 +++++++++++++++++++++++++++++++-------------------------------
1 file changed, 34 insertions(+), 35 deletions(-)
diff --git a/go-mode.el b/go-mode.el
index af962e5..d345750 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -161,53 +161,52 @@ built-ins, functions, and some types.")
(go-goto-beginning-of-string-or-comment)
(backward-char))))))
-(defun go-indentation-at-point (point)
+(defun go-indentation-at-point ()
(save-excursion
(let (start-nesting (outindent 0))
- (goto-char point)
(back-to-indentation)
- (if (go-in-string-p)
- (current-indentation)
- (setq start-nesting (go-paren-level))
- (if (looking-at "[])}]")
- (progn
- (go-goto-opening-parenthesis (char-after))
- (if (go-previous-line-has-dangling-op-p)
- (- (current-indentation) tab-width)
- (current-indentation)))
- (go--backward-irrelevant t)
- (if (looking-back go-dangling-operators-regexp)
- ;; only one nesting for all dangling operators in one operation
- (if (go-previous-line-has-dangling-op-p)
- (current-indentation)
- (+ (current-indentation) tab-width))
- (go--backward-irrelevant)
- (if (= (go-paren-level) 0)
- 0
- (go-goto-opening-parenthesis)
- (if (< (go-paren-level) start-nesting)
- (progn
- (if (go-previous-line-has-dangling-op-p)
- (setq outindent tab-width))
- (+ (current-indentation) tab-width (- outindent)))
- (- (current-indentation) outindent)))))))))
+ (setq start-nesting (go-paren-level))
+
+ (cond
+ ((go-in-string-p)
+ (current-indentation))
+ ((looking-at "[])}]")
+ (go-goto-opening-parenthesis (char-after))
+ (if (go-previous-line-has-dangling-op-p)
+ (- (current-indentation) tab-width)
+ (current-indentation)))
+ ((progn (go--backward-irrelevant t) (looking-back
go-dangling-operators-regexp))
+ ;; only one nesting for all dangling operators in one operation
+ (if (go-previous-line-has-dangling-op-p)
+ (current-indentation)
+ (+ (current-indentation) tab-width)))
+ ((progn (= (go-paren-level) 0))
+ 0)
+ ((progn (go-goto-opening-parenthesis) (< (go-paren-level)
start-nesting))
+ (if (go-previous-line-has-dangling-op-p)
+ (current-indentation)
+ (+ (current-indentation) tab-width)))
+ (t
+ (current-indentation))))))
(defun go-mode-indent-line ()
(interactive)
- (let ((indent (go-indentation-at-point (point)))
+ (let (indent
shift-amt
end
(pos (- (point-max) (point)))
(point (point))
- (beg (progn (beginning-of-line) (point))))
+ (beg (line-beginning-position)))
(back-to-indentation)
- (if (go-in-comment-p) ;; Do not change the indentation of multi-line
comments
+ (if (go-in-comment-p)
(goto-char point)
- (if (looking-at "case .+:\\|default:")
- (setq indent (- indent tab-width)))
- (if (and (looking-at "[[:word:]]+:\\([[:space:]]*/.+\\)?$")
- (not (looking-at "default:")))
- (setq indent 0))
+ (setq indent (go-indentation-at-point))
+ (cond
+ ((looking-at "case .+:\\|default:")
+ (setq indent (- indent tab-width)))
+ ((looking-at "[[:word:]]+:\\([[:space:]]*/.+\\)?$")
+ (setq indent 0)))
+
(setq shift-amt (- indent (current-column)))
(if (zerop shift-amt)
nil
- [nongnu] elpa/go-mode 438f671 082/495: update documentation, (continued)
- [nongnu] elpa/go-mode 438f671 082/495: update documentation, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode c2366b2 084/495: formatting, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode fb9ab02 087/495: buffer-file-truename is an *abbreviated* truename, so use file-truename instead., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 745c437 092/495: style fixes, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode c833b77 094/495: Fix cache invalidation for dangling operator cache, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 87c8b6e 096/495: do not use dangling op cache when buffer is narrowed, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 8e19ae5 097/495: add some documentation, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode b5960fe 099/495: nicer messages in gofmt, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 939d630 100/495: style fixes, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 47b3928 102/495: disable read-only on error buffer before trying to write to it, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode c94ca2e 064/495: refactor,
ELPA Syncer <=
- [nongnu] elpa/go-mode 6b77ff1 065/495: allow disabling fontification for function/method calls, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 02d44df 067/495: add function for downloading playgrounds into emacs, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode ec6fef4 066/495: Define a customization group for go-mode, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 856eff3 105/495: Instead of relying on gofmt's -d flag, use diff -n directly. This, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode d5839a0 106/495: use kill-whole-line directly, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode e1bb58a 109/495: Update README because go-mode.el is now upstream, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode b1bb0e0 111/495: replace shell-command-on-region with call-process-region, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 9f1f94e 113/495: use own implementation of go--string-prefix-p because it has been added in Emacs 24 and people are still using Emacs 23, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 22192f7 121/495: use featurep instead of version string to check for xemacs, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 3b0efdd 132/495: docstrings, ELPA Syncer, 2021/08/07