From 14f492ba0ca2bacd254ebda8a7756731f282f2a4 Mon Sep 17 00:00:00 2001 From: Alexander Botero-Lowry Date: Thu, 19 Nov 2009 12:30:32 -0800 Subject: [PATCH 1/7] Buttonize citation expander. Currently the button has no action or special handling at all. --- notmuch.el | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/notmuch.el b/notmuch.el index a5474158..67e87ea2 100644 --- a/notmuch.el +++ b/notmuch.el @@ -490,10 +490,17 @@ which this thread was originally shown." (forward-line)) (let ((overlay (make-overlay beg-sub (point)))) (overlay-put overlay 'invisible 'notmuch-show-citation) - (overlay-put overlay 'before-string - (concat indent - "[" (number-to-string (count-lines beg-sub (point))) - "-line citation. Press 'c' to show.]\n"))))) + (let ( + (p (point)) + (cite-button-text (concat "[" (number-to-string (count-lines beg-sub (point))) + "-line citation. Press 'c' to show.]")) + ) + (goto-char (- beg-sub 1)) + (insert (concat "\n" indent)) + (insert-button cite-button-text) + (insert "\n") + (goto-char (+ (length cite-button-text) p)) + )))) (move-to-column depth) (if (looking-at notmuch-show-signature-regexp) (let ((sig-lines (- (count-lines beg-sub end) 1))) From 89f55ab84b77f7b3a58b8ad56734613a2803bc2b Mon Sep 17 00:00:00 2001 From: Alexander Botero-Lowry Date: Thu, 19 Nov 2009 22:11:48 -0800 Subject: [PATCH 2/7] buttonize signatures as well --- notmuch.el | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/notmuch.el b/notmuch.el index 67e87ea2..93f3914f 100644 --- a/notmuch.el +++ b/notmuch.el @@ -508,11 +508,11 @@ which this thread was originally shown." (progn (overlay-put (make-overlay beg-sub end) 'invisible 'notmuch-show-signature) - (overlay-put (make-overlay beg (- beg-sub 1)) - 'after-string - (concat "\n" indent - "[" (number-to-string sig-lines) - "-line signature. Press 's' to show.]")) + (goto-char (- beg-sub 1)) + (insert (concat "\n" indent)) + (insert-button (concat "[" (number-to-string sig-lines) + "-line signature. Press 's' to show.]")) + (insert "\n") (goto-char end))))) (forward-line)))) From b38bd7efd83a8b7ea2c961060d8007efa055b9b6 Mon Sep 17 00:00:00 2001 From: Alexander Botero-Lowry Date: Thu, 19 Nov 2009 23:21:04 -0800 Subject: [PATCH 3/7] Make expanding/collapsing signatures and citations local to them This is the first step towards localizing all the expand/collapse operations in the show buffer --- notmuch.el | 53 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/notmuch.el b/notmuch.el index 93f3914f..763c85ff 100644 --- a/notmuch.el +++ b/notmuch.el @@ -477,6 +477,14 @@ which this thread was originally shown." (if last (notmuch-show-archive-thread)))))) +(defun notmuch-toggle-invisible-action (cite-button) + (let ((invis-spec (button-get button 'invisibility-spec))) + (if (invisible-p invis-spec) + (remove-from-invisibility-spec invis-spec) + (add-to-invisibility-spec invis-spec) + )) + (goto-char (button-end cite-button))) + (defun notmuch-show-markup-citations-region (beg end depth) (goto-char beg) (beginning-of-line) @@ -488,16 +496,25 @@ which this thread was originally shown." (progn (while (looking-at citation) (forward-line)) - (let ((overlay (make-overlay beg-sub (point)))) - (overlay-put overlay 'invisible 'notmuch-show-citation) + (let ((overlay (make-overlay beg-sub (point))) + (invis-spec (make-symbol "notmuch-citation-region"))) + (add-to-invisibility-spec invis-spec) + (overlay-put overlay 'invisible invis-spec) (let ( (p (point)) - (cite-button-text (concat "[" (number-to-string (count-lines beg-sub (point))) - "-line citation. Press 'c' to show.]")) + (cite-button-text + (concat "[" (number-to-string (count-lines beg-sub (point))) + "-line citation.]")) ) (goto-char (- beg-sub 1)) (insert (concat "\n" indent)) - (insert-button cite-button-text) + (let ((cite-button (insert-button cite-button-text))) + (button-put cite-button 'invisibility-spec invis-spec) + (button-put cite-button 'action 'notmuch-toggle-invisible-action) + (button-put cite-button 'help-echo + "mouse-2, RET: Show citation") + + ) (insert "\n") (goto-char (+ (length cite-button-text) p)) )))) @@ -506,14 +523,24 @@ which this thread was originally shown." (let ((sig-lines (- (count-lines beg-sub end) 1))) (if (<= sig-lines notmuch-show-signature-lines-max) (progn - (overlay-put (make-overlay beg-sub end) - 'invisible 'notmuch-show-signature) - (goto-char (- beg-sub 1)) - (insert (concat "\n" indent)) - (insert-button (concat "[" (number-to-string sig-lines) - "-line signature. Press 's' to show.]")) - (insert "\n") - (goto-char end))))) + (let ((invis-spec (make-symbol "notmuch-signature-region"))) + (add-to-invisibility-spec invis-spec) + (overlay-put (make-overlay beg-sub end) + 'invisible invis-spec) + + (goto-char (- beg-sub 1)) + (insert (concat "\n" indent)) + (let ((sig-button (insert-button + (concat "[" (number-to-string sig-lines) + "-line signature.]")))) + (button-put sig-button 'invisibility-spec invis-spec) + (button-put sig-button 'action + 'notmuch-toggle-invisible-action) + (button-put sig-button 'help-echo + "mouse-2, RET: Show signature") + ) + (insert "\n") + (goto-char end)))))) (forward-line)))) (defun notmuch-show-markup-part (beg end depth) From 00c0896c9b9369ec2a844cea4d841be7d4485220 Mon Sep 17 00:00:00 2001 From: Alexander Botero-Lowry Date: Fri, 20 Nov 2009 00:06:17 -0800 Subject: [PATCH 4/7] make header names bold in show-mode --- notmuch.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/notmuch.el b/notmuch.el index 763c85ff..70dbe5ba 100644 --- a/notmuch.el +++ b/notmuch.el @@ -593,6 +593,14 @@ which this thread was originally shown." (re-search-forward notmuch-show-header-end-regexp) (beginning-of-line) (let ((end (point-marker))) + (goto-char beg) + (forward-line) + (while (looking-at "[A-Za-z][-A-Za-z0-9]*:") + (beginning-of-line) + (overlay-put (make-overlay (point) (re-search-forward ":")) + 'face 'bold) + (forward-line) + ) (indent-rigidly beg end depth) (overlay-put (make-overlay beg-hidden end) 'invisible 'notmuch-show-header) From 89d85e28b2dc9b0a75a963dd4042aa657ba871b8 Mon Sep 17 00:00:00 2001 From: Alexander Botero-Lowry Date: Fri, 20 Nov 2009 14:17:06 -0800 Subject: [PATCH 5/7] put a newline after the headers --- notmuch.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/notmuch.el b/notmuch.el index 70dbe5ba..b0fa5fb2 100644 --- a/notmuch.el +++ b/notmuch.el @@ -604,6 +604,8 @@ which this thread was originally shown." (indent-rigidly beg end depth) (overlay-put (make-overlay beg-hidden end) 'invisible 'notmuch-show-header) + (goto-char end) + (insert "\n") (set-marker beg nil) (set-marker beg-hidden nil) (set-marker end nil) From 5aea0dcb61368b416b2243e7cdf3bab8d919b696 Mon Sep 17 00:00:00 2001 From: Alexander Botero-Lowry Date: Sun, 22 Nov 2009 15:24:25 -0800 Subject: [PATCH 6/7] instead of trying to cause a redisplay, actually do a redisplay --- notmuch.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/notmuch.el b/notmuch.el index b0fa5fb2..ef2a72a8 100644 --- a/notmuch.el +++ b/notmuch.el @@ -483,7 +483,8 @@ which this thread was originally shown." (remove-from-invisibility-spec invis-spec) (add-to-invisibility-spec invis-spec) )) - (goto-char (button-end cite-button))) + (force-window-update) + (redisplay t)) (defun notmuch-show-markup-citations-region (beg end depth) (goto-char beg) From 82bcd1b2d09e89a01b9dea63c0c656e3c9ed5ba7 Mon Sep 17 00:00:00 2001 From: Alexander Botero-Lowry Date: Sun, 22 Nov 2009 15:42:59 -0800 Subject: [PATCH 7/7] switch to button-1, which seems to interact poorly with text-selection by mouse --- notmuch.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/notmuch.el b/notmuch.el index ef2a72a8..59277379 100644 --- a/notmuch.el +++ b/notmuch.el @@ -512,8 +512,9 @@ which this thread was originally shown." (let ((cite-button (insert-button cite-button-text))) (button-put cite-button 'invisibility-spec invis-spec) (button-put cite-button 'action 'notmuch-toggle-invisible-action) + (button-put cite-button 'follow-link t) (button-put cite-button 'help-echo - "mouse-2, RET: Show citation") + "mouse-1, RET: Show citation") ) (insert "\n") @@ -537,8 +538,9 @@ which this thread was originally shown." (button-put sig-button 'invisibility-spec invis-spec) (button-put sig-button 'action 'notmuch-toggle-invisible-action) + (button-put sig-button 'follow-link t) (button-put sig-button 'help-echo - "mouse-2, RET: Show signature") + "mouse-1, RET: Show signature") ) (insert "\n") (goto-char end))))))