* xdg-open and start-process-shell-command: Unable to open files in external apps
@ 2021-08-28 5:46 Chandan Babu R
2021-08-28 7:26 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: Chandan Babu R @ 2021-08-28 5:46 UTC (permalink / raw)
To: help-gnu-emacs
Hi all,
I have been using the following Emacs lisp code snippet to open files from
dired buffer on Emacs 26.1 which is shipped with Debian 10.
(defun sjihs-open-in-external-app ()
(interactive)
(let ((do-it nil)
(file-path nil)
(file-list
(cond
((string-equal major-mode "dired-mode") (dired-get-marked-files))
(t (list (buffer-file-name))))))
(setq do-it (if (<= (length file-list) 5)
t
(y-or-n-p "Open more than 5 files?")))
(when do-it
(mapc (lambda (file-path)
(start-process-shell-command
(concat "xdg-open " file-path) "sjihs async processes"
(format "xdg-open %s" (shell-quote-argument file-path))))
file-list))))
(define-key dired-mode-map (kbd "<f12>") 'sjihs-open-in-external-app)
The above code was originally obtained from
http://ergoemacs.org/emacs/emacs_dired_open_file_in_ext_apps.html.
After moving to (via a fresh install) Debian 11 (which ships Emacs 27.1) the
code snippet has stopped working.
However, the command "xdg-open /home/chandan/2016-2017.pdf" when invoked from the
shell command line opens the pdf application viewer (i.e. Okular)
correctly.
The failure occurs only when start-process-shell-command procedure is invoked
from within Emacs. The failure can also be recreated when
start-process-shell-command is invoked from ielm buffer as shown below,
(start-process-shell-command
"Opening file"
"sjihs async processes"
(concat "xdg-open "
(shell-quote-argument "/home/chandan/2016-2017.pdf")))
I wrote the following trivial script ...
#!/usr/bin/zsh -f
echo "\$0 = $0; \$1 = $1" > /tmp/debug.log
and associated the script with application/pdf MIME type.
debug.log file contains the following string,
$0 = /home/chandan/bin/open-pdf.sh; $1 = /home/chandan/2016-2017.pdf
... when xdg-open is invoked either from the command line or through Emacs'
start-process-shell-command procedure. However, Okular does not get spawned
only when trying to open the pdf file from within Emacs.
Any solutions or pointers to debugging this problem is very much appreciated.
--
chandan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: xdg-open and start-process-shell-command: Unable to open files in external apps
2021-08-28 5:46 xdg-open and start-process-shell-command: Unable to open files in external apps Chandan Babu R
@ 2021-08-28 7:26 ` Eli Zaretskii
2021-08-28 13:42 ` Chandan Babu R
0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2021-08-28 7:26 UTC (permalink / raw)
To: help-gnu-emacs
> From: Chandan Babu R <chandanrlinux@gmail.com>
> Date: Sat, 28 Aug 2021 11:16:35 +0530
>
> The above code was originally obtained from
> http://ergoemacs.org/emacs/emacs_dired_open_file_in_ext_apps.html.
>
> After moving to (via a fresh install) Debian 11 (which ships Emacs 27.1) the
> code snippet has stopped working.
>
> However, the command "xdg-open /home/chandan/2016-2017.pdf" when invoked from the
> shell command line opens the pdf application viewer (i.e. Okular)
> correctly.
>
> The failure occurs only when start-process-shell-command procedure is invoked
> from within Emacs. The failure can also be recreated when
> start-process-shell-command is invoked from ielm buffer as shown below,
>
> (start-process-shell-command
> "Opening file"
> "sjihs async processes"
> (concat "xdg-open "
> (shell-quote-argument "/home/chandan/2016-2017.pdf")))
>
> I wrote the following trivial script ...
>
> #!/usr/bin/zsh -f
>
> echo "\$0 = $0; \$1 = $1" > /tmp/debug.log
>
> and associated the script with application/pdf MIME type.
>
> debug.log file contains the following string,
> $0 = /home/chandan/bin/open-pdf.sh; $1 = /home/chandan/2016-2017.pdf
> ... when xdg-open is invoked either from the command line or through Emacs'
> start-process-shell-command procedure. However, Okular does not get spawned
> only when trying to open the pdf file from within Emacs.
>
> Any solutions or pointers to debugging this problem is very much appreciated.
I believe the reason for this was recently found and resolved in Git
on the master branch.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: xdg-open and start-process-shell-command: Unable to open files in external apps
2021-08-28 7:26 ` Eli Zaretskii
@ 2021-08-28 13:42 ` Chandan Babu R
2021-08-28 13:51 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: Chandan Babu R @ 2021-08-28 13:42 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
On 28 Aug 2021 at 12:56, Eli Zaretskii wrote:
>> From: Chandan Babu R <chandanrlinux@gmail.com>
>> Date: Sat, 28 Aug 2021 11:16:35 +0530
>>
>> The above code was originally obtained from
>> http://ergoemacs.org/emacs/emacs_dired_open_file_in_ext_apps.html.
>>
>> After moving to (via a fresh install) Debian 11 (which ships Emacs 27.1) the
>> code snippet has stopped working.
>>
>> However, the command "xdg-open /home/chandan/2016-2017.pdf" when invoked from the
>> shell command line opens the pdf application viewer (i.e. Okular)
>> correctly.
>>
>> The failure occurs only when start-process-shell-command procedure is invoked
>> from within Emacs. The failure can also be recreated when
>> start-process-shell-command is invoked from ielm buffer as shown below,
>>
>> (start-process-shell-command
>> "Opening file"
>> "sjihs async processes"
>> (concat "xdg-open "
>> (shell-quote-argument "/home/chandan/2016-2017.pdf")))
>>
>> I wrote the following trivial script ...
>>
>> #!/usr/bin/zsh -f
>>
>> echo "\$0 = $0; \$1 = $1" > /tmp/debug.log
>>
>> and associated the script with application/pdf MIME type.
>>
>> debug.log file contains the following string,
>> $0 = /home/chandan/bin/open-pdf.sh; $1 = /home/chandan/2016-2017.pdf
>> ... when xdg-open is invoked either from the command line or through Emacs'
>> start-process-shell-command procedure. However, Okular does not get spawned
>> only when trying to open the pdf file from within Emacs.
>>
>> Any solutions or pointers to debugging this problem is very much appreciated.
>
> I believe the reason for this was recently found and resolved in Git
> on the master branch.
Thanks for the response.
I built the code present in the master branch. The topmost commit was,
commit 55e77a811a6f137b02eb786fb00c43f0f14bb028
Author: Juri Linkov <juri@linkov.net>
* lisp/progmodes/flymake.el: Bind mouse-3 to flymake-menu on mode-line.
* lisp/progmodes/flymake.el (flymake--mode-line-title):
Bind [mode-line down-mouse-3] to flymake-menu (bug#50067)
The problem described above is still recreatable.
--
chandan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: xdg-open and start-process-shell-command: Unable to open files in external apps
2021-08-28 13:42 ` Chandan Babu R
@ 2021-08-28 13:51 ` Eli Zaretskii
0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2021-08-28 13:51 UTC (permalink / raw)
To: help-gnu-emacs
> From: Chandan Babu R <chandanrlinux@gmail.com>
> Cc: help-gnu-emacs@gnu.org
> Date: Sat, 28 Aug 2021 19:12:54 +0530
>
> > I believe the reason for this was recently found and resolved in Git
> > on the master branch.
>
> Thanks for the response.
>
> I built the code present in the master branch. The topmost commit was,
>
> commit 55e77a811a6f137b02eb786fb00c43f0f14bb028
> Author: Juri Linkov <juri@linkov.net>
>
> * lisp/progmodes/flymake.el: Bind mouse-3 to flymake-menu on mode-line.
>
> * lisp/progmodes/flymake.el (flymake--mode-line-title):
> Bind [mode-line down-mouse-3] to flymake-menu (bug#50067)
>
> The problem described above is still recreatable.
See
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44824
Perhaps there's more places where xdg-open needs such special
treatment.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-08-28 13:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-28 5:46 xdg-open and start-process-shell-command: Unable to open files in external apps Chandan Babu R
2021-08-28 7:26 ` Eli Zaretskii
2021-08-28 13:42 ` Chandan Babu R
2021-08-28 13:51 ` Eli Zaretskii
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.