summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-07-26 16:28:02 +0100
committerjao <jao@gnu.org>2021-07-26 16:28:02 +0100
commit21e519036f0672a95c344137800f78c38b18f761 (patch)
tree1628070b0e58d29136c81fd5f87e99a823ea8e9b /lib
parente662013059ee6a0801499b962f6681a1bde998dc (diff)
downloadelibs-21e519036f0672a95c344137800f78c38b18f761.tar.gz
elibs-21e519036f0672a95c344137800f78c38b18f761.tar.bz2
notmuch: simpler mime/image toggling for html emails
Diffstat (limited to 'lib')
-rw-r--r--lib/net/jao-notmuch.el49
1 files changed, 24 insertions, 25 deletions
diff --git a/lib/net/jao-notmuch.el b/lib/net/jao-notmuch.el
index 52e0fe8..c470682 100644
--- a/lib/net/jao-notmuch.el
+++ b/lib/net/jao-notmuch.el
@@ -116,13 +116,6 @@
(goto-char (previous-single-property-change pos 'w3m-href-anchor))
(backward-button 1)))
-(defun jao-notmuch-show-ret ()
- (interactive)
- (if-let (url (or (get-text-property (point) 'w3m-href-anchor)
- (thing-at-point-url-at-point)))
- (browse-url url)
- (notmuch-show-toggle-message)))
-
(defun jao-w3m-get-page-urls (res)
(save-excursion
(goto-char (point-min))
@@ -132,24 +125,25 @@
(add-to-list 'res url t)))
res)))
-(defun jao-notmuch-browse-urls ()
- (interactive)
+(defun jao-notmuch-browse-urls (&optional external)
+ (interactive "P")
(when (or (derived-mode-p 'notmuch-show-mode)
(jao-notmuch-goto-message-buffer))
- (let ((urls (jao-w3m-get-page-urls (notmuch-show--gather-urls))))
+ (let ((urls (jao-w3m-get-page-urls (notmuch-show--gather-urls)))
+ (fn (if external browse-url-secondary-browser-function #'browse-url)))
(if urls
- (browse-url (completing-read "Browse URL: " urls))
+ (funcall fn (completing-read "Browse URL: " urls))
(message "No URLs in this message")))))
+
+;; Toggling mime parts and images
+
(defun jao-notmuch--toggle-mime ()
(save-excursion
(goto-char (point-min))
- (when (forward-button 1 nil nil t)
- (when (looking-at-p "\\[ multipart/alternative")
- (when (looking-at-p "\\[ multipart/alternative (hidden)")
- (push-button))
- (while (forward-button 1 nil nil t)
- (notmuch-show-toggle-part-invisibility))))))
+ (while (and (re-search-forward "^\\[ text/\\(html\\|plain\\) " nil t)
+ (button-at (point)))
+ (notmuch-show-toggle-part-invisibility))))
(defun jao-notmuch-toggle-mime-parts ()
(interactive)
@@ -164,14 +158,19 @@
(save-window-excursion
(when (and (jao-notmuch-goto-message-buffer nil t)
(derived-mode-p 'notmuch-show-mode))
- (when (or mm-w3m-safe-url-regexp
- notmuch-show-text/html-blocked-images)
- (setq-local mm-w3m-safe-url-regexp nil
- notmuch-show-text/html-blocked-images nil
- shr-inhibit-images nil
- shr-blocked-images nil)
- (notmuch-refresh-this-buffer))
- (jao-notmuch--toggle-mime))))
+ (goto-char (point-min))
+ (when (re-search-forward "^\\[ text/html " nil t)
+ (when (looking-at-p "(hidden)")
+ (notmuch-show-toggle-part-invisibility))
+ (forward-line 1)
+ (w3m-toggle-inline-images)))))
+
+(defun jao-notmuch-show-ret ()
+ (interactive)
+ (if-let (url (or (get-text-property (point) 'w3m-href-anchor)
+ (thing-at-point-url-at-point)))
+ (browse-url url)
+ (notmuch-show-toggle-message)))
;; Keeping track of unread messages in current tree view