[PATCH v2] emacs: add function to toggle display of all multipart/alternative parts

2012-08-10 Thread Jani Nikula
On Aug 10, 2012 7:18 PM, "Jameson Graef Rollins" 
wrote:
>
> On Fri, Aug 10 2012, Jani Nikula  wrote:
> > How would this work together with something like [1] (rationale in [2])?
> >
> > [1] id:"
ab777cf0fa83778d3399ac52094df9230738819d.1328798471.git.jani at nikula.org"
> > [2] id:"cover.1328719309.git.jani at nikula.org"
> >
> > If you introduce a mechanism to store the state, could it be extended to
> > store the state of each individual part? That, in turn, could be used to
> > add support for expanding/collapsing each alternative part through the
> > buttons (e.g. [ text/html (not shown) ]). Each button could toggle the
> > state of the part, and refresh buffer.
>
> Hey, Jani.  Are these patches needed if we have Mark's patch?  I would
> prefer to see Mark's solution.  Since alternative parts are supposed to
> be just that, alternative, it seems to me that a solution that would
> cycle through display of these parts is really what we want.  Is there a
> strong need to show multiple alternative parts at the exact same time?

Thanks to broken Microsoft mail clients, I get plenty of invitations that
have text/plain and text/calendar alternative parts with information
complimenting each other. I usually need to see both (luckily the included
html part I can ignore) and it's helpful if I can see them at the same
time. In a perfect world neither you or me would need any of this
functionality...

I suppose cycling through the alternative parts is, in a sense, correct for
the reasons you state, we have the code here to do just that, and I can
always cook up something for myself. Let's go with this, then, to move
forward.

BR,
Jani.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120810/486b027d/attachment.html>


[PATCH v2] emacs: add function to toggle display of all multipart/alternative parts

2012-08-10 Thread Mark Walters

On Fri, 10 Aug 2012, Jani Nikula  wrote:
> On Aug 10, 2012 7:18 PM, "Jameson Graef Rollins"  finestructure.net>
> wrote:
>>
>> On Fri, Aug 10 2012, Jani Nikula  wrote:
>> > How would this work together with something like [1] (rationale in [2])?
>> >
>> > [1] id:"
> ab777cf0fa83778d3399ac52094df9230738819d.1328798471.git.jani at nikula.org"
>> > [2] id:"cover.1328719309.git.jani at nikula.org"
>> >
>> > If you introduce a mechanism to store the state, could it be extended to
>> > store the state of each individual part? That, in turn, could be used to
>> > add support for expanding/collapsing each alternative part through the
>> > buttons (e.g. [ text/html (not shown) ]). Each button could toggle the
>> > state of the part, and refresh buffer.
>>
>> Hey, Jani.  Are these patches needed if we have Mark's patch?  I would
>> prefer to see Mark's solution.  Since alternative parts are supposed to
>> be just that, alternative, it seems to me that a solution that would
>> cycle through display of these parts is really what we want.  Is there a
>> strong need to show multiple alternative parts at the exact same time?
>
> Thanks to broken Microsoft mail clients, I get plenty of invitations that
> have text/plain and text/calendar alternative parts with information
> complimenting each other. I usually need to see both (luckily the included
> html part I can ignore) and it's helpful if I can see them at the same
> time. In a perfect world neither you or me would need any of this
> functionality...
>
> I suppose cycling through the alternative parts is, in a sense, correct for
> the reasons you state, we have the code here to do just that, and I can
> always cook up something for myself. Let's go with this, then, to move
> forward.

Hi

I am not sure I agree: I think maybe toggling parts is better. Either
the parts contain the same information and then the current behaviour is
probably fine, or they are not in which case we might want to see both
at once

Best wishes

Mark




[PATCH v2] emacs: add function to toggle display of all multipart/alternative parts

2012-08-10 Thread Jani Nikula
On Fri, 10 Aug 2012, Mark Walters  wrote:
> Some messages are sent as multipart/alternative but the alternatives
> contain different information. This allows the user to cycle which
> part to view. By default this is bound to 'W'.
> ---
>
> On Thu, 09 Aug 2012, Jameson Graef Rollins  
> wrote:
>> On Mon, Jun 18 2012, Mark Walters  wrote:
>>> I agree with this cycling approach but I think it needs to be per
>>> message rather than per buffer. I attach a rather hacky attempt at this
>>> below: on minimal testing it seems to work. But the lisp is really a bit
>>> gross. In particular  I have no idea if I should be escaping the message
>>> ids (so this could break in unfortunate/insecure ways)
>>
>> Thanks to broken Apple mail clients, I'm getting more and more messages
>> that have attachments hidden in multipart/"alternatives" to text/plain
>> parts.  So I would really like to revive this patch.
>>
>> I just tested it and it still applies to current master, and actually
>> seems to work great.  'W' cycles through which part is displayed in the
>> current message.  Pretty much exactly what I want.
>>
>> Mark seems to think this patch is less than ideal.  One issue is that
>> it's trying to store a setting for a single displayed message in a
>> variable of full buffer scope.  So he's storing a list of message ids
>> there:
>>
>>> +(defvar notmuch-show-message-multipart/alternative nil)
>>> +(make-variable-buffer-local 'notmuch-show-message-multipart/alternative)
>>> +(put 'notmuch-show-message-multipart/alternative 'permanent-local t)
>> ...
>>> +   (lax-plist-put notmuch-show-message-multipart/alternative 
>>> (plist-get msg :id) 0)))
>>
>> I can see that might get a little hairy.  Can any elisp experts out
>> there think of a better way to do this?  (actually, this is making me
>> again want a show mode that only displays one message at a time (which I
>> guess means I need to try pick again)).
>
> This version at least uses the notmuch escaping for message-id which
> makes me a bit happier: it probably doesn't have any nasty security
> flaws. I do still feel that the lisp is a bit ugly though.
>
> Incidentally, Austin suggested I might be able to use text-properties
> rather than this big list. Unfortunately, I use
> notmuch-show-refresh-view to do the redisplay and that deletes all
> text-properties.
>
> Note this is not very well tested as I have very few
> multipart/alternative messages.

How would this work together with something like [1] (rationale in [2])?

[1] id:"ab777cf0fa83778d3399ac52094df9230738819d.1328798471.git.jani at 
nikula.org"
[2] id:"cover.1328719309.git.jani at nikula.org"

If you introduce a mechanism to store the state, could it be extended to
store the state of each individual part? That, in turn, could be used to
add support for expanding/collapsing each alternative part through the
buttons (e.g. [ text/html (not shown) ]). Each button could toggle the
state of the part, and refresh buffer.

I guess basically the above are related. If you stored a list of parts
to display per each message id, the initial list could be created based
on customized regexps, the buttons could be used for toggling each
individual part (adding/removing the type from the list), and you could
have a function that would cycle the list to your heart's content.

BR,
Jani.



>
> Best wishes
>
> Mark
>
>
>  emacs/notmuch-show.el |   31 ---
>  1 files changed, 28 insertions(+), 3 deletions(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index dcfc190..dee6b85 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -154,6 +154,10 @@ indentation."
>  (make-variable-buffer-local 'notmuch-show-indent-content)
>  (put 'notmuch-show-indent-content 'permanent-local t)
>  
> +(defvar notmuch-show-message-multipart/alternative-display-part nil)
> +(make-variable-buffer-local 
> 'notmuch-show-message-multipart/alternative-display-part)
> +(put 'notmuch-show-message-multipart/alternative-display-part 
> 'permanent-local t)
> +
>  (defcustom notmuch-show-stash-mlarchive-link-alist
>'(("Gmane" . "http://mid.gmane.org/;)
>  ("MARC" . "http://marc.info/?i=;)
> @@ -536,9 +540,19 @@ message at DEPTH in the current thread."
>  
>  (defun notmuch-show-insert-part-multipart/alternative (msg part content-type 
> nth depth declared-type)
>(notmuch-show-insert-part-header nth declared-type content-type nil)
> -  (let ((chosen-type (car (notmuch-multipart/alternative-choose 
> (notmuch-show-multipart/*-to-list part
> - (inner-parts (plist-get part :content))
> - (start (point)))
> +  (let* ((chosen-nth (or (lax-plist-get 
> notmuch-show-message-multipart/alternative-display-part
> + (notmuch-id-to-query (plist-get msg 
> :id))) 0))
> +  (chosen-type (nth chosen-nth
> +   (notmuch-multipart/alternative-choose 
> (notmuch-show-multipart/*-to-list part
> +  (inner-parts 

Vim plugins

2012-08-10 Thread Anton Khirnov

On Thu, 9 Aug 2012 09:49:19 +0100 (BST), Sepp Tannhuber  wrote:
> Dear Anton,
> 
> for some reason the file did not exist here. Perhaps I deleted it 
> accidentally. So I cloned the
> repository again. And there it is.
> Now I'm trying?if it is useful for me. I changed some code that I can use 
> python-ranger to
> attach files:
> ##
> function! s:NM_compose_attach()
> 
> if filereadable('/tmp/chosendir')
> silent !ranger --choosefiles=/tmp/chosenfiles --choosedir=/tmp/chosendir 
> "$(cat /tmp/chosendir)"
> else
> silent !ranger --choosefiles=/tmp/chosenfiles --choosedir=/tmp/chosendir
> endif
> if filereadable('/tmp/chosenfiles')
> let attachments = readfile('/tmp/chosenfiles')
> call system('rm /tmp/chosenfiles')
> for attach in attachments
> python nm_vim.get_current_buffer().attach(vim.eval('attach'))
> endfor
> call append(10, map(attachments, '"Attach: ".escape(v:val," \t\\")'))
> redraw!
> endif
> endfunction
> ##
> It's even possible to mark and attach multiple files at once.
> 

Looks useful, but needs more work I think.
First, I think it should be a new function, so there are separate
'attach one file'/'attach multiple files' commands.
Second, using hardcoded filenames would break horribly with multiple
instances of the client running.

> Is it possible suppress the message returned by
> ? ? python nm_vim.get_current_buffer()?
> ?

What message?

> And do you have?an idea?what's the reason for the following message?
> 
> ##
> :call 33_NM_folders_show_search('') ? ? ? Exception in thread Thread-1: 
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
> Traceback (most recent call last):
> ? File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
> ? ? self.run()
> ? File "/usr/lib/python2.7/threading.py", line 504, in run
> ? ? self.__target(*self.__args, **self.__kwargs)
> ? File "/home/sepp/.vim/plugin/nm_vim.py", line 195, in _refresh_thread
> ? ? authors, subj, tags)).encode('utf-8')
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: 
> ordinal not in range(128)
> ##
> 

Should be fixed now.

-- 
Anton Khirnov


[PATCH v2] emacs: add function to toggle display of all multipart/alternative parts

2012-08-10 Thread Jameson Graef Rollins
On Fri, Aug 10 2012, Jani Nikula  wrote:
> How would this work together with something like [1] (rationale in [2])?
>
> [1] id:"ab777cf0fa83778d3399ac52094df9230738819d.1328798471.git.jani at 
> nikula.org"
> [2] id:"cover.1328719309.git.jani at nikula.org"
>
> If you introduce a mechanism to store the state, could it be extended to
> store the state of each individual part? That, in turn, could be used to
> add support for expanding/collapsing each alternative part through the
> buttons (e.g. [ text/html (not shown) ]). Each button could toggle the
> state of the part, and refresh buffer.

Hey, Jani.  Are these patches needed if we have Mark's patch?  I would
prefer to see Mark's solution.  Since alternative parts are supposed to
be just that, alternative, it seems to me that a solution that would
cycle through display of these parts is really what we want.  Is there a
strong need to show multiple alternative parts at the exact same time?

jamie.
-- 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/20120810/1b978f37/attachment.pgp>


[PATCH v2] emacs: add function to toggle display of all multipart/alternative parts

2012-08-10 Thread Mark Walters

Some messages are sent as multipart/alternative but the alternatives
contain different information. This allows the user to cycle which
part to view. By default this is bound to 'W'.
---

On Thu, 09 Aug 2012, Jameson Graef Rollins  
wrote:
> On Mon, Jun 18 2012, Mark Walters  wrote:
>> I agree with this cycling approach but I think it needs to be per
>> message rather than per buffer. I attach a rather hacky attempt at this
>> below: on minimal testing it seems to work. But the lisp is really a bit
>> gross. In particular  I have no idea if I should be escaping the message
>> ids (so this could break in unfortunate/insecure ways)
>
> Thanks to broken Apple mail clients, I'm getting more and more messages
> that have attachments hidden in multipart/"alternatives" to text/plain
> parts.  So I would really like to revive this patch.
>
> I just tested it and it still applies to current master, and actually
> seems to work great.  'W' cycles through which part is displayed in the
> current message.  Pretty much exactly what I want.
>
> Mark seems to think this patch is less than ideal.  One issue is that
> it's trying to store a setting for a single displayed message in a
> variable of full buffer scope.  So he's storing a list of message ids
> there:
>
>> +(defvar notmuch-show-message-multipart/alternative nil)
>> +(make-variable-buffer-local 'notmuch-show-message-multipart/alternative)
>> +(put 'notmuch-show-message-multipart/alternative 'permanent-local t)
> ...
>> +(lax-plist-put notmuch-show-message-multipart/alternative 
>> (plist-get msg :id) 0)))
>
> I can see that might get a little hairy.  Can any elisp experts out
> there think of a better way to do this?  (actually, this is making me
> again want a show mode that only displays one message at a time (which I
> guess means I need to try pick again)).

This version at least uses the notmuch escaping for message-id which
makes me a bit happier: it probably doesn't have any nasty security
flaws. I do still feel that the lisp is a bit ugly though.

Incidentally, Austin suggested I might be able to use text-properties
rather than this big list. Unfortunately, I use
notmuch-show-refresh-view to do the redisplay and that deletes all
text-properties.

Note this is not very well tested as I have very few
multipart/alternative messages.

Best wishes

Mark


 emacs/notmuch-show.el |   31 ---
 1 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index dcfc190..dee6b85 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -154,6 +154,10 @@ indentation."
 (make-variable-buffer-local 'notmuch-show-indent-content)
 (put 'notmuch-show-indent-content 'permanent-local t)

+(defvar notmuch-show-message-multipart/alternative-display-part nil)
+(make-variable-buffer-local 
'notmuch-show-message-multipart/alternative-display-part)
+(put 'notmuch-show-message-multipart/alternative-display-part 'permanent-local 
t)
+
 (defcustom notmuch-show-stash-mlarchive-link-alist
   '(("Gmane" . "http://mid.gmane.org/;)
 ("MARC" . "http://marc.info/?i=;)
@@ -536,9 +540,19 @@ message at DEPTH in the current thread."

 (defun notmuch-show-insert-part-multipart/alternative (msg part content-type 
nth depth declared-type)
   (notmuch-show-insert-part-header nth declared-type content-type nil)
-  (let ((chosen-type (car (notmuch-multipart/alternative-choose 
(notmuch-show-multipart/*-to-list part
-   (inner-parts (plist-get part :content))
-   (start (point)))
+  (let* ((chosen-nth (or (lax-plist-get 
notmuch-show-message-multipart/alternative-display-part
+   (notmuch-id-to-query (plist-get msg 
:id))) 0))
+(chosen-type (nth chosen-nth
+ (notmuch-multipart/alternative-choose 
(notmuch-show-multipart/*-to-list part
+(inner-parts (plist-get part :content))
+(start (point)))
+;; If we have run out of possible content-types restart from the beginning
+(unless chosen-type
+  (setq chosen-type (car (notmuch-multipart/alternative-choose 
(notmuch-show-multipart/*-to-list part
+  (setq notmuch-show-message-multipart/alternative-display-part
+   (lax-plist-put 
notmuch-show-message-multipart/alternative-display-part
+  (notmuch-id-to-query (plist-get msg :id)) 0)))
+
 ;; This inserts all parts of the chosen type rather than just one,
 ;; but it's not clear that this is the wrong thing to do - which
 ;; should be chosen if there are more than one that match?
@@ -942,6 +956,16 @@ message at DEPTH in the current thread."
 "Not processing cryptographic MIME parts."))
   (notmuch-show-refresh-view))

+(defun notmuch-show-cycle-message-multipart ()
+  "Cycle which part to display of a multipart messageToggle the display of 
non-matching messages."
+  (interactive)
+  (let* ((msg-id (notmuch-show-get-message-id))
+

[PATCH v2] emacs: add function to toggle display of all multipart/alternative parts

2012-08-10 Thread Mark Walters

Some messages are sent as multipart/alternative but the alternatives
contain different information. This allows the user to cycle which
part to view. By default this is bound to 'W'.
---

On Thu, 09 Aug 2012, Jameson Graef Rollins jroll...@finestructure.net wrote:
 On Mon, Jun 18 2012, Mark Walters markwalters1...@gmail.com wrote:
 I agree with this cycling approach but I think it needs to be per
 message rather than per buffer. I attach a rather hacky attempt at this
 below: on minimal testing it seems to work. But the lisp is really a bit
 gross. In particular  I have no idea if I should be escaping the message
 ids (so this could break in unfortunate/insecure ways)

 Thanks to broken Apple mail clients, I'm getting more and more messages
 that have attachments hidden in multipart/alternatives to text/plain
 parts.  So I would really like to revive this patch.

 I just tested it and it still applies to current master, and actually
 seems to work great.  'W' cycles through which part is displayed in the
 current message.  Pretty much exactly what I want.

 Mark seems to think this patch is less than ideal.  One issue is that
 it's trying to store a setting for a single displayed message in a
 variable of full buffer scope.  So he's storing a list of message ids
 there:

 +(defvar notmuch-show-message-multipart/alternative nil)
 +(make-variable-buffer-local 'notmuch-show-message-multipart/alternative)
 +(put 'notmuch-show-message-multipart/alternative 'permanent-local t)
 ...
 +(lax-plist-put notmuch-show-message-multipart/alternative 
 (plist-get msg :id) 0)))

 I can see that might get a little hairy.  Can any elisp experts out
 there think of a better way to do this?  (actually, this is making me
 again want a show mode that only displays one message at a time (which I
 guess means I need to try pick again)).

This version at least uses the notmuch escaping for message-id which
makes me a bit happier: it probably doesn't have any nasty security
flaws. I do still feel that the lisp is a bit ugly though.

Incidentally, Austin suggested I might be able to use text-properties
rather than this big list. Unfortunately, I use
notmuch-show-refresh-view to do the redisplay and that deletes all
text-properties.

Note this is not very well tested as I have very few
multipart/alternative messages.

Best wishes

Mark


 emacs/notmuch-show.el |   31 ---
 1 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index dcfc190..dee6b85 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -154,6 +154,10 @@ indentation.
 (make-variable-buffer-local 'notmuch-show-indent-content)
 (put 'notmuch-show-indent-content 'permanent-local t)
 
+(defvar notmuch-show-message-multipart/alternative-display-part nil)
+(make-variable-buffer-local 
'notmuch-show-message-multipart/alternative-display-part)
+(put 'notmuch-show-message-multipart/alternative-display-part 'permanent-local 
t)
+
 (defcustom notmuch-show-stash-mlarchive-link-alist
   '((Gmane . http://mid.gmane.org/;)
 (MARC . http://marc.info/?i=;)
@@ -536,9 +540,19 @@ message at DEPTH in the current thread.
 
 (defun notmuch-show-insert-part-multipart/alternative (msg part content-type 
nth depth declared-type)
   (notmuch-show-insert-part-header nth declared-type content-type nil)
-  (let ((chosen-type (car (notmuch-multipart/alternative-choose 
(notmuch-show-multipart/*-to-list part
-   (inner-parts (plist-get part :content))
-   (start (point)))
+  (let* ((chosen-nth (or (lax-plist-get 
notmuch-show-message-multipart/alternative-display-part
+   (notmuch-id-to-query (plist-get msg 
:id))) 0))
+(chosen-type (nth chosen-nth
+ (notmuch-multipart/alternative-choose 
(notmuch-show-multipart/*-to-list part
+(inner-parts (plist-get part :content))
+(start (point)))
+;; If we have run out of possible content-types restart from the beginning
+(unless chosen-type
+  (setq chosen-type (car (notmuch-multipart/alternative-choose 
(notmuch-show-multipart/*-to-list part
+  (setq notmuch-show-message-multipart/alternative-display-part
+   (lax-plist-put 
notmuch-show-message-multipart/alternative-display-part
+  (notmuch-id-to-query (plist-get msg :id)) 0)))
+
 ;; This inserts all parts of the chosen type rather than just one,
 ;; but it's not clear that this is the wrong thing to do - which
 ;; should be chosen if there are more than one that match?
@@ -942,6 +956,16 @@ message at DEPTH in the current thread.
 Not processing cryptographic MIME parts.))
   (notmuch-show-refresh-view))
 
+(defun notmuch-show-cycle-message-multipart ()
+  Cycle which part to display of a multipart messageToggle the display of 
non-matching messages.
+  (interactive)
+  (let* ((msg-id (notmuch-show-get-message-id))
+

Re: Vim plugins

2012-08-10 Thread Anton Khirnov

On Thu, 9 Aug 2012 09:49:19 +0100 (BST), Sepp Tannhuber 
sepp.tannhu...@yahoo.de wrote:
 Dear Anton,
 
 for some reason the file did not exist here. Perhaps I deleted it 
 accidentally. So I cloned the
 repository again. And there it is.
 Now I'm trying if it is useful for me. I changed some code that I can use 
 python-ranger to
 attach files:
 ##
 function! s:NM_compose_attach()
 
 if filereadable('/tmp/chosendir')
 silent !ranger --choosefiles=/tmp/chosenfiles --choosedir=/tmp/chosendir 
 $(cat /tmp/chosendir)
 else
 silent !ranger --choosefiles=/tmp/chosenfiles --choosedir=/tmp/chosendir
 endif
 if filereadable('/tmp/chosenfiles')
 let attachments = readfile('/tmp/chosenfiles')
 call system('rm /tmp/chosenfiles')
 for attach in attachments
 python nm_vim.get_current_buffer().attach(vim.eval('attach'))
 endfor
 call append(10, map(attachments, 'Attach: .escape(v:val, \t\\)'))
 redraw!
 endif
 endfunction
 ##
 It's even possible to mark and attach multiple files at once.
 

Looks useful, but needs more work I think.
First, I think it should be a new function, so there are separate
'attach one file'/'attach multiple files' commands.
Second, using hardcoded filenames would break horribly with multiple
instances of the client running.

 Is it possible suppress the message returned by
     python nm_vim.get_current_buffer()?
  

What message?

 And do you have an idea what's the reason for the following message?
 
 ##
 :call SNR33_NM_folders_show_search('')       Exception in thread Thread-1:  
                               
 Traceback (most recent call last):
   File /usr/lib/python2.7/threading.py, line 551, in __bootstrap_inner
     self.run()
   File /usr/lib/python2.7/threading.py, line 504, in run
     self.__target(*self.__args, **self.__kwargs)
   File /home/sepp/.vim/plugin/nm_vim.py, line 195, in _refresh_thread
     authors, subj, tags)).encode('utf-8')
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: 
 ordinal not in range(128)
 ##
 

Should be fixed now.

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


Re: [PATCH v2] emacs: add function to toggle display of all multipart/alternative parts

2012-08-10 Thread Jani Nikula
On Fri, 10 Aug 2012, Mark Walters markwalters1...@gmail.com wrote:
 Some messages are sent as multipart/alternative but the alternatives
 contain different information. This allows the user to cycle which
 part to view. By default this is bound to 'W'.
 ---

 On Thu, 09 Aug 2012, Jameson Graef Rollins jroll...@finestructure.net wrote:
 On Mon, Jun 18 2012, Mark Walters markwalters1...@gmail.com wrote:
 I agree with this cycling approach but I think it needs to be per
 message rather than per buffer. I attach a rather hacky attempt at this
 below: on minimal testing it seems to work. But the lisp is really a bit
 gross. In particular  I have no idea if I should be escaping the message
 ids (so this could break in unfortunate/insecure ways)

 Thanks to broken Apple mail clients, I'm getting more and more messages
 that have attachments hidden in multipart/alternatives to text/plain
 parts.  So I would really like to revive this patch.

 I just tested it and it still applies to current master, and actually
 seems to work great.  'W' cycles through which part is displayed in the
 current message.  Pretty much exactly what I want.

 Mark seems to think this patch is less than ideal.  One issue is that
 it's trying to store a setting for a single displayed message in a
 variable of full buffer scope.  So he's storing a list of message ids
 there:

 +(defvar notmuch-show-message-multipart/alternative nil)
 +(make-variable-buffer-local 'notmuch-show-message-multipart/alternative)
 +(put 'notmuch-show-message-multipart/alternative 'permanent-local t)
 ...
 +   (lax-plist-put notmuch-show-message-multipart/alternative 
 (plist-get msg :id) 0)))

 I can see that might get a little hairy.  Can any elisp experts out
 there think of a better way to do this?  (actually, this is making me
 again want a show mode that only displays one message at a time (which I
 guess means I need to try pick again)).

 This version at least uses the notmuch escaping for message-id which
 makes me a bit happier: it probably doesn't have any nasty security
 flaws. I do still feel that the lisp is a bit ugly though.

 Incidentally, Austin suggested I might be able to use text-properties
 rather than this big list. Unfortunately, I use
 notmuch-show-refresh-view to do the redisplay and that deletes all
 text-properties.

 Note this is not very well tested as I have very few
 multipart/alternative messages.

How would this work together with something like [1] (rationale in [2])?

[1] id:ab777cf0fa83778d3399ac52094df9230738819d.1328798471.git.j...@nikula.org
[2] id:cover.1328719309.git.j...@nikula.org

If you introduce a mechanism to store the state, could it be extended to
store the state of each individual part? That, in turn, could be used to
add support for expanding/collapsing each alternative part through the
buttons (e.g. [ text/html (not shown) ]). Each button could toggle the
state of the part, and refresh buffer.

I guess basically the above are related. If you stored a list of parts
to display per each message id, the initial list could be created based
on customized regexps, the buttons could be used for toggling each
individual part (adding/removing the type from the list), and you could
have a function that would cycle the list to your heart's content.

BR,
Jani.




 Best wishes

 Mark


  emacs/notmuch-show.el |   31 ---
  1 files changed, 28 insertions(+), 3 deletions(-)

 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
 index dcfc190..dee6b85 100644
 --- a/emacs/notmuch-show.el
 +++ b/emacs/notmuch-show.el
 @@ -154,6 +154,10 @@ indentation.
  (make-variable-buffer-local 'notmuch-show-indent-content)
  (put 'notmuch-show-indent-content 'permanent-local t)
  
 +(defvar notmuch-show-message-multipart/alternative-display-part nil)
 +(make-variable-buffer-local 
 'notmuch-show-message-multipart/alternative-display-part)
 +(put 'notmuch-show-message-multipart/alternative-display-part 
 'permanent-local t)
 +
  (defcustom notmuch-show-stash-mlarchive-link-alist
'((Gmane . http://mid.gmane.org/;)
  (MARC . http://marc.info/?i=;)
 @@ -536,9 +540,19 @@ message at DEPTH in the current thread.
  
  (defun notmuch-show-insert-part-multipart/alternative (msg part content-type 
 nth depth declared-type)
(notmuch-show-insert-part-header nth declared-type content-type nil)
 -  (let ((chosen-type (car (notmuch-multipart/alternative-choose 
 (notmuch-show-multipart/*-to-list part
 - (inner-parts (plist-get part :content))
 - (start (point)))
 +  (let* ((chosen-nth (or (lax-plist-get 
 notmuch-show-message-multipart/alternative-display-part
 + (notmuch-id-to-query (plist-get msg 
 :id))) 0))
 +  (chosen-type (nth chosen-nth
 +   (notmuch-multipart/alternative-choose 
 (notmuch-show-multipart/*-to-list part
 +  (inner-parts (plist-get part :content))
 +  (start (point)))
 +;; If we have run out of 

Re: [PATCH v2] emacs: add function to toggle display of all multipart/alternative parts

2012-08-10 Thread Jameson Graef Rollins
On Fri, Aug 10 2012, Jani Nikula j...@nikula.org wrote:
 How would this work together with something like [1] (rationale in [2])?

 [1] 
 id:ab777cf0fa83778d3399ac52094df9230738819d.1328798471.git.j...@nikula.org
 [2] id:cover.1328719309.git.j...@nikula.org

 If you introduce a mechanism to store the state, could it be extended to
 store the state of each individual part? That, in turn, could be used to
 add support for expanding/collapsing each alternative part through the
 buttons (e.g. [ text/html (not shown) ]). Each button could toggle the
 state of the part, and refresh buffer.

Hey, Jani.  Are these patches needed if we have Mark's patch?  I would
prefer to see Mark's solution.  Since alternative parts are supposed to
be just that, alternative, it seems to me that a solution that would
cycle through display of these parts is really what we want.  Is there a
strong need to show multiple alternative parts at the exact same time?

jamie.


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


Re: [PATCH v2] emacs: add function to toggle display of all multipart/alternative parts

2012-08-10 Thread Jani Nikula
On Aug 10, 2012 7:18 PM, Jameson Graef Rollins jroll...@finestructure.net
wrote:

 On Fri, Aug 10 2012, Jani Nikula j...@nikula.org wrote:
  How would this work together with something like [1] (rationale in [2])?
 
  [1] id:
ab777cf0fa83778d3399ac52094df9230738819d.1328798471.git.j...@nikula.org
  [2] id:cover.1328719309.git.j...@nikula.org
 
  If you introduce a mechanism to store the state, could it be extended to
  store the state of each individual part? That, in turn, could be used to
  add support for expanding/collapsing each alternative part through the
  buttons (e.g. [ text/html (not shown) ]). Each button could toggle the
  state of the part, and refresh buffer.

 Hey, Jani.  Are these patches needed if we have Mark's patch?  I would
 prefer to see Mark's solution.  Since alternative parts are supposed to
 be just that, alternative, it seems to me that a solution that would
 cycle through display of these parts is really what we want.  Is there a
 strong need to show multiple alternative parts at the exact same time?

Thanks to broken Microsoft mail clients, I get plenty of invitations that
have text/plain and text/calendar alternative parts with information
complimenting each other. I usually need to see both (luckily the included
html part I can ignore) and it's helpful if I can see them at the same
time. In a perfect world neither you or me would need any of this
functionality...

I suppose cycling through the alternative parts is, in a sense, correct for
the reasons you state, we have the code here to do just that, and I can
always cook up something for myself. Let's go with this, then, to move
forward.

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


Re: [PATCH v2] emacs: add function to toggle display of all multipart/alternative parts

2012-08-10 Thread Mark Walters

On Fri, 10 Aug 2012, Jani Nikula j...@nikula.org wrote:
 On Aug 10, 2012 7:18 PM, Jameson Graef Rollins jroll...@finestructure.net
 wrote:

 On Fri, Aug 10 2012, Jani Nikula j...@nikula.org wrote:
  How would this work together with something like [1] (rationale in [2])?
 
  [1] id:
 ab777cf0fa83778d3399ac52094df9230738819d.1328798471.git.j...@nikula.org
  [2] id:cover.1328719309.git.j...@nikula.org
 
  If you introduce a mechanism to store the state, could it be extended to
  store the state of each individual part? That, in turn, could be used to
  add support for expanding/collapsing each alternative part through the
  buttons (e.g. [ text/html (not shown) ]). Each button could toggle the
  state of the part, and refresh buffer.

 Hey, Jani.  Are these patches needed if we have Mark's patch?  I would
 prefer to see Mark's solution.  Since alternative parts are supposed to
 be just that, alternative, it seems to me that a solution that would
 cycle through display of these parts is really what we want.  Is there a
 strong need to show multiple alternative parts at the exact same time?

 Thanks to broken Microsoft mail clients, I get plenty of invitations that
 have text/plain and text/calendar alternative parts with information
 complimenting each other. I usually need to see both (luckily the included
 html part I can ignore) and it's helpful if I can see them at the same
 time. In a perfect world neither you or me would need any of this
 functionality...

 I suppose cycling through the alternative parts is, in a sense, correct for
 the reasons you state, we have the code here to do just that, and I can
 always cook up something for myself. Let's go with this, then, to move
 forward.

Hi

I am not sure I agree: I think maybe toggling parts is better. Either
the parts contain the same information and then the current behaviour is
probably fine, or they are not in which case we might want to see both
at once

Best wishes

Mark


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


Re: [PATCH v2] emacs: add function to toggle display of all multipart/alternative parts

2012-08-10 Thread Jameson Graef Rollins
On Fri, Aug 10 2012, Mark Walters markwalters1...@gmail.com wrote:
 I am not sure I agree: I think maybe toggling parts is better. Either
 the parts contain the same information and then the current behaviour is
 probably fine, or they are not in which case we might want to see both
 at once

If the case we're talking about is the alternative part having
additional information, then why is cycling not sufficient?  Shouldn't I
be able to cycle to a part that shows all the information I'm interested
in?  I assume that even in the most broken mailers the alternatives
still show mostly redundant information.

I really like the cycling behavior, but If this solution is really not
enough then how about we just start off with the alternate parts
collapsed, and you can click on them to open them.  I don't really like
the idea of having special code to handle specific alternative parts.
That seems overly complicated to me.

jamie.


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