emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Max Nikulin <manikulin@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: [DISCUSSION, default settings] Using mailcap as default handler for opening file links
Date: Tue, 27 Feb 2024 17:43:49 +0700	[thread overview]
Message-ID: <urked7$137i$1@ciao.gmane.io> (raw)
In-Reply-To: <875xyrt7xy.fsf@localhost>

Ihor,

To be clear, I am not against taking into account XDG media types 
associations. I just believe that emacs settings should have higher 
priorities. Another point is that xdg-open is not intelligent enough to 
be used unconditionally.

I have the following idea. If (mailcap-mime-info mime-type) returns a 
function then it is used to open the file. If it is a string (shell 
command) then depending on some user option and DISPLAY, WAYLAND_DISPLAY 
environment variables either xdg-open or mailcap shell command is executed.

Notice the following issue:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=12972
Move `org-open-file' and associated code out of Org mode

Several issues with running external handlers are highlighted in 
comments. The changes were committed before I discovered history of code 
around xdg-open in browse-url.el. It is unclear to me what Eli had in mind.

If some XDG-related code appears in Org then likely it will be demand to 
have it in Emacs core (dired already has some kludge). However my 
experience of communication with Emacs developers is not encouraging.

A side note. On Debian there is the "open" command that may be 
configured to either xdg-open or run-mailcap through alternatives.

Some notes are inline.

On 14/02/2024 21:51, Ihor Radchenko wrote:
> Max Nikulin writes:
> 
> May you please explain more about this?
> What happens if a mailcap entry, say, declares "less" as a mimetype
> handler and Emacs is running in terminal?

An entry for "less" likely has terminal requirement in the "test" field 
and likely will be discarded by mailcap.el (I have not checked it).

> Also, I tried to run xdg-open from terminal (not emulator - C-M-<F1> on
> Linux) and it runs w3m for .png image vs. feh when running from terminal
> emulator on X.

xdg-open has a fallback to some hardcoded list of browsers. It is far 
from mailcap configuration. It does not use "see" and similar 
mailcap-related tools.

> So, I'd say that ordinary Emacs user probably has no idea that Emacs
> consults .mailcap to open /files/. Maybe some users (who are already
> familiar with .mailcap) expect .mailcap to be consulted when opening
> email attachments. But I am not sure - even reading
> https://man.archlinux.org/man/mailcap.5.en I cannot easily see why this
> would be used to open files; not to render them inline.

Users of mutt/pine/alpine have more chances to be familiar with mailcap.
Debian's version
https://manpages.debian.org/bookworm/mailcap/mailcap.5.en.html
is linked to more informative
https://manpages.debian.org/bookworm/mailcap/mailcap.order.5.en.html
https://manpages.debian.org/bookworm/mailcap/update-mime.8.en.html
though these tools are specific to Debian.

> I feel that we are abusing the scope of mailcap when opening file links.

 From my point of view, Org just uses facility that Emacs provides.

>> - Eli had objections, but did not provide any details.
>> - Error handling code was dropped for the sake of Emacs-25.
>> - In the case of no DE, quit from emacs means terminating of started
>> applications.
>> - I hope a bug I faced is exotic enough to never happen in real life.
> 
> Sorry, but I have no idea what you are talking about. I assume that it
> is some kind of Emacs bug you reported some time ago. I am not sure
> which one. And I do not see how it is related to this discussion.

See the link above.

>> Ideally Emacs should provide API that uses either xdg.el or mailcap.el
>> as backend depending on runtime and user configuration. Org is not the
>> only package that needs it.
> 
> Yes. But that's a lot of work; adding support of libmagic being just the
> first step. Implementing something more reasonable for Org mode only is
> a lower-handing fruit.

There are two orthogonal XDG specs:
- Lookup for a handler when media type is known
- Database of media types with file suffixes and signatures (magic 
sequences)

The former one is more important, unfortunately its implementation in 
Emacs has not nearly completed.



  reply	other threads:[~2024-02-27 10:44 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-15 16:49 Bug in 9.5.3 org--file-default-apps Craig STCR
2022-05-16  4:53 ` Ihor Radchenko
     [not found]   ` <6615610d-93ae-171f-b554-3f4cc79354cc@gmail.com>
2022-05-16  8:33     ` Ihor Radchenko
     [not found]       ` <86692975-4d5f-6933-3227-c6b208f76862@gmail.com>
2022-05-16 11:57         ` Ihor Radchenko
2022-05-16 15:14           ` Max Nikulin
2022-05-16 19:15             ` Craig STCR
2022-05-16 19:29             ` Craig STCR
2022-05-17 16:03               ` Max Nikulin
2022-05-18 11:36             ` Ihor Radchenko
2022-05-18 16:10               ` Max Nikulin
2022-05-19 13:39                 ` Ihor Radchenko
2022-05-19 14:45                   ` Max Nikulin
2022-05-20  8:22                     ` Ihor Radchenko
2022-05-20 11:31                       ` Max Nikulin
2022-05-21  1:44                         ` Ihor Radchenko
2022-05-21 14:56                           ` Max Nikulin
2022-05-22  4:10                             ` [PATCH] " Ihor Radchenko
2022-05-22  7:40                               ` Max Nikulin
2022-05-26  4:23                                 ` [PATCH v2] " Ihor Radchenko
2022-05-29  6:07                                   ` Max Nikulin
2022-05-30 14:00                                     ` [PATCH v3] " Ihor Radchenko
2022-05-30 15:38                                       ` Max Nikulin
2022-05-31 15:07                                         ` Max Nikulin
2022-06-04 13:42                                         ` [DISCUSSION, default settings] Using mailcap as default handler for opening file links (was: [PATCH v3] Re: Bug in 9.5.3 org--file-default-apps) Ihor Radchenko
2022-06-04 17:01                                           ` Greg Minshall
2022-06-06 12:50                                           ` [DISCUSSION, default settings] Using mailcap as default handler for opening file links Max Nikulin
2022-06-06 15:22                                             ` Max Nikulin
2022-06-06 17:47                                             ` Bhavin Gandhi
2022-06-10 16:38                                               ` Max Nikulin
2024-02-12 12:36                                             ` Ihor Radchenko
2024-02-13 10:59                                               ` Max Nikulin
2024-02-13 11:27                                                 ` Ihor Radchenko
2024-02-13 15:44                                                   ` Max Nikulin
2024-02-13 15:47                                                     ` Max Nikulin
2024-02-14 14:51                                                     ` Ihor Radchenko
2024-02-27 10:43                                                       ` Max Nikulin [this message]
2022-05-29  7:07                                   ` [PATCH v2] Re: Bug in 9.5.3 org--file-default-apps Max Nikulin
2022-05-23 12:40                           ` Craig STCR
2022-05-23 12:59                             ` Craig STCR
2022-05-23 14:14                               ` Craig STCR
2022-05-23 14:32                                 ` Craig STCR
2022-05-25  6:18                               ` Ihor Radchenko
2022-05-23 15:28                             ` Max Nikulin
2022-05-25  6:24                               ` Ihor Radchenko
2022-05-25 11:38                                 ` Craig STCR
2022-05-25  6:10                             ` Ihor Radchenko
     [not found]         ` <e9b4e88d-3807-9080-fa86-c297b17794cb@gmail.com>
2022-05-16 12:38           ` Craig STCR
2022-05-18 11:38             ` Ihor Radchenko

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='urked7$137i$1@ciao.gmane.io' \
    --to=manikulin@gmail.com \
    --cc=emacs-orgmode@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 public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).