emacs-helm/helm

Cygwin compatibility for helm-open-file-with-default-tool

mcarpenter opened this issue · 2 comments

What happened?

Tried to open a PDF using helm-open-file-with-default-tool under Cygwin.

It failed silently.

How to reproduce?

  1. Using Cygwin on Windows
  2. Install and run emacs-w32
  3. Install helm.
  4. 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

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:

  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 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).