[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode 17a7d8a 370/495: cmd/guru: emacs: add function for
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode 17a7d8a 370/495: cmd/guru: emacs: add function for expandiong region |
Date: |
Sat, 7 Aug 2021 09:05:50 -0400 (EDT) |
branch: elpa/go-mode
commit 17a7d8ae3f95eba1047debe97dc6b2b0d75b3604
Author: Dominik Honnef <dominik@honnef.co>
Commit: Dominik Honnef <dominik@honnef.co>
cmd/guru: emacs: add function for expandiong region
The go-guru-expand-region function uses the "what" query to determine
the enclosing regions. Consecutive calls to go-guru-expand-region will
reuse a cached version of the list.
Change-Id: Ice9ac5540c1b639c6cbdc505866bbab347be1e98
Reviewed-on: https://go-review.googlesource.com/21754
Reviewed-by: Alan Donovan <adonovan@google.com>
---
guru_import/cmd/guru/go-guru.el | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/guru_import/cmd/guru/go-guru.el b/guru_import/cmd/guru/go-guru.el
index b79fe82..564791b 100644
--- a/guru_import/cmd/guru/go-guru.el
+++ b/guru_import/cmd/guru/go-guru.el
@@ -73,6 +73,10 @@
nil
"The global timer used for highlighting identifiers.")
+(defvar go-guru--last-enclosing
+ nil
+ "The remaining enclosing regions of the previous go-expand-region
invocation.")
+
;; Extend go-mode-map.
(let ((m (define-prefix-command 'go-guru-map)))
(define-key m "d" #'go-guru-describe)
@@ -85,7 +89,8 @@
(define-key m "s" #'go-guru-callstack) ; s for stack
(define-key m "e" #'go-guru-whicherrs) ; e for error
(define-key m "<" #'go-guru-callers)
- (define-key m ">" #'go-guru-callees))
+ (define-key m ">" #'go-guru-callees)
+ (define-key m "x" #'go-guru-expand-region)) ;; x for expand
(define-key go-mode-map (kbd "C-c C-o") #'go-guru-map)
@@ -447,6 +452,31 @@ timeout."
;; TODO(dominikh): a future feature may be to cycle through all uses
;; of an identifier.
+(defun go-guru--enclosing ()
+ "Return a list of enclosing regions, with duplicates removed."
+ (let ((enclosing (cdr (assoc 'enclosing (go-guru-what)))))
+ (cl-remove-duplicates enclosing
+ :test (lambda (a b)
+ (and (= (cdr (assoc 'start a))
+ (cdr (assoc 'start b)))
+ (= (cdr (assoc 'end a))
+ (cdr (assoc 'end b))))))))
+
+(defun go-guru-expand-region ()
+ "Expand region to the next enclosing syntactic unit."
+ (interactive)
+ (let* ((enclosing (if (eq last-command #'go-guru-expand-region)
+ go-guru--last-enclosing
+ (go-guru--enclosing)))
+ (block (if (> (length enclosing) 0) (elt enclosing 0))))
+ (when block
+ (goto-char (1+ (cdr (assoc 'start block))))
+ (set-mark (1+ (cdr (assoc 'end block))))
+ (setq go-guru--last-enclosing (subseq enclosing 1))
+ (message "Region: %s" (cdr (assoc 'desc block)))
+ (setq deactivate-mark nil))))
+
+
(provide 'go-guru)
;;; go-guru.el ends here
- [nongnu] elpa/go-mode d17d210 489/495: Improve go-fontify-variables logic., (continued)
- [nongnu] elpa/go-mode d17d210 489/495: Improve go-fontify-variables logic., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 3497434 495/495: Fix fontification of chained map types., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 8d1594f 295/495: Automatically detect goimports, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 734d523 488/495: Move some defconsts up to fix compiler warnings., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 51f507c 315/495: Complete list of commands in mode docstring, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 004575e 330/495: Don't leave godef buffer around, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 409cc64 344/495: cmd/oracle: usability improvements to "describe", "referrers", ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode d9d47fa 332/495: go.tools/oracle: change -ptalog default to ""., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode bd236e5 367/495: cmd/guru: emacs: update default-directory, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 2db2ff6 333/495: go.tools/oracle: change -pos flag syntax from "file pos-pos" to file:pos-pos., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 17a7d8a 370/495: cmd/guru: emacs: add function for expandiong region,
ELPA Syncer <=
- [nongnu] elpa/go-mode dbc9124 378/495: Move go-guru.el to top level, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode b949a9b 363/495: cmd/guru: emacs: add go-guru-debug variable, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 04a2946 380/495: Merge branch 'import-guru', ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 259110b 396/495: Use a named function for before-change-functions., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode d964767 399/495: Use forward-word-strictly when available, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 7c38d6a 477/495: Improve commenting partial lines., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 24990df 400/495: Some simple style fixes for issues found by checkdoc, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 10d6ab4 486/495: Allow leading spaces for compilation error message, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode e79970d 224/495: fix beginning-of-defun for abs(count) > 1, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode cec546c 306/495: Clarify some points in NEWS, ELPA Syncer, 2021/08/07