-
-
Notifications
You must be signed in to change notification settings - Fork 338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
counsel.el: fix xdg-open under Ubuntu for counsel-locate-action-extern #1759
Conversation
`start-process-shell-command` doesn't seem to wait for `counsel-locate-action-extern` to finish under Ubuntu. [Gist to reproduce the issue](https://gist.github.com/yiufung/38be4c3a6832334f36f2441550cf0b12). Related discussion: ([#1](https://askubuntu.com/questions/646631/emacs-doesnot-work-with-xdg-open), [#2](https://emacs.stackexchange.com/questions/19344/why-does-xdg-open-not-work-in-eshell), [#3](http://emacs.1067599.n8.nabble.com/emacs-and-xdg-open-td106892.html)) suggests to: 1. Set `process-connection-type` as nil temporarily 2. Called with `setsid -w` to wait for the process to finish. To avoid interfering with other platforms and applications, I adopted the latter approach which uses `lsb_release` to check distribution type with fall back as `xdg-open`. Currently only check for Ubuntu, and to be extended in the future. Related issues: #863 and #1401.
Thanks, I confirm the issue is reproducible and is now fixed. |
How does: (let ((process-connection-type nil))
(start-process-shell-command ...)) interfere with other platforms and applications? Perhaps you were thinking of I think this issue is also related to #1483 (comment) and #1537. |
(counsel-locate-action-extern): Avoid issues with start-process-shell-command returning too soon by passing 0 as the BUFFER argument to call-process-shell-command. Re: abo-abo#1537, abo-abo#1759
That would have duplicated (defun ...
(cl-case system-type
(darwin (start-process-shell-command
shell-file-name nil (format "%s %s" "open"
(shell-quote-argument x))))
(cygwin (start-process-shell-command
shell-file-name nil (format "%s %s" "cygstart"
(shell-quote-argument x))))
(t (if (ubuntu-check)
(let ((process-connection-type nil))
start-process-shell-command ....)
(start-process-shell-command ....))))) Or maybe there are some other ways to refactor it more nicely. I was trying to |
No: (let ((process-connection-type nil))
(start-process-shell-command shell-file-name nil
(format "%s %s"
(cl-case system-type
(darwin "open")
(cygwin "cygstart")
(t "xdg-open"))
(shell-quote-argument x)))) There is nothing intrusive about |
(BTW, this is another case where invoking the shell, rather than |
Oh, that's exactly what I was avoiding at the start. I noticed the diffs about pty and pipe in Emacs manual, but I'm uncertain whether not |
Its default value of
Shell compatibility problems are very common even amongst POSIX OSes, and are not related to the current issue of synchronous vs asynchronous processes and ptys vs pipes. This is why libraries should always prefer direct process invocation via |
start-process-shell-command
doesn't seem to wait forcounsel-locate-action-extern
to finish under Ubuntu. Gist to reproduce the issue.Related discussions (#1, #2, #3) suggest to:
process-connection-type
as nil temporarilysetsid -w
to wait for the process to finish.To avoid interfering with other platforms and applications, I adopted the latter approach which uses
lsb_release
to check distribution type with fall back asxdg-open
. Currently only check for Ubuntu, and to be extended in the future.Related issues: #863 and #1401.