Cygwin compatibility for helm-open-file-with-default-tool
mcarpenter opened this issue · 2 comments
mcarpenter commented
What happened?
Tried to open a PDF using helm-open-file-with-default-tool
under Cygwin.
It failed silently.
How to reproduce?
- Using Cygwin on Windows
- Install and run
emacs-w32
- Install helm.
- In the scratch buffer invoke:
(helm-open-file-with-default-tool "/path/to/some/file.pdf")
Helm Version
Melpa or NonGnuElpa
Emacs Version
Emacs-29.1
OS
Other
Relevant backtrace (if possible)
No response
Minimal configuration
- I agree using a minimal configuration
mcarpenter commented
Hi,
Here's a quick fix:
--- a/helm-utils.el
+++ b/helm-utils.el
@@ -1071,7 +1071,9 @@ Assume regexp is a pcre based regexp."
"xdg-open")
((or (eq system-type 'darwin) ;; Mac OS X
(eq system-type 'macos)) ;; Mac OS 9
- "open"))
+ "open")
+ ((eq system-type 'cygwin)
+ "cygstart"))
file))))
Some notes:
cygstart
is shipped in thecygutils
package. Although this package is in the Base category it is not installed by default.- Cygwin also provides
xdg-open
in thexdg-utils
package, category X11, also not installed by default. cygstart
andxdg-open
are largely equivalent.- I think Cygwin users are more likely to have
cygutils
installed since it has some other useful stuff and x11 is less relevant today. But this is not guaranteed. - A better fix would perhaps (a) check for both possibilities on Cygwin and (b) verify the availability of the returned helper for all cases. (Maybe factor out
(defun helm-command-runner() ...)
or so?). I'd be happy to contribute such a fn if you think that's worthwhile but fix as in diff above also fine for me.
(I also checked the other references to system-type
in the repo and couldn't see any other similar cases affecting Cygwin).
thierryvolpiatto commented
Martin Carpenter ***@***.***> writes:
1. ( ) text/plain (*) text/html
Hi,
Here's a quick fix:
--- a/helm-utils.el
+++ b/helm-utils.el
@@ -1071,7 +1071,9 @@ Assume regexp is a pcre based regexp."
"xdg-open")
((or (eq system-type 'darwin) ;; Mac OS X
(eq system-type 'macos)) ;; Mac OS 9
- "open"))
+ "open")
+ ((eq system-type 'cygwin)
+ "cygstart"))
file))))
Thanks. PR welcome, I have no windows box to test such changes.
Some notes:
1. cygstart is shipped in the cygutils package. Although this package is in the Base category it is not installed by default.
2. Cygwin also provides xdg-open in the xdg-utils package, category X11, also not installed by default.
3. cygstart and xdg-open are largely equivalent.
4. I think Cygwin users are more likely to have cygutils installed since it has some other useful stuff and x11 is less relevant today. But this is not guaranteed.
5. A better fix would perhaps (a) check for both possibilities on Cygwin and (b) verify the availability of the returned helper for all cases. (Maybe factor out (defun helm-command-runner
() ...) or so?). I'd be happy to contribute a fn as in (5) if you
think that's worthwhile but fix as in diff above also fine for me.
Don't think we need something sophisticated here, only make the best
tool taking precedence on the other, I know nothing about Cygwin
unfortunately, so I trust the change you will make in this area.
Thanks.
…--
Thierry