[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/dart-mode d507fa1 101/192: Add a binding to re-run searche
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/dart-mode d507fa1 101/192: Add a binding to re-run searches |
Date: |
Sun, 29 Aug 2021 11:01:58 -0400 (EDT) |
branch: elpa/dart-mode
commit d507fa125a94f744ec85b16be5d01967891ab5eb
Author: Natalie Weizenbaum <nex342@gmail.com>
Commit: Natalie Weizenbaum <nex342@gmail.com>
Add a binding to re-run searches
---
dart-mode.el | 74 +++++++++++++++++++++++++++++++++++++++++++++---------------
1 file changed, 56 insertions(+), 18 deletions(-)
diff --git a/dart-mode.el b/dart-mode.el
index a3d183e..fa528be 100644
--- a/dart-mode.el
+++ b/dart-mode.el
@@ -1049,10 +1049,11 @@ minibuffer."
(interactive "P")
(-when-let (filename (buffer-file-name))
(lexical-let ((show-in-buffer show-in-buffer)
- (buffer (current-buffer)))
+ (buffer (current-buffer))
+ (pos (point)))
(dart--analysis-server-send
"analysis.getHover"
- `(("file" . ,filename) ("offset" . ,(point)))
+ `(("file" . ,filename) ("offset" . ,pos))
(lambda (response)
(-when-let* ((result (cdr (assoc 'result response)))
(hovers (cdr (assoc 'hovers result)))
@@ -1093,7 +1094,14 @@ minibuffer."
(with-current-buffer-window
"*Dart Analysis*" nil nil
(insert text)
- (dart-popup-mode))
+ (dart-popup-mode)
+
+ (setq dart--do-it-again-callback
+ (lambda ()
+ (save-excursion
+ (with-current-buffer buffer
+ (goto-char pos)
+ (dart-show-hover t))))))
(message "%s" text)))))))))))
(defconst dart--highlight-keyword-re
@@ -1208,19 +1216,27 @@ minibuffer."
`(("file" . ,filename)
("offset" . ,pos)
("includePotential" . ,(or include-potential json-false)))
- (lambda (response)
- (-when-let (result (cdr (assoc 'result response)))
- (lexical-let* ((element (cdr (assoc 'element result)))
- (name (cdr (assoc 'name element)))
- (location (cdr (assoc 'location element))))
- (dart--display-search-results
- (cdr (assoc 'id result))
- (lambda ()
- (insert "References to ")
- (insert-button
- name
- 'action (lambda (_) (dart--goto-location location)))
- (insert ":\n\n")))))))))
+ (lexical-let ((buffer (current-buffer))
+ (pos pos)
+ (include-potential include-potential))
+ (lambda (response)
+ (-when-let (result (cdr (assoc 'result response)))
+ (lexical-let* ((element (cdr (assoc 'element result)))
+ (name (cdr (assoc 'name element)))
+ (location (cdr (assoc 'location element))))
+ (dart--display-search-results
+ (cdr (assoc 'id result))
+ (lambda ()
+ (setq dart--do-it-again-callback
+ (lambda ()
+ (with-current-buffer buffer
+ (dart-find-refs pos include-potential))))
+
+ (insert "References to ")
+ (insert-button
+ name
+ 'action (lambda (_) (dart--goto-location location)))
+ (insert ":\n\n"))))))))))
(defun dart-find-member-decls (name)
"Find member declarations named NAME."
@@ -1248,12 +1264,19 @@ ARGUMENT. Displays a header beginning with HEADER in
the results."
(dart--analysis-server-send
method
(list (cons argument name))
- (lexical-let ((name name) (header header))
+ (lexical-let ((method method)
+ (argument argument)
+ (name name)
+ (header header))
(lambda (response)
(-when-let (result (cdr (assoc 'result response)))
(dart--display-search-results
(cdr (assoc 'id result))
- (lambda () (insert header name ":\n\n"))))))))
+ (lambda ()
+ (setq dart--do-it-again-callback
+ (lambda ()
+ (dart--find-by-name method argument name header)))
+ (insert header name ":\n\n"))))))))
(defun dart--display-search-results (search-id callback)
"Displays search results with the given SEARCH-ID.
@@ -1337,10 +1360,18 @@ to add a header and otherwise prepare it for displaying
results."
(put 'dart-popup-mode 'mode-class 'special)
+(defvar dart--do-it-again-callback nil
+ "A callback to call when `dart-do-it-again' is invoked.
+
+Only set in `dart-popup-mode'.")
+(make-variable-buffer-local 'dart--do-it-again-callback)
+
(defvar dart-popup-mode-map (make-sparse-keymap)
"Keymap used in Dart popup buffers.")
(set-keymap-parent dart-popup-mode-map help-mode-map)
+(define-key dart-popup-mode-map (kbd "g") 'dart-do-it-again)
+
;; Unbind help-specific keys.
(define-key dart-popup-mode-map (kbd "RET") nil)
(define-key dart-popup-mode-map (kbd "l") nil)
@@ -1352,6 +1383,13 @@ to add a header and otherwise prepare it for displaying
results."
(define-key dart-popup-mode-map (kbd "C-c C-c") nil)
(define-key dart-popup-mode-map (kbd "C-c C-f") nil)
+(defun dart-do-it-again ()
+ "Re-runs the logic that generated the current buffer."
+ (interactive)
+ (when dart--do-it-again-callback
+ (apply dart--do-it-again-callback nil)))
+
+
;;; Formatting
(defcustom dartfmt-command "dartfmt"
- [nongnu] elpa/dart-mode b380818 085/192: Adapt the gofmt-related code in go-mode.el for dartfmt. (#39), (continued)
- [nongnu] elpa/dart-mode b380818 085/192: Adapt the gofmt-related code in go-mode.el for dartfmt. (#39), ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode f5962c3 080/192: Make version check work in Emacs 25., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 93efb54 089/192: Update the version and URL and flesh out the README, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode ecf3191 091/192: Add a command to show hover information, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 0cf32d5 092/192: Highlight hover descriptions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode c4a5045 096/192: Add support for navigation, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode a1f36f4 094/192: Allow dart-show-hover to display in a new buffer, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 89a2d4e 100/192: Add a special mode for popups, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode eca3f15 105/192: Add the ability to autocomplete parameters, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode d333a73 102/192: Add an analyzer-based auto-complete, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode d507fa1 101/192: Add a binding to re-run searches,
ELPA Syncer <=
- [nongnu] elpa/dart-mode a2ab55b 114/192: Make more thorough use of dash, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode c11d02a 137/192: Remedy invalid file path format, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 8f972c0 097/192: Add support for finding references, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 848f983 104/192: Show docs for expansions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 6bc08f7 136/192: Adds failing test against dart dev, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 9c9a63e 130/192: Fix dart-format, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 1f27d03 119/192: Properly set up font-lock variables, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 6397b3d 115/192: Clean up the way the SDK is configured, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode e9cd33d 109/192: Use proper private name convention, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode a087c75 099/192: Add a result counter in search results, ELPA Syncer, 2021/08/29