mu4e-view: Add defcustom mu4e-view-open-program

When xdg-open is not enough.
This commit is contained in:
Dirk-Jan C. Binnema 2022-01-12 22:32:21 +02:00
parent 324b6f5022
commit b072b4a57e
2 changed files with 24 additions and 15 deletions

View File

@ -44,9 +44,9 @@
- the old mu4e-view is *gone*; only the gnus-based one remains. This allowed - the old mu4e-view is *gone*; only the gnus-based one remains. This allowed
for removing quite a bit of old code. for removing quite a bit of old code.
- the mu4e message rendering is much faster (a factor of 3+), which - the mu4e headers rendering is much faster (a factor of 3+), which makes
makes displaying big results snappier. This required some updates in the displaying big results snappier. This required some updates in the headers
headers handling and in the server protocol. handling and in the server protocol.
- ~mu4e-index-updated-hook~ now fires after indexing completed, regardless of - ~mu4e-index-updated-hook~ now fires after indexing completed, regardless of
whether anything changed (before, it fired only is something changed). In whether anything changed (before, it fired only is something changed). In
@ -63,6 +63,10 @@
automatically change the ~Organization:~ header, and attempts to update the automatically change the ~Organization:~ header, and attempts to update the
message signature. Also, there's a key-binding now: ~C-c ;~ message signature. Also, there's a key-binding now: ~C-c ;~
- A new ~defcustom~, ~mu4e-view-open-program~ for starting the appropriate
program for a give file (e.g., ~xdg-open~). There are some reasonable
defaults for various systems.
- undo is now supported across message-saves - undo is now supported across message-saves
- a lot of the internals have been changed: - a lot of the internals have been changed:

View File

@ -91,11 +91,22 @@ The first letter of NAME is used as a shortcut character."
:group 'mu4e-view :group 'mu4e-view
:type '(alist :key-type string :value-type function)) :type '(alist :key-type string :value-type function))
(defcustom mu4e-view-open-program
(pcase system-type
('darwin "open")
('cygwin "cygstart")
(_ "xdg-open"))
"Tool to open the correct program for a given file."
:type 'string
:group 'mu4e-view)
(defcustom mu4e-view-max-specpdl-size 4096 (defcustom mu4e-view-max-specpdl-size 4096
"The value of `max-specpdl-size' for displaying messages with Gnus." "The value of `max-specpdl-size' for displaying messages with Gnus."
:type 'integer :type 'integer
:group 'mu4e-view) :group 'mu4e-view)
;;; Old options ;;; Old options
@ -671,10 +682,7 @@ determine which browser function to use."
(mm-destroy-parts parts)))) (mm-destroy-parts parts))))
(defun mu4e-action-view-in-xwidget (msg) (defun mu4e-action-view-in-xwidget (msg)
"Show current MSG in an embedded xwidget, if available. "Show current MSG in an embedded xwidget, if available."
This is an experimental feature; this appear to work for all
messages."
(unless (fboundp 'xwidget-webkit-browse-url) (unless (fboundp 'xwidget-webkit-browse-url)
(mu4e-error "No xwidget support available")) (mu4e-error "No xwidget support available"))
(let ((browse-url-browser-function (let ((browse-url-browser-function
@ -1196,14 +1204,11 @@ The directory and file are self-destructed."
"Open FILE with default handler, if any. "Open FILE with default handler, if any.
Otherwise, or if FORCE-ASK is set, ask user for the program to Otherwise, or if FORCE-ASK is set, ask user for the program to
open with." open with."
(let* ((opener (let ((opener
(pcase system-type (or (and (not force-ask) mu4e-view-open-program
(`darwin "open") (executable-find mu4e-view-open-program))
((or 'gnu 'gnu/linux 'gnu/kfreebsd) "xdg-open"))) (read-shell-command "Open MIME-part with: "))))
(prog (if (or force-ask (not opener)) (call-process opener nil 0 nil file)))
(read-shell-command "Open MIME-part with: ")
opener)))
(call-process prog nil 0 nil file)))
(defun mu4e-view-mime-part-action (&optional n) (defun mu4e-view-mime-part-action (&optional n)
"Apply some action to MIME-part N in the current messsage. "Apply some action to MIME-part N in the current messsage.