all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Gabriel <gabriel376@hotmail.com>
To: 59581@debbugs.gnu.org
Subject: bug#59581: 29.0.50; [PATCH] Add completions details to Bookmarks
Date: Fri, 25 Nov 2022 16:19:38 -0300	[thread overview]
Message-ID: <SJ0PR06MB86091171C1021EAC173EE5B88B0E9@SJ0PR06MB8609.namprd06.prod.outlook.com> (raw)

[-- 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

             reply	other threads:[~2022-11-25 19:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-25 19:19 Gabriel [this message]
2022-12-01  8:45 ` bug#59581: 29.0.50; [PATCH] Add completions details to Bookmarks Eli Zaretskii
2023-12-18 23:51   ` Karl Fogel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SJ0PR06MB86091171C1021EAC173EE5B88B0E9@SJ0PR06MB8609.namprd06.prod.outlook.com \
    --to=gabriel376@hotmail.com \
    --cc=59581@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.