Function: dired-context-menu
dired-context-menu is a byte-compiled function defined in dired.el.gz.
Signature
(dired-context-menu MENU CLICK)
Documentation
Populate MENU with Dired mode commands at CLICK.
Source Code
;; Defined in /usr/src/emacs/lisp/dired.el.gz
(defun dired-context-menu (menu click)
"Populate MENU with Dired mode commands at CLICK."
(when (mouse-posn-property (event-start click) 'dired-filename)
(keymap-set menu "<dired-separator>" menu-bar-separator)
(let* ((filename (save-excursion
(mouse-set-point click)
(dired-get-filename nil t)))
(commands (shell-command-guess (list filename)))
(easy-menu (make-sparse-keymap "Immediate")))
(easy-menu-define nil easy-menu nil
`("Immediate"
["Find This File" dired-mouse-find-file
:help "Edit file at mouse click"]
["Find in Other Window" dired-mouse-find-file-other-window
:help "Edit file at mouse click in other window"]
,@(when shell-command-guess-open
'(["Open" dired-do-open
:help "Open this file with the default application"]))
,@(when commands
(list (cons "Open With"
(append
(mapcar (lambda (command)
`[,(or (get-text-property 0 'name command)
command)
(lambda ()
(interactive)
(dired-do-async-shell-command
,command nil (list ,filename)))])
commands)))))
,@(when (eq system-type 'windows-nt)
`(["Select system app"
(lambda ()
(interactive)
(w32-shell-execute "openas" ,filename))
:help "Choose one of the apps available on your system"]))))
(dolist (item (reverse (lookup-key easy-menu [menu-bar immediate])))
(when (consp item)
(define-key menu (vector (car item)) (cdr item))))))
menu)