Org-mode mailing list
 help / color / mirror / Atom feed
* bug#12972: 24.3.50; Move `org-open-file' and associated code out of Org mode
       [not found] <F3C1A7E58B2441F7A674239043AC031A@us.oracle.com>
@ 2021-06-01  6:56 ` Lars Ingebrigtsen
       [not found] ` <87r1hmdqek.fsf__16088.3597027109$1622530682$gmane$org@gnus.org>
  1 sibling, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2021-06-01  6:56 UTC (permalink / raw)
  To: Drew Adams; +Cc: 12972

"Drew Adams" <drew.adams@oracle.com> writes:

> IIUC, `org-open-file' and its associated code, such as `org-file-apps',
> `org-default-apps', and `org-apps-regexp-alist', have nothing
> particularly to do with Org mode.  They constitute general-purpose code
> for opening files using associated programs.  Code that uses them
> should not need to load the Org code, and this code should be
> maintained separately for general use.

`org-open-file' is too Org-specific to move out of Org.  But there
should be a command to do what it essentially does outside of Org --
that is, use ~/.mailcap to determine what viewer to use.  So I've now
added this to Emacs 28 under the name `mailcap-view-file'.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: bug#12972: 24.3.50; Move `org-open-file' and associated code out of Org mode
       [not found] ` <87r1hmdqek.fsf__16088.3597027109$1622530682$gmane$org@gnus.org>
@ 2021-06-02 16:20   ` Maxim Nikulin
  0 siblings, 0 replies; 2+ messages in thread
From: Maxim Nikulin @ 2021-06-02 16:20 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Lars Ingebrigtsen, 12972

On 01/06/2021 13:56, Lars Ingebrigtsen wrote:
> So I've now added this to Emacs 28 under the name
> `mailcap-view-file'.

I am sorry if it is a false alarm. Feel free to close the bug again if 
something changed recently in `start-process-shell-command' or if you 
prefer to discuss the issue as another bug.

It seems that implementation of `mailcap-view-file' is unreliable due to 
creation of unnecessary terminal session and it can cause obscure and
difficult to reproduce failures similar to
https://lists.gnu.org/archive/html/emacs-orgmode/2020-09/msg00195.html
https://lists.gnu.org/archive/html/emacs-orgmode/2020-06/msg00332.html
The thread is actually longer than it is shown in the archive interface.
Another lengthy discussion:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44824

In Org latest change was required for compatibility reason:
https://code.orgmode.org/bzg/org-mode/commit/869b7a21b94ed112f6640c8f2711c2a68b661dea

Let-bind (process-connection-type nil) is a minimal required change to 
avoid unnecessary terminal session. However it is not friendly to users 
in the case when troubleshooting is required. `make-process' with 
sentinel is hopefully better.

The following could be ignored since it likely requires significant 
amount of work with unclear benefits.

1. `org-open-file' besides Org-specific stuff allows to specify precise 
target inside the file. It can be quite useful, e.g.

     okular --page 11 --find "some pattern" file.pdf

PDF files have internal anchors as well. I have no consistent vision how 
to express additional "locators" in general API.

2. There are at least two sources of truth for MIME-handlers on linux 
desktop that are not necessary synchronized. Info from extracted from 
.desktop files may be configurable from desktop UI unlike mailcap. 
Distros may have some instruments to mitigate discrepancies. Debian adds 
entries from .desktop handlers to system-wide mailcap DB. Another 
approach is to add to maicap greedy xdg-open handler that tries to guess 
currently running desktop and pass arguments to appropriate command.

Maybe mailcap should be secondary MIME database in Emacs, not the 
primary one.

3. Currently only file suffix is inspected to determine MIME type of a 
file. libmagic (or file command) usually provides more precise info, so 
it is possible to open an incorrectly named file.

4. Mailcap has more features that are not addressed in Emacs. They may 
be handy if Emacs is launched in terminal on remote server. It might 
allow e.g. to open PDF file using pdftotext handler.
- A buffer for command output should be created for "copiousoutput"  option.
- A buffer should be created and terminal session should be enabled if 
an entry "needsterminal".
- There are more substitutions than "%s". However I am unsure if it is 
possible to provide more info than application can obtain from the file.
I think, it is intended for mail multipart messages and additional headers.

On the other hand mailcap handlers might expect safe file names (minimal 
ASCII subset), users may have files with arbitrary names (national 
charset or some special characters). I hope, almost all handlers do not 
have such problem.

In summary, during launch of external command terminal session must be 
suppressed. There is enough room for MIME-related improvements in Emacs 
in general and in Org mode in particular.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-02 16:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <F3C1A7E58B2441F7A674239043AC031A@us.oracle.com>
2021-06-01  6:56 ` bug#12972: 24.3.50; Move `org-open-file' and associated code out of Org mode Lars Ingebrigtsen
     [not found] ` <87r1hmdqek.fsf__16088.3597027109$1622530682$gmane$org@gnus.org>
2021-06-02 16:20   ` Maxim Nikulin

Org-mode mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://orgmode.org/list/0 list/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 list list/ https://orgmode.org/list \
		emacs-orgmode@gnu.org
	public-inbox-index list

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.orgmode
	nntp://news.gmane.io/gmane.emacs.orgmode


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git