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

* Re: lots of emacs mode enhancements
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Carl Worth @ 2009-11-22 23:11 UTC (permalink / raw)
  To: Alexander Botero-Lowry, notmuch

On Fri, 20 Nov 2009 00:26:33 -0800, Alexander Botero-Lowry <alex.boterolowry@gmail.com> wrote:
> I've just been diving into the elisp, and have added a bunch of useful
> features.

This is fantastic stuff, Alex. Thanks so much for working on it. (And
I'm sorry it took me a while before I got around to reviewing
it. Hopefully I'll be more responsive when I'm done travelling in a
couple of days.

> 1) buttonized citation and signature expanders and made them locally
> collapsable instead of globally 
> 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

I really like the bold headers. And I can tell that the buttonization is
going to be very nice. But I can't actually get it to work completely. I
first clicked[*] on a signature to make it visible, which worked
find. But then clicking on it again I got "buffer is read-only" and it
wouldn't hide. At that point I couldn't get any of the other buttons to
make things visible either.

So, being unwilling to have hidden content that I can't make visible, I
can't merge this work in its current state. If you can't replicate the
bug, let me know and I'll try to look closer at what's going on.

> (this could take some cleanup to remove
> the global key-map binding or make it work again)

Obviously, we should not have a keybinding that doesn't work. But I'd be
glad to just remove it---if we can do local expansion I don't see a big
reason to have global expansion. At least for things like citations and
signature. For message bodies, that's different, so I can imagine having
an "expand all" keybinding for them.

Meanwhile, the feature that I *will* want is something to make it easy
to use the keyboard alone to show/hide hidden parts. What I want is for
TAB to advance to the next button, so that then I can just press RET on
it to toggle it.

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

Great. I'll look forward to that.

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

Very nice. It's appreciated.

-Carl

[*] Any reason we can't make button 1 do this instead of button 2? That
should be more intuitive, and at worst it means that the text on the
button itself is hard to select, which shouldn't be an option.

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

* Re: lots of emacs mode enhancements
  2009-11-22 23:11 ` Carl Worth
@ 2009-11-22 23:53   ` Carl Worth
  0 siblings, 0 replies; 3+ messages in thread
From: Carl Worth @ 2009-11-22 23:53 UTC (permalink / raw)
  To: Alexander Botero-Lowry, notmuch

On Mon, 23 Nov 2009 00:11:22 +0100, Carl Worth <cworth@cworth.org> wrote:
> On Fri, 20 Nov 2009 00:26:33 -0800, Alexander Botero-Lowry <alex.boterolowry@gmail.com> wrote:
> I really like the bold headers. And I can tell that the buttonization is
> going to be very nice. But I can't actually get it to work completely. I
> first clicked[*] on a signature to make it visible, which worked
> find. But then clicking on it again I got "buffer is read-only" and it
> wouldn't hide. At that point I couldn't get any of the other buttons to
> make things visible either.

This was simply a re-display bug which Alexander fixed. And he also
changed the buttons from button-2 to button-1.

I really like the final result, so it's pushed now.

Citations and signatures can now be expanded locally!

It is slightly harder to do this with the keyboard now. You have to
actually position point right on the button. This is just a temporary
thing, as I want to add a TAB binding to move point to the next button.

So keyboard-lovers, don't worry, notmuch (at least the emacs interface)
will always be very friendly for keyboard use (excepting temporary
lapses like this current one).

-Carl

^ permalink raw reply	[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).