From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Chandan Babu R Newsgroups: gmane.emacs.help Subject: xdg-open and start-process-shell-command: Unable to open files in external apps Date: Sat, 28 Aug 2021 11:16:35 +0530 Message-ID: <87k0k6p1dw.fsf@debian-BULLSEYE-live-builder-AMD64> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24085"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.4.15; emacs 27.1 To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 28 07:47:22 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mJrBa-000640-NY for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 28 Aug 2021 07:47:22 +0200 Original-Received: from localhost ([::1]:46694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJrBY-0005ou-Tl for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 28 Aug 2021 01:47:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJrB2-0005oX-9S for help-gnu-emacs@gnu.org; Sat, 28 Aug 2021 01:46:48 -0400 Original-Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:34752) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mJrAx-00081r-5G for help-gnu-emacs@gnu.org; Sat, 28 Aug 2021 01:46:47 -0400 Original-Received: by mail-pf1-x42c.google.com with SMTP id g14so7624107pfm.1 for ; Fri, 27 Aug 2021 22:46:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=user-agent:from:to:subject:message-id:date:mime-version; bh=XFlRBsG1aeqI7FitWeENme4SQ94G4KYJcr/tizevXDw=; b=oITM14qAUM+GCoXCOPnJX/MNd0Dw6PqewlhH04zsNg/IxGzbaKCpsGJ94dvmbJgny5 b9WNdRWUQ08DluPK0Z/7XhyiLUY0wddcA4POgdYblOjh78b3ZGH7PsZt3UjUa2k1DBh8 griXjMQYYGFUBP09jOrX6cG+AjjXwHDnvRL6raANr3EzIwA5GRVqsM+TrRRu9ABU76gk fdLMaAZ41bKg6UPXCHugRaObGP1peSb8sraOjrqlZ/QwRuX/fqH0jfR2L9AuvKZQ3Nb0 Yo1WfyxRilmG2BWB/sR57vPr9kJ92vF93Wv6oR0lviI56utbsuP89jnLZXekvQBPggzd UVVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:user-agent:from:to:subject:message-id:date :mime-version; bh=XFlRBsG1aeqI7FitWeENme4SQ94G4KYJcr/tizevXDw=; b=eYuRbLfl1A8KzHmoGZ4ezbOcc0uLR7fCUzZCu4MVgqb2f6hhtMPhfx+w3gtPMb9AnX Ob4eB+Am6sAPFdms1aa4M967xYsw3ob3Y9UcNFqzbM2Y9jQWBKAKb7P3gYtQQ3IEwDBS pL7OxIO9FGX60Z44mxaPjyyyeFGKIZOcy8gJ2tOxjgZGtCB16JyBUalCRz2d9O+Cry9J YD6eyRu9V+EmjHStA+dk0Sm3MdxcUzanXZHP8q039nR/s3AXnG1NzgVk1b/x+pb1aWww /nBOjUI7kZPgOtUxerKSF7wpvyRFLx72v+5Mecxl38T6E8ROo5KaWLkWk29L5GTdcSew Kotg== X-Gm-Message-State: AOAM532LXuNFn9vagj34vfQRY5VGc3HDYHq+dtSggW3lZOnxRtfkoIZs AjqG0BZJa04NiJtC7+9XBnKweasju2Y= X-Google-Smtp-Source: ABdhPJwzopB5fLc+ws4qTXJEedicpSMBXBkLfCas1R2m8c+bzF6fmAKEw59ToZhvTnvEhP7KmLifLg== X-Received: by 2002:a63:4b4c:: with SMTP id k12mr3044646pgl.172.1630129598039; Fri, 27 Aug 2021 22:46:38 -0700 (PDT) Original-Received: from garuda ([122.179.4.232]) by smtp.gmail.com with ESMTPSA id m64sm8969893pga.55.2021.08.27.22.46.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Aug 2021 22:46:37 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=chandanrlinux@gmail.com; helo=mail-pf1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:132791 Archived-At: 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 "") '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