Re: [PATCH v1 1/1] emacs: Add `notmuch-wash-cut-here'

2019-04-25 Thread David Bremner
David Edmondson  writes:

> 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'.

How hard would it be to test this? Usually we like to have a test added
to the test suite for a new feature.

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v1 1/1] emacs: Add `notmuch-wash-cut-here'

2019-04-03 Thread Pierre Neidhardt
That'd be great!
Would you like to implement this?

Either way, the patch looks good to me and it'd be great to see it
merged upstream.

Thanks!

-- 
Pierre Neidhardt
https://ambrevar.xyz/


signature.asc
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v1 1/1] emacs: Add `notmuch-wash-cut-here'

2019-03-20 Thread David Edmondson
On Wednesday, 2019-03-20 at 09:52:24 +01, Pierre Neidhardt wrote:

> Question: Is is possible to configure the wash function to be expanded
> by default?

Probably the simplest approach would be to have
`notmuch-wash-region-to-button' return the button it creates to the
caller, which could then call `notmuch-wash-toggle-invisible-action' to
cause the button to be visible.

dme.
-- 
I'm in a backless dress on a pastel ward that's shining.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v1 1/1] emacs: Add `notmuch-wash-cut-here'

2019-03-20 Thread Pierre Neidhardt
I've added notmuch-wash-cut-here to notmuch-show-insert-text/plain-hook, and
this works great, thanks for the prompt solution! :)

Question: Is is possible to configure the wash function to be expanded
by default?

-- 
Pierre Neidhardt
https://ambrevar.xyz/


signature.asc
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v1 1/1] emacs: Add `notmuch-wash-cut-here'

2019-03-19 Thread David Edmondson
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

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch