* [PATCH v2] emacs: display tags in notmuch-show with links
@ 2012-11-10 16:41 Damien Cassou
2012-11-14 2:03 ` Ethan Glasser-Camp
2012-11-14 12:41 ` Mark Walters
0 siblings, 2 replies; 11+ messages in thread
From: Damien Cassou @ 2012-11-10 16:41 UTC (permalink / raw)
To: notmuch mailing list
This patch obsoletes
id:1352234344-28119-1-git-send-email-damien.cassou@gmail.com
This patch makes clickable all tags that appear in notmuch-show
buffers. Each tag is a link to open a new notmuch-search buffer for
this tag. Additionally, the buffer's header-line now shows the
thread's tags (also clickable).
This patch is the first one of an upcoming series whose goal is to
integrate notmuch-labeler into notmuch. See the following for more
details:
https://github.com/DamienCassou/notmuch-labeler
This patch includes header-button.el, a package contributed by Jonas
Bernoulli that fixes a limitation of the button.el Emacs library.
Jonas gave me the authorization to include the package in notmuch, but
only if the package is first searched in the existing `load-path'. See
this thread:
id:CA+y5ggiGrAcicQLeskaXFoxYyJQVVXZ1VRX=XS8zPFR9_mBFxA@mail.gmail.com
With respect to v1, I took care of the comments you made:
- Renamed tager to tagger;
- Avoided an additional call to notmuch by reading existing data in
the buffer with `notmuch-show-mapc';
- As a result of previous point, a thread's tags now equals the union
of the emails' tags that are visible;
- Stopped stripping "thread:" from the thread-id to add it back
later.
With respect to v1, I added the following:
- Each label on each message is now clickable;
- Moved header-button.el to fallback-libs/ and only load this one when
it is not already in the `load-path'.
You can follow this patch series on
https://github.com/DamienCassou/notmuch/tree/labeler-integration
Signed-off-by: Damien Cassou <damien.cassou@gmail.com>
---
emacs/fallback-libs/.nosearch | 1 +
| 138 ++++++++++++++++++++++++++++++++++
emacs/notmuch-show.el | 33 ++++++--
emacs/notmuch-tagger.el | 129 +++++++++++++++++++++++++++++++
test/emacs | 61 +++++++++++++++
5 files changed, 355 insertions(+), 7 deletions(-)
create mode 100644 emacs/fallback-libs/.nosearch
create mode 100644 emacs/fallback-libs/header-button.el
create mode 100644 emacs/notmuch-tagger.el
diff --git a/emacs/fallback-libs/.nosearch b/emacs/fallback-libs/.nosearch
new file mode 100644
index 0000000..0a01dc9
--- /dev/null
+++ b/emacs/fallback-libs/.nosearch
@@ -0,0 +1 @@
+This file prevents Emacs from adding the directory to the `load-path'.
--git a/emacs/fallback-libs/header-button.el b/emacs/fallback-libs/header-button.el
new file mode 100644
index 0000000..05f6f32
--- /dev/null
+++ b/emacs/fallback-libs/header-button.el
@@ -0,0 +1,138 @@
+;;; header-button.el --- clickable buttons in header lines
+
+;; Copyright (C) 2010-2012 Jonas Bernoulli
+
+;; Author: Jonas Bernoulli <jonas@bernoul.li>
+;; Created: 20100604
+;; Version: 0.2.2
+;; Homepage: https://github.com/tarsius/header-button
+;; Keywords: extensions
+
+;; This file is not part of GNU Emacs.
+
+;; This file is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This package extends `button' by adding support for adding buttons to
+;; the header line. Since the header line is very limited compared to a
+;; buffer most of the functionality provided by `button' is not available
+;; for buttons in the header line.
+
+;; While `button' provides the function `insert-button' (as well as
+;; others) to insert a button into a buffer at point, something similar
+;; can't be done here, due to the lack of point in header lines.
+
+;; Instead use `header-button-format' like this:
+;;
+;; (setq header-line-format
+;; (concat "Here's a button: "
+;; (header-button-format "Click me!" :action 'my-action)))
+
+;; Like with `button' you can create your own derived button types:
+;;
+;; (define-button-type 'my-header
+;; :supertype 'header
+;; :action 'my-action)
+;;
+;; (setq header-line-format
+;; (concat (header-button-format "Click me!" :action 'my-action) " "
+;; (header-button-format "No me!" :type 'my-header)))
+
+;; The function associated with `:action' is called with the button plist
+;; as only argument. Do no use `plist-get' to extract a value from it.
+;; Instead use `header-button-get' which will also extract values stored
+;; in it's type.
+;;
+;; (defun my-action (button)
+;; (message "This button labeled `%s' belongs to category `%s'"
+;; (header-button-label button)
+;; (header-button-get button 'category)))
+
+;;; Code:
+
+(require 'button)
+
+(defvar header-button-map
+ (let ((map (make-sparse-keymap)))
+ ;; $$$ follow-link does not work here
+ (define-key map [header-line mouse-1] 'header-button-push)
+ (define-key map [header-line mouse-2] 'header-button-push)
+ map)
+ "Keymap used by buttons in header lines.")
+
+(define-button-type 'header
+ 'keymap header-button-map
+ 'help-echo (purecopy "mouse-1: Push this button"))
+
+(defun header-button-get (button prop)
+ "Get the property of header button BUTTON named PROP."
+ (let ((entry (plist-member button prop)))
+ (if entry
+ (cadr entry)
+ (get (plist-get button 'category) prop))))
+
+(defun header-button-label (button)
+ "Return header button BUTTON's text label."
+ (plist-get button 'label))
+
+(defun header-button-format (label &rest properties)
+ "Format a header button string with the label LABEL.
+The remaining arguments form a sequence of PROPERTY VALUE pairs,
+specifying properties to add to the button.
+In addition, the keyword argument :type may be used to specify a
+button-type from which to inherit other properties; see
+`define-button-type'.
+
+To actually create the header button set the value of variable
+`header-line-format' to the string returned by this function
+\(or a string created by concatenating that string with others."
+ (let ((type-entry (or (plist-member properties 'type)
+ (plist-member properties :type))))
+ (when (plist-get properties 'category)
+ (error "Button `category' property may not be set directly"))
+ (if (null type-entry)
+ (setq properties
+ (cons 'category
+ (cons (button-category-symbol 'header) properties)))
+ (setcar type-entry 'category)
+ (setcar (cdr type-entry)
+ (button-category-symbol (car (cdr type-entry)))))
+ (apply #'propertize label
+ (nconc (list 'button (list t) 'label label) properties))))
+
+(defun header-button-activate (button)
+ "Call header button BUTTON's `:action' property."
+ ;; Older versions only supported `:action' but button.el uses
+ ;; `action' instead. Now we support both and query `:action'
+ ;; first because `action' defaults to function `ignore'.
+ (funcall (or (header-button-get button :action)
+ (header-button-get button 'action))
+ button))
+
+(defun header-button-push ()
+ "Perform the action specified by the pressed header button."
+ (interactive)
+ (let* ((posn (event-start last-command-event))
+ (object (posn-object posn))
+ (buffer (window-buffer (posn-window posn)))
+ (button (text-properties-at (cdr object) (car object))))
+ (with-current-buffer buffer
+ (header-button-activate button))))
+
+(provide 'header-button)
+;; Local Variables:
+;; indent-tabs-mode: nil
+;; End:
+;;; header-button.el ends here
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index d061367..6f38381 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -36,6 +36,7 @@
(require 'notmuch-mua)
(require 'notmuch-crypto)
(require 'notmuch-print)
+(require 'notmuch-tagger)
(declare-function notmuch-call-notmuch-process "notmuch" (&rest args))
(declare-function notmuch-fontify-headers "notmuch" nil)
@@ -430,10 +431,11 @@ message at DEPTH in the current thread."
(notmuch-show-clean-address (plist-get headers :From))
" ("
date
- ") ("
- (propertize (mapconcat 'identity tags " ")
- 'face 'notmuch-tag-face)
- ")\n")
+ ") "
+ (propertize
+ (format-mode-line (notmuch-tagger-present-tags tags))
+ 'face 'notmuch-tag-face)
+ "\n")
(overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face)))
(defun notmuch-show-insert-header (header header-value)
@@ -1082,11 +1084,28 @@ function is used."
(jit-lock-register #'notmuch-show-buttonise-links)
- ;; Set the header line to the subject of the first message.
- (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-subject)))
-
+ (notmuch-show-update-header-line)
(run-hooks 'notmuch-show-hook))))
+(defun notmuch-show-thread-tags ()
+ "Return the list of tags for the current thread."
+ (let ((tags (list)))
+ (notmuch-show-mapc (lambda ()
+ (mapcar (lambda (elt)
+ ;; Avoid adding duplicate tags
+ (add-to-list 'tags elt))
+ (notmuch-show-get-tags))))
+ tags))
+
+(defun notmuch-show-update-header-line ()
+ "Make the header-line show the thread's subject and tags."
+ (let ((thread-subject (notmuch-show-strip-re (notmuch-show-get-subject))))
+ (setq header-line-format
+ (list
+ thread-subject
+ " "
+ (notmuch-tagger-present-tags (notmuch-show-thread-tags) t)))))
+
(defun notmuch-show-capture-state ()
"Capture the state of the current buffer.
diff --git a/emacs/notmuch-tagger.el b/emacs/notmuch-tagger.el
new file mode 100644
index 0000000..e825df5
--- /dev/null
+++ b/emacs/notmuch-tagger.el
@@ -0,0 +1,129 @@
+;; notmuch-tagger.el --- Library to show labels as links
+;;
+;; Copyright © Damien Cassou
+;;
+;; This file is part of Notmuch.
+;;
+;; Notmuch is free software: you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; Notmuch is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with Notmuch. If not, see <http://www.gnu.org/licenses/>.
+;;
+;; Authors: Damien Cassou <damien.cassou@gmail.com>
+;;; Commentary:
+;;
+;;; Code:
+;;
+
+(require 'button)
+
+(or (require 'header-button nil t)
+ (let ((load-path
+ (cons (expand-file-name
+ "fallback-libs"
+ (file-name-directory (or load-file-name buffer-file-name)))
+ load-path)))
+ (require 'header-button)))
+
+(defun notmuch-tagger-separate-elems (list sep)
+ "Return a list with all elements of LIST separated by SEP."
+ (let ((first t)
+ (res nil))
+ (dolist (elt (reverse list) res)
+ (unless first
+ (push sep res))
+ (setq first nil)
+ (push elt res))))
+
+(defun notmuch-tagger-goto-target (target)
+ "Show a `notmuch-search' buffer for the TARGET tag."
+ (notmuch-search (concat "tag:" target)))
+
+(defun notmuch-tagger-headerline-button-action (button)
+ "Open `notmuch-search' for the tag referenced by BUTTON."
+ (let ((tag (header-button-get button 'notmuch-tagger-tag)))
+ (notmuch-tagger-goto-target tag)))
+
+(defun notmuch-tagger-body-button-action (button)
+ "Open `notmuch-search' for the tag referenced by BUTTON."
+ (let ((tag (button-get button 'notmuch-tagger-tag)))
+ (notmuch-tagger-goto-target tag)))
+
+(define-button-type 'notmuch-tagger-headerline-button-type
+ 'supertype 'header
+ 'action #'notmuch-tagger-headerline-button-action
+ 'follow-link t)
+
+(define-button-type 'notmuch-tagger-body-button-type
+ 'action #'notmuch-tagger-body-button-action
+ 'follow-link t)
+
+(defun notmuch-tagger-make-headerline-link (target)
+ "Return a property list that presents a link to TARGET.
+
+TARGET is a notmuch tag.
+The returned property list will only work in the header-line."
+ (header-button-format
+ target
+ :type 'notmuch-tagger-headerline-button-type
+ 'notmuch-tagger-tag target
+ 'help-echo (format "%s: Search other messages like this" target)))
+
+(defun notmuch-tagger-make-body-link (target)
+ "Return a property list that presents a link to TARGET.
+
+TARGET is a notmuch tag.
+The returned property list will work everywhere except in the
+header-line."
+ (let ((button (copy-sequence target)))
+ (make-text-button
+ button nil
+ 'type 'notmuch-tagger-body-button-type
+ 'notmuch-tagger-tag target
+ 'help-echo (format "%s: Search other messages like this" target))
+ button))
+
+(defun notmuch-tagger-make-link (target headerline)
+"Return a property list that presents a link to TARGET.
+
+TARGET is a notmuch tag.
+
+If HEADERLINE is non-nil the returned list will be ready for
+inclusion in the buffer's header-line. HEADERLINE must be nil in
+all other cases."
+ (if headerline
+ (notmuch-tagger-make-headerline-link target)
+ (notmuch-tagger-make-body-link target)))
+
+(defun notmuch-tagger-format-tags (tags &optional headerline)
+ "Return a format list for TAGS suitable for use in header line.
+See Info node `(elisp)Mode Line Format' for more information.
+
+If HEADERLINE is non-nil the returned list will be ready for
+inclusion in the buffer's header-line. HEADERLINE must be nil in
+all other cases."
+ (mapcar
+ (lambda (tag) (notmuch-tagger-make-link tag headerline))
+ tags))
+
+(defun notmuch-tagger-present-tags (tags &optional headerline)
+ "Return a property list which nicely presents all TAGS.
+
+If HEADERLINE is non-nil the returned list will be ready for
+inclusion in the buffer's header-line. HEADERLINE must be nil in
+all other cases."
+ (list
+ "("
+ (notmuch-tagger-separate-elems (notmuch-tagger-format-tags tags headerline) " ")
+ ")"))
+
+(provide 'notmuch-tagger)
+;;; notmuch-tagger.el ends here
diff --git a/test/emacs b/test/emacs
index 44f641e..ecdc841 100755
--- a/test/emacs
+++ b/test/emacs
@@ -820,5 +820,66 @@ Date: Fri, 05 Jan 2001 15:43:57 +0000
EOF
test_expect_equal_file OUTPUT EXPECTED
+test_begin_subtest "Extracting all tags from a thread"
+add_message \
+ '[subject]="Extracting all tags from a thread"' \
+ '[body]="body 1"'
+parent=${gen_msg_id}
+add_message \
+ '[subject]="Extracting all tags from a thread"' \
+ '[body]="body 2"' \
+ "[in-reply-to]=\<$parent\>"
+add_message \
+ '[subject]="Extracting all tags from a thread"' \
+ '[body]="body 3"' \
+ "[in-reply-to]=\<$parent\>"
+latest=${gen_msg_id}
+# Extract the thread-id from one of the emails
+thread_id=$(notmuch search id:${latest} | sed -e "s/thread:\([a-f0-9]*\).*/\1/")
+# Add tag "mytagfoo" to one of the emails
+notmuch tag +mytagfoo id:${latest}
+test_emacs_expect_t \
+ "(notmuch-show \"thread:${thread_id}\")
+ (let ((output (notmuch-show-thread-tags))
+ (expected '(\"inbox\" \"mytagfoo\" \"unread\")))
+ (notmuch-test-expect-equal
+ (sort output #'string<)
+ (sort expected #'string<)))"
+
+test_begin_subtest "The tags appear in the header-line of notmuch-show"
+add_message \
+ '[subject]="foo bar"' \
+ '[body]="body 1"'
+parent=${gen_msg_id}
+# Add tag "mytagfoo" to one of the emails
+notmuch tag +mytagfoo id:${parent}
+# Extract the thread-id from one of the emails
+thread_id=$(notmuch search id:${latest} | sed -e "s/thread:\([a-f0-9]*\).*/\1/")
+test_emacs_expect_t \
+ "(notmuch-show \"thread:${thread_id}\")
+ (if (string-match-p \"mytagfoo\" (format-mode-line header-line-format))
+ t
+ \"The tag mytagfoo was not in the header-line-format\")"
+
+test_begin_subtest "The tags of notmuch-show emails are clickable"
+add_message \
+ '[subject]="foo bar"' \
+ '[body]="body 1"'
+parent=${gen_msg_id}
+# Add tag "mytagfoo" to one of the emails
+notmuch tag +mytagfoo id:${parent}
+# Extract the thread-id from one of the emails
+thread_id=$(notmuch search id:${latest} | sed -e "s/thread:\([a-f0-9]*\).*/\1/")
+test_emacs_expect_t \
+ "(notmuch-show \"thread:${thread_id}\")
+ (goto-char (point-min))
+ (re-search-forward \"mytagfoo\")
+ (backward-char) ;; to be 'in' the tag
+ (unless (eq major-mode 'notmuch-show-mode)
+ (error \"We must be in notmch-show at this point but we are in %s.\" major-mode))
+ (push-button) ;; simulate a press on the RET key
+ (if (eq major-mode 'notmuch-search-mode)
+ t
+ (format \"We must be in notmch-search at this point but we are in %s.\" major-mode))"
test_done
--
1.7.10.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2] emacs: display tags in notmuch-show with links
2012-11-10 16:41 [PATCH v2] emacs: display tags in notmuch-show with links Damien Cassou
@ 2012-11-14 2:03 ` Ethan Glasser-Camp
2012-11-15 15:09 ` Damien Cassou
2012-11-14 12:41 ` Mark Walters
1 sibling, 1 reply; 11+ messages in thread
From: Ethan Glasser-Camp @ 2012-11-14 2:03 UTC (permalink / raw)
To: Damien Cassou, notmuch mailing list
Damien Cassou <damien.cassou@gmail.com> writes:
> +(defun notmuch-tagger-present-tags (tags &optional headerline)
> + "Return a property list which nicely presents all TAGS.
> +
> +If HEADERLINE is non-nil the returned list will be ready for
> +inclusion in the buffer's header-line. HEADERLINE must be nil in
> +all other cases."
> + (list
> + "("
> + (notmuch-tagger-separate-elems (notmuch-tagger-format-tags tags headerline) " ")
> + ")"))
It is kind of appalling that it takes 128 lines just to do this. It
seems like there has to be an easier way, or several easier
ways. Unfortunately, I don't see any.
> diff --git a/test/emacs b/test/emacs
> index 44f641e..ecdc841 100755
> --- a/test/emacs
> +++ b/test/emacs
> @@ -820,5 +820,66 @@ Date: Fri, 05 Jan 2001 15:43:57 +0000
> EOF
> test_expect_equal_file OUTPUT EXPECTED
>
> +test_begin_subtest "Extracting all tags from a thread"
> +add_message \
> + '[subject]="Extracting all tags from a thread"' \
> + '[body]="body 1"'
> +parent=${gen_msg_id}
> +add_message \
> + '[subject]="Extracting all tags from a thread"' \
> + '[body]="body 2"' \
> + "[in-reply-to]=\<$parent\>"
> +add_message \
> + '[subject]="Extracting all tags from a thread"' \
> + '[body]="body 3"' \
> + "[in-reply-to]=\<$parent\>"
> +latest=${gen_msg_id}
> +# Extract the thread-id from one of the emails
> +thread_id=$(notmuch search id:${latest} | sed -e "s/thread:\([a-f0-9]*\).*/\1/")
I think the accepted idiom is to use "notmuch search
--output=threads". This will output just a string like
"thread:00000000000000b9", so if you really need just the ID, you could
still use sed here...
> +# Add tag "mytagfoo" to one of the emails
> +notmuch tag +mytagfoo id:${latest}
> +test_emacs_expect_t \
> + "(notmuch-show \"thread:${thread_id}\")
... but it seems like "thread:..." is good enough for you.
> + (error \"We must be in notmch-show at this point but we are in %s.\" major-mode))
> + (push-button) ;; simulate a press on the RET key
> + (if (eq major-mode 'notmuch-search-mode)
> + t
> + (format \"We must be in notmch-search at this point but we are in %s.\" major-mode))"
s/notmch/notmuch/ here.
Otherwise I think the code looks fine. I think the design concerns
raised by Mark Walters are probably valid, though.
Ethan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] emacs: display tags in notmuch-show with links
2012-11-14 2:03 ` Ethan Glasser-Camp
@ 2012-11-15 15:09 ` Damien Cassou
0 siblings, 0 replies; 11+ messages in thread
From: Damien Cassou @ 2012-11-15 15:09 UTC (permalink / raw)
To: Ethan Glasser-Camp; +Cc: notmuch mailing list
On Wed, Nov 14, 2012 at 3:03 AM, Ethan Glasser-Camp
<ethan.glasser.camp@gmail.com> wrote:
> I think the accepted idiom is to use "notmuch search
> --output=threads". This will output just a string like
> "thread:00000000000000b9",
>> + (error \"We must be in notmch-show at this point but we are in %s.\" major-mode))
>> + (push-button) ;; simulate a press on the RET key
>> + (if (eq major-mode 'notmuch-search-mode)
>> + t
>> + (format \"We must be in notmch-search at this point but we are in %s.\" major-mode))"
>
> s/notmch/notmuch/ here.
thank you very much for your two fixes. I applied them.
--
Damien Cassou
http://damiencassou.seasidehosting.st
"Success is the ability to go from one failure to another without
losing enthusiasm."
Winston Churchill
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] emacs: display tags in notmuch-show with links
2012-11-10 16:41 [PATCH v2] emacs: display tags in notmuch-show with links Damien Cassou
2012-11-14 2:03 ` Ethan Glasser-Camp
@ 2012-11-14 12:41 ` Mark Walters
2012-11-15 15:42 ` Damien Cassou
1 sibling, 1 reply; 11+ messages in thread
From: Mark Walters @ 2012-11-14 12:41 UTC (permalink / raw)
To: Damien Cassou, notmuch mailing list
Hi
I have read this patch and am broadly happy with it. In particular I do
not think I have any "design concerns" with this version: I think
picking the tags from the visible messages is fine and this version
avoids the query and the thread-id stuff.
On the loading library issues I defer to Adam and Tomi.
I do have a couple of comments on the current version
though. First the patch is very big. I would prefer it split into
several pieces something like:
1) Add tags to the headerline but not clickable
2) Add the header-button library if appropriate
3) Add notmuch-tagger and change headerline to buttonize the tags
4) Add the tests.
The first would be small and uncontroversial I think, for the second it
would not really be code review just "do we want to do it this way" as
is being discussed in the other thread. The third obviously has the meat
of the series and 4 is relatively innocuous.
Possibly you could also split the add clickable buttons to tags in the
buffer and add clickable buttons to headerline tags as two separate
steps.
One advantage of the split is that it would be easy to see who had
reviewed which bits. For example I have not read the
header-button-library bit or the tests but have looked at the rest.
My other comment is on your comments in notmuch-tagger
> +(defun notmuch-tagger-present-tags (tags &optional headerline)
> + "Return a property list which nicely presents all TAGS.
> +
> +If HEADERLINE is non-nil the returned list will be ready for
> +inclusion in the buffer's header-line. HEADERLINE must be nil in
> +all other cases."
I find it odd to say what it returns if HEADERLINE is non-nil and then
say otherwise HEADERLINE must be nil. Could you say what it returns in
the nil case? Something along them lines of
"if HEADERLINE is non-nil the returned will be ready for inclusion in
the buffer's header-line (i.e., will use header-buttons if
available). Otherwise it returns a list?? ready for inclusion in a
buffer."
Best wishes
Mark
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] emacs: display tags in notmuch-show with links
2012-11-14 12:41 ` Mark Walters
@ 2012-11-15 15:42 ` Damien Cassou
0 siblings, 0 replies; 11+ messages in thread
From: Damien Cassou @ 2012-11-15 15:42 UTC (permalink / raw)
To: Mark Walters; +Cc: notmuch mailing list
On Wed, Nov 14, 2012 at 1:41 PM, Mark Walters <markwalters1009@gmail.com> wrote:
> On the loading library issues I defer to Adam and Tomi.
I think they are right and I will try to make my code do something
good by default and do something better if header-button is detected.
> I do have a couple of comments on the current version
> though. First the patch is very big. I would prefer it split into
> several pieces
do you want me to send totally separate emails or do you want me to
send 1 discussion of multiple emails (with 0/4, 1/4, 2/4,...) ?
> something like:
>
> 1) Add tags to the headerline but not clickable
makes perfect sense
> 2) Add the header-button library if appropriate
I will try the other approach of not embedding the library in notmuch
> 3) Add notmuch-tagger and change headerline to buttonize the tags
makes perfect sense. The patch will buttonize the links if
header-button is present and nothing otherwise.
> 4) Add the tests.
ok
+ 5) Add buttons to tags in the body
>> +(defun notmuch-tagger-present-tags (tags &optional headerline)
>> + "Return a property list which nicely presents all TAGS.
>> +
>> +If HEADERLINE is non-nil the returned list will be ready for
>> +inclusion in the buffer's header-line. HEADERLINE must be nil in
>> +all other cases."
>
> I find it odd to say what it returns if HEADERLINE is non-nil and then
> say otherwise HEADERLINE must be nil. Could you say what it returns in
> the nil case? Something along them lines of
>
> "if HEADERLINE is non-nil the returned will be ready for inclusion in
> the buffer's header-line (i.e., will use header-buttons if
> available). Otherwise it returns a list?? ready for inclusion in a
> buffer."
thank you for the comment, I will fix it and propose new patches
--
Damien Cassou
http://damiencassou.seasidehosting.st
"Success is the ability to go from one failure to another without
losing enthusiasm."
Winston Churchill
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2] emacs: display tags in notmuch-show with links
@ 2012-11-18 19:18 Damien Cassou
2012-11-18 22:59 ` Ethan Glasser-Camp
0 siblings, 1 reply; 11+ messages in thread
From: Damien Cassou @ 2012-11-18 19:18 UTC (permalink / raw)
To: notmuch mailing list
This patch obsoletes
id:1352565719-12397-1-git-send-email-damien.cassou@gmail.com
[PATCH 1/4] emacs: Add a thread's tags to emacs header-line
[PATCH 2/4] emacs: Make tags in header-line clickable
[PATCH 3/4] emacs: Make tags that appear in `notmuch-show' clickable
[PATCH 4/4] emacs: Add unit-tests for clickable tags in notmuch-show
This patch makes clickable all tags that appear in notmuch-show
buffers. Each tag is a link to open a new notmuch-search buffer for
this tag. Additionally, the buffer's header-line now shows the
thread's tags (clickable only if the `header-button' library is loaded
or loadable).
This patch is the first one of an upcoming series whose goal is to
integrate notmuch-labeler into notmuch. See the following for more
details:
https://github.com/DamienCassou/notmuch-labeler
With respect to v2, I took care of the comments you made:
- The header-button library is not attached to the patch anymore. The
tags in the header-line are always displayed but made clickable only
if the library is loaded or loadable.
- The large patch is separated into a series of 4 smaller patches.
You can follow this patch series on
https://github.com/DamienCassou/notmuch/tree/labeler-integration-slow
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] emacs: display tags in notmuch-show with links
2012-11-18 19:18 Damien Cassou
@ 2012-11-18 22:59 ` Ethan Glasser-Camp
2012-11-19 0:10 ` Aaron Ecay
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Ethan Glasser-Camp @ 2012-11-18 22:59 UTC (permalink / raw)
To: Damien Cassou, notmuch mailing list
Damien Cassou <damien.cassou@gmail.com> writes:
> This patch obsoletes
> id:1352565719-12397-1-git-send-email-damien.cassou@gmail.com
>
> [PATCH 1/4] emacs: Add a thread's tags to emacs header-line
> [PATCH 2/4] emacs: Make tags in header-line clickable
> [PATCH 3/4] emacs: Make tags that appear in `notmuch-show' clickable
> [PATCH 4/4] emacs: Add unit-tests for clickable tags in notmuch-show
>
> This patch makes clickable all tags that appear in notmuch-show
> buffers. Each tag is a link to open a new notmuch-search buffer for
> this tag. Additionally, the buffer's header-line now shows the
> thread's tags (clickable only if the `header-button' library is loaded
> or loadable).
Looks fine to me. Let me just get the notes from my bikeshed, in case
you get asked to roll another version :)
- You might want to use #' on lambdas.
- It bothers me how similar notmuch-tagger-{body,header}-button-action
are. I thought it might be better to unify them by seeing what type
the button argument was. Here's my (untested) approach which you might
find prettier or uglier.
(notmuch-tagger-all-button-get (button attrib)
"Utility function to do button-get on different kinds of buttons."
(cond
((integer-or-marker-p button)
(button-get button attrib))
((and (featurep 'header-button)
(listp button))
(header-button-get button attrib))
(t (error "unknown type of button %s" button))
- The comment for notmuch-tagger-make-body-link reads that it will work
"everywhere except in the header-line". Does this mean mode-line, menu
bar, or what? How about just "won't work in the header-line"?
- In patch 3:
+If tags the result of this function is to be used within the
I think this should just read "If the result".
Ethan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] emacs: display tags in notmuch-show with links
2012-11-18 22:59 ` Ethan Glasser-Camp
@ 2012-11-19 0:10 ` Aaron Ecay
2012-11-20 4:23 ` Austin Clements
2012-11-22 18:11 ` Damien Cassou
2 siblings, 0 replies; 11+ messages in thread
From: Aaron Ecay @ 2012-11-19 0:10 UTC (permalink / raw)
To: Ethan Glasser-Camp, Damien Cassou, notmuch mailing list
2012ko azaroak 18an, Ethan Glasser-Camp-ek idatzi zuen:
>
> - You might want to use #' on lambdas.
This is actually unnecessary – as the info node "(elisp) Anonymous
Functions" says, the forms with and without #' are equivalent. The
current notmuch style is not to have #' on lambdas (that is, there are 0
instances of #'(lambda ...) in the code base). IMO that’s correct:
the unnecessary #' is just line-noise-ish.
--
Aaron Ecay
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] emacs: display tags in notmuch-show with links
2012-11-18 22:59 ` Ethan Glasser-Camp
2012-11-19 0:10 ` Aaron Ecay
@ 2012-11-20 4:23 ` Austin Clements
2012-11-20 4:50 ` Ethan
2012-11-22 18:11 ` Damien Cassou
2 siblings, 1 reply; 11+ messages in thread
From: Austin Clements @ 2012-11-20 4:23 UTC (permalink / raw)
To: Ethan Glasser-Camp; +Cc: notmuch mailing list
Quoth Ethan Glasser-Camp on Nov 18 at 5:59 pm:
> Damien Cassou <damien.cassou@gmail.com> writes:
>
> > This patch obsoletes
> > id:1352565719-12397-1-git-send-email-damien.cassou@gmail.com
> >
> > [PATCH 1/4] emacs: Add a thread's tags to emacs header-line
> > [PATCH 2/4] emacs: Make tags in header-line clickable
> > [PATCH 3/4] emacs: Make tags that appear in `notmuch-show' clickable
> > [PATCH 4/4] emacs: Add unit-tests for clickable tags in notmuch-show
> >
> > This patch makes clickable all tags that appear in notmuch-show
> > buffers. Each tag is a link to open a new notmuch-search buffer for
> > this tag. Additionally, the buffer's header-line now shows the
> > thread's tags (clickable only if the `header-button' library is loaded
> > or loadable).
>
> Looks fine to me. Let me just get the notes from my bikeshed, in case
> you get asked to roll another version :)
>
> - You might want to use #' on lambdas.
>
> - It bothers me how similar notmuch-tagger-{body,header}-button-action
> are. I thought it might be better to unify them by seeing what type
> the button argument was. Here's my (untested) approach which you might
> find prettier or uglier.
>
> (notmuch-tagger-all-button-get (button attrib)
> "Utility function to do button-get on different kinds of buttons."
> (cond
> ((integer-or-marker-p button)
> (button-get button attrib))
> ((and (featurep 'header-button)
> (listp button))
> (header-button-get button attrib))
> (t (error "unknown type of button %s" button))
This seems like overkill given that all of the common code in
notmuch-tagger-{body,header}-button-action is already abstracted into
a common function. Were there other places where code was duplicated
because of the difference between regular buttons and header buttons?
> - The comment for notmuch-tagger-make-body-link reads that it will work
> "everywhere except in the header-line". Does this mean mode-line, menu
> bar, or what? How about just "won't work in the header-line"?
>
> - In patch 3:
>
> +If tags the result of this function is to be used within the
>
> I think this should just read "If the result".
>
> Ethan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] emacs: display tags in notmuch-show with links
2012-11-18 22:59 ` Ethan Glasser-Camp
2012-11-19 0:10 ` Aaron Ecay
2012-11-20 4:23 ` Austin Clements
@ 2012-11-22 18:11 ` Damien Cassou
2 siblings, 0 replies; 11+ messages in thread
From: Damien Cassou @ 2012-11-22 18:11 UTC (permalink / raw)
To: Ethan Glasser-Camp; +Cc: notmuch mailing list
[-- Attachment #1: Type: text/plain, Size: 461 bytes --]
On Sun, Nov 18, 2012 at 11:59 PM, Ethan Glasser-Camp <
ethan.glasser.camp@gmail.com> wrote:
> Looks fine to me. Let me just get the notes from my bikeshed, in case
> you get asked to roll another version :)
>
thanks to all of you for taking the time to review. I will improve and get
back to you.
--
Damien Cassou
http://damiencassou.seasidehosting.st
"Success is the ability to go from one failure to another without losing
enthusiasm."
Winston Churchill
[-- Attachment #2: Type: text/html, Size: 882 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2012-11-22 18:11 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-10 16:41 [PATCH v2] emacs: display tags in notmuch-show with links Damien Cassou
2012-11-14 2:03 ` Ethan Glasser-Camp
2012-11-15 15:09 ` Damien Cassou
2012-11-14 12:41 ` Mark Walters
2012-11-15 15:42 ` Damien Cassou
-- strict thread matches above, loose matches on Subject: below --
2012-11-18 19:18 Damien Cassou
2012-11-18 22:59 ` Ethan Glasser-Camp
2012-11-19 0:10 ` Aaron Ecay
2012-11-20 4:23 ` Austin Clements
2012-11-20 4:50 ` Ethan
2012-11-22 18:11 ` Damien Cassou
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).