Skip to content

Commit fcbd957

Browse files
committed
Using format-prompt to show default in minibuffer prompts
1 parent 3fbd08f commit fcbd957

File tree

1 file changed

+28
-20
lines changed

1 file changed

+28
-20
lines changed

dape.el

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2541,7 +2541,7 @@ CONN is inferred for interactive invocations."
25412541

25422542
(defun dape-breakpoint-log (message)
25432543
"Add log breakpoint at current line with MESSAGE.
2544-
Expressions within `{}` are interpolated."
2544+
Expressions within {} are interpolated."
25452545
(interactive
25462546
(list
25472547
(read-string "Log (Expressions within {} are interpolated): "
@@ -2684,17 +2684,17 @@ If ADD-ONLY-P is non-nil only allow adding a new watch.
26842684
If DISPLAY-P is non-nil display-p the watch buffer."
26852685
(interactive
26862686
(let* ((map (copy-keymap minibuffer-local-completion-map))
2687-
(minibuffer-local-completion-map map))
2687+
(minibuffer-local-completion-map map)
2688+
(default (or (and (region-active-p)
2689+
(buffer-substring (region-beginning) (region-end)))
2690+
(thing-at-point 'symbol))))
26882691
(define-key map " " #'self-insert-command)
26892692
(define-key map "?" #'self-insert-command)
26902693
(list (string-trim
26912694
(completing-read
2692-
"Toggle watch of expression: "
2695+
(format-prompt "Toggle watch of expression" default)
26932696
(mapcar (lambda (plist) (plist-get plist :name)) dape--watched)
2694-
nil nil nil nil
2695-
(or (and (region-active-p)
2696-
(buffer-substring (region-beginning) (region-end)))
2697-
(thing-at-point 'symbol))))
2697+
nil nil nil nil default))
26982698
nil nil t)))
26992699
(if-let* ((watched
27002700
(cl-find expression dape--watched
@@ -2718,7 +2718,8 @@ CONN is inferred by either last stopped then last created connection."
27182718
(or (dape--live-connection 'stopped t) (dape--live-connection 'last))
27192719
(if (region-active-p)
27202720
(buffer-substring (region-beginning) (region-end))
2721-
(read-string "Evaluate: " nil nil (thing-at-point 'symbol)))))
2721+
(let ((default (thing-at-point 'symbol)))
2722+
(read-string (format-prompt "Evaluate" default) nil nil default)))))
27222723
(dape--with-request-bind
27232724
((&whole body &key variablesReference result &allow-other-keys) error)
27242725
(dape--evaluate-expression conn (plist-get (dape--current-stack-frame conn) :id)
@@ -2932,9 +2933,11 @@ If REUSE-BUFFER is non-nil reuse the current buffer to display result
29322933
of memory read."
29332934
(interactive
29342935
(list (string-trim
2935-
(read-string "View memory at address: " nil nil
2936-
(when-let* ((number (thing-at-point 'number)))
2937-
(format "0x%08x" number))))))
2936+
(let ((default
2937+
(when-let* ((number (thing-at-point 'number)))
2938+
(format "0x%08x" number))))
2939+
(read-string (format-prompt "View memory at address" default)
2940+
nil nil default)))))
29382941
(let ((conn (dape--live-connection 'stopped)))
29392942
(unless (dape--capable-p conn :supportsReadMemoryRequest)
29402943
(user-error "Adapter not capable of reading memory"))
@@ -2979,16 +2982,18 @@ of memory read."
29792982
"View disassemble of instructions at ADDRESS.
29802983
If DISPLAY-P is non-nil, display buffer."
29812984
(interactive
2982-
(list (string-trim
2983-
(read-string
2984-
"Disassemble at address: " nil nil
2985+
(list
2986+
(let ((default
29852987
`(,@(when-let* ((number (thing-at-point 'number)))
29862988
(list (format "0x%08x" number)))
29872989
,@(when-let* ((conn (dape--live-connection 'stopped t))
29882990
(address (plist-get (dape--current-stack-frame conn)
29892991
:instructionPointerReference)))
29902992
(list address)))))
2991-
t))
2993+
(string-trim
2994+
(read-string (format-prompt "Disassemble at address" default) nil nil
2995+
default)))
2996+
t))
29922997
(if-let* ((conn (dape--live-connection 'stopped))
29932998
((not (dape--capable-p conn :supportsDisassembleRequest))))
29942999
(user-error "Adapter does not support disassemble")
@@ -4345,11 +4350,14 @@ current buffer with CONN config."
43454350
"Edit variable value at current line."
43464351
(dape--set-variable
43474352
(dape--live-connection 'stopped) dape--reference dape--variable
4348-
(read-string (format "Set value of %s `%s' = "
4349-
(plist-get dape--variable :type)
4350-
(plist-get dape--variable :name))
4351-
nil nil (or (plist-get dape--variable :value)
4352-
(plist-get dape--variable :result)))))
4353+
(let ((default
4354+
(or (plist-get dape--variable :value)
4355+
(plist-get dape--variable :result))))
4356+
(read-string (format-prompt "Set value of %s `%s'"
4357+
default
4358+
(plist-get dape--variable :type)
4359+
(plist-get dape--variable :name))
4360+
nil nil default))))
43534361

43544362
(dape--buffer-map dape-info-variable-value-map dape-info-variable-edit)
43554363

0 commit comments

Comments
 (0)