[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#63911: Dired Open With
From: |
Juri Linkov |
Subject: |
bug#63911: Dired Open With |
Date: |
Mon, 05 Jun 2023 19:07:49 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) |
Tags: patch
As requested in bug#63875, here is a new context submenu "Open With" in Dired:
diff --git a/lisp/dired.el b/lisp/dired.el
index e70467ca53b..a295ece128d 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -2504,17 +2504,33 @@ dired-mode-operate-menu
["Delete Image Tag..." image-dired-delete-tag
:help "Delete image tag from current or marked files"]))
+(declare-function mailcap-file-default-commands "mailcap" (files))
+
(defun dired-context-menu (menu click)
"Populate MENU with Dired mode commands at CLICK."
(when (mouse-posn-property (event-start click) 'dired-filename)
(define-key menu [dired-separator] menu-bar-separator)
- (let ((easy-menu (make-sparse-keymap "Immediate")))
+ (require 'mailcap nil t)
+ (let* ((filename (save-excursion
+ (mouse-set-point click)
+ (dired-get-filename nil t)))
+ (commands (mailcap-file-default-commands (list filename)))
+ (easy-menu (make-sparse-keymap "Immediate")))
(easy-menu-define nil easy-menu nil
- '("Immediate"
+ `("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"]))
+ :help "Edit file at mouse click in other window"]
+ ,@(when commands
+ (list (cons "Open With"
+ (mapcar (lambda (command)
+ `[,command
+ (lambda ()
+ (interactive)
+ (dired-do-async-shell-command
+ ,command nil (list ,filename)))])
+ commands))))))
(dolist (item (reverse (lookup-key easy-menu [menu-bar immediate])))
(when (consp item)
(define-key menu (vector (car item)) (cdr item))))))
- bug#63911: Dired Open With,
Juri Linkov <=