[PATCH] emacs: Turn id:"" elements into buttons for notmuch searches
This fixes the minor annoyance that message ids were parsed as mail addresses by goto-address-mode in notmuch-show buffers. --- emacs/notmuch-show.el | 23 --- 1 files changed, 20 insertions(+), 3 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index f96743b..0f7fcfe 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -778,6 +778,24 @@ current buffer, if possible." (defvar notmuch-show-parent-buffer nil) (make-variable-buffer-local 'notmuch-show-parent-buffer) +(defun notmuch-show-buttonise-links (start end) + "Buttonise URLs and mail addresses between START and END. + +This also turns id:\"\"-parts into buttons for +a corresponding notmuch search." + (goto-address-fontify-region start end) + (save-excursion +(goto-char start) +(while (re-search-forward "id:\"[^ ]+\"" end t) + ;; remove the overlay created by goto-address-mode + (remove-overlays (match-beginning 0) (match-end 0) 'goto-address t) + (make-text-button (match-beginning 0) (match-end 0) + 'action `(lambda (arg) + (notmuch-search ,(match-string-no-properties 0))) + 'follow-link t + 'help-echo "Mouse-1, RET: search for this message" + 'face goto-address-mail-face + ;;;###autoload (defun notmuch-show (thread-id parent-buffer query-context buffer-name crypto-switch) "Run \"notmuch show\" with the given thread ID and display results. @@ -822,9 +840,8 @@ function is used. " (notmuch-show-insert-forest (notmuch-query-get-threads basic-args - ;; Enable buttonisation of URLs and email addresses in the - ;; buffer. - (goto-address-mode t) + (jit-lock-register #'notmuch-show-buttonise-links) + ;; Act on visual lines rather than logical lines. (visual-line-mode t) -- 1.7.5.4
[PROTO] possible solution for "Race condition for '*' command"
On Mon, 04 Jul 2011 20:48:12 +0200, Pieter Praet wrote: > On Mon, 04 Jul 2011 13:56:26 -0400, Austin Clements > wrote: > > I should probably emit two lists per thread: one of matched IDs and > > one of unmatched IDs. Tagging a region can then operate on the > > concatenation of these, while * can operate only on the matched > > lists. This should be easy to do. I'll send an updated patch when I'm > > back at a computer. > > The matched MsgIds will be sufficient, as we'll want to operate on > either the matched messages or the entire thread (for which the > `thread-id' property is already present). > > Can't think of a use case for non-matched messages right now, > but if required, we'll just use `set-exclusive-or'. Wasn't thinking clearly: You're right, we *will* be needing both a list of matched as well as one of unmatched Message-Id's per result. Otherwise there would still be a potential race condition when tagging with +/-. Peace -- Pieter
[PATCH] emacs: logically group def{custom,face}s
To allow for expansion whilst keeping everything tidy and organized, move all defcustom/defface variables to the following subgroups, defined in notmuch-lib.el: - Hello - Search - Show - Send - Crypto - Hooks - Appearance - External Commands Signed-off-by: Pieter Praet --- emacs/notmuch-address.el |3 +- emacs/notmuch-crypto.el | 17 ++- emacs/notmuch-hello.el | 20 ++ emacs/notmuch-lib.el | 44 - emacs/notmuch-maildir-fcc.el |2 +- emacs/notmuch-message.el |2 +- emacs/notmuch-mua.el | 11 + emacs/notmuch-show.el| 14 ++-- emacs/notmuch.el | 35 + 9 files changed, 103 insertions(+), 45 deletions(-) diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el index 1a7c577..553a04e 100644 --- a/emacs/notmuch-address.el +++ b/emacs/notmuch-address.el @@ -28,7 +28,8 @@ single argument and output a list of possible matches, one per line." :type 'string - :group 'notmuch) + :group 'notmuch-send + :group 'notmuch-external) (defvar notmuch-address-message-alist-member '("^\\(Resent-\\)?\\(To\\|B?Cc\\|Reply-To\\|From\\|Mail-Followup-To\\|Mail-Copies-To\\):" diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el index f03266f..b8132f5 100644 --- a/emacs/notmuch-crypto.el +++ b/emacs/notmuch-crypto.el @@ -33,33 +33,38 @@ validity of user ID of the signer. The effect of setting this variable can be seen temporarily by viewing a signed or encrypted message with M-RET in notmuch search." - :group 'notmuch + :group 'notmuch-crypto :type 'boolean) (defface notmuch-crypto-signature-good '((t (:background "green" :foreground "black"))) "Face used for good signatures." - :group 'notmuch) + :group 'notmuch-crypto + :group 'notmuch-appearance) (defface notmuch-crypto-signature-good-key '((t (:background "orange" :foreground "black"))) "Face used for good signatures." - :group 'notmuch) + :group 'notmuch-crypto + :group 'notmuch-appearance) (defface notmuch-crypto-signature-bad '((t (:background "red" :foreground "black"))) "Face used for bad signatures." - :group 'notmuch) + :group 'notmuch-crypto + :group 'notmuch-appearance) (defface notmuch-crypto-signature-unknown '((t (:background "red" :foreground "black"))) "Face used for signatures of unknown status." - :group 'notmuch) + :group 'notmuch-crypto + :group 'notmuch-appearance) (defface notmuch-crypto-decryption '((t (:background "purple" :foreground "black"))) "Face used for encryption/decryption status messages." - :group 'notmuch) + :group 'notmuch-crypto + :group 'notmuch-appearance) (define-button-type 'notmuch-crypto-status-button-type 'action '(lambda (button) (message (button-get button 'help-echo))) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 65fde75..060ffe4 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -35,12 +35,12 @@ (defcustom notmuch-recent-searches-max 10 "The number of recent searches to store and display." :type 'integer - :group 'notmuch) + :group 'notmuch-hello) (defcustom notmuch-show-empty-saved-searches nil "Should saved searches with no messages be listed?" :type 'boolean - :group 'notmuch) + :group 'notmuch-hello) (defvar notmuch-hello-indent 4 "How much to indent non-headers.") @@ -48,12 +48,13 @@ (defcustom notmuch-show-logo t "Should the notmuch logo be shown?" :type 'boolean - :group 'notmuch) + :group 'notmuch-hello + :group 'notmuch-appearance) (defcustom notmuch-show-all-tags-list nil "Should all tags be shown in the notmuch-hello view?" :type 'boolean - :group 'notmuch) + :group 'notmuch-hello) (defcustom notmuch-hello-tag-list-make-query nil "Function or string to generate queries for the all tags list. @@ -68,12 +69,12 @@ should return a filter for that tag, or nil to hide the tag." (const :tag "Unread messages" "tag:unread") (const :tag "Custom filter" string) (const :tag "Custom filter function" function)) - :group 'notmuch) + :group 'notmuch-hello) (defcustom notmuch-hello-hide-tags nil "List of tags to be hidden in the \"all tags\"-section." :type '(repeat string) - :group 'notmuch) + :group 'notmuch-hello) (defface notmuch-hello-logo-background 'class color) @@ -83,7 +84,8 @@ should return a filter for that tag, or nil to hide the tag." (background light)) (:background "white"))) "Background colour for the notmuch logo." - :group 'notmuch) + :group 'notmuch-hello + :group 'notmuch-appearance) (defcustom notmuch-column-control t "Controls the number of columns for saved searches/tags in notmuch view. @@ -105,7 +107,7 @@ So: 30. - if you don't want to worry about all of this nonsense, leave this set to `t'." - :group 'notmuch + :group
[PATCH 0/2] emacs: User-defined sections in notmuch-hello
On Tue, 05 Jul 2011 16:09:14 +0200, Michal Sojka wrote: > I wanted to say that it might be useful to have the similar options for > saved searches. For example, what I do in my notmuch-hello-insert-inbox > is to take the saved searches and filter them by tag:inbox. I guess that > if there is a possibility to do that without coding in elisp, some > people may find it useful. What do you think? I sent a new version of the patch that incorporates your suggestions with one exception: I removed notmuch-hello-insert-inbox from the default value for notmuch-hello-sections, since personally I find it a bit confusing to have all tags with inbox-tagged messages mixed with the saved searches in one place. -- next part -- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 835 bytes Desc: not available URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20110705/9d61bc8b/attachment-0001.pgp>
[PATCH v3 1/2] emacs: User-defined sections in notmuch-hello
This patch makes the notmuch-hello screen fully customizable by allowing the user to add and remove arbitrary sections. It also provides some convenience functions for constructing sections, e.g. showing the unread message count for each tag. This is done by specifying a list of functions that will be run when notmuch-hello is invoked. --- emacs/notmuch-hello.el | 609 +++- 1 files changed, 393 insertions(+), 216 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 65fde75..9c18caa 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -55,26 +55,6 @@ :type 'boolean :group 'notmuch) -(defcustom notmuch-hello-tag-list-make-query nil - "Function or string to generate queries for the all tags list. - -This variable controls which query results are shown for each tag -in the \"all tags\" list. If nil, it will use all messages with -that tag. If this is set to a string, it is used as a filter for -messages having that tag (equivalent to \"tag:TAG and (THIS-VARIABLE)\"). -Finally this can be a function that will be called for each tag and -should return a filter for that tag, or nil to hide the tag." - :type '(choice (const :tag "All messages" nil) -(const :tag "Unread messages" "tag:unread") -(const :tag "Custom filter" string) -(const :tag "Custom filter function" function)) - :group 'notmuch) - -(defcustom notmuch-hello-hide-tags nil - "List of tags to be hidden in the \"all tags\"-section." - :type '(repeat string) - :group 'notmuch) - (defface notmuch-hello-logo-background 'class color) (background dark)) @@ -123,6 +103,75 @@ Typically \",\" in the US and UK and \".\" in Europe." (defvar notmuch-hello-recent-searches nil) +(define-widget 'notmuch-hello-tags-section 'lazy + "Customize-type for notmuch-hello tag-list sections." + :tag "Customized tag-list" + :type + (let ((opts +'((:title (string :tag "Title for this section")) + (:make-query (string :tag "Filter for each tag")) + (:make-count (string :tag "Different query to generate counts")) + (:hide-tags (repeat :tag "Tags that will be hidden" string)) + (:initially-hidden (boolean :tag "Hide this on startup?")) + (:hide-empty-tags (boolean :tag "Hide tags with no matching messages")) + (:hide-if-empty (boolean :tag "Hide if empty") +`(list (const :tag "" notmuch-hello-insert-tags-section) + (plist :inline t :options ,opts + +(define-widget 'notmuch-hello-query-section 'lazy + "Customize-type for custom saved-search-like sections" + :tag "Customized queries section" + :type + '(list (const :tag "" notmuch-hello-insert-query-list) +(string :tag "Title for this section") +(repeat :tag "Queries" +(cons (string :tag "Name") (string :tag "Query"))) +(plist :inline t + :options + ((:initially-hidden (boolean :tag "Hide this on startup?")) +(:hide-empty-tags + (boolean :tag "Hide tags with no matching messages")) +(:hide-if-empty (boolean :tag "Hide if empty")) + +(defcustom notmuch-hello-sections + (list #'notmuch-hello-insert-header + #'notmuch-hello-insert-saved-searches + #'notmuch-hello-insert-search + #'notmuch-hello-insert-recent-searches + #'notmuch-hello-insert-alltags + #'notmuch-hello-insert-footer) + "Sections for notmuch-hello. + +Each entry of this list should be a function of no arguments that +should return if notmuch-hello-target is produced as part of its +output and nil otherwise. For convenience an element can also be +a list of the form (FUNC ARG1 ARG2 .. ARGN) in which case FUNC +will be applied to the rest of the list. + +The functions will be run to construct the content of the +notmuch-hello buffer in the order they appear in this list." + :group 'notmuch + :type + '(repeat +(choice (function-item notmuch-hello-insert-header) + (function-item notmuch-hello-insert-saved-searches) + (function-item notmuch-hello-insert-search) + (function-item notmuch-hello-insert-recent-searches) + (function-item notmuch-hello-insert-alltags) + (function-item notmuch-hello-insert-footer) + (function-item notmuch-hello-insert-inbox) + notmuch-hello-tags-section + notmuch-hello-query-section + (function :tag "Custom function" + +;; only defined to avoid compilation warnings about free variables +(defvar notmuch-hello-target nil) + +(defvar notmuch-hello-hidden-sections nil + "List of query sections whose contents are hidden") + +(defvar notmuch-hello-first-run t) + (defun notmuch-hello-remember-search (search) (if (not (member search notmuch-hello-recent-searches)) (push search notmuch-hello-recent-searches)) @@ -173,8 +222,8 @@ Typically
[PATCH 0/2] emacs: User-defined sections in notmuch-hello
On Tue, 05 Jul 2011 16:09:14 +0200, Michal Sojka wrote: > I'm talking about notmuch-hello-section. It seems it is not possible > easily specify there your own function. You can either select a > predefined section or "Customized section", which is in fact "Customized > all-tags section". So I propose to renaming this entry like this and > adding another one called "Custom function", where you could enter the > name of your function. Ah, I see why it confused me: You are referring to the first version of the patch. This particular bit is already clarified in the second iteration of the patch, starting at id:"1309613471-23465-1-git-send-email-daniel.schoepe at googlemail.com" In that case I also fully understand why you found the customize-interface confusing. :) > It seems that I still do not understand what the "Customized section" > was intended to provide. I have to say I'm not able to fully decode the > definition of notmuch-hello-customized-section, but it seems to me that > it is a way how to customize a call to notmuch-hello-insert-all-tags. Yes, that was the intention, in v2 I used a cleaner way to do that. > I wanted to say that it might be useful to have the similar options for > saved searches. For example, what I do in my notmuch-hello-insert-inbox > is to take the saved searches and filter them by tag:inbox. I guess that > if there is a possibility to do that without coding in elisp, some > people may find it useful. What do you think? Ah okay, then I understood you correctly. I agree that this would make sense. Cheers, Daniel -- next part -- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 835 bytes Desc: not available URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20110705/3de95057/attachment.pgp>
[PATCH 0/2] emacs: User-defined sections in notmuch-hello
On Tue, 05 Jul 2011, Daniel Schoepe wrote: Non-text part: multipart/signed > On Tue, 05 Jul 2011 02:00:33 +0200, Michal Sojka > wrote: > > First, the customization interface for the custom sections (not the > > predefined ones) is very confusing. I was not able to use it at all. > > Instead I hacked the source code (see below) to add my section to the > > notmuch-hello-sections list. > > What specifically did you find confusing? Sorry for not being clear - I wrote the mail late at night, looking forward to some sleep :) > The first customization-option is intended for sections like the all > tags section which various configuration options which should be > explained by the docstrings next to the options. The second item > allows saved-searches-like sections. I'm talking about notmuch-hello-section. It seems it is not possible easily specify there your own function. You can either select a predefined section or "Customized section", which is in fact "Customized all-tags section". So I propose to renaming this entry like this and adding another one called "Custom function", where you could enter the name of your function. > By the way: Instead of editing the source directly, you can also put all > customizations like that in your configuration files and set > notmuch-hello-sections from there. Nevertheless your inbox-display > functions look useful in general so they should indeed be included. I know that, but I wanted to do the experiment quickly and this was the easiest way for me. Regarding setting of notmuch-hello-sections from .emacs, I prefer customizing it through the customization interface because when somebody else introduces a new section it is more convenient for me to try it by choosing from predefined values than modifying that in .emacs. > > And last but not least, you allow quite wild modifications of tag > > searches (e.g. in notmuch-hello-generate-tag-alist), but is might be > > also useful to use such modifications for other searches. For example, I > > want to modify the saved searches in a similar way. > > Are you referring to things like specifying a filter for each tag or > count in saved-searches? My thinking was that since you specify each > item manually anyway, you can append any filter you might want to use > there. But I guess you're right that it's a bit more convenient to be > able to specify those once and not having to repeat it for each item. It seems that I still do not understand what the "Customized section" was intended to provide. I have to say I'm not able to fully decode the definition of notmuch-hello-customized-section, but it seems to me that it is a way how to customize a call to notmuch-hello-insert-all-tags. I wanted to say that it might be useful to have the similar options for saved searches. For example, what I do in my notmuch-hello-insert-inbox is to take the saved searches and filter them by tag:inbox. I guess that if there is a possibility to do that without coding in elisp, some people may find it useful. What do you think? -Michal
[PATCH 2/2] emacs: skip forward to visible text in notmuch-show-message-extent
On Sun, 3 Jul 2011 08:28:06 +0400, Dmitry Kurochkin wrote: > The patch rewrites `notmuch-show-message-extent' to be more > robust. The main goal is to make it work as expected if point is > invisible. Besides, there are no more point movements and > property search functions are used instead manual loops. The > comment regarding properties strangeness is removed since there > is no strangeness here: property ranges (as well as overlay, and > many others, I believe) are given as [begin, end), not [begin, > end]. Please do not apply this patch. I am considering a different solution: instead of making the trailing newline invisible, make the preceding newline invisible. This way a message would always have a visible newline at the end and it would prevent `beginning-of-visual-line' going beyond the beginning of message. FYI there is a discussion on emacs-devel [1] regarding point adjustment inside invisible regions. Regards, Dmitry [1] http://thread.gmane.org/gmane.emacs.devel/141479 > --- > emacs/notmuch-show.el | 19 +++ > 1 files changed, 11 insertions(+), 8 deletions(-) > > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el > index f96743b..cf8b405 100644 > --- a/emacs/notmuch-show.el > +++ b/emacs/notmuch-show.el > @@ -933,15 +933,18 @@ All currently available key bindings: > > ;; Movement related functions. > > -;; There's some strangeness here where a text property applied to a > -;; region a->b is not found when point is at b. We walk backwards > -;; until finding the property. > (defun notmuch-show-message-extent () > - (let (r) > -(save-excursion > - (while (not (setq r (get-text-property (point) > :notmuch-message-extent))) > - (backward-char))) > -r)) > + (let ((p (point))) > +;; if point is invisible, skip forward to visible text > +(while (invisible-p p) > + (setq p (next-single-char-property-change p 'invisible))) > +;; if no visible text found, use the point > +(or p (setq p (point))) > +(or (get-text-property p :notmuch-message-extent) > + ;; if there is no text property, skip to the previous message > + (and (setq p (previous-single-char-property-change > + p :notmuch-message-extent)) > + (get-text-property p :notmuch-message-extent) > > (defun notmuch-show-message-top () >(car (notmuch-show-message-extent))) > -- > 1.7.5.4 >
[PATCH 0/2] emacs: User-defined sections in notmuch-hello
On Tue, 05 Jul 2011 02:00:33 +0200, Michal Sojka wrote: > First, the customization interface for the custom sections (not the > predefined ones) is very confusing. I was not able to use it at all. > Instead I hacked the source code (see below) to add my section to the > notmuch-hello-sections list. What specifically did you find confusing? The first customization-option is intended for sections like the all tags section which various configuration options which should be explained by the docstrings next to the options. The second item allows saved-searches-like sections. By the way: Instead of editing the source directly, you can also put all customizations like that in your configuration files and set notmuch-hello-sections from there. Nevertheless your inbox-display functions look useful in general so they should indeed be included. > Second, when I tried to understand your patch, I found some names of > functions and variables quite confusing. In the patch below, I tried to > give them a better names and I also updated the documentation. Feel free > to use my changes for your later patch submission. Thanks, those look quite a bit clearer, naming things like that is really not my strong suit. I'll include them in the next version of the patch. > > And last but not least, you allow quite wild modifications of tag > searches (e.g. in notmuch-hello-generate-tag-alist), but is might be > also useful to use such modifications for other searches. For example, I > want to modify the saved searches in a similar way. > Are you referring to things like specifying a filter for each tag or count in saved-searches? My thinking was that since you specify each item manually anyway, you can append any filter you might want to use there. But I guess you're right that it's a bit more convenient to be able to specify those once and not having to repeat it for each item. > And here are my changes to your patch, which you might use as a > suggestions for a next version of your patch. As I wrote above, it > renames some functions and variables to more understandable names, > updates documentation and adds a custom section for my personal use (I > can live with this custom section in my .emacs if others do not like > it). If we add the same configuration options that notmuch-hello-generate-tag-alist accepts, this section should be easy to specify in your ~/.emacs with one or two lines anyway. Cheers, Daniel -- next part -- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 835 bytes Desc: not available URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20110705/77af31b1/attachment.pgp>
[PATCH 0/2] emacs: User-defined sections in notmuch-hello
On Wed, 29 Jun 2011, Daniel Schoepe wrote: > Unfortunately the customize-interface for more customized entries in > notmuch-hello-sections looks a bit weird, but I couldn't figure out how > to get rid of the empty lines produced by generating the lambda expression > needed. Hi Daniel, this looks really great and it comes at the right time for me. I can use it for creating a custom section "What's in your inbox" - a functionality which I previously implemented in my personal branch [*] but I was unable to rebase it on the current HEAD. Basically, it took all saved searches and tag searches, filtered them with tag:inbox and displayed the buttons for those searches. With your patch it is "quite easy" to implement such a functionality. There are a few problems, though. First, the customization interface for the custom sections (not the predefined ones) is very confusing. I was not able to use it at all. Instead I hacked the source code (see below) to add my section to the notmuch-hello-sections list. Second, when I tried to understand your patch, I found some names of functions and variables quite confusing. In the patch below, I tried to give them a better names and I also updated the documentation. Feel free to use my changes for your later patch submission. And last but not least, you allow quite wild modifications of tag searches (e.g. in notmuch-hello-generate-tag-alist), but is might be also useful to use such modifications for other searches. For example, I want to modify the saved searches in a similar way. > To avoid unnecessary complexity in the code this patch removes > aligning all the tag entries in different sections (e.g. saved > searches and all tags) the same way. So if someone really thinks this > was an important features, please yell loudly. I do not miss this at all. And here are my changes to your patch, which you might use as a suggestions for a next version of your patch. As I wrote above, it renames some functions and variables to more understandable names, updates documentation and adds a custom section for my personal use (I can live with this custom section in my .emacs if others do not like it). Cheers, -Michal diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index e4c9307..226024c 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -124,6 +124,7 @@ Typically \",\" in the US and UK and \".\" in Europe." (defcustom notmuch-hello-sections (list #'notmuch-hello-insert-header + #'notmuch-hello-insert-inbox #'notmuch-hello-insert-saved-searches #'notmuch-hello-insert-search #'notmuch-hello-insert-recent-searches @@ -205,8 +206,8 @@ in the order they appear in this list." (message "Saved '%s' as '%s'." search name) (notmuch-hello-update))) -(defun notmuch-hello-longest-label (tag-alist) - (or (loop for elem in tag-alist +(defun notmuch-hello-longest-label (searches-alist) + (or (loop for elem in searches-alist maximize (length (car elem))) 0)) @@ -270,11 +271,18 @@ should be. Returns a cons cell `(tags-per-line width)'." (* tags-per-line (+ 9 1 tags-per-line -(defun notmuch-hello-query-entries (tag-alist hide-empty) - "Compute list of counts and queries for TAG-ALIST. +(defun notmuch-hello-query-counts (query-alist hide-empty) + "Compute list of counts of matched messages from QUERY-ALIST. -If HIDE-EMPTY is non-nil, entries with no matching messages will be -removed from the result." +QUERY-ALIST must be a list containing elements of the form (NAME . QUERY) +or (NAME QUERY COUNT-QUERY). If the latter form is used, +COUNT-QUERY specifies an alternate query to be used to generate +the count for the associated query. + +The result is the list of elements of the form (NAME QUERY COUNT). + +If HIDE-EMPTY is non-nil, searches with no matching messages +(COUNT equal to zero) will be removed from the result." (notmuch-remove-if-not #'identity (mapcar @@ -289,21 +297,21 @@ removed from the result." (cdr query-and-count) (and (or (not hide-empty) (> message-count 0)) (list name (car query-and-count) message-count -tag-alist))) +query-alist))) -(defun notmuch-hello-insert-tags (entries) - "Insert query items from ENTRIES. +(defun notmuch-hello-insert-buttons (searches) + "Insert buttons for SEARCHES. -ENTRIES must be a list containing lists of the form (NAME QUERY COUNT), where +SEARCHES must be a list containing lists of the form (NAME QUERY COUNT), where QUERY is the query to start when the button for the corresponding entry is activated. COUNT should be the number of messages matching the query. -Such a list can be computed with `notmuch-hello-query-entries'." - (let* ((widest (notmuch-hello-longest-label entries)) +Such a list can be computed with `notmuch-hello-query-counts'." + (let* ((widest (notmuch-hello-longest-label
Re: [PATCH 0/2] emacs: User-defined sections in notmuch-hello
On Tue, 05 Jul 2011 02:00:33 +0200, Michal Sojka sojk...@fel.cvut.cz wrote: First, the customization interface for the custom sections (not the predefined ones) is very confusing. I was not able to use it at all. Instead I hacked the source code (see below) to add my section to the notmuch-hello-sections list. What specifically did you find confusing? The first customization-option is intended for sections like the all tags section which various configuration options which should be explained by the docstrings next to the options. The second item allows saved-searches-like sections. By the way: Instead of editing the source directly, you can also put all customizations like that in your configuration files and set notmuch-hello-sections from there. Nevertheless your inbox-display functions look useful in general so they should indeed be included. Second, when I tried to understand your patch, I found some names of functions and variables quite confusing. In the patch below, I tried to give them a better names and I also updated the documentation. Feel free to use my changes for your later patch submission. Thanks, those look quite a bit clearer, naming things like that is really not my strong suit. I'll include them in the next version of the patch. And last but not least, you allow quite wild modifications of tag searches (e.g. in notmuch-hello-generate-tag-alist), but is might be also useful to use such modifications for other searches. For example, I want to modify the saved searches in a similar way. Are you referring to things like specifying a filter for each tag or count in saved-searches? My thinking was that since you specify each item manually anyway, you can append any filter you might want to use there. But I guess you're right that it's a bit more convenient to be able to specify those once and not having to repeat it for each item. And here are my changes to your patch, which you might use as a suggestions for a next version of your patch. As I wrote above, it renames some functions and variables to more understandable names, updates documentation and adds a custom section for my personal use (I can live with this custom section in my .emacs if others do not like it). If we add the same configuration options that notmuch-hello-generate-tag-alist accepts, this section should be easy to specify in your ~/.emacs with one or two lines anyway. Cheers, Daniel pgpYz0VlBurE2.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 2/2] emacs: skip forward to visible text in notmuch-show-message-extent
On Sun, 3 Jul 2011 08:28:06 +0400, Dmitry Kurochkin dmitry.kuroch...@gmail.com wrote: The patch rewrites `notmuch-show-message-extent' to be more robust. The main goal is to make it work as expected if point is invisible. Besides, there are no more point movements and property search functions are used instead manual loops. The comment regarding properties strangeness is removed since there is no strangeness here: property ranges (as well as overlay, and many others, I believe) are given as [begin, end), not [begin, end]. Please do not apply this patch. I am considering a different solution: instead of making the trailing newline invisible, make the preceding newline invisible. This way a message would always have a visible newline at the end and it would prevent `beginning-of-visual-line' going beyond the beginning of message. FYI there is a discussion on emacs-devel [1] regarding point adjustment inside invisible regions. Regards, Dmitry [1] http://thread.gmane.org/gmane.emacs.devel/141479 --- emacs/notmuch-show.el | 19 +++ 1 files changed, 11 insertions(+), 8 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index f96743b..cf8b405 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -933,15 +933,18 @@ All currently available key bindings: ;; Movement related functions. -;; There's some strangeness here where a text property applied to a -;; region a-b is not found when point is at b. We walk backwards -;; until finding the property. (defun notmuch-show-message-extent () - (let (r) -(save-excursion - (while (not (setq r (get-text-property (point) :notmuch-message-extent))) - (backward-char))) -r)) + (let ((p (point))) +;; if point is invisible, skip forward to visible text +(while (invisible-p p) + (setq p (next-single-char-property-change p 'invisible))) +;; if no visible text found, use the point +(or p (setq p (point))) +(or (get-text-property p :notmuch-message-extent) + ;; if there is no text property, skip to the previous message + (and (setq p (previous-single-char-property-change + p :notmuch-message-extent)) + (get-text-property p :notmuch-message-extent) (defun notmuch-show-message-top () (car (notmuch-show-message-extent))) -- 1.7.5.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 0/2] emacs: User-defined sections in notmuch-hello
On Tue, 05 Jul 2011, Daniel Schoepe wrote: Non-text part: multipart/signed On Tue, 05 Jul 2011 02:00:33 +0200, Michal Sojka sojk...@fel.cvut.cz wrote: First, the customization interface for the custom sections (not the predefined ones) is very confusing. I was not able to use it at all. Instead I hacked the source code (see below) to add my section to the notmuch-hello-sections list. What specifically did you find confusing? Sorry for not being clear - I wrote the mail late at night, looking forward to some sleep :) The first customization-option is intended for sections like the all tags section which various configuration options which should be explained by the docstrings next to the options. The second item allows saved-searches-like sections. I'm talking about notmuch-hello-section. It seems it is not possible easily specify there your own function. You can either select a predefined section or Customized section, which is in fact Customized all-tags section. So I propose to renaming this entry like this and adding another one called Custom function, where you could enter the name of your function. By the way: Instead of editing the source directly, you can also put all customizations like that in your configuration files and set notmuch-hello-sections from there. Nevertheless your inbox-display functions look useful in general so they should indeed be included. I know that, but I wanted to do the experiment quickly and this was the easiest way for me. Regarding setting of notmuch-hello-sections from .emacs, I prefer customizing it through the customization interface because when somebody else introduces a new section it is more convenient for me to try it by choosing from predefined values than modifying that in .emacs. And last but not least, you allow quite wild modifications of tag searches (e.g. in notmuch-hello-generate-tag-alist), but is might be also useful to use such modifications for other searches. For example, I want to modify the saved searches in a similar way. Are you referring to things like specifying a filter for each tag or count in saved-searches? My thinking was that since you specify each item manually anyway, you can append any filter you might want to use there. But I guess you're right that it's a bit more convenient to be able to specify those once and not having to repeat it for each item. It seems that I still do not understand what the Customized section was intended to provide. I have to say I'm not able to fully decode the definition of notmuch-hello-customized-section, but it seems to me that it is a way how to customize a call to notmuch-hello-insert-all-tags. I wanted to say that it might be useful to have the similar options for saved searches. For example, what I do in my notmuch-hello-insert-inbox is to take the saved searches and filter them by tag:inbox. I guess that if there is a possibility to do that without coding in elisp, some people may find it useful. What do you think? -Michal ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v3 0/2] emacs: User-defined sections in notmuch-hello
This version incorporates the changes suggested by Michal Sojka; thanks for your help with this, Michal. ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v3 2/2] emacs: Tests for user-defined sections
--- test/emacs | 37 test/emacs.expected-output/notmuch-hello |3 +- .../notmuch-hello-new-section |4 ++ .../notmuch-hello-no-saved-searches|3 +- .../notmuch-hello-section-before | 18 + .../notmuch-hello-section-counts |5 +++ .../notmuch-hello-section-hidden-tag |4 ++ .../notmuch-hello-section-with-empty |4 ++ .../emacs.expected-output/notmuch-hello-with-empty |3 +- 9 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 test/emacs.expected-output/notmuch-hello-new-section create mode 100644 test/emacs.expected-output/notmuch-hello-section-before create mode 100644 test/emacs.expected-output/notmuch-hello-section-counts create mode 100644 test/emacs.expected-output/notmuch-hello-section-hidden-tag create mode 100644 test/emacs.expected-output/notmuch-hello-section-with-empty diff --git a/test/emacs b/test/emacs index 53f455a..40e2563 100755 --- a/test/emacs +++ b/test/emacs @@ -34,6 +34,43 @@ test_emacs '(let ((notmuch-saved-searches (test-output))' test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-no-saved-searches +test_begin_subtest User defined section with inbox tag +test_emacs (let ((notmuch-hello-sections + (list (lambda () (notmuch-hello-insert-searches + \Test: \ '((\inbox\ . \tag:inbox\))) + (notmuch-hello) + (test-output)) +test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-new-section + +test_begin_subtest User defined section with empty, hidden entry +test_emacs (let ((notmuch-hello-sections + (list (lambda () (notmuch-hello-insert-searches + \Test-with-empty:\ + '((\inbox\ . \tag:inbox\) + (\doesnotexist\ . \tag:doesnotexist\)) + :hide-empty-searches t) + (notmuch-hello) + (test-output)) +test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-section-with-empty + +test_begin_subtest User defined section, unread tag filtered out +test_emacs (let ((notmuch-hello-sections + (list (lambda () (notmuch-hello-insert-tags-section + \Test-with-filtered: \ + :hide-tags '(\unread\)) + (notmuch-hello) + (test-output)) +test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-section-hidden-tag + +test_begin_subtest User defined section, different query for counts +test_emacs (let ((notmuch-hello-sections + (list (lambda () (notmuch-hello-insert-tags-section + \Test-with-counts: \ + :make-count \tag:signed\) + (notmuch-hello) + (test-output)) +test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-section-counts + test_begin_subtest Basic notmuch-search view in emacs test_emacs '(notmuch-search tag:inbox) (notmuch-test-wait) diff --git a/test/emacs.expected-output/notmuch-hello b/test/emacs.expected-output/notmuch-hello index 64b7e42..9666327 100644 --- a/test/emacs.expected-output/notmuch-hello +++ b/test/emacs.expected-output/notmuch-hello @@ -6,9 +6,10 @@ Saved searches: [edit] Search: -[Show all tags] +All tags: [show] Type a search query and hit RET to view matching threads. Edit saved searches with the `edit' button. Hit RET or click on a saved search or tag name to view matching threads. `=' refreshes this screen. `s' jumps to the search box. `q' to quit. + diff --git a/test/emacs.expected-output/notmuch-hello-new-section b/test/emacs.expected-output/notmuch-hello-new-section new file mode 100644 index 000..be7b26a --- /dev/null +++ b/test/emacs.expected-output/notmuch-hello-new-section @@ -0,0 +1,4 @@ +Test: [hide] + + 50 inbox + diff --git a/test/emacs.expected-output/notmuch-hello-no-saved-searches b/test/emacs.expected-output/notmuch-hello-no-saved-searches index 7f8206a..744a8f1 100644 --- a/test/emacs.expected-output/notmuch-hello-no-saved-searches +++ b/test/emacs.expected-output/notmuch-hello-no-saved-searches @@ -2,9 +2,10 @@ Search: -[Show all tags] +All tags: [show] Type a search query and hit RET to view matching threads. Edit saved searches with the `edit' button. Hit RET or click on a saved search or tag name to view matching threads. `=' refreshes this screen. `s' jumps to the search box. `q' to quit. + diff --git a/test/emacs.expected-output/notmuch-hello-section-before
[PATCH v3 1/2] emacs: User-defined sections in notmuch-hello
This patch makes the notmuch-hello screen fully customizable by allowing the user to add and remove arbitrary sections. It also provides some convenience functions for constructing sections, e.g. showing the unread message count for each tag. This is done by specifying a list of functions that will be run when notmuch-hello is invoked. --- emacs/notmuch-hello.el | 609 +++- 1 files changed, 393 insertions(+), 216 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 65fde75..9c18caa 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -55,26 +55,6 @@ :type 'boolean :group 'notmuch) -(defcustom notmuch-hello-tag-list-make-query nil - Function or string to generate queries for the all tags list. - -This variable controls which query results are shown for each tag -in the \all tags\ list. If nil, it will use all messages with -that tag. If this is set to a string, it is used as a filter for -messages having that tag (equivalent to \tag:TAG and (THIS-VARIABLE)\). -Finally this can be a function that will be called for each tag and -should return a filter for that tag, or nil to hide the tag. - :type '(choice (const :tag All messages nil) -(const :tag Unread messages tag:unread) -(const :tag Custom filter string) -(const :tag Custom filter function function)) - :group 'notmuch) - -(defcustom notmuch-hello-hide-tags nil - List of tags to be hidden in the \all tags\-section. - :type '(repeat string) - :group 'notmuch) - (defface notmuch-hello-logo-background 'class color) (background dark)) @@ -123,6 +103,75 @@ Typically \,\ in the US and UK and \.\ in Europe. (defvar notmuch-hello-recent-searches nil) +(define-widget 'notmuch-hello-tags-section 'lazy + Customize-type for notmuch-hello tag-list sections. + :tag Customized tag-list + :type + (let ((opts +'((:title (string :tag Title for this section)) + (:make-query (string :tag Filter for each tag)) + (:make-count (string :tag Different query to generate counts)) + (:hide-tags (repeat :tag Tags that will be hidden string)) + (:initially-hidden (boolean :tag Hide this on startup?)) + (:hide-empty-tags (boolean :tag Hide tags with no matching messages)) + (:hide-if-empty (boolean :tag Hide if empty) +`(list (const :tag notmuch-hello-insert-tags-section) + (plist :inline t :options ,opts + +(define-widget 'notmuch-hello-query-section 'lazy + Customize-type for custom saved-search-like sections + :tag Customized queries section + :type + '(list (const :tag notmuch-hello-insert-query-list) +(string :tag Title for this section) +(repeat :tag Queries +(cons (string :tag Name) (string :tag Query))) +(plist :inline t + :options + ((:initially-hidden (boolean :tag Hide this on startup?)) +(:hide-empty-tags + (boolean :tag Hide tags with no matching messages)) +(:hide-if-empty (boolean :tag Hide if empty)) + +(defcustom notmuch-hello-sections + (list #'notmuch-hello-insert-header + #'notmuch-hello-insert-saved-searches + #'notmuch-hello-insert-search + #'notmuch-hello-insert-recent-searches + #'notmuch-hello-insert-alltags + #'notmuch-hello-insert-footer) + Sections for notmuch-hello. + +Each entry of this list should be a function of no arguments that +should return if notmuch-hello-target is produced as part of its +output and nil otherwise. For convenience an element can also be +a list of the form (FUNC ARG1 ARG2 .. ARGN) in which case FUNC +will be applied to the rest of the list. + +The functions will be run to construct the content of the +notmuch-hello buffer in the order they appear in this list. + :group 'notmuch + :type + '(repeat +(choice (function-item notmuch-hello-insert-header) + (function-item notmuch-hello-insert-saved-searches) + (function-item notmuch-hello-insert-search) + (function-item notmuch-hello-insert-recent-searches) + (function-item notmuch-hello-insert-alltags) + (function-item notmuch-hello-insert-footer) + (function-item notmuch-hello-insert-inbox) + notmuch-hello-tags-section + notmuch-hello-query-section + (function :tag Custom function + +;; only defined to avoid compilation warnings about free variables +(defvar notmuch-hello-target nil) + +(defvar notmuch-hello-hidden-sections nil + List of query sections whose contents are hidden) + +(defvar notmuch-hello-first-run t) + (defun notmuch-hello-remember-search (search) (if (not (member search notmuch-hello-recent-searches)) (push search notmuch-hello-recent-searches)) @@ -173,8 +222,8 @@ Typically \,\ in the US and UK and \.\ in Europe. (message Saved '%s' as
Re: [PATCH 0/2] emacs: User-defined sections in notmuch-hello
On Tue, 05 Jul 2011 16:09:14 +0200, Michal Sojka sojk...@fel.cvut.cz wrote: I wanted to say that it might be useful to have the similar options for saved searches. For example, what I do in my notmuch-hello-insert-inbox is to take the saved searches and filter them by tag:inbox. I guess that if there is a possibility to do that without coding in elisp, some people may find it useful. What do you think? I sent a new version of the patch that incorporates your suggestions with one exception: I removed notmuch-hello-insert-inbox from the default value for notmuch-hello-sections, since personally I find it a bit confusing to have all tags with inbox-tagged messages mixed with the saved searches in one place. pgpialJiBAPxg.pgp Description: PGP signature ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] emacs: Turn id:message-id elements into buttons for notmuch searches
This fixes the minor annoyance that message ids were parsed as mail addresses by goto-address-mode in notmuch-show buffers. --- emacs/notmuch-show.el | 23 --- 1 files changed, 20 insertions(+), 3 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index f96743b..0f7fcfe 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -778,6 +778,24 @@ current buffer, if possible. (defvar notmuch-show-parent-buffer nil) (make-variable-buffer-local 'notmuch-show-parent-buffer) +(defun notmuch-show-buttonise-links (start end) + Buttonise URLs and mail addresses between START and END. + +This also turns id:\message id\-parts into buttons for +a corresponding notmuch search. + (goto-address-fontify-region start end) + (save-excursion +(goto-char start) +(while (re-search-forward id:\[^ ]+\ end t) + ;; remove the overlay created by goto-address-mode + (remove-overlays (match-beginning 0) (match-end 0) 'goto-address t) + (make-text-button (match-beginning 0) (match-end 0) + 'action `(lambda (arg) + (notmuch-search ,(match-string-no-properties 0))) + 'follow-link t + 'help-echo Mouse-1, RET: search for this message + 'face goto-address-mail-face + ;;;###autoload (defun notmuch-show (thread-id optional parent-buffer query-context buffer-name crypto-switch) Run \notmuch show\ with the given thread ID and display results. @@ -822,9 +840,8 @@ function is used. (notmuch-show-insert-forest (notmuch-query-get-threads basic-args - ;; Enable buttonisation of URLs and email addresses in the - ;; buffer. - (goto-address-mode t) + (jit-lock-register #'notmuch-show-buttonise-links) + ;; Act on visual lines rather than logical lines. (visual-line-mode t) -- 1.7.5.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: Dangerous space bar key (was: Preventing the user shooting themself in the foot)
On Mon, 04 Jul 2011 17:03:51 -0700, Jameson Graef Rollins jroll...@finestructure.net wrote: Non-text part: multipart/signed On Mon, 04 Jul 2011 23:36:35 +0200, Matthieu Lemerre ra...@free.fr wrote: I like to use the space (and sometimes the backspace key) to read threads back and forth, but sometimes I might read stuff to quickly and archive a thread without wanting it. It is then complex to find it back (especially if the thread contained a single message and I hit space before actually reading the message, so I can't find it again). As a workaround, I have changed the space key function notmuch-show-advance-and-archive to not archive the thread if we are at the end of the thread, but to just do nothing. Thus I have to expicitely archive the thread when I have finished reading it, which I find much safer. I completely agree with your discomfort with the current function bound to space. I don't like it at all, and I similarly rebound space to be a much more sensible function: [...] Notice I also made it so that this does not exit the current thread view. I patched notmuch to use exactly the same function... Given that we are two people who independently requested for this behaviour, I think this should at least be a customisable option, and imo the default should do nothing and not archive the thread because of this dangerous behaviour. And, hitting 'a' instead of space to go to the next thread is the same number of keypresses... Matthieu ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch