[Utils] Add simple way to add external bookmarks
This commit is contained in:
parent
7252c1ddf4
commit
c77cd7e889
5
init.el
5
init.el
|
@ -202,6 +202,7 @@
|
|||
(bind-key "C-x C-r" #'revert-buffer)
|
||||
(bind-key "C-x g" #'db/helm-shortcuts)
|
||||
(bind-key "C-x SPC" #'hydra-rectangle/body)
|
||||
(bind-key "C-x r M" #'db/bookmark-add-url)
|
||||
(bind-key "C-x r v" #'list-registers)
|
||||
(bind-key "C-x t" #'hydra-toggle/body)
|
||||
(bind-key "C-z" #'undo)
|
||||
|
@ -530,7 +531,9 @@
|
|||
hydra-rectangle/body
|
||||
db/two-monitors-xrandr
|
||||
db/one-monitor-xrandr
|
||||
db/pretty-print-xml))
|
||||
db/pretty-print-xml
|
||||
db/bookmark-add-external
|
||||
db/bookmark-add-url))
|
||||
|
||||
(use-package hydra
|
||||
:commands (defhydra))
|
||||
|
|
|
@ -542,6 +542,34 @@ _h_ _l_ _o_k _y_ank
|
|||
(call-process "xrandr" nil nil nil
|
||||
"--output" "HDMI-3" "--off"))
|
||||
|
||||
|
||||
;;; Bookmarks
|
||||
|
||||
(defun db/bookmark-add-with-handler (name location handler)
|
||||
"Add NAME as bookmark to LOCATION and use HANDLER to open it.
|
||||
HANDLER is a function receiving a single argument, namely
|
||||
LOCATION. If a bookmark named NAME is already present, replace
|
||||
it."
|
||||
(when (assoc name bookmark-alist)
|
||||
(setq bookmark-alist
|
||||
(cl-delete-if #'(lambda (bmk) (equal (car bmk) name))
|
||||
bookmark-alist)))
|
||||
(push `(,name
|
||||
(filename . ,location)
|
||||
(handler . ,#'(lambda (arg)
|
||||
(funcall handler (cdr (assoc 'filename arg))))))
|
||||
bookmark-alist))
|
||||
|
||||
(defun db/bookmark-add-external (location name)
|
||||
"Add NAME as bookmark to LOCATION that is opened by the operating system."
|
||||
(interactive "sLocation: \nsName: ")
|
||||
(db/bookmark-add-with-handler name location #'db/system-open))
|
||||
|
||||
(defun db/bookmark-add-url (url name)
|
||||
"Add NAME as bookmark to URL that is opened by `browse-url’."
|
||||
(interactive "sURL: \nsName: ")
|
||||
(db/bookmark-add-with-handler name url #'browse-url))
|
||||
|
||||
|
||||
;;; End
|
||||
|
||||
|
|
Loading…
Reference in New Issue