From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#63911: Dired Open With Date: Mon, 05 Jun 2023 19:07:49 +0300 Organization: LINKOV.NET Message-ID: <86bkhuney2.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24588"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) To: 63911@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jun 05 18:40:19 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q6DFi-0006I0-Ms for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 05 Jun 2023 18:40:18 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6DFU-0004Ul-7o; Mon, 05 Jun 2023 12:40:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6DFS-0004UM-G0 for bug-gnu-emacs@gnu.org; Mon, 05 Jun 2023 12:40:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q6DFS-00046s-7C for bug-gnu-emacs@gnu.org; Mon, 05 Jun 2023 12:40:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q6DFS-0004oq-1O for bug-gnu-emacs@gnu.org; Mon, 05 Jun 2023 12:40:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 05 Jun 2023 16:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 63911 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.168598320018511 (code B ref -1); Mon, 05 Jun 2023 16:40:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 5 Jun 2023 16:40:00 +0000 Original-Received: from localhost ([127.0.0.1]:50258 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q6DFQ-0004oV-GQ for submit@debbugs.gnu.org; Mon, 05 Jun 2023 12:40:00 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:39816) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q6DFP-0004oM-2z for submit@debbugs.gnu.org; Mon, 05 Jun 2023 12:39:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6DFO-0004Tb-Sy for bug-gnu-emacs@gnu.org; Mon, 05 Jun 2023 12:39:58 -0400 Original-Received: from relay8-d.mail.gandi.net ([217.70.183.201]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6DFN-00043H-4P for bug-gnu-emacs@gnu.org; Mon, 05 Jun 2023 12:39:58 -0400 X-GND-Sasl: juri@linkov.net Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id ABE0E1BF207 for ; Mon, 5 Jun 2023 16:39:52 +0000 (UTC) Received-SPF: pass client-ip=217.70.183.201; envelope-from=juri@linkov.net; helo=relay8-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:263022 Archived-At: --=-=-= Content-Type: text/plain Tags: patch As requested in bug#63875, here is a new context submenu "Open With" in Dired: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=dired-open-with.patch 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)))))) --=-=-=--