* bug#59581: 29.0.50; [PATCH] Add completions details to Bookmarks
@ 2022-11-25 19:19 Gabriel
2022-12-01 8:45 ` Eli Zaretskii
0 siblings, 1 reply; 3+ messages in thread
From: Gabriel @ 2022-11-25 19:19 UTC (permalink / raw)
To: 59581
[-- Attachment #1: Type: text/plain, Size: 368 bytes --]
Severity: wishlist
Description:
Add completions details (see `completions-detailed') to Bookmarks. It
affects all bookmark functions that make uses of
`bookmark-completing-read' (e.g.: `bookmark-jump', `bookmark-relocate',
`bookmark-insert-location', `bookmark-rename' etc). See also [1].
[1] https://lists.gnu.org/archive/html/emacs-devel/2022-11/msg00995.html
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-completions-details-to-Bookmarks.patch --]
[-- Type: text/x-diff, Size: 2683 bytes --]
From 188d924aaa8842c85a4d4206d6c71ca31727240e Mon Sep 17 00:00:00 2001
From: Gabriel do Nascimento Ribeiro <gabriel376@hotmail.com>
Date: Fri, 25 Nov 2022 16:07:14 -0300
Subject: [PATCH 1/1] Add completions details to Bookmarks
* lisp/bookmark.el (bookmark-completing-read--collection)
(bookmark-completing-read--affixation-function): New auxiliary
functions to add completion details to bookmark-completing-read.
(bookmark-completing-read): Make use of new auxiliary function.
---
lisp/bookmark.el | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index 7f3a264f53..9050668f4f 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -541,6 +541,23 @@ bookmark-maybe-sort-alist
(t (time-less-p ty tx)))))))
(t copy))))
+(defun bookmark-completing-read--collection (string pred action)
+ (if (eq action 'metadata)
+ `(metadata (category . bookmark)
+ ,@(when completions-detailed
+ '((affixation-function . bookmark-completing-read--affixation-function))))
+ (complete-with-action action bookmark-alist string pred)))
+
+(defun bookmark-completing-read--affixation-function (bookmarks)
+ (seq-map (lambda (record)
+ (list record
+ nil
+ (propertize (format " %-11s %s"
+ (or (bookmark-type-from-full-record record) "")
+ (bookmark-location record))
+ 'face 'completions-annotations)))
+ bookmarks))
+
(defun bookmark-completing-read (prompt &optional default)
"Prompting with PROMPT, read a bookmark name in completion.
PROMPT will get a \": \" stuck on the end no matter what, so you
@@ -555,14 +572,9 @@ bookmark-completing-read
(let* ((completion-ignore-case bookmark-completion-ignore-case)
(default (unless (equal "" default) default)))
(completing-read (format-prompt prompt default)
- (lambda (string pred action)
- (if (eq action 'metadata)
- '(metadata (category . bookmark))
- (complete-with-action
- action bookmark-alist string pred)))
+ #'bookmark-completing-read--collection
nil 0 nil 'bookmark-history default))))
-
(defmacro bookmark-maybe-historicize-string (string)
"Put STRING into the bookmark prompt history, if caller non-interactive.
We need this because sometimes bookmark functions are invoked
--
2.34.1
[-- Attachment #3: Type: text/plain, Size: 13 bytes --]
---
Gabriel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#59581: 29.0.50; [PATCH] Add completions details to Bookmarks
2022-11-25 19:19 bug#59581: 29.0.50; [PATCH] Add completions details to Bookmarks Gabriel
@ 2022-12-01 8:45 ` Eli Zaretskii
2023-12-18 23:51 ` Karl Fogel
0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2022-12-01 8:45 UTC (permalink / raw)
To: Gabriel, Karl Fogel; +Cc: 59581
> From: Gabriel <gabriel376@hotmail.com>
> Date: Fri, 25 Nov 2022 16:19:38 -0300
>
> Description:
>
> Add completions details (see `completions-detailed') to Bookmarks. It
> affects all bookmark functions that make uses of
> `bookmark-completing-read' (e.g.: `bookmark-jump', `bookmark-relocate',
> `bookmark-insert-location', `bookmark-rename' etc). See also [1].
>
> [1] https://lists.gnu.org/archive/html/emacs-devel/2022-11/msg00995.html
Karl, any comments to the patch?
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#59581: 29.0.50; [PATCH] Add completions details to Bookmarks
2022-12-01 8:45 ` Eli Zaretskii
@ 2023-12-18 23:51 ` Karl Fogel
0 siblings, 0 replies; 3+ messages in thread
From: Karl Fogel @ 2023-12-18 23:51 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Gabriel, 59581
On 01 Dec 2022, Eli Zaretskii wrote:
>> From: Gabriel <gabriel376@hotmail.com>
>> Date: Fri, 25 Nov 2022 16:19:38 -0300
>>
>> Description:
>>
>> Add completions details (see `completions-detailed') to
>> Bookmarks. It
>> affects all bookmark functions that make uses of
>> `bookmark-completing-read' (e.g.: `bookmark-jump',
>> `bookmark-relocate',
>> `bookmark-insert-location', `bookmark-rename' etc). See also
>> [1].
>>
>> [1]
>> https://lists.gnu.org/archive/html/emacs-devel/2022-11/msg00995.html
>
>Karl, any comments to the patch?
I applied this patch, reloaded bookmark.el, and then tested `M-x
bookmark-jump' in two ways:
1) With `completions-detailed' == nil (my default)
2) With `completions-detailed' == t
In case (1) I saw the expected default behavior. My bookmarks
completed normally by name, and just their names were offered
during completion.
In case (2), though, things seemed broken. The "*Completions*"
buffer says "19 possible completions:" at the top (as expected),
but the buffer is otherwise blank. And when I hit SPC or TAB at
the "Jump to bookmark:" prompt, I get "[Wrong type argument:
stringp, nil]" in the minibuffer. My "*Messages*" buffer fills
with messages like this:
Making completion list...
#<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_56>: \
Wrong type argument: stringp, nil
Similar behavior happens for all the functions that depend on
`bookmark-completing-read'.
This is in Emacs 30.0.50 (built today from 'master', commit
1d5d2f16c330e).
Gabriel, does the patch maybe need a bit of updating? I assume it
worked for in the version of Emacs you originally wrote it in
(which would be from a littl over a year ago now -- sorry for the
delay; I wish I'd been able to follow up to this sooner).
Best regards,
-Karl
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-18 23:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-25 19:19 bug#59581: 29.0.50; [PATCH] Add completions details to Bookmarks Gabriel
2022-12-01 8:45 ` Eli Zaretskii
2023-12-18 23:51 ` Karl Fogel
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.