Function: filesets-spawn-external-viewer
filesets-spawn-external-viewer is a byte-compiled function defined in
filesets.el.gz.
Signature
(filesets-spawn-external-viewer FILE &optional EV-ENTRY)
Documentation
Start an external viewer for FILE.
Use the viewer defined in EV-ENTRY (a valid element of
filesets-external-viewers) if provided.
Source Code
;; Defined in /usr/src/emacs/lisp/filesets.el.gz
(defun filesets-spawn-external-viewer (file &optional ev-entry)
"Start an external viewer for FILE.
Use the viewer defined in EV-ENTRY (a valid element of
`filesets-external-viewers') if provided."
(let* ((file (expand-file-name file))
(entry (or ev-entry
(filesets-get-external-viewer file))))
(if entry
(let* ((vwr (cadr entry))
(co-flag (filesets-filetype-get-prop ':capture-output file entry))
(oh (filesets-filetype-get-prop ':open-hook file entry))
(args (let ((fmt (filesets-filetype-get-prop ':args file entry)))
(if fmt
(mapconcat
(lambda (this)
(if (stringp this)
(format this (shell-quote-argument file))
(shell-quote-argument (if (functionp this)
(funcall this)
this))))
fmt)
(shell-quote-argument file))))
(output
(cond
((and (functionp vwr) co-flag)
(funcall vwr file))
((functionp vwr)
(funcall vwr file)
nil)
(co-flag
(shell-command-to-string (format "%s %s" vwr args)))
(t
(shell-command (format "%s %s&" vwr args))
nil))))
(if co-flag
(progn
(switch-to-buffer (format "Filesets: %s %s" vwr file))
(insert output)
(setq-local filesets-output-buffer-flag t)
(set-visited-file-name file t)
(if (functionp oh)
(funcall oh)
(mapc #'funcall oh))
(set-buffer-modified-p nil)
(setq buffer-read-only t)
(goto-char (point-min)))
(if (functionp oh)
(funcall oh)
(mapc #'funcall oh))))
(error "Filesets: general error when spawning external viewer"))))