From b072b4a57e846b6c5d3a316fa6495685cbe7fd54 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Wed, 12 Jan 2022 22:32:21 +0200 Subject: [PATCH] mu4e-view: Add defcustom mu4e-view-open-program When xdg-open is not enough. --- NEWS.org | 10 +++++++--- mu4e/mu4e-view.el | 29 +++++++++++++++++------------ 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/NEWS.org b/NEWS.org index d9e50256..fdb335f2 100644 --- a/NEWS.org +++ b/NEWS.org @@ -44,9 +44,9 @@ - the old mu4e-view is *gone*; only the gnus-based one remains. This allowed for removing quite a bit of old code. - - the mu4e message rendering is much faster (a factor of 3+), which - makes displaying big results snappier. This required some updates in the - headers handling and in the server protocol. + - the mu4e headers rendering is much faster (a factor of 3+), which makes + displaying big results snappier. This required some updates in the headers + handling and in the server protocol. - ~mu4e-index-updated-hook~ now fires after indexing completed, regardless of 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 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 - a lot of the internals have been changed: diff --git a/mu4e/mu4e-view.el b/mu4e/mu4e-view.el index 26f9ac36..02ee6e7a 100644 --- a/mu4e/mu4e-view.el +++ b/mu4e/mu4e-view.el @@ -91,11 +91,22 @@ The first letter of NAME is used as a shortcut character." :group 'mu4e-view :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 "The value of `max-specpdl-size' for displaying messages with Gnus." :type 'integer :group 'mu4e-view) + + ;;; Old options @@ -671,10 +682,7 @@ determine which browser function to use." (mm-destroy-parts parts)))) (defun mu4e-action-view-in-xwidget (msg) - "Show current MSG in an embedded xwidget, if available. - -This is an experimental feature; this appear to work for all -messages." + "Show current MSG in an embedded xwidget, if available." (unless (fboundp 'xwidget-webkit-browse-url) (mu4e-error "No xwidget support available")) (let ((browse-url-browser-function @@ -1196,14 +1204,11 @@ The directory and file are self-destructed." "Open FILE with default handler, if any. Otherwise, or if FORCE-ASK is set, ask user for the program to open with." - (let* ((opener - (pcase system-type - (`darwin "open") - ((or 'gnu 'gnu/linux 'gnu/kfreebsd) "xdg-open"))) - (prog (if (or force-ask (not opener)) - (read-shell-command "Open MIME-part with: ") - opener))) - (call-process prog nil 0 nil file))) + (let ((opener + (or (and (not force-ask) mu4e-view-open-program + (executable-find mu4e-view-open-program)) + (read-shell-command "Open MIME-part with: ")))) + (call-process opener nil 0 nil file))) (defun mu4e-view-mime-part-action (&optional n) "Apply some action to MIME-part N in the current messsage.