[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/git-commit c1def98185 2/2: magit--minibuf-default-add-comm
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/git-commit c1def98185 2/2: magit--minibuf-default-add-commit: Fix position of commit |
Date: |
Wed, 31 Aug 2022 23:58:36 -0400 (EDT) |
branch: elpa/git-commit
commit c1def981857614f737561ff38bac89fc19d4bc21
Author: Kyle Meyer <kyle@kyleam.com>
Commit: Kyle Meyer <kyle@kyleam.com>
magit--minibuf-default-add-commit: Fix position of commit
Functions for reading commits let-bind minibuffer-default-add-function
to magit--minibuf-default-add-commit in order to add the commit at
point to the minibuffer's "next history". However, the added commit
isn't actually accessible via M-n, at least with default completion.
Instead an 'M-n M-n M-p' sequence is needed to reach it.
The problem is that goto-history-element expects the value returned by
minibuffer-default-add-function to include minibuffer-default, and, if
there is a non-nil default that's not the same as the commit,
magit--minibuf-default-add-commit puts the commit upstream of the next
position that goto-history-element selects.
Fix this issue by making minibuffer-default-add-function insert
minibuffer-default in the front of the list, in the same way as
minibuffer-default-add-completions does. When there is a default
other than the commit at point, the commit is accessible via 'M-n
M-n'.
Notes on two third-party completion frameworks:
* With ivy, the let-bound minibuffer-default-add-function doesn't
seem to have an effect, while using minibuffer-with-setup-hook, as
is done in the Emacs code base, does. That's worth considering as
a future change.
* With helm, the minibuffer-selected-window call in
magit--minibuf-default-add-commit selects a helm window rather than
the expected window, so the commit isn't returned. We could work
around that by binding the magit-commit-at-point return value
outside of the lambda, though that might be a bit too much special
handling for one completion framework.
Fixes #4740.
---
lisp/magit-git.el | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index 0cc8c09390..e2fdb9b5c7 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -2430,7 +2430,11 @@ and this option only controls what face is used.")
(lambda ()
(if-let ((commit (with-selected-window (minibuffer-selected-window)
(magit-commit-at-point))))
- (cons commit (delete commit (funcall fn)))
+ (let ((rest (cons commit (delete commit (funcall fn))))
+ (def minibuffer-default))
+ (if (listp def)
+ (append def rest)
+ (cons def (delete def rest))))
(funcall fn)))))
(defun magit-read-branch (prompt &optional secondary-default)