From c9e84a7e281209fc22f7eb32ad90ef3264021375 Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Mon, 7 Sep 2020 18:10:44 +0200 Subject: [PATCH] Offer simple completion when creating external bookmarks In dired, offer all marked files, or the currently selected file if there are none. Otherwise, just use the list of recently opened files as completing. This is meant as a very simple replacement for dired+'s dired bookmarks. --- site-lisp/db-utils.el | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/site-lisp/db-utils.el b/site-lisp/db-utils.el index f1b9a5d..0090c76 100644 --- a/site-lisp/db-utils.el +++ b/site-lisp/db-utils.el @@ -473,8 +473,14 @@ it. The bookmarks will finally be sorted by their name." (setq bookmark-alist (cl-sort bookmark-alist #'string-lessp :key #'car))) (defun db/bookmark-add-external (location name) - "Add NAME as bookmark to LOCATION that is opened by the operating system." - (interactive "sLocation: \nsName: ") + "Add NAME as bookmark to LOCATION that is opened by the operating system. +Offers simple completing from the list of recently opened files. +In dired, offer all marked files or the currently selected file +as completing instead." + (interactive (list (completing-read "Location: " (if (derived-mode-p 'dired-mode) + (dired-get-marked-files) + recentf-list)) + (read-string "Name: "))) (db/bookmark-add-with-handler name location #'db/system-open)) (defun db/bookmark-add-url (url name)