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.
This commit is contained in:
Daniel - 2020-09-07 18:10:44 +02:00
parent a20b5faa42
commit c9e84a7e28
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
1 changed files with 8 additions and 2 deletions

View File

@ -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)