Philip Jackson <[email protected]> writes: > At Fri, 24 Sep 2010 22:20:45 +0100, > Philip Jackson wrote: >> >> BTW. Try `anything-completing-read' for >> `magit-completing-read-function'. Works _really_ well. > > Hmm, actually, your patch breaks other *-completing-reads (missing > colon and space). Will push a fix tomorrow (unless you beat me to it).
It was kind of intentional, though now that you mention it, I agree it was misguided. With the attached patch you can use any completing-read compatible function as magit-completing-read-function, but default displaying in form "Prompt (default <default>): " with the built-in completing-read is still handled by the completing-read wrapper and thus it doesn't bother other completing-read functions that have other means of displaying the default (which is what I wanted to achieve). Thanks for the anything-completing-read tip, it sure seems to work well with Magit. I didn't know about that package. -- Hannu
>From 91c63361323a573a86aee0203fbb6a12f954dd66 Mon Sep 17 00:00:00 2001 From: Hannu Koivisto <[email protected]> Date: Sat, 25 Sep 2010 02:21:02 +0300 Subject: [PATCH] Fix magit-completing-read prompting. Prompts are now fed to magit-completing-read in a form that makes them look ok if magit-completing-read-function is set directly to completing-read or a compatible function instead of a Magit-specific wrapper. --- magit.el | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-) diff --git a/magit.el b/magit.el index 3788926..f7dafdf 100644 --- a/magit.el +++ b/magit.el @@ -533,14 +533,15 @@ Many Magit faces inherit from this one by default." (setq iswitchb-temp-buflist (if (consp (first choices)) (mapcar #'car choices) choices))))) - (iswitchb-read-buffer (format "%s: " prompt) (or initial-input def) require-match))) + (iswitchb-read-buffer prompt (or initial-input def) require-match))) (defun magit-builtin-completing-read (prompt choices &optional predicate require-match initial-input hist def) "Magit wrapper for standard completing-read function." - (completing-read (if def - (format "%s (default %s): " prompt def) - (format "%s: " prompt)) + (completing-read (if (and def (> (length prompt) 2) + (string-equal ": " (substring prompt -2))) + (format "%s (default %s): " (substring prompt 0 -2) def) + prompt) choices predicate require-match initial-input hist def)) (defun magit-completing-read (prompt choices &optional predicate require-match @@ -856,8 +857,8 @@ pair (START . END), then the range is START..END.") (defun magit-read-rev (prompt &optional def uninteresting) (let* ((interesting-refs (magit-list-interesting-refs (or uninteresting magit-uninteresting-refs))) - (reply (magit-completing-read prompt interesting-refs nil nil nil - 'magit-read-rev-history def)) + (reply (magit-completing-read (concat prompt ": ") interesting-refs + nil nil nil 'magit-read-rev-history def)) (rev (or (cdr (assoc reply interesting-refs)) reply))) (if (string= rev "") nil @@ -919,7 +920,7 @@ pair (START . END), then the range is START..END.") "Read the name of a remote. PROMPT is used as the prompt, and defaults to \"Remote\". DEF is the default value, and defaults to the value of `magit-get-current-branch'." - (let* ((prompt (or prompt "Remote")) + (let* ((prompt (or prompt "Remote: ")) (def (or def (magit-get-current-remote))) (remotes (magit-git-lines "remote")) (reply (magit-completing-read prompt remotes @@ -3190,7 +3191,7 @@ typing and automatically refreshes the status buffer." (branch-remote (magit-get-remote branch)) (push-remote (if (or current-prefix-arg (not branch-remote)) - (magit-read-remote (format "Push %s to" branch) + (magit-read-remote (format "Push %s to: " branch) branch-remote) branch-remote)) (ref-branch (magit-get "branch" branch "merge"))) -- 1.7.0.4
