Re: [PATCH v4 2/3] emacs: `notmuch-show-buttonize-links' only `notmuch-show's a message if it exists

2017-03-05 Thread David Bremner
David Edmondson  writes:

> [ Trimmed to/cc list. ]
>
> On Sun, Jan 22 2012, Pieter Praet wrote:
>> * emacs/notmuch-show.el (notmuch-show-found-target-p): new predicate function
>>   that uses notmuch(1) 'count' to see if a query turns up any results.
>>
>> * emacs/notmuch-show.el (notmuch-show-if-found): new function that only shows
>>   a message/thread if present in the database and otherwise returns an error.
>>
>> * emacs/notmuch-show.el (notmuch-show-buttonize-links): some deduplication,
>>   and use new function `notmuch-show-if-found' instead of `notmuch-show'
>>   to prevent showing a blank screen for Message-Id's which aren't present
>>   in the database.
>
> Mark provided some feedback about this (relating to exclusions), but
> more generally there is a problem that `M-x notmuch-show id:doesntexist'
> will result in an error ("notmuch-show-message-top: Beginning of
> buffer"). That seems like a bug that should be fixed.

This also now seems fixed in 0.23.7-131-g85df8b39

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v4 2/3] emacs: `notmuch-show-buttonize-links' only `notmuch-show's a message if it exists

2014-05-07 Thread David Edmondson
[ Trimmed to/cc list. ]

On Sun, Jan 22 2012, Pieter Praet wrote:
 * emacs/notmuch-show.el (notmuch-show-found-target-p): new predicate function
   that uses notmuch(1) 'count' to see if a query turns up any results.

 * emacs/notmuch-show.el (notmuch-show-if-found): new function that only shows
   a message/thread if present in the database and otherwise returns an error.

 * emacs/notmuch-show.el (notmuch-show-buttonize-links): some deduplication,
   and use new function `notmuch-show-if-found' instead of `notmuch-show'
   to prevent showing a blank screen for Message-Id's which aren't present
   in the database.

Mark provided some feedback about this (relating to exclusions), but
more generally there is a problem that `M-x notmuch-show id:doesntexist'
will result in an error (notmuch-show-message-top: Beginning of
buffer). That seems like a bug that should be fixed.


signature.asc
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v4 2/3] emacs: `notmuch-show-buttonize-links' only `notmuch-show's a message if it exists

2012-01-25 Thread Pieter Praet
On Sun, 22 Jan 2012 11:10:02 +, Mark Walters  
wrote:
> 
> > * emacs/notmuch-show.el (notmuch-show-if-found): new function that only 
> > shows
> >   a message/thread if present in the database and otherwise returns an 
> > error.
> 
> I like this in principle but it interacts awkwardly with the automatic tag
> exclusion. If the id: matches a message with an excluded tag
> then notmuch-show-if-found will not let you view it, but if you typed the
> same search in a search field it would show you the message. 
> 
> Note notmuch show currently does not currently respect excluded tags (see
> id:"871uqvgrnm.fsf at qmul.ac.uk"), and this is not completely trivial to
> fix since it is not clear quite what its behaviour should be in some
> corner cases.
> 
> Perhaps we could have an option like "--include-all" to notmuch
> search/count to tell it not to apply the exclusions. On the other hand
> that might also be useful as something the user can type in a search box
> so a special search term (eg include:all) might be better.
> 

Hmm, interesting...

Sorry I haven't taken the time to have a look at your patch series yet.
(I probably wouldn't have anything useful to contribute anyway...)

I'll be taking a stab at fixing this when the exclusion-dust settles.

Thanks for pointing it out!


> Best wishes
> 
> Mark
> 
> 


Peace

-- 
Pieter


[PATCH v4 2/3] emacs: `notmuch-show-buttonize-links' only `notmuch-show's a message if it exists

2012-01-22 Thread Mark Walters

> * emacs/notmuch-show.el (notmuch-show-if-found): new function that only shows
>   a message/thread if present in the database and otherwise returns an error.

I like this in principle but it interacts awkwardly with the automatic tag
exclusion. If the id: matches a message with an excluded tag
then notmuch-show-if-found will not let you view it, but if you typed the
same search in a search field it would show you the message. 

Note notmuch show currently does not currently respect excluded tags (see
id:"871uqvgrnm.fsf at qmul.ac.uk"), and this is not completely trivial to
fix since it is not clear quite what its behaviour should be in some
corner cases.

Perhaps we could have an option like "--include-all" to notmuch
search/count to tell it not to apply the exclusions. On the other hand
that might also be useful as something the user can type in a search box
so a special search term (eg include:all) might be better.

Best wishes

Mark




[PATCH v4 2/3] emacs: `notmuch-show-buttonize-links' only `notmuch-show's a message if it exists

2012-01-22 Thread Pieter Praet
* emacs/notmuch-show.el (notmuch-show-found-target-p): new predicate function
  that uses notmuch(1) 'count' to see if a query turns up any results.

* emacs/notmuch-show.el (notmuch-show-if-found): new function that only shows
  a message/thread if present in the database and otherwise returns an error.

* emacs/notmuch-show.el (notmuch-show-buttonize-links): some deduplication,
  and use new function `notmuch-show-if-found' instead of `notmuch-show'
  to prevent showing a blank screen for Message-Id's which aren't present
  in the database.
---
 emacs/notmuch-show.el |   31 +++
 1 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 57dd232..972ac79 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -908,14 +908,17 @@ a corresponding notmuch search."
   (save-excursion
 (goto-char start)
 (while (re-search-forward "id:\\(\"?\\)[^[:space:]\"]+\\1" 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-show ,(match-string-no-properties 
0)))
-   'follow-link t
-   'help-echo "Mouse-1, RET: search for this message"
-   'face goto-address-mail-face
+  (let ((message-id (match-string-no-properties 0))
+   (string-start (match-beginning 0))
+   (string-end (match-end 0)))
+   ;; remove the overlay created by goto-address-mode
+   (remove-overlays string-start string-end 'goto-address t)
+   (make-text-button string-start string-end
+ 'action `(lambda (arg)
+(notmuch-show-if-found ,message-id))
+ '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)
@@ -1005,6 +1008,18 @@ thread id.  If a prefix is given, crypto processing is 
toggled."
 (notmuch-kill-this-buffer)
 (notmuch-show-worker thread-id parent-buffer query-context buffer-name 
process-crypto)))

+(defun notmuch-show-found-target-p (target)
+  (let ((args `("count" ,target)))
+(> (string-to-number
+   (with-output-to-string
+ (apply 'call-process notmuch-command nil standard-output nil args)))
+   0)))
+
+(defun notmuch-show-if-found (target  args)
+  (if (notmuch-show-found-target-p target)
+  (notmuch-show target args)
+(error "Can't find target: %s" target)))
+
 (defvar notmuch-show-stash-map
   (let ((map (make-sparse-keymap)))
 (define-key map "c" 'notmuch-show-stash-cc)
-- 
1.7.8.1



Re: [PATCH v4 2/3] emacs: `notmuch-show-buttonize-links' only `notmuch-show's a message if it exists

2012-01-22 Thread Mark Walters

 * emacs/notmuch-show.el (notmuch-show-if-found): new function that only shows
   a message/thread if present in the database and otherwise returns an error.

I like this in principle but it interacts awkwardly with the automatic tag
exclusion. If the id:message-id matches a message with an excluded tag
then notmuch-show-if-found will not let you view it, but if you typed the
same search in a search field it would show you the message. 

Note notmuch show currently does not currently respect excluded tags (see
id:871uqvgrnm@qmul.ac.uk), and this is not completely trivial to
fix since it is not clear quite what its behaviour should be in some
corner cases.

Perhaps we could have an option like --include-all to notmuch
search/count to tell it not to apply the exclusions. On the other hand
that might also be useful as something the user can type in a search box
so a special search term (eg include:all) might be better.

Best wishes

Mark


___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch