Is it possible to combine the following two functions so that the combined function will work with the keyboard keys (e.g., [return]
) and also work with the mouse buttons? If so, how please?
Background: The functions are custom creations for an addition to dired-mode that propertizes the dired heading directory (i.e., the path at the top of the dired buffer) with links to open new dired buffers -- e.g., bredcrumbs -- Dired heading directory with text-properties to jump to parent directories
(defun dired-follow-link-with-mouse (event)
"Follow the link in the dired directory heading, causing a new
dired buffer to be opened."
(interactive "e")
(mouse-set-point event)
(let ((path (get-text-property (point) 'breadcrumb)))
(dired path)))
(defun dired-follow-link-without-mouse ()
"Follow the link in the dired directory heading, causing a new
dired buffer to be opened."
(interactive)
(let ((path (get-text-property (point) 'breadcrumb)))
(dired path)))
(defvar dired-mouse-map
(let ((map (make-sparse-keymap)))
(define-key map [mouse-2] 'dired-follow-link-with-mouse)
(define-key map [return] 'dired-follow-link-without-mouse)
(define-key map [follow-link] 'mouse-face)
map)
"Keymap for mouse when in `dired-mode'.")