From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fabrice Popineau Subject: Re: Bug: wsl org-open-at-point [9.1.14 (9.1.14-9-g131531-elpa @ /home/boss5/.emacs.d/elpa/org-20181112/)] Date: Fri, 27 Dec 2019 18:28:24 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000038da0f059ab2d34b" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:44343) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iktPs-0003nd-0D for emacs-orgmode@gnu.org; Fri, 27 Dec 2019 12:28:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iktPq-0005v2-4y for emacs-orgmode@gnu.org; Fri, 27 Dec 2019 12:28:47 -0500 Received: from smtp2.supelec.fr ([160.228.120.31]:55888) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iktPp-0005ta-Nv for emacs-orgmode@gnu.org; Fri, 27 Dec 2019 12:28:46 -0500 Received: from localhost (localhost [127.0.0.1]) by smtp2.supelec.fr (Postfix) with ESMTP id 57D67802B7 for ; Fri, 27 Dec 2019 18:28:44 +0100 (CET) Received: from smtp2.supelec.fr ([127.0.0.1]) by localhost (smtp2.supelec.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eQxfrcldfK4B for ; Fri, 27 Dec 2019 18:28:43 +0100 (CET) Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) by smtp2.supelec.fr (Postfix) with ESMTPSA id D7E69802AF for ; Fri, 27 Dec 2019 18:28:42 +0100 (CET) Received: by mail-qk1-f175.google.com with SMTP id z76so22333291qka.2 for ; Fri, 27 Dec 2019 09:28:42 -0800 (PST) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Steve Miano Cc: emacs-orgmode --00000000000038da0f059ab2d34b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sent the message too quickly. Obviously, you will have to adapt the paths in w32-shell-execute with your own setup and the location of files you want to open. WSL allows different options to mount your NTFS drive or to create links between directories. Regards, Fabrice Le ven. 27 d=C3=A9c. 2019 =C3=A0 18:25, Fabrice Popineau < fabrice.popineau@centralesupelec.fr> a =C3=A9crit : > Hi, > > I had to solve this problem too. > > I used these functions: > > (defun w32-shell-execute (operation document &optional parameters > show-flag) > (if (and operation (not (string=3D "open" operation))) > (error "Don't know how to %s %s" operation document) > (call-process "/mnt/c/Windows/System32/cmd.exe" nil nil t "/c" > "start" "\"\"" > (concat "" > (replace-regexp-in-string "^/mnt/c/" "c:/" > > (replace-regexp-in-string "^\\(/mnt/c\\)?/home/Fabrice/" "c:/home/" > document)) > "")))) > (defun wsl-open-url (url &rest args) > (w32-shell-execute "open" url)) > > (setq browse-url-browser-function #'wsl-open-url) > (setq browse-url-mailto-function #'wsl-open-url) > > Regards, > > Fabrice > > Le ven. 27 d=C3=A9c. 2019 =C3=A0 18:10, Steve Miano a > =C3=A9crit : > >> On WSL, using emacs 25.1, in org-mode there is a bug/design issue. >> >> It the issue is: >> When opening a link in org-mode using C-c C-o, org-open-at-point doesn't >> work. It does find the browser, if you have set >> >> (setq browse-url-firefox-program "/mnt/c/PROGRA~1/MOZILL~1/firefox.exe") >> >> and does run the process, but it doesn't bring up a browser. You can >> see the process in list-processes and if you run that command in the >> console it works, but in org-mode the console never show and the >> process remains. >> >> The function browse-url-default-browse finds and runs the correct >> browser. However, it runs the browser using the wrong command >> depending on the case. If you are on WSL, without the graphical >> interface, you need to run the shell-command to use the windows >> browser. This is how it is done when it detects cygwin using >> system-type. However, System-type cannot be used to detect WSL because >> it doesn't find that you are on windows. The uname command detects it. >> >> Obviously this isn't straight forward as in different situations you >> want to do different things, graphical vs non-graphical. Perhaps >> modify the function which sets system-type to return wsl then detect >> graphical environment and use the non shell-command approach? >> >> I humbly bring this to your attention. Thanks in advance. >> >> >> Emacs : GNU Emacs 25.1.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.11) >> of 2017-09-15, modified by Debian >> Package: Org mode version 9.1.14 (9.1.14-9-g131531-elpa @ >> /home/XXXX/.emacs.d/elpa/org-20181112/) >> >> current state: >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> (setq >> org-src-lang-modes '(("python" . python) ("plantuml" . fundamental) >> ("ocaml" . tuareg) ("elisp" . emacs-lisp) ("ditaa" . artist) >> ("asymptote" . asy) >> ("dot" . fundamental) ("sqlite" . sql) ("calc" . >> fundamental) ("C" . c) ("cpp" . c++) ("C++" . c++) ("screen" . >> shell-script) >> ("shell" . sh) ("bash" . sh)) >> org-tab-first-hook '(org-babel-hide-result-toggle-maybe >> org-babel-header-arg-expand) >> org-babel-results-keyword "results" >> org-speed-command-hook '(org-speed-command-activate >> org-babel-speed-command-activate) >> org-occur-hook '(org-first-headline-recenter) >> org-metaup-hook '(org-babel-load-in-session-maybe) >> org-log-done t >> org-confirm-shell-link-function 'yes-or-no-p >> org-link-search-must-match-exact-headline nil >> org-default-notes-file "~/org/notes.org" >> org-after-todo-state-change-hook '(org-clock-out-if-current) >> org-from-is-user-regexp "\\" >> org-src-mode-hook '(org-src-babel-configure-edit-buffer >> org-src-mode-configure-edit-buffer) >> org-agenda-before-write-hook '(org-agenda-add-entry-text) >> org-babel-pre-tangle-hook '(save-buffer) >> org-table-use-standard-references t >> org-font-lock-set-keywor >> >> >> > > -- > Fabrice Popineau > ----------------------------- > CentraleSupelec > D=C3=A9partement Informatique > 3, rue Joliot Curie > 91192 Gif/Yvette Cedex > Tel direct : +33 (0) 169851950 > Standard : +33 (0) 169851212 > ------------------------------ > > --=20 Fabrice Popineau ----------------------------- CentraleSupelec D=C3=A9partement Informatique 3, rue Joliot Curie 91192 Gif/Yvette Cedex Tel direct : +33 (0) 169851950 Standard : +33 (0) 169851212 ------------------------------ --00000000000038da0f059ab2d34b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Sent the message too quickly.
Obviously, yo= u will have to adapt the paths in w32-shell-execute with your own setup and= the location of files you want to open.
WSL allows different opt= ions to mount your NTFS drive or to create links between directories.
=

Regards,

Fabrice

Le=C2=A0ven. 2= 7 d=C3=A9c. 2019 =C3=A0=C2=A018:25, Fabrice Popineau <fabrice.popineau@centralesupelec.fr> a =C3=A9crit=C2=A0:
Hi,

I had to solve this prob= lem too.

I used these functions:

=C2=A0 (defun w32-shell-execute (operation document &optional p= arameters show-flag)
=C2=A0 =C2=A0 (if (and operation (not (string=3D &q= uot;open" operation)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (error "Don= 't know how to %s %s" operation document)
=C2=A0 =C2=A0 =C2=A0 = (call-process "/mnt/c/Windows/System32/cmd.exe" nil nil t "/= c" "start" "\"\""
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (concat ""=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 (replace-regexp-in-string "^/mnt/c/" &qu= ot;c:/"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (replace-regexp-in-= string "^\\(/mnt/c\\)?/home/Fabrice/" "c:/home/" docume= nt))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ""))))
=C2=A0 (defun wsl-open-= url (url &rest args)
=C2=A0 =C2=A0 (w32-shell-execute "open&quo= t; url))

=C2=A0 =C2=A0 (setq browse-url-browse= r-function #'wsl-open-url)
=C2=A0 =C2=A0 (setq browse-url-mailto-fun= ction #'wsl-open-url)

Regards,
<= br>
Fabrice

On WSL, using emacs 25.1, in org-mode t= here is a bug/design issue.

It the issue is:
When opening a link in org-mode using C-c C-o, org-open-at-point doesn'= t
work. It does find the browser, if you have set

(setq browse-url-firefox-program "/mnt/c/PROGRA~1/MOZILL~1/firefox.exe= ")

and does run the process, but it doesn't bring up a browser. You can see the process in list-processes and if you run that command in the
console it works, but in org-mode the console never show and the
process remains.

The function browse-url-default-browse finds and runs the correct
browser. However, it runs the browser using the wrong command
depending on the case. If you are on WSL, without the graphical
interface, you need to run the shell-command to use the windows
browser. This is how it is done when it detects cygwin using
system-type. However, System-type cannot be used to detect WSL because
it doesn't find that you are on windows. The uname command detects it.<= br>
Obviously this isn't straight forward as in different situations you want to do different things, graphical vs non-graphical. Perhaps
modify the function which sets system-type to return wsl then detect
graphical environment and use the non shell-command approach?

I humbly bring this to your attention. Thanks in advance.


Emacs=C2=A0 : GNU Emacs 25.1.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.11)<= br> =C2=A0=C2=A0of 2017-09-15, modified by Debian
Package: Org mode version 9.1.14 (9.1.14-9-g131531-elpa @
/home/XXXX/.emacs.d/elpa/org-20181112/)

current state:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
(setq
=C2=A0=C2=A0org-src-lang-modes '(("python" . python) ("p= lantuml" . fundamental)
("ocaml" . tuareg) ("elisp" . emacs-lisp) ("ditaa&= quot; . artist)
("asymptote" . asy)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ("dot" = . fundamental) ("sqlite" . sql) ("calc" .
fundamental) ("C" . c) ("cpp" . c++) ("C++" .= c++) ("screen" . shell-script)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ("shell"= ; . sh) ("bash" . sh))
=C2=A0=C2=A0org-tab-first-hook '(org-babel-hide-result-toggle-maybe org-babel-header-arg-expand)
=C2=A0=C2=A0org-babel-results-keyword "results"
=C2=A0=C2=A0org-speed-command-hook '(org-speed-command-activate
org-babel-speed-command-activate)
=C2=A0=C2=A0org-occur-hook '(org-first-headline-recenter)
=C2=A0=C2=A0org-metaup-hook '(org-babel-load-in-session-maybe)
=C2=A0=C2=A0org-log-done t
=C2=A0=C2=A0org-confirm-shell-link-function 'yes-or-no-p
=C2=A0=C2=A0org-link-search-must-match-exact-headline nil
=C2=A0=C2=A0org-default-notes-file "~/org/notes.org"
=C2=A0=C2=A0org-after-todo-state-change-hook '(org-clock-out-if-current= )
=C2=A0=C2=A0org-from-is-user-regexp "\\<XXXXXX-XXXXXX\\>" =C2=A0=C2=A0org-src-mode-hook '(org-src-babel-configure-edit-buffer org-src-mode-configure-edit-buffer)
=C2=A0=C2=A0org-agenda-before-write-hook '(org-agenda-add-entry-text) =C2=A0=C2=A0org-babel-pre-tangle-hook '(save-buffer)
=C2=A0=C2=A0org-table-use-standard-references t
=C2=A0=C2=A0org-font-lock-set-keywor




--
Fabrice Popineau<= div style=3D"font-size:12.8px">-----------------------------
CentraleSupelec
D=C3=A9partement Informatique
3, rue = Joliot Curie
91192 Gif/Yvette Cedex
Tel direct : +33 (0) 169851950
Standard : +33 (0) 169851212
------------------------------



--
Fabrice Popineau
------------------= -----------
CentraleSupelec
D=C3=A9partement Informatique
3, rue Joliot Curie
91192 Gif/Yvette Cedex
Tel direct : += 33 (0) 169851950
Standard : +33 (0) 16= 9851212
------------------------------=

--00000000000038da0f059ab2d34b--