unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: Fix i-search to open up invisible citations as necessary
@ 2010-04-23 17:39 David Edmondson
  2010-04-24 14:42 ` Carl Worth
  0 siblings, 1 reply; 7+ messages in thread
From: David Edmondson @ 2010-04-23 17:39 UTC (permalink / raw)
  To: notmuch

Add an `isearch-open-invisible' property to the overlays used to hide
citations and signatures, together with an appropriate function to
leave the invisible text visible should that be required.
---
 emacs/notmuch-wash.el |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index fe33819..dd5d0a1 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -83,6 +83,9 @@ collapse the remaining lines into a button.")
   'help-echo "mouse-1, RET: Show signature"
   :supertype 'notmuch-wash-button-invisibility-toggle-type)
 
+(defun notmuch-wash-region-isearch-show (overlay)
+  (remove-from-invisibility-spec (overlay-get overlay 'invisible)))
+
 (defun notmuch-wash-region-to-button (beg end type prefix button-text)
   "Auxilary function to do the actual making of overlays and buttons
 
@@ -102,6 +105,7 @@ is what to put on the button."
 					  type "-toggle-type"))))
     (add-to-invisibility-spec invis-spec)
     (overlay-put overlay 'invisible invis-spec)
+    (overlay-put overlay 'isearch-open-invisible #'notmuch-wash-region-isearch-show)
     (goto-char (1+ end))
     (save-excursion
       (goto-char (1- beg))
-- 
1.7.0

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

* Re: [PATCH] emacs: Fix i-search to open up invisible citations as necessary
  2010-04-23 17:39 [PATCH] emacs: Fix i-search to open up invisible citations as necessary David Edmondson
@ 2010-04-24 14:42 ` Carl Worth
  2010-04-24 16:58   ` Dirk Hohndel
  2010-04-30 16:00   ` all authors and subjects in the search buffer [was: Re: [PATCH] emacs: Fix i-search to open up invisible citations as necessary] David Edmondson
  0 siblings, 2 replies; 7+ messages in thread
From: Carl Worth @ 2010-04-24 14:42 UTC (permalink / raw)
  To: David Edmondson, notmuch

[-- Attachment #1: Type: text/plain, Size: 741 bytes --]

On Fri, 23 Apr 2010 18:39:33 +0100, David Edmondson <dme@dme.org> wrote:
> Add an `isearch-open-invisible' property to the overlays used to hide
> citations and signatures, together with an appropriate function to
> leave the invisible text visible should that be required.

This is a fantastic feature, David. Thanks! This is pushed.

I knew emacs could do this kind of thing, and I had even tried to
implement it once, but I hadn't succeeded for some reason.

Next, I wonder if we shouldn't do something similar for the search
view. It might be quite handy if all authors and all unique subjects for
a thread were made available for i-search in the buffer, but hidden by
default and expanded as needed like this. What do you think?

-Carl

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH] emacs: Fix i-search to open up invisible citations as necessary
  2010-04-24 14:42 ` Carl Worth
@ 2010-04-24 16:58   ` Dirk Hohndel
  2010-04-30 16:00   ` all authors and subjects in the search buffer [was: Re: [PATCH] emacs: Fix i-search to open up invisible citations as necessary] David Edmondson
  1 sibling, 0 replies; 7+ messages in thread
From: Dirk Hohndel @ 2010-04-24 16:58 UTC (permalink / raw)
  To: Carl Worth, David Edmondson, notmuch

On Sat, 24 Apr 2010 07:42:48 -0700, Carl Worth <cworth@cworth.org> wrote:
> On Fri, 23 Apr 2010 18:39:33 +0100, David Edmondson <dme@dme.org> wrote:
> > Add an `isearch-open-invisible' property to the overlays used to hide
> > citations and signatures, together with an appropriate function to
> > leave the invisible text visible should that be required.
> 
> This is a fantastic feature, David. Thanks! This is pushed.
> 
> I knew emacs could do this kind of thing, and I had even tried to
> implement it once, but I hadn't succeeded for some reason.
> 
> Next, I wonder if we shouldn't do something similar for the search
> view. It might be quite handy if all authors and all unique subjects for
> a thread were made available for i-search in the buffer, but hidden by
> default and expanded as needed like this. What do you think?

I would love this

/D

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

* Re: all authors and subjects in the search buffer [was: Re: [PATCH] emacs: Fix i-search to open up invisible citations as necessary]
  2010-04-24 14:42 ` Carl Worth
  2010-04-24 16:58   ` Dirk Hohndel
@ 2010-04-30 16:00   ` David Edmondson
  2010-05-03 20:27     ` Carl Worth
  1 sibling, 1 reply; 7+ messages in thread
From: David Edmondson @ 2010-04-30 16:00 UTC (permalink / raw)
  To: Carl Worth, notmuch

[-- Attachment #1: Type: text/plain, Size: 594 bytes --]

On Sat, 24 Apr 2010 07:42:48 -0700, Carl Worth <cworth@cworth.org> wrote:
> Next, I wonder if we shouldn't do something similar for the search
> view. It might be quite handy if all authors and all unique subjects for
> a thread were made available for i-search in the buffer, but hidden by
> default and expanded as needed like this. What do you think?

All of the authors appear in the output already, but that doesn't seem
to be the case of the subjects. Would you envisage doing something
similar to the changes Dirk made for authors?

dme.
-- 
David Edmondson, http://dme.org

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: all authors and subjects in the search buffer [was: Re: [PATCH] emacs: Fix i-search to open up invisible citations as necessary]
  2010-04-30 16:00   ` all authors and subjects in the search buffer [was: Re: [PATCH] emacs: Fix i-search to open up invisible citations as necessary] David Edmondson
@ 2010-05-03 20:27     ` Carl Worth
  2010-05-04 10:55       ` [PATCH] emacs: In search mode, truncate authors using invisible text David Edmondson
  2010-05-04 10:56       ` all authors and subjects in the search buffer [was: Re: [PATCH] emacs: Fix i-search to open up invisible citations as necessary] David Edmondson
  0 siblings, 2 replies; 7+ messages in thread
From: Carl Worth @ 2010-05-03 20:27 UTC (permalink / raw)
  To: David Edmondson, notmuch

[-- Attachment #1: Type: text/plain, Size: 611 bytes --]

On Fri, 30 Apr 2010 17:00:08 +0100, David Edmondson <dme@dme.org> wrote:
> All of the authors appear in the output already, but that doesn't seem
> to be the case of the subjects. Would you envisage doing something
> similar to the changes Dirk made for authors?

Right. We do have a similar approach already for picking out the "first"
matching subject. So it would be an easy extension to have it print a
sorted list of all the subjects.

But let's start by making the emacs interface allow for searching of the
authors. Then we can think about whether it makes sense to list all the
subjects as well.

-Carl

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* [PATCH] emacs: In search mode, truncate authors using invisible text.
  2010-05-03 20:27     ` Carl Worth
@ 2010-05-04 10:55       ` David Edmondson
  2010-05-04 10:56       ` all authors and subjects in the search buffer [was: Re: [PATCH] emacs: Fix i-search to open up invisible citations as necessary] David Edmondson
  1 sibling, 0 replies; 7+ messages in thread
From: David Edmondson @ 2010-05-04 10:55 UTC (permalink / raw)
  To: notmuch

Rather than discarding authors when truncated to fit the defined
column width, mark the text beyond the end of the column as invisible
and allow `isearch' to be used over the text so hidden.

This allows us to retain the compact display whilst enabling a user to
find the elided text.
---
 emacs/notmuch.el |   61 +++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 45 insertions(+), 16 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index c2fefe5..10babe4 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -608,23 +608,52 @@ matching will be applied."
 		  (t
 		   (setq tags-faces (cdr tags-faces)))))))))
 
+(defun notmuch-search-isearch-authors-show (overlay)
+  (remove-from-invisibility-spec (cons (overlay-get overlay 'invisible) t)))
+
 (defun notmuch-search-insert-authors (format-string authors)
-  (insert (let* ((formatted-sample (format format-string ""))
-		 (formatted-authors (format format-string authors))
-		 (truncated-string
-		  (if (> (length formatted-authors)
-			 (length formatted-sample))
-		      (concat (substring authors 0 (- (length formatted-sample) 4)) "... ")
-		    formatted-authors)))
-	    ;; Need to save the match data to avoid interfering with
-	    ;; `notmuch-search-process-filter'.
-	    (save-match-data
-	      (if (string-match "\\(.*\\)|\\(..*\\)" truncated-string)
-		  (concat (propertize (concat (match-string 1 truncated-string) ",")
-				      'face 'notmuch-search-matching-authors)
-			  (propertize (match-string 2 truncated-string)
-				      'face 'notmuch-search-non-matching-authors))
-		(propertize truncated-string 'face 'notmuch-search-matching-authors))))))
+  (let* ((propertized-authors
+	  ;; Need to save the match data to avoid interfering with
+	  ;; `notmuch-search-process-filter'.
+	  (save-match-data
+	    ;; Authors that don't match the search query are shown in a
+	    ;; different font.
+	    (if (string-match "\\(.*\\)|\\(..*\\)" authors)
+		(concat (propertize (concat (match-string 1 authors) ",")
+				    'face 'notmuch-search-matching-authors)
+			(propertize (match-string 2 authors)
+				    'face 'notmuch-search-non-matching-authors))
+	      (propertize authors 'face 'notmuch-search-matching-authors))))
+
+	 (formatted-sample (format format-string ""))
+	 (formatted-authors (format format-string propertized-authors))
+	 visible-string invisible-string)
+
+    ;; Determine the part of the authors that will be visible by
+    ;; default.
+    (if (> (length formatted-authors)
+	   (length formatted-sample))
+	;; 4 is `(length "... ")'.
+	(let ((visible-length (- (length formatted-sample) 4)))
+	  (setq visible-string (substring propertized-authors 0 visible-length)
+		invisible-string (substring propertized-authors visible-length)))
+      (setq visible-string formatted-authors
+	    invisible-string nil))
+
+    ;; Insert both the visible and invisible author strings.
+    (insert visible-string)
+    (when invisible-string
+      (let ((start (point))
+	    (invis-spec (make-symbol "notmuch-search-authors"))
+	    overlay)
+	(insert invisible-string)
+	;; Using a cons-cell here causes an ellipsis to be inserted
+	;; instead of the invisible text.
+	(add-to-invisibility-spec (cons invis-spec t))
+	(setq overlay (make-overlay start (point)))
+	(overlay-put overlay 'invisible invis-spec)
+	(overlay-put overlay 'isearch-open-invisible #'notmuch-search-isearch-authors-show)
+	(insert " ")))))
 
 (defun notmuch-search-insert-field (field date count authors subject tags)
   (cond
-- 
1.7.0

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

* Re: all authors and subjects in the search buffer [was: Re: [PATCH] emacs: Fix i-search to open up invisible citations as necessary]
  2010-05-03 20:27     ` Carl Worth
  2010-05-04 10:55       ` [PATCH] emacs: In search mode, truncate authors using invisible text David Edmondson
@ 2010-05-04 10:56       ` David Edmondson
  1 sibling, 0 replies; 7+ messages in thread
From: David Edmondson @ 2010-05-04 10:56 UTC (permalink / raw)
  To: Carl Worth, notmuch

[-- Attachment #1: Type: text/plain, Size: 1002 bytes --]

On Mon, 03 May 2010 13:27:35 -0700, Carl Worth <cworth@cworth.org> wrote:
> On Fri, 30 Apr 2010 17:00:08 +0100, David Edmondson <dme@dme.org> wrote:
> > All of the authors appear in the output already, but that doesn't seem
> > to be the case of the subjects. Would you envisage doing something
> > similar to the changes Dirk made for authors?
> 
> Right. We do have a similar approach already for picking out the "first"
> matching subject. So it would be an easy extension to have it print a
> sorted list of all the subjects.
> 
> But let's start by making the emacs interface allow for searching of the
> authors. Then we can think about whether it makes sense to list all the
> subjects as well.

Patch sent to allow searching of the hidden authors.

Given that the tags are displayed after the subject, I suspect that we
would choose to hide _all_ of the 'non-matching' subject(s), displaying
it only as necessary during isearch.

dme.
-- 
David Edmondson, http://dme.org

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

end of thread, other threads:[~2010-05-04 10:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-23 17:39 [PATCH] emacs: Fix i-search to open up invisible citations as necessary David Edmondson
2010-04-24 14:42 ` Carl Worth
2010-04-24 16:58   ` Dirk Hohndel
2010-04-30 16:00   ` all authors and subjects in the search buffer [was: Re: [PATCH] emacs: Fix i-search to open up invisible citations as necessary] David Edmondson
2010-05-03 20:27     ` Carl Worth
2010-05-04 10:55       ` [PATCH] emacs: In search mode, truncate authors using invisible text David Edmondson
2010-05-04 10:56       ` all authors and subjects in the search buffer [was: Re: [PATCH] emacs: Fix i-search to open up invisible citations as necessary] David Edmondson

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