From unknown Sun Aug 17 04:15:30 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#63911 <63911@debbugs.gnu.org> To: bug#63911 <63911@debbugs.gnu.org> Subject: Status: Dired Open With Reply-To: bug#63911 <63911@debbugs.gnu.org> Date: Sun, 17 Aug 2025 11:15:30 +0000 retitle 63911 Dired Open With reassign 63911 emacs submitter 63911 Juri Linkov severity 63911 normal tag 63911 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 05 12:40:00 2023 Received: (at submit) by debbugs.gnu.org; 5 Jun 2023 16:40:00 +0000 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 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 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 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 Received: by mail.gandi.net (Postfix) with ESMTPSA id ABE0E1BF207 for ; Mon, 5 Jun 2023 16:39:52 +0000 (UTC) From: Juri Linkov To: bug-gnu-emacs@gnu.org Subject: Dired Open With Organization: LINKOV.NET Date: Mon, 05 Jun 2023 19:07:49 +0300 Message-ID: <86bkhuney2.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) --=-=-= 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)))))) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 23 12:59:41 2023 Received: (at 63911) by debbugs.gnu.org; 23 Jun 2023 16:59:42 +0000 Received: from localhost ([127.0.0.1]:39487 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qCk8L-0004KH-Gc for submit@debbugs.gnu.org; Fri, 23 Jun 2023 12:59:41 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:55573) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qCk8J-0004Jz-K8 for 63911@debbugs.gnu.org; Fri, 23 Jun 2023 12:59:40 -0400 X-GND-Sasl: juri@linkov.net Received: by mail.gandi.net (Postfix) with ESMTPSA id E311C1C0008 for <63911@debbugs.gnu.org>; Fri, 23 Jun 2023 16:59:32 +0000 (UTC) From: Juri Linkov To: 63911@debbugs.gnu.org Subject: Re: bug#63911: Dired Open With In-Reply-To: <86bkhuney2.fsf@mail.linkov.net> (Juri Linkov's message of "Mon, 05 Jun 2023 19:07:49 +0300") Organization: LINKOV.NET References: <86bkhuney2.fsf@mail.linkov.net> Date: Fri, 23 Jun 2023 19:27:10 +0300 Message-ID: <868rca9map.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 63911 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain > As requested in bug#63875, here is a new context submenu "Open With" in Dired: > > + (require 'mailcap nil t) > + (let* ((filename (save-excursion > + (mouse-set-point click) > + (dired-get-filename nil t))) > + (commands (mailcap-file-default-commands (list filename))) After using this for a while I noticed that most of the time mailcap suggestions are useless - they don't contain the same items as in the context menus of a File Manager. For example, clicking the right mouse button on a ScreamTracker .stm file opens a menu with Rhythmbox, and clicking on a ScreamTracker3 .s3m file opens a menu where the first item is Celluloid and the second is Rhythmbox. So I implemented support for xdg commands that now displays exactly the same menus in Emacs as in the File Manager, and with the same order. This is not the final patch, maybe more customization needed before pushing to master. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=dired-context-menu-desktop-commands.patch diff --git a/lisp/dired.el b/lisp/dired.el index 914d0a0e783..7d5691df352 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -2504,17 +2504,58 @@ 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)) +(declare-function xdg-mime-apps "xdg" (mime)) +(declare-function xdg-desktop-read-file "xdg" (filename &optional group)) + (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) + (require 'xdg) + (let* ((filename (save-excursion + (mouse-set-point click) + (dired-get-filename nil t))) + (mailcap-commands (mailcap-file-default-commands (list filename))) + (xdg-mime (when (executable-find "xdg-mime") + (string-trim-right + (shell-command-to-string + (concat "xdg-mime query filetype " filename))))) + (xdg-mime-apps (unless (string-empty-p xdg-mime) + (xdg-mime-apps xdg-mime))) + (desktop-commands + (mapcar (lambda (desktop) + (setq desktop (xdg-desktop-read-file desktop)) + (cons (gethash "Name" desktop) + (replace-regexp-in-string + " .*" "" (gethash "Exec" desktop)))) + xdg-mime-apps)) + (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 (or desktop-commands mailcap-commands) + (list (cons "Open With" + (append + (mapcar (lambda (desktop-command) + `[,(car desktop-command) + (lambda () + (interactive) + (dired-do-async-shell-command + ,(cdr desktop-command) nil + (list ,filename)))]) + desktop-commands) + (mapcar (lambda (mailcap-command) + `[,mailcap-command + (lambda () + (interactive) + (dired-do-async-shell-command + ,mailcap-command nil (list ,filename)))]) + mailcap-commands))))))) (dolist (item (reverse (lookup-key easy-menu [menu-bar immediate]))) (when (consp item) (define-key menu (vector (car item)) (cdr item)))))) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 01 18:34:00 2023 Received: (at 63911) by debbugs.gnu.org; 1 Sep 2023 22:34:00 +0000 Received: from localhost ([127.0.0.1]:34398 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcCiG-00057X-2c for submit@debbugs.gnu.org; Fri, 01 Sep 2023 18:34:00 -0400 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]:54501) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcCiE-00057I-Hq for 63911@debbugs.gnu.org; Fri, 01 Sep 2023 18:33:59 -0400 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-5009d4a4897so4511057e87.0 for <63911@debbugs.gnu.org>; Fri, 01 Sep 2023 15:33:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693607621; x=1694212421; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=yXhrO6e3aYNVazk6IfqG5+XXIcn1SXylCvzR2rhBmrc=; b=aMQyQUZp3AMyY/qY5otlOhPsKBlNCBwmuqIrMSSqYO3gm5bXy7k+rqhfkkhU3LHTia +RtqhdqHlad+MdKvbZ1aZh4oOZFqA6Q6cLMsngJ2PORKlZwQ23RuM9WOA0+xpuywWkq0 FmcvN4V95ietdpF9lq+rmsxI+leLkigZ2ku9vXOtf2exa4qpxbgEN++TdULrHGj730Rs iYFg6GxdVZA2HCoyVdTBw1hYQJ3D/GJs2SodUPyGu0Et7JQPf+TNxYaqltism7QB2mhl 2PQxKJHlHYjddHEzLkNhi0qZDwYhgkXeBUQ8LvvYhSks5ZgVvryZk1TubFYDU7Nh5p10 OH9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693607621; x=1694212421; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=yXhrO6e3aYNVazk6IfqG5+XXIcn1SXylCvzR2rhBmrc=; b=kBqeL4s14tIiIsE6dOZmc4Sdo72gwtu2/lfgRXygKJgP55B55uL6385FweSEEDZDPD 8sNu4NHH00EONDoQ2HeGIyySVRUjGfP47rK+OgThGIS62XeIg6zv6uPuF64nnDmyN/2p ZCFJNfVjNLsTdLFac+dqf54/FeuHK9qIwGKmDPgjXccwWU5X9ZrgaR5D2YUmz1VYaKVc 9qXdmkdDnt8XX/Ms83KS/9yVmnd24TdaPvdq9xbJKgJrBP47X9IKg9Wr/0Q/cIVUfKam CqTHCteUgiXjNcWyOJ5RoKjkcERoQ3P8zxIMHH7jKVeEu4CdxpHEhnb2Xtib01mN9v6B +ASA== X-Gm-Message-State: AOJu0YylF0JjH61rcEhUPi03apF8Z0H+Enp+WpMA8sF+YtBLhRkrSY82 GlRxPw8NeEDcxnRDhpkKRF2SM/EaGx72quqdf/DdFhMLEHyq8g== X-Google-Smtp-Source: AGHT+IEZZDbNOXHbQx93gqacqRua+u1CvyvUbYnUWMmxFMpO1oODE/9o2YAjp/pz+5kkYYMEemBb2N+OY6OG9vwLGVc= X-Received: by 2002:a05:6512:3085:b0:4f8:ff52:93b7 with SMTP id z5-20020a056512308500b004f8ff5293b7mr3078229lfd.30.1693607620796; Fri, 01 Sep 2023 15:33:40 -0700 (PDT) MIME-Version: 1.0 References: <86bkhuney2.fsf@mail.linkov.net> <868rca9map.fsf@mail.linkov.net> In-Reply-To: <868rca9map.fsf@mail.linkov.net> From: Stefan Kangas Date: Sat, 2 Sep 2023 00:33:29 +0200 Message-ID: Subject: Re: bug#63911: Dired Open With To: Juri Linkov Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63911 Cc: 63911@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Juri Linkov writes: > After using this for a while I noticed that most of the time > mailcap suggestions are useless - they don't contain the same > items as in the context menus of a File Manager. For example, > clicking the right mouse button on a ScreamTracker .stm file > opens a menu with Rhythmbox, and clicking on a ScreamTracker3 > .s3m file opens a menu where the first item is Celluloid > and the second is Rhythmbox. > > So I implemented support for xdg commands that now displays exactly > the same menus in Emacs as in the File Manager, and with the same order. Agreed, it's better to use the xdg commands for this. > This is not the final patch, maybe more customization needed > before pushing to master. I guess a NEWS item is in order, too. From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 02 14:40:46 2023 Received: (at submit) by debbugs.gnu.org; 2 Sep 2023 18:40:46 +0000 Received: from localhost ([127.0.0.1]:38639 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcVY6-0001iU-36 for submit@debbugs.gnu.org; Sat, 02 Sep 2023 14:40:46 -0400 Received: from lists.gnu.org ([2001:470:142::17]:50966) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcVY3-0001iC-Oa for submit@debbugs.gnu.org; Sat, 02 Sep 2023 14:40:44 -0400 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 1qcVXo-000493-A4 for bug-gnu-emacs@gnu.org; Sat, 02 Sep 2023 14:40:28 -0400 Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcVXl-0006Ej-Qe for bug-gnu-emacs@gnu.org; Sat, 02 Sep 2023 14:40:28 -0400 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1qcVXh-0007yx-Ec for bug-gnu-emacs@gnu.org; Sat, 02 Sep 2023 20:40:21 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: bug-gnu-emacs@gnu.org From: Howard Melman Subject: Re: bug#63911: Dired Open With Date: Sat, 02 Sep 2023 14:40:13 -0400 Message-ID: References: <86bkhuney2.fsf@mail.linkov.net> <868rca9map.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:ARHEW/Nw+BkIZ3asn/XtG90lj9c= Received-SPF: pass client-ip=116.202.254.214; envelope-from=geb-bug-gnu-emacs@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.5 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Stefan Kangas writes: > Juri Linkov writes: > >> After using this for a while I noticed that most of the time >> mailcap suggestions are useless - they don't contain the same >> items as in the context menus of a File Ma [...] Content analysis details: (1.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.0 FORGED_GMAIL_RCVD 'From' gmail.com does not match 'Received' headers 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 T_SPF_PERMERROR SPF: test of record failed (permerror) 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (hmelman[at]gmail.com) -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) Stefan Kangas writes: > Juri Linkov writes: > >> After using this for a while I noticed that most of the time >> mailcap suggestions are useless - they don't contain the same >> items as in the context menus of a File Manager. For example, >> clicking the right mouse button on a ScreamTracker .stm file >> opens a menu with Rhythmbox, and clicking on a ScreamTracker3 >> .s3m file opens a menu where the first item is Celluloid >> and the second is Rhythmbox. >> >> So I implemented support for xdg commands that now displays exactly >> the same menus in Emacs as in the File Manager, and with the same order. > > Agreed, it's better to use the xdg commands for this. Will this work (or at least not break) on mac or windows or other non-xgd systems? -- Howard From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 02 15:01:37 2023 Received: (at 63911) by debbugs.gnu.org; 2 Sep 2023 19:01:37 +0000 Received: from localhost ([127.0.0.1]:38675 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcVsH-0004uz-E8 for submit@debbugs.gnu.org; Sat, 02 Sep 2023 15:01:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45840) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcVsE-0004um-Dq for 63911@debbugs.gnu.org; Sat, 02 Sep 2023 15:01:36 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcVrz-0006wD-5N; Sat, 02 Sep 2023 15:01:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=BhU3Y6pVXNHSgBLYMOfNeBdPIyvnAPWb0sqbQ0Vk46E=; b=RNq9MBPRX6nF KwoY1vB6XKGYq+QTuy8C+m+Ta+9THM9TzuwdJsXebqBX5mTcxX7oSlqN3cJps1SXclCGoOBKKdVU8 4RmP1rYja7d+SVzLNHxS8b92VhS5rjkgNgQwW77c1ol163IX5D9MoAQyJcu5A5LyAHtFwso81TVX0 BNrfVBGqG9xnqHIx8hC+s5JfYBbexLctKXWqM/rfVlz+K8xL1m8cSJySIyv7kv3QxJ7whkmqLqltF QWxDUAItAr207WUP5YqkS8OdNNCz1JdfKJ8vqK3tnGsKSSM+YdO1yAUYQXPQ16v+k8XdBNESVzSzO 4za2QbNvW9e+HMFT+EPRiQ==; Date: Sat, 02 Sep 2023 22:01:16 +0300 Message-Id: <83ttsc8kn7.fsf@gnu.org> From: Eli Zaretskii To: Howard Melman In-Reply-To: (message from Howard Melman on Sat, 02 Sep 2023 14:40:13 -0400) Subject: Re: bug#63911: Dired Open With References: <86bkhuney2.fsf@mail.linkov.net> <868rca9map.fsf@mail.linkov.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63911 Cc: 63911@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Howard Melman > Date: Sat, 02 Sep 2023 14:40:13 -0400 > > Stefan Kangas writes: > > > Juri Linkov writes: > > > >> After using this for a while I noticed that most of the time > >> mailcap suggestions are useless - they don't contain the same > >> items as in the context menus of a File Manager. For example, > >> clicking the right mouse button on a ScreamTracker .stm file > >> opens a menu with Rhythmbox, and clicking on a ScreamTracker3 > >> .s3m file opens a menu where the first item is Celluloid > >> and the second is Rhythmbox. > >> > >> So I implemented support for xdg commands that now displays exactly > >> the same menus in Emacs as in the File Manager, and with the same order. > > > > Agreed, it's better to use the xdg commands for this. > > Will this work (or at least not break) on mac or windows or > other non-xgd systems? The MS-Windows port already has a function that's the equivalent of xdg-open: w32-shell-execute. Patches to add this to the menu discussed here are welcome. From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 22 21:10:52 2023 Received: (at 63911) by debbugs.gnu.org; 23 Sep 2023 01:10:52 +0000 Received: from localhost ([127.0.0.1]:37530 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qjrAX-0002Q0-5m for submit@debbugs.gnu.org; Fri, 22 Sep 2023 21:10:52 -0400 Received: from thaodan.de ([2a03:4000:4f:f15::1]:44020) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qjrAR-0002Pl-Jv for 63911@debbugs.gnu.org; Fri, 22 Sep 2023 21:10:47 -0400 Received: from odin (dsl-trebng12-50dc77-87.dhcp.inet.fi [80.220.119.87]) by thaodan.de (Postfix) with ESMTPSA id D000ED08DD3; Sat, 23 Sep 2023 04:10:29 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=thaodan.de; s=mail; t=1695431430; bh=jiTb/SFukLYWEccOXsl85wke/QZjrWuwL7GdC8bWLzU=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=B/xtKuklmu0AlAf/cuwqdsae8WBUkx+QMenu26YliNPvbUKOTaXih4Vtl66O57vQ3 4Ouk/nioIrQqPYBzQJ+/6C94ENsgveztneJm6MBsVmzu+9u1jUkS+xG6tYgmIvjbzU 17ANOrXMthx75pHhpMzq9lyCjg6Z5cIWJfntooylajHVoFKlpGUb3lkWQG261YakHd Kc4LiQJjl98xXInYU6y352HFX/fFJACmbbSxSqxSnG9DYCznzXt+qmW/PORhR0fdGI oriR8U6S/mJVDOoNCnTziPKyRsJ0OsI6QlaBMAK8cYS1HnMJAftfxAs7taKWlyo0K5 IKFzDV31QBeBZXGrqREiGzYhYYRe/NH/9ht3ZufuMnrx24yTi5eTSgsW0zGjlLSu1S HhYYfprb42UfBWKecjxU5GsCJAxpl4aWSqI6eC7fwuXgBno75YWaefSJYNZi6vuDx3 /h9ZKR3hbjoEYfDx7RQgBQTagzjVktz7SDU4wzw6agolQHg398nzIe3aO8KxsIwd4e OpZOlkk7yc3RC7fJ18CuzbvCelONAX/3WXwt1tbMnNnDwINs7GKW6Vm8tt6RBuk9Yw MJtvHl9fqZ13eoJ2Bt5LQPm0aCDJ+/y7AGvTMrCn98Ge/UVfCFZLLphcoSQUheYDTL 1UWIsz+nKoxVb3CQ14qkSusM= From: =?utf-8?Q?Bj=C3=B6rn?= Bidar To: Eli Zaretskii Subject: Re: bug#63911: Dired Open With In-Reply-To: <83ttsc8kn7.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 02 Sep 2023 22:01:16 +0300") References: <86bkhuney2.fsf@mail.linkov.net> <868rca9map.fsf@mail.linkov.net> <83ttsc8kn7.fsf@gnu.org> Autocrypt: addr=bjorn.bidar@thaodan.de; prefer-encrypt=nopreference; keydata= mDMEZNfpPhYJKwYBBAHaRw8BAQdACBEmr+0xwIIHZfIDlZmm7sa+lHHSb0g9FZrN6qE6ru60JUJq w7ZybiBCaWRhciA8Ympvcm4uYmlkYXJAdGhhb2Rhbi5kZT6IlgQTFgoAPgIbAwULCQgHAgIiAgYV CgkICwIEFgIDAQIeBwIXgBYhBFHxdut1RzAepymoq1wbdKFlHF9oBQJk1/YmAhkBAAoJEFwbdKFl HF9oB9cBAJoIIGQKXm4cpap+Flxc/EGnYl0123lcEyzuduqvlDT0AQC3OlFKm/OiqJ8IMTrzJRZ8 phFssTkSrrFXnM2jm5PYDoiTBBMWCgA7FiEEUfF263VHMB6nKairXBt0oWUcX2gFAmTX6T4CGwMF CwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4AACgkQXBt0oWUcX2hbCQEAtru7kvM8hi8zo6z9ux2h K+B5xViKuo7Z8K3IXuK5ugwA+wUfKzomzdBPhfxDsqLcEziGRxoyx0Q3ld9aermBUccHtBxCasO2 cm4gQmlkYXIgPG1lQHRoYW9kYW4uZGU+iJMEExYKADsCGwMFCwkIBwICIgIGFQoJCAsCBBYCAwEC HgcCF4AWIQRR8XbrdUcwHqcpqKtcG3ShZRxfaAUCZNf2FQAKCRBcG3ShZRxfaCzSAP4hZ7cSp0YN XYpcjHdsySh2MuBhhoPeLGXs+2kSiqBiOwD/TP8AgPEg/R+SI9GI9on7fBJJ0mp2IT8kZ2rhDOjg gA6IkwQTFgoAOxYhBFHxdut1RzAepymoq1wbdKFlHF9oBQJk1+ntAhsDBQsJCAcCAiICBhUKCQgL AgQWAgMBAh4HAheAAAoJEFwbdKFlHF9oBgwA/iQHwe0VL4Df4GGTYlNjMSHFlIkBmN4UfYGLYj3E TrOUAQC51M+M3cjsL8WHdpBz6VAo6df9d+rVwhQ9vQuFHqevArg4BGTX6T4SCisGAQQBl1UBBQEB B0Cbohc3JEfn005/cm0AOGjSsW1ZxAkgaoVNjbpqk4MgNAMBCAeIeAQYFgoAIBYhBFHxdut1RzAe pymoq1wbdKFlHF9oBQJk1+k+AhsMAAoJEFwbdKFlHF9ooHABAKGmrGBic/Vys3BBrOQiRB3Z7izO HwhqTRpAqFZtXS2nAQDZhp/5aYw1TZjTzkm1KVt9QiYnjd/MvxRE9iaY6x4mDbgzBGTX6T4WCSsG AQQB2kcPAQEHQAgRJq/tMcCCB2XyA5WZpu7GvpRx0m9IPRWazeqhOq7uiO8EGBYKACAWIQRR8Xbr dUcwHqcpqKtcG3ShZRxfaAUCZNf71AIbIgCBCRBcG3ShZRxfaHYgBBkWCgAdFiEEUfF263VHMB6n KairXBt0oWUcX2gFAmTX+9QACgkQXBt0oWUcX2jeSwD6AtWn0cuo8IF35YRo4o3cDRJnUfJnbvJy GxyCDThR+zYBAKG6/jdwmZkBQZKslnDAbMMd2WfiZZT5JW3IWC4EaKMO7HkBAKYPGZ3UbfkRvfFK S+pQ9CgtNfkSJQBtT1Ob7Y6nsacgAQCpyXN7yppmhW/oBgivITPy9Lkg+V4NK9WZYZCU9Q7LBA== Date: Sat, 23 Sep 2023 04:10:28 +0300 Message-ID: <87zg1dae4b.fsf@thaodan.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 63911 Cc: 63911@debbugs.gnu.org, Howard Melman X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> From: Howard Melman >> Date: Sat, 02 Sep 2023 14:40:13 -0400 >> >> Stefan Kangas writes: >> >> > Juri Linkov writes: >> > >> >> After using this for a while I noticed that most of the time >> >> mailcap suggestions are useless - they don't contain the same >> >> items as in the context menus of a File Manager. For example, >> >> clicking the right mouse button on a ScreamTracker .stm file >> >> opens a menu with Rhythmbox, and clicking on a ScreamTracker3 >> >> .s3m file opens a menu where the first item is Celluloid >> >> and the second is Rhythmbox. >> >> >> >> So I implemented support for xdg commands that now displays exactly >> >> the same menus in Emacs as in the File Manager, and with the same order. >> > >> > Agreed, it's better to use the xdg commands for this. >> >> Will this work (or at least not break) on mac or windows or >> other non-xgd systems? > > The MS-Windows port already has a function that's the equivalent of > xdg-open: w32-shell-execute. Patches to add this to the menu > discussed here are welcome. For macOS there's man 1 open which behaves very similar to xdg-open. https://www.unix.com/man-page/osx/1/open/ From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 23 13:04:29 2023 Received: (at 63911) by debbugs.gnu.org; 23 Nov 2023 18:04:29 +0000 Received: from localhost ([127.0.0.1]:35071 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6E3x-0001gp-7s for submit@debbugs.gnu.org; Thu, 23 Nov 2023 13:04:29 -0500 Received: from relay8-d.mail.gandi.net ([2001:4b98:dc4:8::228]:53965) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6E3t-0001gK-PA for 63911@debbugs.gnu.org; Thu, 23 Nov 2023 13:04:26 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id AB3A61BF204 for <63911@debbugs.gnu.org>; Thu, 23 Nov 2023 18:04:14 +0000 (UTC) From: Juri Linkov To: 63911@debbugs.gnu.org Subject: Re: bug#63911: Dired Open With In-Reply-To: (Stefan Kangas's message of "Sat, 2 Sep 2023 00:33:29 +0200") Organization: LINKOV.NET References: <86bkhuney2.fsf@mail.linkov.net> <868rca9map.fsf@mail.linkov.net> Date: Thu, 23 Nov 2023 19:54:12 +0200 Message-ID: <86pm00xsmz.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 63911 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain >> After using this for a while I noticed that most of the time >> mailcap suggestions are useless - they don't contain the same >> items as in the context menus of a File Manager. For example, >> clicking the right mouse button on a ScreamTracker .stm file >> opens a menu with Rhythmbox, and clicking on a ScreamTracker3 >> .s3m file opens a menu where the first item is Celluloid >> and the second is Rhythmbox. >> >> So I implemented support for xdg commands that now displays exactly >> the same menus in Emacs as in the File Manager, and with the same order. > > Agreed, it's better to use the xdg commands for this. Here is a new patch that uses a new generalized function 'shell-command-guess' from bug#18132: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=dired-context-menu-shell-command-guess.patch diff --git a/lisp/dired.el b/lisp/dired.el index c212e3094f8..bb55add9d33 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -2533,13 +2533,30 @@ dired-context-menu "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) + (require 'xdg) + (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" + `("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" + (append + (mapcar (lambda (command) + `[,(or (get-text-property 0 'name 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)))))) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 27 12:37:44 2023 Received: (at 63911) by debbugs.gnu.org; 27 Nov 2023 17:37:44 +0000 Received: from localhost ([127.0.0.1]:44723 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7fYG-0006SI-Ar for submit@debbugs.gnu.org; Mon, 27 Nov 2023 12:37:44 -0500 Received: from relay3-d.mail.gandi.net ([2001:4b98:dc4:8::223]:53545) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7fYD-0006Rn-7x; Mon, 27 Nov 2023 12:37:41 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id 31EAC60008; Mon, 27 Nov 2023 17:37:27 +0000 (UTC) From: Juri Linkov To: 63911@debbugs.gnu.org Subject: Re: bug#63911: Dired Open With In-Reply-To: <86pm00xsmz.fsf@mail.linkov.net> (Juri Linkov's message of "Thu, 23 Nov 2023 19:54:12 +0200") Organization: LINKOV.NET References: <86bkhuney2.fsf@mail.linkov.net> <868rca9map.fsf@mail.linkov.net> <86pm00xsmz.fsf@mail.linkov.net> Date: Mon, 27 Nov 2023 19:36:02 +0200 Message-ID: <86h6l75cal.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 63911 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) close 63911 30.0.50 quit >> Agreed, it's better to use the xdg commands for this. > > Here is a new patch that uses a new generalized function > 'shell-command-guess' from bug#18132: Now pushed to master, and closed. From unknown Sun Aug 17 04:15:30 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 26 Dec 2023 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator