cmd/guru: emacs: report most specific element in expand-region
Keep the leftmost element when removing duplicates, so that we report "function call" instead of "expression statement". Also split go-guru--enclosing into two functions. Change-Id: Ie325613e292e36dda9558eda54bc7323fbf0bc6d Reviewed-on: https://go-review.googlesource.com/22132 Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
321c6fd171
commit
837ce23ea3
|
@ -453,9 +453,16 @@ timeout."
|
|||
;; of an identifier.
|
||||
|
||||
(defun go-guru--enclosing ()
|
||||
"Return a list of enclosing regions, with duplicates removed."
|
||||
(let ((enclosing (cdr (assoc 'enclosing (go-guru-what)))))
|
||||
"Return a list of enclosing regions."
|
||||
(cdr (assoc 'enclosing (go-guru-what))))
|
||||
|
||||
(defun go-guru--enclosing-unique ()
|
||||
"Return a list of enclosing regions, with duplicates removed.
|
||||
Two regions are considered equal if they have the same start and
|
||||
end point."
|
||||
(let ((enclosing (go-guru--enclosing)))
|
||||
(cl-remove-duplicates enclosing
|
||||
:from-end t
|
||||
:test (lambda (a b)
|
||||
(and (= (cdr (assoc 'start a))
|
||||
(cdr (assoc 'start b)))
|
||||
|
@ -467,7 +474,7 @@ timeout."
|
|||
(interactive)
|
||||
(let* ((enclosing (if (eq last-command #'go-guru-expand-region)
|
||||
go-guru--last-enclosing
|
||||
(go-guru--enclosing)))
|
||||
(go-guru--enclosing-unique)))
|
||||
(block (if (> (length enclosing) 0) (elt enclosing 0))))
|
||||
(when block
|
||||
(goto-char (1+ (cdr (assoc 'start block))))
|
||||
|
|
Loading…
Reference in New Issue