[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode e8674fe 437/495: Expand electric indent config a b
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode e8674fe 437/495: Expand electric indent config a bit |
Date: |
Sat, 7 Aug 2021 09:06:04 -0400 (EDT) |
branch: elpa/go-mode
commit e8674febca6caf6b5030808e1b10677a9fd8f503
Author: Muir Manders <muir@retailnext.net>
Commit: Peter Sanford <psanford@sanford.io>
Expand electric indent config a bit
Add an electric indent function to trigger reindent after typing "//",
"/*", or "case ". This makes it less annoying when you are adding
comments to case statements or adding a new case statement itself.
Also add ":" to electric-indent-chars. This will trigger reindent
after typing labels.
---
go-mode.el | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/go-mode.el b/go-mode.el
index 11646cc..bbc0de2 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -1113,6 +1113,21 @@ Function result is a unparenthesized type or a parameter
list."
This is intended to be called from `before-change-functions'."
(setq go-dangling-cache (make-hash-table :test 'eql)))
+(defun go--electric-indent-function (inserted-char)
+ (cond
+ ;; Indent after starting a "//" or "/*" comment.
+ ;; This is handy for comments above "case" statements.
+ ((or (eq inserted-char ?/) (eq inserted-char ?*))
+ (when (eq (char-before (1- (point))) ?/)
+ 'do-indent))
+
+ ((eq inserted-char ? )
+ (and
+ (eq (char-before (- (point) 1)) ?e)
+ (eq (char-before (- (point) 2)) ?s)
+ (eq (char-before (- (point) 3)) ?a)
+ (eq (char-before (- (point) 4)) ?c)))))
+
;;;###autoload
(define-derived-mode go-mode prog-mode "Go"
"Major mode for editing Go source text.
@@ -1196,8 +1211,9 @@ with goflymake \(see URL
`https://github.com/dougm/goflymake'), gocode
(set (make-local-variable 'parse-sexp-lookup-properties) t)
(set (make-local-variable 'syntax-propertize-function)
#'go-propertize-syntax)
- (if (boundp 'electric-indent-chars)
- (set (make-local-variable 'electric-indent-chars) '(?\n ?} ?\))))
+ (when (boundp 'electric-indent-chars)
+ (set (make-local-variable 'electric-indent-chars) '(?\n ?} ?\) ?:))
+ (add-hook 'electric-indent-functions #'go--electric-indent-function nil t))
(set (make-local-variable 'compilation-error-screen-columns) nil)
- [nongnu] elpa/go-mode 269eb01 398/495: Remove support for Emacs 23, (continued)
- [nongnu] elpa/go-mode 269eb01 398/495: Remove support for Emacs 23, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 5056b85 403/495: Use xref functions if available, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 3f02a16 406/495: Add go-guru-definition-other-window, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 7eb5b3d 409/495: Delete go-mode-autoloads.el, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 2d1d33a 407/495: Fix off-by-one in point calculations, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 7f87c32 416/495: Permit empty guru scope, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode be9186c 417/495: Support remote files in `gofmt', ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 287595a 420/495: Don't traverse symlinks when recursing directories, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode b990645 425/495: Fix call expr indenting after dangling operator., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode ac6dd8c 430/495: Fix go-remove-unused-imports, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode e8674fe 437/495: Expand electric indent config a bit,
ELPA Syncer <=
- [nongnu] elpa/go-mode 6a64cbf 439/495: Fix indentation for composite literal keys., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode fb1272c 441/495: indent: fix performance in giant comments, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode c020e2c 456/495: Fontify type names in more places., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 2a1584f 454/495: Readme: add note recommending goimports, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 57becfb 460/495: Fontify type names in interface declarations, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode cf53daa 459/495: Fix indentation in naked blocks., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode f872781 466/495: Fontify variable names., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode acec0aa 471/495: Fix Content-Type for https://play.golang.org/share, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode cad6d0a 472/495: Fix fontification performance issue, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 1fbe6a8 490/495: Fix comment filling at start of buffer., ELPA Syncer, 2021/08/07