unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* lots of emacs mode enhancements
@ 2009-11-20  8:26 Alexander Botero-Lowry
  2009-11-22 23:11 ` Carl Worth
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Botero-Lowry @ 2009-11-20  8:26 UTC (permalink / raw)
  To: notmuch

I've just been diving into the elisp, and have added a bunch of useful
features.

1) buttonized citation and signature expanders and made them locally
collapsable instead of globally (this could take some cleanup to remove
the global key-map binding or make it work again)
2) fixed an annoying warning about cons not being a face name
3) made header names bold to make it easier to distingush them from
their value

My next target is to carry the buttonization through to threads and
headers, and then I'm going to look into doing better mime-handling in
general.

also, RFP includes a -p argument that gives a patch :)

alex

----
The following changes since commit 9b560fb3eb87b2a4f9d092bc1b124ccb6d11c975:
  Alexander Botero-Lowry (1):
        Checkin some command-only tcsh completions

are available in the git repository at:

  git://alexbl.net/notmuch.git master

Alexander Botero-Lowry (5):
      Buttonize citation expander.
      buttonize signatures as well
      fix the message about cons not being a valid face attribute
      Make expanding/collapsing signatures and citations local to them
      make header names bold in show-mode

 notmuch.el |   72 +++++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 57 insertions(+), 15 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 1fc54c3..bb69aa3 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -440,6 +440,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)
@@ -451,25 +459,51 @@ 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)
-	      (overlay-put overlay 'before-string
-			   (concat indent
-				   "[" (number-to-string (count-lines beg-sub (point)))
-				   "-line citation. Press 'c' to show.]\n")))))
+	    (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.]"))
+                    )
+                (goto-char (- beg-sub 1))
+                (insert (concat "\n" indent))
+                (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))
+              ))))
       (move-to-column depth)
       (if (looking-at notmuch-show-signature-regexp)
 	  (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)
-		  (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 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)
@@ -516,12 +550,20 @@ which this thread was originally shown."
   (let ((beg (point-marker)))
     (end-of-line)
     ; Inverse video for subject
-    (overlay-put (make-overlay beg (point)) 'face '((cons :inverse-video t)))
+    (overlay-put (make-overlay beg (point)) 'face '(:inverse-video t))
     (forward-line 2)
     (let ((beg-hidden (point-marker)))
       (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)

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-11-22 23:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-20  8:26 lots of emacs mode enhancements Alexander Botero-Lowry
2009-11-22 23:11 ` Carl Worth
2009-11-22 23:53   ` Carl Worth

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).