emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3] Re: Bug in 9.5.3 org--file-default-apps


From: Max Nikulin
Subject: Re: [PATCH v3] Re: Bug in 9.5.3 org--file-default-apps
Date: Tue, 31 May 2022 22:07:18 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1

On 30/05/2022 22:38, Max Nikulin wrote:
(let* ((file-executable (executable-find "file"))
        (mime-type-file
         (and file-executable
          (shell-command-to-string
           (format "%s --brief --mime-type --dereference %s 2>/dev/null"
                  ; ...
         )))
        (mime-type (if (org-string-nw-p mime-type-file)
                       mime-type-file
                     (mailcap-extension-to-mime (or ext "")))

There is an implementation of "file" that does not support --mime-type in particular and long options at all in general: https://landley.net/toybox/help.html#file toybox that is installed on Android. Windows port http://gnuwin32.sourceforge.net/packages/file.htm looks dead, but anyway for cmd.exe "2> nul" should be used instead of ">/dev/null". It may be safer to check
   (string-match-p "\\`[-a-zA-Z0-9+_.]+/[-a-zA-Z0-9+_.]+\\'"
                   mime-file-type)
instead of error redirection. I still think that `mailcap-extension-to-mime' should be fallback, not just alternative to trying file command.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]