[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/dart-mode eca3f15 105/192: Add the ability to autocomplete
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/dart-mode eca3f15 105/192: Add the ability to autocomplete parameters |
Date: |
Sun, 29 Aug 2021 11:01:59 -0400 (EDT) |
branch: elpa/dart-mode
commit eca3f153c058c713a1c2c91f1a067a003130d625
Author: Natalie Weizenbaum <nex342@gmail.com>
Commit: Natalie Weizenbaum <nex342@gmail.com>
Add the ability to autocomplete parameters
---
dart-mode.el | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 49 insertions(+), 1 deletion(-)
diff --git a/dart-mode.el b/dart-mode.el
index 180583f..ac4f41c 100644
--- a/dart-mode.el
+++ b/dart-mode.el
@@ -423,6 +423,7 @@ Any stderr is logged using dart-log. Returns nil if the
exit code is non-0."
(define-key dart-mode-map (kbd "C-c C-r") 'dart-find-member-refs)
(define-key dart-mode-map (kbd "C-c C-t") 'dart-find-top-level-decls)
(define-key dart-mode-map (kbd "M-/") 'dart-expand)
+(define-key dart-mode-map (kbd "M-?") 'dart-expand-parameters)
;;; CC indentation support
@@ -1383,7 +1384,8 @@ defaults to the command globally bound to M-/."
(if (not dart-enable-analysis-server)
(call-interactively dart-expand-fallback t)
- (if (and (eq last-command 'dart-expand) dart--last-expand-results)
+ (if (and (memq last-command '(dart-expand dart-expand-parameters))
+ dart--last-expand-results)
(progn
(incf dart--last-expand-index)
(when (>= dart--last-expand-index (length dart--last-expand-results))
@@ -1503,6 +1505,52 @@ If FIRST is non-nil, this is the first completion event
for this completion."
(when return-type (insert " → " return-type)))
(buffer-string))))
+(defun dart-expand-parameters ()
+ "Adds parameters to the currently-selected `dart-expand' completion.
+
+This will select the first parameter, if one exists."
+ (interactive "*")
+ (when (and (eq last-command 'dart-expand)
+ dart--last-expand-results)
+ (dart--json-let (elt dart--last-expand-results dart--last-expand-index)
+ ((parameter-names parameterNames)
+ (argument-string defaultArgumentListString)
+ (argument-ranges defaultArgumentListTextRanges))
+ (when parameter-names
+ (setq argument-string (or argument-string ""))
+ (setq argument-ranges (or argument-ranges [0 0]))
+
+ (save-excursion
+ (insert ?\( argument-string ?\)))
+ (incf dart--last-expand-length (+ (length argument-string) 2))
+
+ (setq transient-mark-mode nil)
+ (forward-char (+ 1 (elt argument-ranges 0)))
+ (push-mark nil t)
+ (forward-char (elt argument-ranges 1))
+
+ ;; Run this in a timer because `activate-mark' doesn't seem to work
+ ;; directly, and because we don't want to disable
`delete-selection-mode'
+ ;; after this command.
+ (run-at-time
+ "0 sec" nil
+ (lambda ()
+ (activate-mark)
+
+ ;; Overwrite the current selection, but don't globally enable
+ ;; delete-selection-mode.
+ (unless delete-selection-mode
+ (delete-selection-mode 1)
+ (add-hook 'post-command-hook 'dart--disable-highlight t t))))))))
+
+(defun dart--disable-highlight ()
+ "Disables `delete-selection-mode' and deactivates the mark.
+
+Also removes this function from `post-command-hook'."
+ (deactivate-mark)
+ (delete-selection-mode 0)
+ (remove-hook 'post-command-hook 'dart--disable-delete-selection-mode t))
+
;;; Popup Mode
- [nongnu] elpa/dart-mode be9e422 077/192: Fix a bunch of byte-compilation warnings., (continued)
- [nongnu] elpa/dart-mode be9e422 077/192: Fix a bunch of byte-compilation warnings., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode e6635b3 084/192: Bump version to 0.15. (#38), ELPA Syncer, 2021/08/29
- [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 <=
- [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, 2021/08/29
- [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