branch: master
commit a1deb86ae498a3c0fce163ad57d276693e2875fb
Author: Clément Pit--Claudel <[email protected]>
Commit: Clément Pit--Claudel <[email protected]>
Show default buffer when automatically attaching
---
realgud/common/buffer/source.el | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/realgud/common/buffer/source.el b/realgud/common/buffer/source.el
index ca0ac85..1bd82b9 100644
--- a/realgud/common/buffer/source.el
+++ b/realgud/common/buffer/source.el
@@ -72,12 +72,13 @@ to be debugged."
(defun realgud--read-cmd-buf (prompt)
"Read a command buffer, prompting with PROMPT."
(let* ((cmd-bufs (cl-remove-if-not #'realgud-cmdbuf? (buffer-list)))
- (cmd-buf-names (mapcar #'buffer-name cmd-bufs)))
- (when cmd-buf-names
+ (buf-names (mapcar #'buffer-name cmd-bufs))
+ (default (car buf-names)))
+ (when buf-names
;; Use completing-read instead of read-buffer: annoyingly, ido's
;; read-buffer ignores predicates.
- (get-buffer (completing-read prompt cmd-buf-names nil t
- nil nil (car cmd-buf-names))))))
+ (setq prompt (format "%s (default: %s): " prompt default))
+ (get-buffer (completing-read prompt buf-names nil t nil nil default)))))
(defun realgud--ensure-attached (&optional src-buf)
"Try to attach SRC-BUF to a command buffer.
@@ -87,7 +88,7 @@ non-nil if association was successful. SRC-BUF defaults to
current buffer."
(setq src-buf (or src-buf (current-buffer)))
(unless (realgud-srcbuf? src-buf)
- (let ((cmd-buf (realgud--read-cmd-buf "Command buffer to associate to: ")))
+ (let ((cmd-buf (realgud--read-cmd-buf "Command buffer to attach to")))
(if cmd-buf
(realgud-srcbuf-init src-buf cmd-buf)
(message "No debugger process found to attach %s to" (buffer-name)))))