Function: shell-command-guess-xdg

shell-command-guess-xdg is a byte-compiled function defined in dired-aux.el.gz.

Signature

(shell-command-guess-xdg COMMANDS FILES)

Documentation

Populate COMMANDS by XDG configuration for FILES.

Source Code

;; Defined in /usr/src/emacs/lisp/dired-aux.el.gz
(defun shell-command-guess-xdg (commands files)
  "Populate COMMANDS by XDG configuration for FILES."
  (require 'xdg)
  (let* ((xdg-mime (when (executable-find "xdg-mime")
                     (string-trim-right
                      (shell-command-to-string
                       (concat "xdg-mime query filetype "
                               (shell-quote-argument (car files)))))))
         (xdg-mime-apps (unless (or (null xdg-mime)
                                    (string-empty-p xdg-mime))
                          (xdg-mime-apps xdg-mime)))
         (xdg-commands
          (mapcar (lambda (desktop)
                    (setq desktop (xdg-desktop-read-file desktop))
                    (propertize
                     (replace-regexp-in-string
                      " .*" "" (gethash "Exec" desktop))
                     'name (gethash "Name" desktop)))
                  xdg-mime-apps)))
    (append xdg-commands commands)))