org-open-file: Avoid make-process for Emacs 24 compatibility

* lisp/org.el (org-open-file): Select a pipe connection type with
process-connection-type rather than make-process, which isn't
available until Emacs 25.

This uses the alternative approach suggested by Eli Zaretskii in the
thread that led to 5db61eb0f (org.el: Avoid xdg-open silent failure,
2021-03-21): https://orgmode.org/list/83y2g96ta6.fsf@gnu.org

Reported-by: Ihor Radchenko <yantar92@gmail.com>
Link: https://orgmode.org/list/87y2d2mqik.fsf@localhost
This commit is contained in:
Kyle Meyer 2021-05-01 00:07:09 -04:00
parent 45a3d7a900
commit 869b7a21b9
1 changed files with 9 additions and 14 deletions

View File

@ -8740,20 +8740,15 @@ If the file does not exist, throw an error."
(save-window-excursion (save-window-excursion
(message "Running %s...done" cmd) (message "Running %s...done" cmd)
;; Handlers such as "gio open" and kde-open5 start viewer in background ;; Handlers such as "gio open" and kde-open5 start viewer in background
;; and exit immediately. Avoid `start-process' since it assumes ;; and exit immediately. Use pipe connnection type instead of pty to
;; :connection-type 'pty and kills children processes with SIGHUP ;; avoid killing children processes with SIGHUP when temporary terminal
;; when temporary terminal session is finished. ;; session is finished.
(make-process ;;
:name "org-open-file" :connection-type 'pipe :noquery t ;; TODO: Once minimum Emacs version is 25.1 or above, consider using
:buffer nil ; use "*Messages*" for debugging ;; the `make-process' invocation from 5db61eb0f929 to get more helpful
:sentinel (lambda (proc event) ;; error messages.
(when (and (memq (process-status proc) '(exit signal)) (let ((process-connection-type nil))
(/= (process-exit-status proc) 0)) (start-process-shell-command cmd nil cmd))
(message
"Command %s: %s."
(mapconcat #'identity (process-command proc) " ")
(substring event 0 -1))))
:command (list shell-file-name shell-command-switch cmd))
(and (boundp 'org-wait) (numberp org-wait) (sit-for org-wait)))) (and (boundp 'org-wait) (numberp org-wait) (sit-for org-wait))))
((or (stringp cmd) ((or (stringp cmd)
(eq cmd 'emacs)) (eq cmd 'emacs))