From: Max Nikulin <manikulin@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] org.el: Use `call-process' to launch external viewers (was: Re: [BUG] org-open-file immediately termininates when calling xdg-open that calls emacsclient)
Date: Fri, 3 Jun 2022 00:04:12 +0700 [thread overview]
Message-ID: <t7aqif$c2f$1@ciao.gmane.io> (raw)
In-Reply-To: <87bkvj57ip.fsf@localhost>
[-- Attachment #1: Type: text/plain, Size: 958 bytes --]
On 27/05/2022 22:18, Ihor Radchenko wrote:
> Max Nikulin writes:
>
>>> With this exact init.el, trying to run
>>> (let ((process-connection-type nil))
>>> (start-process-shell-command "1" nil "xdg-open ~/.bashrc"))
>>
>> Does it mean that you can not reproduce it with emacsclient instead of
>> xdg-open? Anyway I can not reproduce it with Emacs-27.1 from
>> Ubuntu-20.04.
>
> I have reported this to Emacs. The more precise steps are in
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=55672
As expected, nobody wishes to dig into obscure X11 issue.
You may try the attached patch. I do not consider it as unambiguous
improvement since almost all errors are swallowed due to requirement to
interpret viewer command using shell. The same approach settled on
`browse-url' after several fixes, but there at least wrong executable
name may be reported.
I suspect that you faced the bug working on another issue, so you do not
really suffer from it.
[-- Attachment #2: 0001-org.el-Use-call-process-to-launch-external-viewers.patch --]
[-- Type: text/x-patch, Size: 2282 bytes --]
From 01c5625d4c9b47573b1b3c8fb9d5672ff87b6696 Mon Sep 17 00:00:00 2001
From: Max Nikulin <manikulin@gmail.com>
Date: Thu, 2 Jun 2022 23:55:09 +0700
Subject: [PATCH] org.el: Use `call-process' to launch external viewers
lisp/org.el (org-open-file): Another attempt to make launching
of viewers more reliable by using approach from `browse-url'
with hope to alleviate (bug#55672). Unfortunately any errors
are silently ignored.
---
lisp/org.el | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index 95dff27ad..2cc122f5f 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8015,16 +8015,19 @@ If the file does not exist, throw an error."
(save-window-excursion
(message "Running %s...done" cmd)
- ;; Handlers such as "gio open" and kde-open5 start viewer in background
- ;; and exit immediately. Use pipe connection type instead of pty to
- ;; avoid killing children processes with SIGHUP when temporary terminal
- ;; session is finished.
- ;;
- ;; TODO: Once minimum Emacs version is 25.1 or above, consider using
- ;; the `make-process' invocation from 5db61eb0f929 to get more helpful
- ;; error messages.
- (let ((process-connection-type nil))
- (start-process-shell-command cmd nil cmd))
+ ;; Handlers such as "gio open" and kde-open5 start viewer in
+ ;; background and exit immediately. As a result
+ ;; `start-shell-process' with default pty
+ ;; `process-connection-type', children processes are killed
+ ;; with SIGHUP when temporary terminal session is finished.
+ ;; Pipe processes have other set of problems, see (bug#55672),
+ ;; (bug#12972) message 47. Shoot and forget method borrowed
+ ;; from `browse-url-xdg-open' has an advantage that launched
+ ;; viewer may run after quitting from Emacs. It is hard to
+ ;; avoid shell here since it is required by mailcap
+ ;; specification, but with shell all errors are silently
+ ;; ignored.
+ (call-process shell-file-name nil 0 nil shell-command-switch cmd)
(and (boundp 'org-wait) (numberp org-wait) (sit-for org-wait))))
((or (stringp cmd)
(eq cmd 'emacs))
--
2.25.1
next prev parent reply other threads:[~2022-06-02 17:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-22 4:37 [BUG] org-open-file immediately termininates when calling xdg-open that calls emacsclient [9.5.3 (release_9.5.3-508-ge268e4 @ /home/yantar92/.emacs.d/straight/build/org/)] Ihor Radchenko
2022-05-22 8:13 ` [BUG] org-open-file immediately termininates when calling xdg-open that calls emacsclient Max Nikulin
2022-05-26 14:24 ` Ihor Radchenko
2022-05-26 16:14 ` Max Nikulin
2022-05-27 6:19 ` Ihor Radchenko
2022-05-27 12:03 ` Max Nikulin
2022-05-27 15:18 ` Ihor Radchenko
2022-06-02 17:04 ` Max Nikulin [this message]
2022-07-24 5:51 ` [PATCH] org.el: Use `call-process' to launch external viewers (was: Re: [BUG] org-open-file immediately termininates when calling xdg-open that calls emacsclient) 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='t7aqif$c2f$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).