[PATCH v1 1/1] emacs: Add `notmuch-wash-cut-here'
David Edmondson
dme at dme.org
Tue Mar 19 09:41:56 PDT 2019
Add `notmuch-wash-cut-here' as a washing function that can be added to
`notmuch-show-insert-text/plain-hook' to excerpt 'cut here' sections,
such as those generated by `message-mark-inserted-region'.
---
emacs/notmuch-wash.el | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index 54108d93..2ca9c108 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -426,6 +426,37 @@ for error."
;;
+(defcustom notmuch-wash-button-cut/here-hidden-format
+ "[ %d-line cut here. Click/Enter to show. ]"
+ "String used to construct button text for hidden 'cut here' sections.
+Can use up to one integer format parameter, i.e. %d."
+ :type 'string
+ :group 'notmuch-wash)
+
+(defcustom notmuch-wash-button-cut/here-visible-format
+ "[ %d-line cut here. Click/Enter to hide. ]"
+ "String used to construct button text for visible 'cut here' sections.
+Can use up to one integer format parameter, i.e. %d."
+ :type 'string
+ :group 'notmuch-wash)
+
+(define-button-type 'notmuch-wash-button-cut/here-toggle-type
+ 'help-echo "mouse-1, RET: Show original message"
+ :supertype 'notmuch-wash-button-invisibility-toggle-type)
+
+(defconst notmuch-wash--cut-here-start (concat "^" message-mark-insert-begin))
+(defconst notmuch-wash--cut-here-end (concat "^" message-mark-insert-end))
+
+(defun notmuch-wash-cut-here (msg depth)
+ "Excerpt 'cut here' sections, hiding them by default."
+ (goto-char (point-min))
+ (while (re-search-forward notmuch-wash--cut-here-start nil t)
+ (let ((start (match-beginning 0)))
+ (when (re-search-forward notmuch-wash--cut-here-end nil t)
+ (notmuch-wash-region-to-button msg start (point) "cut/here")))))
+
+;;
+
(provide 'notmuch-wash)
;;; notmuch-wash.el ends here
--
2.21.0
More information about the notmuch
mailing list