diff --git a/mu4e/mu4e-vars.el b/mu4e/mu4e-vars.el index 73c22f1c..cb7006d2 100644 --- a/mu4e/mu4e-vars.el +++ b/mu4e/mu4e-vars.el @@ -524,7 +524,12 @@ mu4e-compose-mode." "Face for the separator between headers / message in mu4e-compose-mode." :group 'mu4e-faces) - + +(defface mu4e-region-code + '((t (:background "DarkSlateGray"))) + "Face for highlighting marked region in mu4e-view buffer." + :group 'mu4e-faces) + ;; headers info (defconst mu4e-header-info '( (:attachments . diff --git a/mu4e/mu4e-view.el b/mu4e/mu4e-view.el index f6cf9221..7bab9e2f 100644 --- a/mu4e/mu4e-view.el +++ b/mu4e/mu4e-view.el @@ -903,6 +903,32 @@ all messages in the subthread at point in the headers view." (interactive) (mu4e~view-in-headers-context (mu4e-headers-search-edit))) +(defun mu4e-mark-region-code () + "Highlight region marked with `message-mark-inserted-region'. +Add this function to `mu4e-view-mode-hook' to enable this feature." + (require 'message) + (let (beg end ov-beg ov-end ov-inv) + (save-excursion + (goto-char (point-min)) + (while (re-search-forward + (concat "^" message-mark-insert-begin) nil t) + (setq ov-beg (match-beginning 0) + ov-end (match-end 0) + ov-inv (make-overlay ov-beg ov-end) + beg ov-end) + (overlay-put ov-inv 'invisible t) + (when (re-search-forward + (concat "^" message-mark-insert-end) nil t) + (setq ov-beg (match-beginning 0) + ov-end (match-end 0) + ov-inv (make-overlay ov-beg ov-end) + end ov-beg) + (overlay-put ov-inv 'invisible t)) + (when (and beg end) + (let ((ov (make-overlay beg end))) + (overlay-put ov 'face 'mu4e-region-code)) + (setq beg nil end nil)))))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; attachment handling (defun mu4e~view-get-attach-num (prompt msg &optional multi)