SAKDOSS · 2022-08-25 08:42
Hello,
When selecting a file in a browser (e.g., an email attachment), an app is opened to help you select the file. Is it possible to use emacs dired mode to do that?
I am using linux and chrome but if you know how to do it with another browser it would help also.
ftrx · 2022-08-25 09:36
IMVHO it's not much a matter of Emacs or even browser but of host OS/desktop environment file associations (i.e. the default application configured per mime type), on GNU/Linux Chrome normally run `xdg-open`, a wrapper part of FreeDesktop spec, who look at `mimeapps.list` for the right app to fire up per file mime type, for details:
- https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html
- https://saveriomiroddi.github.io/Linux-associating-file-types-to-applications/
In general/practical terms, if you are in a DE like Gnome/KDE etc it adhere to FreeDesktop spec and manage `mimeapps.list` alone, so generally in the default file manager, right clicking on a file of the type you want to set (let's say a pdf) pops up a menu with a "property" entry, clicking on property open a dialog with the default application to associate, choosing Emacs run it like "emacs filename". To be more in comfort you probably want to start Emacs with a background daemon [1] or a simple
(unless (server-running-p)
(server-start))
In your config so to run `emacsclient` at a glance when you call it instead of spawning another Emacs instance.
This principle with minor difference works with all modern OSes, there is a way to guess the file type you ask to open (Windows use file extension, most OSes guess the file type by it's header witch is called often the magic bit") and run the associated application. Sometimes you have more than one per file type, in that case you normally get the first and eventually fallback on others.
However is some case that might not work for you because modern systems are a pile of crap stacked on various piles of crap, or for instance when you click on a mail attachment the webmail might catch the click and try to handle the attachment itself with some kind of web-based tools, similarly a modern WebVM improperly named browser for legacy reasons might decide to handle internally certain file types ignoring the OS settings, witch means that you have to test yourself for your use cases and eventually look for some relevant parameters, if any, in both "browser" and "web app" settings.
A bottomline: while it's a long journey because so far no one seems to have collect and automate the entire process you can have your mails in Emacs. Personally I download them from various IMAPs to a homeserver via fetchmail, auto-refile them a bit with MailDrop and index/serve via notmuch. Muchsync on my desktops sync anything over ssh. Notmuch-emacs if my default "mail application" and I mostly access mails via org-mode `notmuch:` or `notmuch-search:` links, like `[[notmuch-search:tag:unread][Unread mails]]`. It might sound long, it is, and overkill (perhaps) but the outcome is a different way of using a desktop, so much more effective, easy and flexible that you hardly go back...
[1] https://www.emacswiki.org/emacs/EmacsAsDaemon
_viz_ · 2022-08-25 16:16
It should be possible, see https://github.com/GermainZ/xdg-desktop-portal-termfilechooser
deaddyfreddy · 2022-08-25 16:36
probably using something like LD_PRELOAD magic calling Emacs instead of native GTK functions