From: Juri Linkov <juri@linkov.net>
To: 63911@debbugs.gnu.org
Subject: bug#63911: Dired Open With
Date: Thu, 23 Nov 2023 19:54:12 +0200 [thread overview]
Message-ID: <86pm00xsmz.fsf@mail.linkov.net> (raw)
In-Reply-To: <CADwFkmnJdG9KP6JmDpMWNH1286k9-EA_zfgCHm8O7tArrvrW+Q@mail.gmail.com> (Stefan Kangas's message of "Sat, 2 Sep 2023 00:33:29 +0200")
[-- Attachment #1: Type: text/plain, Size: 721 bytes --]
>> 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:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: dired-context-menu-shell-command-guess.patch --]
[-- Type: text/x-diff, Size: 1853 bytes --]
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))))))
next prev parent reply other threads:[~2023-11-23 17:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-05 16:07 bug#63911: Dired Open With Juri Linkov
2023-06-23 16:27 ` Juri Linkov
2023-09-01 22:33 ` Stefan Kangas
2023-09-02 18:40 ` Howard Melman
2023-09-02 19:01 ` Eli Zaretskii
2023-09-23 1:10 ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-23 17:54 ` Juri Linkov [this message]
2023-11-27 17:36 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86pm00xsmz.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=63911@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.