Compare commits
2 Commits
c74eed5df1
...
de123f7cea
| Author | SHA1 | Date | |
|---|---|---|---|
| de123f7cea | |||
| 76815c0171 |
6
init.el
6
init.el
@ -380,6 +380,8 @@
|
||||
db/pretty-print-xml
|
||||
db/bookmark-add-external
|
||||
db/bookmark-add-url
|
||||
db/bookmark-relocate
|
||||
db/bookmark-bmenu-relocate
|
||||
db/lookup-smime-key
|
||||
db/dired-from-shell-command
|
||||
db/system-open
|
||||
@ -2363,7 +2365,9 @@ eventuelly be set to nil, however)."
|
||||
(use-package bookmark
|
||||
:init (setq bookmark-default-file (expand-file-name "bookmarks" emacs-d-userdata)
|
||||
bookmark-menu-confirm-deletion t
|
||||
bookmark-save-flag 1))
|
||||
bookmark-save-flag 1)
|
||||
:bind (:map bookmark-bmenu-mode-map
|
||||
("R" . db/bookmark-bmenu-relocate)))
|
||||
|
||||
(use-package dumb-jump
|
||||
:commands (dumb-jump-xref-activate)
|
||||
|
||||
@ -845,14 +845,14 @@ number of bytes has been inserted."
|
||||
HANDLER is a function receiving a single argument, namely
|
||||
LOCATION. If a bookmark named NAME is already present, replace
|
||||
it."
|
||||
(let ((new-record `((filename . ,location)
|
||||
(let ((new-record `((location . ,location)
|
||||
(handler . ,handler))))
|
||||
(bookmark-update-last-modified new-record)
|
||||
(bookmark-store name new-record nil)))
|
||||
|
||||
(defun db/bookmark-browse-url (bmk)
|
||||
"Extract filename from bookmark BMK and apply `browse-url' to it."
|
||||
(browse-url (bookmark-get-filename bmk)))
|
||||
(browse-url (bookmark-location bmk)))
|
||||
|
||||
;; https://takeonrules.com/2024/12/17/extending-built-in-emacs-bookmark-package/
|
||||
(put 'db/bookmark-browse-url 'bookmark-handler-type "URL")
|
||||
@ -863,7 +863,7 @@ it."
|
||||
|
||||
(defun db/bookmark-eww (bmk)
|
||||
"Extract filename from bookmark BMK and apply `eww' to it."
|
||||
(eww (bookmark-get-filename bmk)))
|
||||
(eww (bookmark-location bmk)))
|
||||
|
||||
(put 'db/bookmark-eww 'bookmark-handler-type "EWW")
|
||||
|
||||
@ -888,6 +888,41 @@ as completing instead."
|
||||
(interactive "sURL: \nsName: ")
|
||||
(db/bookmark-add-with-handler name url #'db/bookmark-eww))
|
||||
|
||||
(defun db/bookmark-relocate (bookmark-name)
|
||||
"Relocate BOOKMARK-NAME to another location.
|
||||
|
||||
Bookmarks with type “URL” or “EWW” can be set to arbitrary locations,
|
||||
all other bookmarks are handled via the default `bookmark-relocate'
|
||||
mechanism."
|
||||
(interactive (list (bookmark-completing-read "Bookmark to relocate")))
|
||||
(bookmark-maybe-load-default-file)
|
||||
(let ((bmk-type (bookmark-type-from-full-record (bookmark-get-bookmark bookmark-name))))
|
||||
;; TODO: it might be nice to use `cl-defmethod' instead for easier extensibility instead of
|
||||
;; explicitly listing all currently available link types.
|
||||
(cond
|
||||
((member bmk-type '("URL" "EWW"))
|
||||
(let ((newloc (read-string (format "Relocate %s to: " bookmark-name)
|
||||
(bookmark-location bookmark-name))))
|
||||
(when (bookmark-get-filename bookmark-name)
|
||||
(bookmark-set-filename bookmark-name nil))
|
||||
(bookmark-prop-set bookmark-name 'location newloc)
|
||||
(bookmark-update-last-modified bookmark-name)
|
||||
(setq bookmark-alist-modification-count
|
||||
(1+ bookmark-alist-modification-count))
|
||||
(when (bookmark-time-to-save-p)
|
||||
(bookmark-save))
|
||||
(bookmark-bmenu-surreptitiously-rebuild-list)))
|
||||
(t (bookmark-relocate bookmark-name)))))
|
||||
|
||||
(defun db/bookmark-bmenu-relocate ()
|
||||
"Change location of bookmark at point in `bookmark-bmenu-mode'.
|
||||
Uses `db/bookmark-relocate'."
|
||||
;; Adapted from `bookmark-bmenu-relocate'.
|
||||
(interactive nil bookmark-bmenu-mode)
|
||||
(let ((thispoint (point)))
|
||||
(db/bookmark-relocate (bookmark-bmenu-bookmark))
|
||||
(goto-char thispoint)))
|
||||
|
||||
|
||||
;;; Switching Themes
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user