GNU bug report logs - #44824
27.1; Org export as pdf and open file does not open it

Previous Next

Packages: emacs, org-mode;

Reported by: Geraldo Biotti <gbiotti <at> gmail.com>

Date: Mon, 23 Nov 2020 17:41:02 UTC

Severity: normal

Tags: moreinfo

Found in version 27.1

Done: Kyle Meyer <kyle <at> kyleam.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 44824 in the body.
You can then email your comments to 44824 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#44824; Package emacs. (Mon, 23 Nov 2020 17:41:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Geraldo Biotti <gbiotti <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 23 Nov 2020 17:41:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Geraldo Biotti <gbiotti <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.1; Org export as pdf and open file does not open it
Date: Mon, 23 Nov 2020 18:40:12 +0100
[Message part 1 (text/plain, inline)]
Create a new org file and save it.
Try to export to LaTeX as PDF file and open (C-c C-e l o)

This is what *messages* says:
(New file)
Saving file /tmp/test2.tex...
Wrote /tmp/test2.tex
Processing LaTeX file test2.tex...
PDF file produced.
Running /usr/bin/xdg-open /tmp/test2.pdf...done

The default PDF program (okular) appears to open (i see the icon, but not
the window) and closes without showing anything.

Working on Manjaro Linux 20.1:
KDE Plasma Version: 5.20.3
KDE Frameworks Version: 5.76.0
Qt version: 5.15.1
Kernel Version: 5.8.18-1-MANJARO
OS Type: 64 bit



In GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.22,
cairo version 1.17.3)
 of 2020-08-28 built on juergen
Windowing system distributor 'The X.Org Foundation', version 11.0.12009000
System Description: Manjaro Linux

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
(New file)
Saving file /tmp/test.org...
Wrote /tmp/test.org
Saving file /tmp/test.tex...
Wrote /tmp/test.tex
Processing LaTeX file test.tex...
PDF file produced.
Running /usr/bin/xdg-open /tmp/test.pdf...done

Configured using:
 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --with-x-toolkit=gtk3 --with-xft --with-wide-int
 --with-modules --with-cairo --with-harfbuzz 'CFLAGS=-march=x86-64
 -mtune=generic -O2 -pipe -fno-plt' CPPFLAGS=-D_FORTIFY_SOURCE=2
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'

Configured features:
XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY
INOTIFY ACL GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD JSON
PDUMPER LCMS2 GMP

Important settings:
  value of $LC_MONETARY: it_IT.UTF-8
  value of $LC_NUMERIC: it_IT.UTF-8
  value of $LC_TIME: it_IT.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Info

Minor modes in effect:
  shell-dirtrack-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug sendmail mule-util info tex-mode compile
shell latexenc cl-extra help-mode ox-odt rng-loc rng-uri rng-parse
rng-match rng-dt rng-util rng-pttrn nxml-parse nxml-ns nxml-enc xmltok
nxml-util ox-latex ox-icalendar ox-html table ox-ascii ox-publish ox
org-element avl-tree generator ol-eww ol-rmail ol-mhe ol-irc ol-info
ol-gnus nnir gnus-sum url url-proxy url-privacy url-expand url-methods
url-history mailcap shr url-cookie url-domsuf url-util url-parse
auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs json map
url-vars svg xml dom browse-url gnus-group gnus-undo gnus-start
gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo parse-time iso8601
gnus-spec gnus-int gnus-range message rmc puny rfc822 mml mml-sec
password-cache epa derived epg epg-config mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader gnus-win gnus
nnheader gnus-util rmail rmail-loaddefs rfc2047 rfc2045 ietf-drums
text-property-search seq byte-opt gv bytecomp byte-compile cconv
mail-utils mm-util mail-prsvr wid-edit ol-docview doc-view jka-compr
image-mode exif dired dired-loaddefs ol-bibtex bibtex ol-bbdb ol-w3m org
ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-footnote
org-src ob-comint org-pcomplete pcomplete comint ansi-color ring
org-list org-faces org-entities time-date subr-x noutline outline
easy-mmode org-version ob-emacs-lisp ob-core ob-eval org-table ol
org-keys org-compat advice org-macs org-loaddefs format-spec find-func
cal-menu easymenu calendar cal-loaddefs cl-loaddefs cl-lib tooltip eldoc
electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win
x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote threads dbusbind inotify lcms2 dynamic-setting
system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit
x multi-tty make-network-process emacs)

Memory information:
((conses 16 192463 13711)
 (symbols 48 20487 1)
 (strings 32 76053 9166)
 (string-bytes 1 2456243)
 (vectors 16 32285)
 (vector-slots 8 365851 18818)
 (floats 8 220 130)
 (intervals 56 360 0)
 (buffers 1000 14))
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#44824; Package emacs. (Mon, 23 Nov 2020 18:38:01 GMT) Full text and rfc822 format available.

Message #8 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: "gbiotti <at> gmail.com" <gbiotti <at> gmail.com>
To: 44824 <at> debbugs.gnu.org
Subject: More info
Date: Mon, 23 Nov 2020 19:37:18 +0100
Changing default program does not work: using evince instead of okular 
-> same results.

Executing the command "xdg-open /path/to/file.pdf" in a terminal 
(Konsole) works.

Executing the same command in Emacs via eshell DOES NOT WORK.






Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Wed, 27 Jan 2021 03:37:02 GMT) Full text and rfc822 format available.

Message #11 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: gbiotti <at> gmail.com
Cc: 44824 <at> debbugs.gnu.org
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Wed, 27 Jan 2021 04:36:45 +0100
"gbiotti <at> gmail.com" <gbiotti <at> gmail.com> writes:

> Executing the command "xdg-open /path/to/file.pdf" in a terminal
> (Konsole) works.
>
> Executing the same command in Emacs via eshell DOES NOT WORK.

What happens if you execute that command in Emacs via eshell?

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




Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 27 Jan 2021 03:38:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Wed, 27 Jan 2021 08:34:02 GMT) Full text and rfc822 format available.

Message #16 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: "gbiotti <at> gmail.com" <gbiotti <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 44824 <at> debbugs.gnu.org
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Wed, 27 Jan 2021 09:33:28 +0100
Il 27/01/2021 04:36, Lars Ingebrigtsen writes:
> "gbiotti <at> gmail.com" <gbiotti <at> gmail.com> writes:
>
>> Executing the command "xdg-open /path/to/file.pdf" in a terminal
>> (Konsole) works.
>>
>> Executing the same command in Emacs via eshell DOES NOT WORK.
> What happens if you execute that command in Emacs via eshell?
>

The same as using C-c C-e l o
"The default PDF program (okular) appears to open (i see the icon, but not
the window) and closes without showing anything."





Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Wed, 27 Jan 2021 13:25:01 GMT) Full text and rfc822 format available.

Message #19 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Nikulin <m.a.nikulin <at> gmail.com>
Cc: 44824 <at> debbugs.gnu.org
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Wed, 27 Jan 2021 19:14:21 +0700
On 27/01/2021 10:36, Lars Ingebrigtsen wrote:
> 
>> Executing the command "xdg-open /path/to/file.pdf" in a terminal
>> (Konsole) works.

The problem may be related to SIGHUP sent to children due to pty created 
by emacs and closed as soon as the handler exits:

https://orgmode.org/list/ru4d75$11sc$1 <at> ciao.gmane.io/

As a workaround you could try to set another handler for PDF files in 
mailcap, e.g. okular directly without xdg-open wrapper. Handler should 
not try to launch actual application in background with immediate exit.

Currently start-process elisp function is used internally in 
org-open-file. Low level (make-process :connection-type 'pipe ...) 
should allow to avoid pty+SIGHUP problem. Maybe there are some 
consequences of such change that I am not aware of.




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Wed, 27 Jan 2021 13:35:01 GMT) Full text and rfc822 format available.

Message #22 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Nikulin <m.a.nikulin <at> gmail.com>
Cc: 44824 <at> debbugs.gnu.org
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Wed, 27 Jan 2021 20:33:51 +0700
I hope, the following link to another emacs-orgmode mail list archive 
will not be mangled by the debbugs web interface, unlike the previous one:
https://lists.gnu.org/archive/html/emacs-orgmode/2021-01/msg00327.html





Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Wed, 27 Jan 2021 16:22:01 GMT) Full text and rfc822 format available.

Message #25 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: 44824 <at> debbugs.gnu.org
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Wed, 27 Jan 2021 11:21:24 -0500
Ref eg https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25234#8
https://bugzilla.gnome.org/show_bug.cgi?id=652262
https://gitlab.gnome.org/GNOME/glib/-/issues/1208
and others going back over a decade.
I think Emacs should have a PROBLEMS entry about this.




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Thu, 28 Jan 2021 03:03:01 GMT) Full text and rfc822 format available.

Message #28 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: gbiotti <at> gmail.com
Cc: 44824 <at> debbugs.gnu.org
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Thu, 28 Jan 2021 04:02:14 +0100
"gbiotti <at> gmail.com" <gbiotti <at> gmail.com> writes:

> The same as using C-c C-e l o
> "The default PDF program (okular) appears to open (i see the icon, but not
> the window) and closes without showing anything."

If I do

$ xdg-open ./doc/lispintro/cons-2.pdf

after `M-x shell', "Document Viewer" is opened as normal.

You don't get any output from xdg-open or anything in the shell buffer?

Glenn Morris <rgm <at> gnu.org> writes:

> Ref eg https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25234#8
> https://bugzilla.gnome.org/show_bug.cgi?id=652262
> https://gitlab.gnome.org/GNOME/glib/-/issues/1208
> and others going back over a decade.
> I think Emacs should have a PROBLEMS entry about this.

Yeah, calling xdg-open (and expecting it not to exit) is a known
problem, but here it seems that xdg-open doesn't even work from *shell*,
which is very odd.

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




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Thu, 28 Jan 2021 11:21:02 GMT) Full text and rfc822 format available.

Message #31 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: "gbiotti <at> gmail.com" <gbiotti <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 44824 <at> debbugs.gnu.org
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Thu, 28 Jan 2021 12:20:36 +0100
Il 28/01/2021 04:02, Lars Ingebrigtsen ha scritto:
> "gbiotti <at> gmail.com" <gbiotti <at> gmail.com> writes:
>
>> The same as using C-c C-e l o
>> "The default PDF program (okular) appears to open (i see the icon, but not
>> the window) and closes without showing anything."
> If I do
>
> $ xdg-open ./doc/lispintro/cons-2.pdf
>
> after `M-x shell', "Document Viewer" is opened as normal.
>
> You don't get any output from xdg-open or anything in the shell buffer?
>
> Glenn Morris <rgm <at> gnu.org> writes:
>
>> Ref eg https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25234#8
>> https://bugzilla.gnome.org/show_bug.cgi?id=652262
>> https://gitlab.gnome.org/GNOME/glib/-/issues/1208
>> and others going back over a decade.
>> I think Emacs should have a PROBLEMS entry about this.
> Yeah, calling xdg-open (and expecting it not to exit) is a known
> problem, but here it seems that xdg-open doesn't even work from *shell*,
> which is very odd.
>

I have no more ideas.
The problem arise even exporting and opening html, so it's not the file 
type.

Doing a better search I found this:
https://forum.manjaro.org/t/xdg-open-or-kde-open-doesnt-work-when-called-from-emacs/39918

Same problem, but without an answer.

If needed I can make a video of what happen (if so please explain where 
to upload it).




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Thu, 28 Jan 2021 11:32:01 GMT) Full text and rfc822 format available.

Message #34 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: "gbiotti <at> gmail.com" <gbiotti <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 44824 <at> debbugs.gnu.org
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Thu, 28 Jan 2021 12:31:08 +0100
Il 28/01/2021 04:02, Lars Ingebrigtsen writes:
> "gbiotti <at> gmail.com" <gbiotti <at> gmail.com> writes:
>
>> The same as using C-c C-e l o
>> "The default PDF program (okular) appears to open (i see the icon, but not
>> the window) and closes without showing anything."
> If I do
>
> $ xdg-open ./doc/lispintro/cons-2.pdf
>
> after `M-x shell', "Document Viewer" is opened as normal.
>
> You don't get any output from xdg-open or anything in the shell buffer?
>
> Glenn Morris <rgm <at> gnu.org> writes:
>
>> Ref eg https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25234#8
>> https://bugzilla.gnome.org/show_bug.cgi?id=652262
>> https://gitlab.gnome.org/GNOME/glib/-/issues/1208
>> and others going back over a decade.
>> I think Emacs should have a PROBLEMS entry about this.
> Yeah, calling xdg-open (and expecting it not to exit) is a known
> problem, but here it seems that xdg-open doesn't even work from *shell*,
> which is very odd.
>

More info:

As per bug 25234, using 'M-! xdg-open /tmp/test.pdf', 'M-& xdg-open 
/tmp/test.pdf'
and 'M-& xdg-open /tmp/test.pdf && sleep 3' I get same results as reported.

If I try in eshell buffer 'xdg-open /tmp/test.pdf && sleep 3' my cursor 
blinks
with the Okular icon for a few seconds and then nothing happens.




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Thu, 28 Jan 2021 16:11:02 GMT) Full text and rfc822 format available.

Message #37 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Nikulin <m.a.nikulin <at> gmail.com>
To: 44824 <at> debbugs.gnu.org
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Thu, 28 Jan 2021 23:10:14 +0700
On 28/01/2021 18:31, gbiotti <at> gmail.com wrote:
> 
> If I try in eshell buffer 'xdg-open /tmp/test.pdf && sleep 3' my cursor 
> blinks
> with the Okular icon for a few seconds and then nothing happens.

If I correctly get what you describe as "blinks", it could last for some 
time after process failure. On the other hand I am surprised that no 
other diagnostics is shown as a KDE dialog or as an error message in the 
eshell buffer. In the case of eshell, it is likely another problem, not 
killing handler with SIGHUP due to instantly closed pty.

What happens if you run the following commands in the Emacs *eshell 
buffer* (with an existing PDF file, of course)? In particular I am 
interested in output appeared in the buffer.

1. okular /tmp/test.pdf

2. kde-open5 /tmp/test.pdf

3. sh -x /usr/bin/xdg-open /tmp/test.pdf

I'm almost sure that okular is configured as the handler, but just to 
confirm it:

4. xdg-mime query default application/pdf

I assume that PDF file is a valid one (not corrupted, not empty, not 
accessible due to file permissions, etc.) since okular is able to report 
such problems.

You could also attach to emacs process with strace, try to launch 
handler, kill strace, and inspect log file which processes are spawned 
("execve" lines) and their exit codes. Run strace from ordinary terminal 
(not from emacs) with proper process ID:

strace -o /tmp/emacs.strace -f -s 128 -tt -p PID_OF_EMACS_PROCESS




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Fri, 29 Jan 2021 04:52:01 GMT) Full text and rfc822 format available.

Message #40 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: gbiotti <at> gmail.com
Cc: 44824 <at> debbugs.gnu.org
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Fri, 29 Jan 2021 05:51:13 +0100
"gbiotti <at> gmail.com" <gbiotti <at> gmail.com> writes:

>> Yeah, calling xdg-open (and expecting it not to exit) is a known
>> problem, but here it seems that xdg-open doesn't even work from *shell*,
>> which is very odd.
>
> More info:
>
> As per bug 25234, using 'M-! xdg-open /tmp/test.pdf', 'M-& xdg-open
> /tmp/test.pdf'
> and 'M-& xdg-open /tmp/test.pdf && sleep 3' I get same results as reported.

I'm not quite sure what you mean here.  Do you mean that
`M-! xdg-open /tmp/test.pdf' works fine, or that it fails?

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




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Fri, 29 Jan 2021 07:00:02 GMT) Full text and rfc822 format available.

Message #43 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Geraldo Biotti <gbiotti <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 44824 <at> debbugs.gnu.org
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Fri, 29 Jan 2021 07:59:19 +0100
[Message part 1 (text/plain, inline)]
Il ven 29 gen 2021, 05:51 Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> "gbiotti <at> gmail.com" <gbiotti <at> gmail.com> writes:
>
> >> Yeah, calling xdg-open (and expecting it not to exit) is a known
> >> problem, but here it seems that xdg-open doesn't even work from *shell*,
> >> which is very odd.
> >
> > More info:
> >
> > As per bug 25234, using 'M-! xdg-open /tmp/test.pdf', 'M-& xdg-open
> > /tmp/test.pdf'
> > and 'M-& xdg-open /tmp/test.pdf && sleep 3' I get same results as
> reported.
>
> I'm not quite sure what you mean here.  Do you mean that
> `M-! xdg-open /tmp/test.pdf' works fine, or that it fails?
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no


I get the same results reported in bug 25234. 'M-! xdg-open /tmp/test.pdf'
works fine. I apologise for my english but it's not my mother language.


>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Sat, 30 Jan 2021 06:11:00 GMT) Full text and rfc822 format available.

Message #46 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Geraldo Biotti <gbiotti <at> gmail.com>
Cc: 44824 <at> debbugs.gnu.org
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Sat, 30 Jan 2021 07:09:50 +0100
Geraldo Biotti <gbiotti <at> gmail.com> writes:

> I get the same results reported in bug 25234. 'M-! xdg-open /tmp/test.pdf' works
> fine. I apologise for my english but it's not my mother language.

So:

This works:
M-! xdg-open /tmp/test.pdf RET

This doesn't work:
M-& xdg-open /tmp/test.pdf RET

This doesn't work:
M-x shell RET xdg-open /tmp/test.pdf RET

?

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




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Sat, 30 Jan 2021 07:51:02 GMT) Full text and rfc822 format available.

Message #49 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Geraldo Biotti <gbiotti <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 44824 <at> debbugs.gnu.org
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Sat, 30 Jan 2021 08:50:32 +0100
[Message part 1 (text/plain, inline)]
Il sab 30 gen 2021, 07:09 Lars Ingebrigtsen <larsi <at> gnus.org> ha scritto:

> Geraldo Biotti <gbiotti <at> gmail.com> writes:
>
> > I get the same results reported in bug 25234. 'M-! xdg-open
> /tmp/test.pdf' works
> > fine. I apologise for my english but it's not my mother language.
>
> So:
>
> This works:
> M-! xdg-open /tmp/test.pdf RET
>
> This doesn't work:
> M-& xdg-open /tmp/test.pdf RET
>
> This doesn't work:
> M-x shell RET xdg-open /tmp/test.pdf RET
>
> ?
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no


Exactly. And it doesn't even "export as PDF and open file" in org-mode,
which I think is a related problem.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Sat, 30 Jan 2021 08:43:02 GMT) Full text and rfc822 format available.

Message #52 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 44824 <at> debbugs.gnu.org, gbiotti <at> gmail.com
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Sat, 30 Jan 2021 10:42:52 +0200
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Date: Sat, 30 Jan 2021 07:09:50 +0100
> Cc: 44824 <at> debbugs.gnu.org
> 
> This works:
> M-! xdg-open /tmp/test.pdf RET
> 
> This doesn't work:
> M-& xdg-open /tmp/test.pdf RET
> 
> This doesn't work:
> M-x shell RET xdg-open /tmp/test.pdf RET

How about asking the xdg-open developers to help us figure out the
reason?  Or, failing that, debug xdg-open in the problematic
situations to find out what fails there and why?  E.g., could it be
that it fails because stdin/stdout is a PTY? what happens if you bind
process-connection-type to nil when starting the async subprocess?




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Sat, 30 Jan 2021 13:33:02 GMT) Full text and rfc822 format available.

Message #55 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Nikulin <m.a.nikulin <at> gmail.com>
To: 44824 <at> debbugs.gnu.org
Cc: gbiotti <at> gmail.com
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Sat, 30 Jan 2021 20:31:53 +0700
On 30/01/2021 15:42, Eli Zaretskii wrote:
>>
>> This works:
>> M-! xdg-open /tmp/test.pdf RET
>>
>> This doesn't work:
>> M-& xdg-open /tmp/test.pdf RET
>>
>> This doesn't work:
>> M-x shell RET xdg-open /tmp/test.pdf RET

Geraldo, "M-x shell" case is rather strange. Could you, please, confirm 
ones more that okular window with the file content does not appear if 
you call xdg-open from an *interactive* emacs shell buffer? The link to 
an emacs-orgmode list message, that I have posted earlier, explains why 
async-shell-command *may* fail while shell-command should work reliably. 
I am really surprised by failure when command is executed in a [e]shell 
buffer.

> How about asking the xdg-open developers to help us figure out the
> reason?  Or, failing that, debug xdg-open in the problematic
> situations to find out what fails there and why?  E.g., could it be
> that it fails because stdin/stdout is a PTY? what happens if you bind
> process-connection-type to nil when starting the async subprocess?

I do not think, it is xdg-open problem. It just calls kde-open5 that 
spawns actual handler and immediately exits.




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Sat, 30 Jan 2021 13:49:02 GMT) Full text and rfc822 format available.

Message #58 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Maxim Nikulin <m.a.nikulin <at> gmail.com>
Cc: 44824 <at> debbugs.gnu.org, gbiotti <at> gmail.com
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Sat, 30 Jan 2021 15:49:02 +0200
> From: Maxim Nikulin <m.a.nikulin <at> gmail.com>
> Date: Sat, 30 Jan 2021 20:31:53 +0700
> Cc: gbiotti <at> gmail.com
> 
> > How about asking the xdg-open developers to help us figure out the
> > reason?  Or, failing that, debug xdg-open in the problematic
> > situations to find out what fails there and why?  E.g., could it be
> > that it fails because stdin/stdout is a PTY? what happens if you bind
> > process-connection-type to nil when starting the async subprocess?
> 
> I do not think, it is xdg-open problem. It just calls kde-open5 that 
> spawns actual handler and immediately exits.

I didn't say it was their problem, I suggested to ask them to help us
understand why xdg-open doesn't work in those cases, under the
assumption that they are familiar with their code better than us.




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Sat, 30 Jan 2021 15:59:01 GMT) Full text and rfc822 format available.

Message #61 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Nikulin <m.a.nikulin <at> gmail.com>
Cc: 44824 <at> debbugs.gnu.org
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Sat, 30 Jan 2021 22:58:06 +0700
On 30/01/2021 20:49, Eli Zaretskii wrote:
>>
>>> How about asking the xdg-open developers to help us figure out the
>>> reason?
>>
>> I do not think, it is xdg-open problem. It just calls kde-open5 that
>> spawns actual handler and immediately exits.
> 
> I didn't say it was their problem, I suggested to ask them to help us
> understand why xdg-open doesn't work in those cases, under the
> assumption that they are familiar with their code better than us.

What kind of help do you expect from xdg-open developers? It is a shell 
script, you could easily inspect it. I have posted already a command how 
to trace its execution. However currently I am almost sure that it 
merely calls 'kde-open5 /tmp/file.pdf'. The problem is that emacs does 
not expect that kde-open5 and thus xdg-open exits instantly. The 
question could be addressed to KDE developers, but unlike the issue with 
temporary files, in my opinion, pty+SIGHUP problem should be fixed in 
org mode. Some convenience function in emacs core would be nice but org 
mode is compatible with older emacs releases. Thus the only option is to 
change the org-open-files function.




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Sat, 30 Jan 2021 16:29:02 GMT) Full text and rfc822 format available.

Message #64 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Maxim Nikulin <m.a.nikulin <at> gmail.com>
Cc: 44824 <at> debbugs.gnu.org
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Sat, 30 Jan 2021 18:28:17 +0200
> From: Maxim Nikulin <m.a.nikulin <at> gmail.com>
> Date: Sat, 30 Jan 2021 22:58:06 +0700
> Cc: 44824 <at> debbugs.gnu.org
> 
> The problem is that emacs does not expect that kde-open5 and thus
> xdg-open exits instantly.

Why is that a problem, and how does it cause the invocation to fail,
i.e. not show the file in question?

> The question could be addressed to KDE developers, but unlike the
> issue with temporary files, in my opinion, pty+SIGHUP problem should
> be fixed in org mode.

What do you mean by "pty+SIGHUP problem" in this case?  What exactly
is the problem?




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Sat, 30 Jan 2021 16:40:01 GMT) Full text and rfc822 format available.

Message #67 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: "gbiotti <at> gmail.com" <gbiotti <at> gmail.com>
To: Maxim Nikulin <m.a.nikulin <at> gmail.com>, 44824 <at> debbugs.gnu.org
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Sat, 30 Jan 2021 17:39:07 +0100
[Message part 1 (text/plain, inline)]
Il 30/01/2021 14:31, Maxim Nikulin ha wrote:
> On 30/01/2021 15:42, Eli Zaretskii wrote:
>>>
>>> This works:
>>> M-! xdg-open /tmp/test.pdf RET
>>>
>>> This doesn't work:
>>> M-& xdg-open /tmp/test.pdf RET
>>>
>>> This doesn't work:
>>> M-x shell RET xdg-open /tmp/test.pdf RET
>
> Geraldo, "M-x shell" case is rather strange. Could you, please, 
> confirm ones more that okular window with the file content does not 
> appear if you call xdg-open from an *interactive* emacs shell buffer? 
> The link to an emacs-orgmode list message, that I have posted earlier, 
> explains why async-shell-command *may* fail while shell-command should 
> work reliably. I am really surprised by failure when command is 
> executed in a [e]shell buffer.
>

I confirm.
I can see the Okular icon appear and disappear immediately in the panel.
As mentioned I can make a video of everything, but I have no idea where 
to upload it.
If it is okay to make the video and you think it is useful please tell 
me which commands to execute for more information on the operating 
environment

>> How about asking the xdg-open developers to help us figure out the
>> reason?  Or, failing that, debug xdg-open in the problematic
>> situations to find out what fails there and why?  E.g., could it be
>> that it fails because stdin/stdout is a PTY? what happens if you bind
>> process-connection-type to nil when starting the async subprocess?
>
> I do not think, it is xdg-open problem. It just calls kde-open5 that 
> spawns actual handler and immediately exits.

[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Sat, 30 Jan 2021 18:52:02 GMT) Full text and rfc822 format available.

Message #70 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Bhavin Gandhi <bhavin7392 <at> gmail.com>
To: "gbiotti <at> gmail.com" <gbiotti <at> gmail.com>
Cc: 44824 <at> debbugs.gnu.org, Maxim Nikulin <m.a.nikulin <at> gmail.com>
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Sun, 31 Jan 2021 00:20:41 +0530
On Sat, 30 Jan 2021 at 19:04, Maxim Nikulin <m.a.nikulin <at> gmail.com> wrote:
> […]
>
> Geraldo, "M-x shell" case is rather strange. Could you, please, confirm
> ones more that okular window with the file content does not appear if
> you call xdg-open from an *interactive* emacs shell buffer? The link to
> an emacs-orgmode list message, that I have posted earlier, explains why
> async-shell-command *may* fail while shell-command should work reliably.
> I am really surprised by failure when command is executed in a [e]shell
> buffer.
>

I was expecting something similar, surprisingly here is what I observed
on my system (with emacs -Q, GNOME and Evince — Document Viewer).

M-x eshell
$ xdg-open ~/Documents/test.pdf
[Nothing happens]

M-x shell
$ xdg-open ~/Documents/test.pdf
[Evince pops up with the PDF]

M-! xdg-open ~/Documents/test.pdf
[Evince pops up with the PDF]

M-& xdg-open ~/Documents/test.pdf
[Nothing happens]

Emacs: 27.1.91
GNOME: 3.38.3
xdg-open 1.1.3+
-- 
Warm Regards,
Bhavin Gandhi (bhavin192) | https://geeksocket.in




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Sun, 31 Jan 2021 07:18:01 GMT) Full text and rfc822 format available.

Message #73 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 44824 <at> debbugs.gnu.org, gbiotti <at> gmail.com
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Sun, 31 Jan 2021 08:17:04 +0100
Eli Zaretskii <eliz <at> gnu.org> writes:

>> This doesn't work:
>> M-x shell RET xdg-open /tmp/test.pdf RET
>
> How about asking the xdg-open developers to help us figure out the
> reason?  Or, failing that, debug xdg-open in the problematic
> situations to find out what fails there and why?  E.g., could it be
> that it fails because stdin/stdout is a PTY? what happens if you bind
> process-connection-type to nil when starting the async subprocess?

I'm unable to reproduce the problem at all -- all the various ways of
calling xdg-open work fine for me (on this Debian bullseye laptop w/
Gnome Shell).

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




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Sun, 31 Jan 2021 11:16:01 GMT) Full text and rfc822 format available.

Message #76 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Nikulin <m.a.nikulin <at> gmail.com>
To: 44824 <at> debbugs.gnu.org
Cc: Eli Zaretskii <eliz <at> gnu.org>, gbiotti <at> gmail.com
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Sun, 31 Jan 2021 18:15:27 +0700
Bhavin, thank you very much for your clear report. I have tried once 
more with eshell session and this time I was lucky enough to reproduce 
the problem in both gnome and kde sessions on Ubuntu-20.04 focal

On 30/01/2021 23:28, Eli Zaretskii wrote:
>> From: Maxim Nikulin
>> Date: Sat, 30 Jan 2021 22:58:06 +0700
>>
>> The problem is that emacs does not expect that kde-open5 and thus
>> xdg-open exits instantly.
> 
> Why is that a problem, and how does it cause the invocation to fail,
> i.e. not show the file in question?
> 
>> The question could be addressed to KDE developers, but unlike the
>> issue with temporary files, in my opinion, pty+SIGHUP problem should
>> be fixed in org mode.
> 
> What do you mean by "pty+SIGHUP problem" in this case?  What exactly
> is the problem?

In the https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44824#22 message I 
have posted a link to another thread in emacs-orgmode mail list thread 
with my earlier strace results: 
https://lists.gnu.org/archive/html/emacs-orgmode/2021-01/msg00327.html

Now I see that the problem with eshell is the same. I am not familiar 
with eshell, but it creates new shell process for every executed 
command. Actual handler is killed when underlying handler (kde-open5, 
"gio open") and thus xdg-open and the main shell process exit.

Excerpts from strace obtained for a eshell buffer

2221  16:59:43.513366 execve("/bin/sh", ["/bin/sh", "/usr/bin/xdg-open", 
"/tmp/test.pdf"], 0x7fff74be7f10 /* 58 vars */ <unfinished ...>
2224  16:59:43.566865 execve("/usr/bin/gio", ["gio", "open", 
"/tmp/test.pdf"], 0x55ee8454ec18 /* 58 vars */) = 0
2229  16:59:43.711846 execve("/bin/sh", ["/bin/sh", "-e", "-u", "-c", 
"export GIO_LAUNCHED_DESKTOP_FILE_PID=$$; exec \"$@\"", "sh", "evince", 
"/tmp/test.pdf"], 0x55bb59e67bb0 /* 59 vars */ <unfinished ...>
2221  16:59:43.717489 +++ exited with 0 +++
2229  16:59:43.719228 +++ killed by SIGHUP +++

Functions dealing with asynchronous processes in emacs, namely 
(start-process ...) and its siblings for shell commands calls 
(make-process :connection-type 'pty ...) that creates a pseudoterminal. 
It is redundant for applications that do not require an interactive 
terminal. When process (xdg-open this case) exits, pty is closed, all 
processes from the same terminal group receives SIGHUP. So actual 
handler is killed unless it has set signal handler or has detached from 
terminal session.

To fix the problem it is better to use (make-process :connection-type 
'pipe ...) that unfortunately has no higher level wrappers. "Pipe" 
process does not creates a pseudoterminal thus its children do not get 
SIGHUP on the exit of the main process. I am unsure concerning best 
values for other arguments however. The complication is that some 
mailcap entries have needsterminal flag, on the other hand they are 
likely irrelevant for GUI.

There is no problem if okular or evince are called directly (without 
kde-open5 or "gio open" wrapper) since main process does not exit while 
window is open.

Maybe the following command executed in eshell (namely eshell, not just 
shell) buffer is the best to demonstrate the problem (for those whose 
desktop environment is affected)

    sh -c "xdg-open /tmp/test.pdf; sleep 5"

The window with file content appears for 5 seconds then the viewer is 
killed.

On 31/01/2021 16:09, tomas <at> tuxteam.de wrote:
> This chaotic behaviour gives me the impression that it's an
> environment thing: desktop environments have the tendency to prime
> the environment variables in "creative" ways, often different from
> what a login shell would do.

Certainly the behavior depends on the desktop environment. You could 
check which DE-specific handler is called (and factor-out xdg-open) with

    sh -x /usr/bin/xdg-open /tmp/test.pdf

As to other options, M-! executes the process synchronously and is not 
affected. M-& has the same pty+SIGHUP problem.

I am almost sure that I have tried eshell before, but I have no idea why 
I have not noticed the problem that time.




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Sun, 31 Jan 2021 11:38:01 GMT) Full text and rfc822 format available.

Message #79 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: <tomas <at> tuxteam.de>
To: Maxim Nikulin <m.a.nikulin <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 44824 <at> debbugs.gnu.org, gbiotti <at> gmail.com
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Sun, 31 Jan 2021 12:37:10 +0100
[Message part 1 (text/plain, inline)]
On Sun, Jan 31, 2021 at 06:15:27PM +0700, Maxim Nikulin wrote:
> Bhavin, thank you very much for your clear report. I have tried once
> more with eshell session and this time I was lucky enough to
> reproduce the problem in both gnome and kde sessions on Ubuntu-20.04
> focal

[...]

> 2221  16:59:43.717489 +++ exited with 0 +++
> 2229  16:59:43.719228 +++ killed by SIGHUP +++

Good catch.

> On 31/01/2021 16:09, tomas <at> tuxteam.de wrote:
> >This chaotic behaviour gives me the impression that it's an
> >environment thing [...]

> Certainly the behavior depends on the desktop environment. You could
> check which DE-specific handler is called (and factor-out xdg-open)
> with
> 
>     sh -x /usr/bin/xdg-open /tmp/test.pdf
> 
> As to other options, M-! executes the process synchronously and is
> not affected. M-& has the same pty+SIGHUP problem.
> 
> I am almost sure that I have tried eshell before, but I have no idea
> why I have not noticed the problem that time.

Yes, but in this case it seems I was barking up the wrong tree :)

Cheers & thanks
 - t
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Sun, 31 Jan 2021 15:06:02 GMT) Full text and rfc822 format available.

Message #82 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Maxim Nikulin <m.a.nikulin <at> gmail.com>
Cc: 44824 <at> debbugs.gnu.org, gbiotti <at> gmail.com
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Sun, 31 Jan 2021 17:05:37 +0200
> From: Maxim Nikulin <m.a.nikulin <at> gmail.com>
> Cc: Eli Zaretskii <eliz <at> gnu.org>, gbiotti <at> gmail.com
> Date: Sun, 31 Jan 2021 18:15:27 +0700
> 
> Now I see that the problem with eshell is the same. I am not familiar 
> with eshell, but it creates new shell process for every executed 
> command. Actual handler is killed when underlying handler (kde-open5, 
> "gio open") and thus xdg-open and the main shell process exit.

What do you mean here by "actual handler" and "underlying handler"?

> Functions dealing with asynchronous processes in emacs, namely 
> (start-process ...) and its siblings for shell commands calls 
> (make-process :connection-type 'pty ...) that creates a pseudoterminal. 
> It is redundant for applications that do not require an interactive 
> terminal. When process (xdg-open this case) exits, pty is closed, all 
> processes from the same terminal group receives SIGHUP. So actual 
> handler is killed unless it has set signal handler or has detached from 
> terminal session.
> 
> To fix the problem it is better to use (make-process :connection-type 
> 'pipe ...) that unfortunately has no higher level wrappers.

Wouldn't it work to let-bind process-connection-type to nil around the
function that starts the async subprocess?

And I still don't understand why some people (like Lars) cannot
reproduce the problem at all -- the issue sounds like something that
should fail deterministically on any GNU/Linux system.  What am I
missing?




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Sun, 31 Jan 2021 15:18:02 GMT) Full text and rfc822 format available.

Message #85 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: gbiotti <at> gmail.com, 44824 <at> debbugs.gnu.org,
 Maxim Nikulin <m.a.nikulin <at> gmail.com>
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Sun, 31 Jan 2021 16:17:46 +0100
On Jan 31 2021, Eli Zaretskii wrote:

> And I still don't understand why some people (like Lars) cannot
> reproduce the problem at all -- the issue sounds like something that
> should fail deterministically on any GNU/Linux system.  What am I
> missing?

If xdg-open doesn't need to start the program itself, and sends the
request to an already running process instead, there won't be any
problem with the disappearing session.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Sun, 31 Jan 2021 15:22:02 GMT) Full text and rfc822 format available.

Message #88 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: gbiotti <at> gmail.com, 44824 <at> debbugs.gnu.org,
 Maxim Nikulin <m.a.nikulin <at> gmail.com>
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Sun, 31 Jan 2021 16:21:34 +0100
Eli Zaretskii <eliz <at> gnu.org> writes:

> And I still don't understand why some people (like Lars) cannot
> reproduce the problem at all -- the issue sounds like something that
> should fail deterministically on any GNU/Linux system.  What am I
> missing?

The recipe said to start with `M-x shell' -- I wasn't able to reproduce
the problem there.  But with `M-x eshell' I can repeat the problem here,
too.

Perhaps the recipe was wrong?

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




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Sun, 31 Jan 2021 15:35:02 GMT) Full text and rfc822 format available.

Message #91 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: gbiotti <at> gmail.com, 44824 <at> debbugs.gnu.org, m.a.nikulin <at> gmail.com
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Sun, 31 Jan 2021 17:34:26 +0200
> From: Andreas Schwab <schwab <at> linux-m68k.org>
> Cc: Maxim Nikulin <m.a.nikulin <at> gmail.com>,  44824 <at> debbugs.gnu.org,
>   gbiotti <at> gmail.com
> Date: Sun, 31 Jan 2021 16:17:46 +0100
> 
> On Jan 31 2021, Eli Zaretskii wrote:
> 
> > And I still don't understand why some people (like Lars) cannot
> > reproduce the problem at all -- the issue sounds like something that
> > should fail deterministically on any GNU/Linux system.  What am I
> > missing?
> 
> If xdg-open doesn't need to start the program itself, and sends the
> request to an already running process instead, there won't be any
> problem with the disappearing session.

Ah, okay.  Lars, could this be what happens on your system?




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Sun, 31 Jan 2021 15:59:01 GMT) Full text and rfc822 format available.

Message #94 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Nikulin <m.a.nikulin <at> gmail.com>
Cc: 44824 <at> debbugs.gnu.org
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Sun, 31 Jan 2021 22:57:57 +0700
On 31/01/2021 22:05, Eli Zaretskii wrote:
>> From: Maxim Nikulin
>> Date: Sun, 31 Jan 2021 18:15:27 +0700
>>
>> Now I see that the problem with eshell is the same. I am not familiar
>> with eshell, but it creates new shell process for every executed
>> command. Actual handler is killed when underlying handler (kde-open5,
>> "gio open") and thus xdg-open and the main shell process exit.
> 
> What do you mean here by "actual handler" and "underlying handler"?

- actual handler: okular, evince, etc.
- underlying handler is what xdg-open actually calls: kde-open5, "gio 
open", etc. and that maps file type to particular .desktop (or mailcap) 
handler.

>> To fix the problem it is better to use (make-process :connection-type
>> 'pipe ...) that unfortunately has no higher level wrappers.
> 
> Wouldn't it work to let-bind process-connection-type to nil around the
> function that starts the async subprocess?

Sorry, for me it easier to reason how to express it in terms of system 
calls and terminal process groups than if let-bind could override a 
variable when lexical-bind is set to true.

> And I still don't understand why some people (like Lars) cannot
> reproduce the problem at all -- the issue sounds like something that
> should fail deterministically on any GNU/Linux system.  What am I
> missing?

On 31/01/2021 22:17, Andreas Schwab wrote:
>
> If xdg-open doesn't need to start the program itself, and sends the
> request to an already running process instead, there won't be any
> problem with the disappearing session.

I have been tempting to say that it is a race (either request is 
completed before SIGHUP or not) since Christopher Miles posted a link to 
stackexchange and I have realized the actual effect of an 
antidaemonizing cast I noticed earlier in a package related to org mode. 
On the other hand, I am not familiar with kde and gnome internals. I 
guess they could use a kind of server processes but I have no idea how 
to arrange parts for a convincing demonstration.




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Sun, 31 Jan 2021 16:34:01 GMT) Full text and rfc822 format available.

Message #97 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Maxim Nikulin <m.a.nikulin <at> gmail.com>
Cc: 44824 <at> debbugs.gnu.org
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Sun, 31 Jan 2021 18:33:31 +0200
> From: Maxim Nikulin <m.a.nikulin <at> gmail.com>
> Date: Sun, 31 Jan 2021 22:57:57 +0700
> Cc: 44824 <at> debbugs.gnu.org
> 
> >> To fix the problem it is better to use (make-process :connection-type
> >> 'pipe ...) that unfortunately has no higher level wrappers.
> > 
> > Wouldn't it work to let-bind process-connection-type to nil around the
> > function that starts the async subprocess?
> 
> Sorry, for me it easier to reason how to express it in terms of system 
> calls and terminal process groups than if let-bind could override a 
> variable when lexical-bind is set to true.

Well, I think we should try this, because if it works, it will show us
a way to fix the problem.  (I don't see how lexical-binding could
interfere with let-binding.)




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Sun, 31 Jan 2021 17:08:02 GMT) Full text and rfc822 format available.

Message #100 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Nikulin <m.a.nikulin <at> gmail.com>
To: 44824 <at> debbugs.gnu.org
Subject: Re: bug#44824: 27.1; Org export as pdf and open file does not open it
Date: Mon, 1 Feb 2021 00:07:10 +0700
On 31/01/2021 23:33, Eli Zaretskii wrote:
>>
>>>> To fix the problem it is better to use (make-process :connection-type
>>>> 'pipe ...) that unfortunately has no higher level wrappers.
>>>
>>> Wouldn't it work to let-bind process-connection-type to nil around the
>>> function that starts the async subprocess?

>> ...

> Well, I think we should try this, because if it works, it will show us
> a way to fix the problem.  (I don't see how lexical-binding could
> interfere with let-binding.)

It is not a great problem to use make-process:

https://lists.gnu.org/archive/html/emacs-orgmode/2021-01/msg00364.html

I think that at least a :sentinel should be added to improve error 
reporting. The code just before these lines has another problem (I hope 
it is really rare): 
https://lists.gnu.org/archive/html/emacs-orgmode/2021-01/msg00353.html

I would avoid shell since direct execution of the handler should be more 
robust, e.g. quoting of arguments is not necessary. Unfortunately RFC on 
mailcap states that command is executed by shell. On the other hand only 
a few of viewer entries have commands that could not be handled without 
shell.




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Thu, 18 Feb 2021 12:57:01 GMT) Full text and rfc822 format available.

Message #103 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Nikulin <m.a.nikulin <at> gmail.com>
To: Maxim Nikulin <m.a.nikulin <at> gmail.com>
Cc: 44824 <at> debbugs.gnu.org
Subject: [PATCH] org.el: Avoid xdg-open silent failure
Date: Thu, 18 Feb 2021 19:56:03 +0700
[Message part 1 (text/plain, inline)]
On 31/01/2021 23:33, Eli Zaretskii wrote:
>> From: Maxim Nikulin <m.a.nikulin <at> gmail.com>
>> Date: Sun, 31 Jan 2021 22:57:57 +0700
>> Cc: 44824 <at> debbugs.gnu.org
>>
>>>> To fix the problem it is better to use (make-process :connection-type
>>>> 'pipe ...) that unfortunately has no higher level wrappers.
>>>
>>> Wouldn't it work to let-bind process-connection-type to nil around the
>>> function that starts the async subprocess?
>>
>> Sorry, for me it easier to reason how to express it in terms of system
>> calls and terminal process groups than if let-bind could override a
>> variable when lexical-bind is set to true.
> 
> Well, I think we should try this, because if it works, it will show us
> a way to fix the problem.  (I don't see how lexical-binding could
> interfere with let-binding.)

I have prepared a patch that uses `make-process'. I hope, error 
reporting is improved a bit, but in the case of this particular problem 
failure is still quiet since xdg-open exits successfully.

I could not estimate effect of such change on windows, so pipe process
is used only on linux. I am unsure concerning mac however.

Another question is if failure message should be suppressed when 
`waiting-for-user-input-p' returns truth to keep user prompt and input 
unaffected.
[open-file-pipe-process.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Thu, 18 Feb 2021 14:49:02 GMT) Full text and rfc822 format available.

Message #106 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Maxim Nikulin <m.a.nikulin <at> gmail.com>
Cc: 44824 <at> debbugs.gnu.org
Subject: Re: bug#44824: [PATCH] org.el: Avoid xdg-open silent failure
Date: Thu, 18 Feb 2021 16:48:26 +0200
> From: Maxim Nikulin <m.a.nikulin <at> gmail.com>
> Date: Thu, 18 Feb 2021 19:56:03 +0700
> Cc: 44824 <at> debbugs.gnu.org
> 
> I could not estimate effect of such change on windows, so pipe process
> is used only on linux. I am unsure concerning mac however.

On Windows Emacs always uses pipes, because we don't have PTYs there.
And there's no xdg-open on MS-Windows anyway, so it's a moot point.




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Fri, 19 Feb 2021 12:31:01 GMT) Full text and rfc822 format available.

Message #109 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Nikulin <m.a.nikulin <at> gmail.com>
Cc: 44824 <at> debbugs.gnu.org
Subject: Re: bug#44824: [PATCH] org.el: Avoid xdg-open silent failure
Date: Fri, 19 Feb 2021 19:29:49 +0700
On 18/02/2021 21:48, Eli Zaretskii wrote:
>> From: Maxim Nikulin
>> Date: Thu, 18 Feb 2021 19:56:03 +0700
>>
>> I could not estimate effect of such change on windows, so pipe process
>> is used only on linux. I am unsure concerning mac however.
> 
> On Windows Emacs always uses pipes, because we don't have PTYs there.
> And there's no xdg-open on MS-Windows anyway, so it's a moot point.

Should I consider your response as a suggestion to remove the `if' 
related to `system-type'?

If I remember correctly, on windows it is possible to communicate with a 
process through stdin and stdout only if the application is compiled as 
a *console* one. That is why it is unclear for me, which component 
handles console or GUI distinction when process is specified as pipe in 
lisp code, and whether all arguments of `make-process', that I have 
used, are suitable on windows.

"start file.pdf" executed in cmd.exe launches an application that does 
not block command prompt. In this sense it similar to background 
processes launched by kde-open5 or "gio open". However I am unaware if 
there is something similar to process groups on windows that leads to 
termination of all group members when leader process finishes.




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Fri, 19 Feb 2021 14:55:01 GMT) Full text and rfc822 format available.

Message #112 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Maxim Nikulin <m.a.nikulin <at> gmail.com>
Cc: 44824 <at> debbugs.gnu.org
Subject: Re: bug#44824: [PATCH] org.el: Avoid xdg-open silent failure
Date: Fri, 19 Feb 2021 16:54:11 +0200
> From: Maxim Nikulin <m.a.nikulin <at> gmail.com>
> Date: Fri, 19 Feb 2021 19:29:49 +0700
> Cc: 44824 <at> debbugs.gnu.org
> 
> > On Windows Emacs always uses pipes, because we don't have PTYs there.
> > And there's no xdg-open on MS-Windows anyway, so it's a moot point.
> 
> Should I consider your response as a suggestion to remove the `if' 
> related to `system-type'?

Yes, that 'if' isn't necessary.

> If I remember correctly, on windows it is possible to communicate with a 
> process through stdin and stdout only if the application is compiled as 
> a *console* one.

That's true.  But in this case we don't really want to communicate
with the sub-process, do we?  We just want to invoke it and let it
run.  So the fact that there's no way of communicating with the
sub-process is not important here, as the pipes will not be used.  We
just need to specify pipes because that works around the problem with
xdg-open.

> "start file.pdf" executed in cmd.exe launches an application that does 
> not block command prompt. In this sense it similar to background 
> processes launched by kde-open5 or "gio open". However I am unaware if 
> there is something similar to process groups on windows that leads to 
> termination of all group members when leader process finishes.

Things are fairly similar on Windows.  But is this really relevant to
the issue at hand?  There's no xdg-open on Windows, so whatever
problems you had with xdg-open will never happen on Windows.  the
proposed patch fixes the problem only on systems where org.el invokes
the PDF viewer via xdg-open.  Right?




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Fri, 19 Feb 2021 16:47:01 GMT) Full text and rfc822 format available.

Message #115 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Nikulin <m.a.nikulin <at> gmail.com>
Cc: 44824 <at> debbugs.gnu.org
Subject: Re: bug#44824: [PATCH] org.el: Avoid xdg-open silent failure
Date: Fri, 19 Feb 2021 23:45:55 +0700
On 19/02/2021 21:54, Eli Zaretskii wrote:
>> From: Maxim Nikulin
>> Date: Fri, 19 Feb 2021 19:29:49 +0700
>>
>>> On Windows Emacs always uses pipes, because we don't have PTYs there.
>>> And there's no xdg-open on MS-Windows anyway, so it's a moot point.
>>
>> Should I consider your response as a suggestion to remove the `if'
>> related to `system-type'?
> 
> Yes, that 'if' isn't necessary.

Let's wait for comments comments from org developers. I do not mind to 
remove the `if' but they could ask for other changes.

>> If I remember correctly, on windows it is possible to communicate with a
>> process through stdin and stdout only if the application is compiled as
>> a *console* one.
> 
> That's true.  But in this case we don't really want to communicate
> with the sub-process, do we?  We just want to invoke it and let it
> run.  So the fact that there's no way of communicating with the
> sub-process is not important here, as the pipes will not be used.  We
> just need to specify pipes because that works around the problem with
> xdg-open.

The reason to switch to pipe process here is to avoid side effects of 
*terminal session*. PTY is redundant here. Pipe process is the only 
alternative available in emacs. Currently there is no data exchange with 
subprocess.

Reading of stderr and stdout from the handler and its descendants could 
be useful to realize a cause of a problem when it happens. At least on 
linux it is enough to specify some buffer instead of `nil' or add a 
:filter function. The reason why I did not make such change is that Gtk 
applications tends to report significant number of failed asserts. I do 
not like to pollute the "*Messages*" buffer. I am in doubts if a 
dedicated buffer should be created for such purpose.

Reading of stdout could be useful in mailcap handlers e.g. to display 
text from PDF file when only text terminal is available (no X11 or 
wayland). Currently emacs ignores "needsterminal" and "copiousoutput" 
flags in mailcap. Example of an entry for PDF:

application/pdf; pdftotext -layout %s -; test=test -z "$DISPLAY"; 
copiousoutput

Likely only a small part of users could benefit from such feature.

>> "start file.pdf" executed in cmd.exe launches an application that does
>> not block command prompt. In this sense it similar to background
>> processes launched by kde-open5 or "gio open". However I am unaware if
>> there is something similar to process groups on windows that leads to
>> termination of all group members when leader process finishes.
> 
> Things are fairly similar on Windows.  But is this really relevant to
> the issue at hand?  There's no xdg-open on Windows, so whatever
> problems you had with xdg-open will never happen on Windows.  the
> proposed patch fixes the problem only on systems where org.el invokes
> the PDF viewer via xdg-open.  Right?

1. It is not a problem of namely xdg-open. It is (mostly reasonable but 
with some caveats however) specific of DE-specific handlers as "gio 
open" and kde-open5. They exit just after spawning of a process with 
actual handler. (Just like "start file.pdf" on windows.) I am afraid 
that I could break something on windows, so I would prefer that somebody 
will test the changes on non-linux systems.

2. It is not specific to PDF files, the problem could happen with any 
format if wrapper handler such as "gio open" is invoked instead of e.g. 
direct execution of eog.




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Fri, 19 Mar 2021 03:51:02 GMT) Full text and rfc822 format available.

Message #118 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Kyle Meyer <kyle <at> kyleam.com>
To: Maxim Nikulin <manikulin <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 44824 <at> debbugs.gnu.org
Subject: Re: [PATCH] org.el: Avoid xdg-open silent failure
Date: Thu, 18 Mar 2021 23:50:06 -0400
Maxim Nikulin writes:

>     org.el: Avoid xdg-open silent failure
>     
>     * lisp/org.el (org-open-file): Use 'pipe :connection-type instead of
>     'pty to prevent killing of background process on handler exit.
>     
>     Problem happens only in some desktop environments where configured
>     through `org-file-apps' or mailcap handlers launches actual viewer
>     (as defined in .desktop files and obtained from mimeapps.list)
>     in background.  E.g. xdg-open invokes "gio open" or kde-open5 for Gnome
>     or KDE accordingly and these handlers launches e.g. eog or okular in
>     background.  As soon as main process exits, temporary terminal session
>     created by `start-process-shell-command' is terminated.  As a result
>     background processes receive SIGHUP.
>     
>     Previously command were executed with no buffer, so the change
>     does not affect "needsterminal" and "copiousoutput" mailcap features,
>     they are not supported as earlier.
>     
>     If handler main process fails then show a message with exit reason.
>     Output (including error messages) is ignored as before.
>     Gtk application tends to report significant amount of failed asserts
>     hardly informative for majority of users.

Thanks for the detailed commit message.

A few comments in addition to Eli's advice to drop the
(eq system-type 'gnu/linux) condition...

> diff --git a/lisp/org.el b/lisp/org.el
> index 7d8733448..a199a65c9 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -8645,6 +8645,15 @@ opened in Emacs."
>     (when add-auto-mode
>       (mapcar (lambda (x) (cons (car x) 'emacs)) auto-mode-alist))))
>  
> +(defun org--error-process-sentinel (proc event)
> +  "Show a message if process failed (exited with non-zero code
> +or killed by a signal.  Pass the function as :SENTINEL argument

Please rework the first sentence so that it fits on the first line,
though I'd be in favor dropping the function and using a lambda in the
make-process call.

> +of `make-process'."
> +  (unless (string-match "finished" event)

There's no need for substring matching, right?  So it could be

  (equal event "finished\n")

Or perhaps

  (when (and (memq (process-status proc) '(exit signal))
             (/= (process-exit-status proc) 0))
    ...)

> +    (message "Command %s: %s."
> +             (mapconcat 'identity (process-command proc) " ")

s/'identity/#'identity/

> +             (substring event 0 -1))))
> +
>  ;;;###autoload
>  (defun org-open-file (path &optional in-emacs line search)
>    "Open the file at PATH.
> @@ -8766,7 +8775,17 @@ If the file does not exist, throw an error."
>  
>        (save-window-excursion
>  	(message "Running %s...done" cmd)
> -	(start-process-shell-command cmd nil cmd)
> +	(if (eq system-type 'gnu/linux)
> +	  ;; Handlers as "gio open" and kde-open5 start viewer in background

s/as/such as/ ?

> +	  ;; and exit immediately. Avoid start-process since it assumes

                                  ^ missing space

> +	  ;; :connection-type 'pty and kills children processes with SIGHUP
> +	  ;; when temporary terminal session is finished.
> +	  (make-process
> +	    :name "org-open-file" :connection-type 'pipe :noquery 't

s/'t/t/

> +	    :buffer nil ; use "*Messages*" for debugging
> +	    :sentinel 'org--error-process-sentinel
> +	    :command (list shell-file-name shell-command-switch cmd))
> +	  (start-process-shell-command cmd nil cmd))
>  	(and (boundp 'org-wait) (numberp org-wait) (sit-for org-wait))))
>       ((or (stringp cmd)
>  	  (eq cmd 'emacs))

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org, emacs-orgmode <at> gnu.org:
bug#44824; Package emacs,org-mode. (Sat, 20 Mar 2021 15:46:02 GMT) Full text and rfc822 format available.

Message #121 received at 44824 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Nikulin <m.a.nikulin <at> gmail.com>
Cc: 44824 <at> debbugs.gnu.org
Subject: Re: bug#44824: [PATCH] org.el: Avoid xdg-open silent failure
Date: Sat, 20 Mar 2021 22:45:16 +0700
[Message part 1 (text/plain, inline)]
On 19/03/2021 10:50, Kyle Meyer wrote:
> Maxim Nikulin writes:
> A few comments in addition to Eli's advice to drop the
> (eq system-type 'gnu/linux) condition...

Feel free to commit the change suggested in
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44824#82
instead of this patch.

>> +(defun org--error-process-sentinel (proc event)
>> +  "Show a message if process failed (exited with non-zero code
>> +or killed by a signal.  Pass the function as :SENTINEL argument
> 
> Please rework the first sentence so that it fits on the first line,
> though I'd be in favor dropping the function and using a lambda in the
> make-process call.

My impression is that org-open-file function is already too long and 
complex. Another reason to use standalone function is that I am unsure 
if elisp compiler and interpreter are smart enough to reuse single 
instance of lambda. I was afraid that every opened file caused creation 
of new sentinel possibly with a closure containing chain of stack 
frames. On the other hand even in worst case memory footprint is 
negligible in comparison to any GUI viewer.

>> +  (unless (string-match "finished" event)
> 
> There's no need for substring matching, right?  So it could be
> 
>    (equal event "finished\n")

I was surprised by final "\n" that is not always suitable and I was in 
doubts concerning its stability. I would prefer something like

    (starts-with event "finished")

Certainly match-data is not necessary, so even match-string-p is better.

>    (when (and (memq (process-status proc) '(exit signal))
>               (/= (process-exit-status proc) 0))

Thank you, I was too lazy to implement such kind of check myself. 
Certainly this variant is better.

I hope, I have addressed other your comments in the updated patch.

[org-open-file-make-process-v2.patch (text/x-patch, attachment)]

Reply sent to Kyle Meyer <kyle <at> kyleam.com>:
You have taken responsibility. (Sun, 21 Mar 2021 15:02:02 GMT) Full text and rfc822 format available.

Notification sent to Geraldo Biotti <gbiotti <at> gmail.com>:
bug acknowledged by developer. (Sun, 21 Mar 2021 15:02:02 GMT) Full text and rfc822 format available.

Message #126 received at 44824-done <at> debbugs.gnu.org (full text, mbox):

From: Kyle Meyer <kyle <at> kyleam.com>
To: Maxim Nikulin <manikulin <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Geraldo Biotti <gbiotti <at> gmail.com>,
 44824-done <at> debbugs.gnu.org
Subject: Re: bug#44824: [PATCH] org.el: Avoid xdg-open silent failure
Date: Sun, 21 Mar 2021 11:01:03 -0400
Maxim Nikulin writes:

> I hope, I have addressed other your comments in the updated patch.
>
> commit 5eca7764d94dd46b9f9a7792d1b786a3f03b20b6
> Author: Max Nikulin <manikulin <at> gmail.com>
> Date:   Wed Feb 17 16:35:58 2021 +0000
>
>     org.el: Avoid xdg-open silent failure

Thanks.  A note for future patches: your patch isn't in a format that's
ready to be consumed by git-am.  git-format-patch can help you here.

Applied to the Org repo (5db61eb0f), adding a TINYCHANGE cookie to the
commit message.  Please consider completing the copyright paperwork for
future patches
(see <https://orgmode.org/worg/org-contribute.html#copyright-issues>).

If I understand correctly, this bug can be closed, but please reopen if
I'm mistaken.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 19 Apr 2021 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 1 day ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.