Re: best practices answering multiple mails (at once?)

2016-11-08 Thread cs

On 08Nov2016 10:28, nfb  wrote:

Oh thank you all guys for your answers. Let me practice what i
learnt then... this kinda seems the appropriate use case too :)

On Tue, Nov 08, 2016 at 10:00:59AM +1100, Cameron Simpson wrote:

It is pretty rare, but when I need to do it I tag all the source messages
and hit 'g' (group-reply), and then pay careful attention to the to/cc list.


Cameron, you meant, hit 'g' always prepended by ';', didn't you?


Yes. I run with "set auto_tag=yes", so i forget this. auto_tag runs commands 
against tagged messages if there are any, or the current message if not.



I
spent lots of time trying out, because i didn't know about the
existence of the ';' function, which i discoverd from a subsequent
mail. So simply hitting 'g' was not working. But it's not your fault,
i thought if there were tagged entries, the action would automatically
refer to all of them, but actually you have to explicitly tell mutt
you want to operate on all the tagged entries with ';'. You obviously
were silently implying it ;)


No, I was forgetting. My apologies. With "auto_tag=yes" mutt behaves roughly as 
you imagined before.



Anyways here i preferred using 'L' to answer, rather than 'g'.


Fair enough. Whatever produces the most appropriate result for you. I often 
deal with ah doc discussions made simply of several people rather than a 
mailing list, so "L" isn't what I naturally reach for.


Cheers,
Cameron Simpson 


Re: Mailing list folders

2016-11-02 Thread cs

On 02Nov2016 08:08, Mihail Konev  wrote:

What is the supposed way of keeping messages from a mailing list in a
dedicated folder?

Right now I'm using

 folder-hook +INBOX 'macro index \Cw "T~h \"To: 
mailing-list\";s\Cu=mailing-list$"'

i.e. tag everything "To: mailing-list", then move all tagged messages to 
"=mailing-list" folder.

Which works for a single list.

But this looks improper, unreliable,
and unefficient (has to purge messages for every list; requires to press
Ctrl-W).

I tried appending a second "T~h...$" for a different list,
but this shuffled message destinations (were it typos, bugs, or whatever).

This just seems not to be the intended way.


I've got a python program that watches my (Maildir) inbox, where the mail 
system deposits my messages. I files them according to rules from a config 
file. I just use mutt to visit the places the messages have been filed.

-- Cameron Simpson 


[SPAM?] Re: add the content of another email to new message

2016-08-24 Thread cs

On 23Aug2016 19:47, Jethro Tull  wrote:

On 16Aug2016 19:58, Jethro Tull  wrote:
>I'm using vim as editor in mutt. I would like to find a way to dump the
>content of another email or part to a new message while being composed. Of
>course without running a new instance of mutt.

Why not by running a new instance of mutt?

Without that, you need some kind of tool that _vim_ can invoke to access
message content. How are you intending to designate that message from inside
vim? [...]


sometimes while composing I could spontaneously need to put all or part of
another email or many others.

So I could save and close the current composition, then from that point I would
need to browse my emails and edit the ones I want to select what I want and
dump the selection into the email I was composing before without a copy/paste
process which would complicate things if I need the content of many emails.

The tricky thing I'm searching about is how to select the right file which
corresponds to the email I was composing. I could of course browse the files in
my maildir repo from within vim, but it doesn't look like a right way because,
first, the files in the maildir repo seem to be named randomly, second, what if
my emails were stored in an mbox format? It's a complicated thing because
edition is made from within vim and email browing is done with mutt.


Firstly, it sounds like you're doing this in a single window; is there any 
special reason for that?


Secondly, regarding the collection of these extra messages, I suggest getting 
them from mutt itself, and copying them into a separate file (even a scratch 
mbox file). More on that later.


It sound to me like you proposed workflow needs:

 a way to suspend your composition

 a way to browse you email to find relevant messages, and to save their 
 content for later use in your composition


 a way to resume your composition and incorporate your saved message text

The first thing to point out is that _outside_ the editing phase of 
composition, mutt has a "postpone" action normally bound to "P". So you can 
quit the editor and instead of sending or aborting your message, postpone it.  
Have a visit to the manual:


 http://www.mutt.org/doc/manual/

and check out the settings for $postpone and $postponed, and the section on 
Postponing Mail:


 http://www.mutt.org/doc/manual/#postponing-mail

I confess I don't use this, but it seems almost purpose built for your needs.

My approach is a little different (I really must write this up properly in the 
mutt wiki): I use these settings in my muttrc:


 set autoedit=yes
 set edit_headers=yes
 set editor=$EDITOR
 macro index g ":set editor=muttedit:set 
editor=$EDITOR" "group reply"

and this script:

 https://bitbucket.org/cameron_simpson/css/src/tip/bin/muttedit

$EDITOR is vim, as I imagine it is for you. But when I reply to a message (I 
always use "g" for this, hence the macro) I replace mutt's default $editor 
setting with "muttedit". This is a special script which is used in place of the 
editor, saving the new message temp file and starting a tmux or screen session 
containing a new "mutt -H" to compose a message based on a copy of that temp 
file.


The benefit here is that now your composition is in a tmux or screen session, 
and you can detach from it (returning to your original mutt session) and 
reattach later. To illustrate, this is in action right now while I write my 
message, and if I go "tmux list-sessions" it shows this line:


 mutt-24aug2016-19_02-Re__add_the_content_of_another_email_to_new_message: 1 
windows (created Wed Aug 24 19:02:19 2016) [178x24] (attached)

which is fairly descriptive; if I detached now, I could resume later by opening 
that session.


The mutt settings above are to provide a seamless feel to this. Using autoedit 
and edit_headers means the complete message text is in the temp file and the 
edit (the muttedit wrapper script) is started immediately. It copies the temp 
file and spawns the tmux session, running a mutt in compose-new-message mode 
using the temp file as a template.


The nifty bit is this: in a normal mutt, if you quit comoposition without 
having changes the temp file at all, mutt silently returns to your reading mode 
without complaint. Because "muttedit" just takes a copy and spawns a separate 
session, regardless of whether you finish and send, or detach and resume later, 
as far as your main mutt is concerned the temp file was untouched and you're 
back in mutt.


Anyway, as a first cut I suggest you try mutt's postpone mechanism. I can help 
you with muttedit later if you want to try that too.


To your "find other messages" issue, that should now be much easier ecause you 
can abandon your composition and return to it.


With that I'd be inclined to locate the other messages in mutt after you 
postpone/suspend your current message. Two methods suggest themselves for 
collecting these other messages: 

  the 

Re: mutt, vim, and autowrapping replies

2016-08-19 Thread cs

On 19Aug2016 12:39, li...@rickv.com  wrote:

On Fri, Aug 19, 2016 at 02:14:15PM +1000, c...@zip.com.au wrote:
One caveat is that in format=flowed a line with no trailing space is 
actually not meant to be reflowed. Such as lines of code.


I'm not sure how it handles this, the way it is. It'll probably need 
tweaking. It's already butchered my sig.


-- Rick Valenzuela Videojournalist Shanghai, China

+86 185 0177 0138 r...@rickv.com

GnuPG ID: 0xD5644029


Note that the sig delimiter convention is two leading dashes and a space _on 
their own on a line_. Was yours like this before the reflow?


Anyway, such a delimiter sounds at least technically feasible to honour.

Cheers,
Cameron Simpson 


Re: mutt, vim, and autowrapping replies

2016-08-18 Thread cs

On 18Aug2016 20:25, Jeremy Volkening  wrote:
Generally speaking I have the interface between mutt and vim regarding 
wrapping, flowed text, and quoting working satisfactorily. However, 
sometimes I receive mail with no line breaks within paragraphs. If I 
reply to such a message, the lack of hard breaks in the quoted 
paragraphs is retained within vim, and I'd rather not send out my 
replies formatted in this way. I can re-format the paragraphs to 
follow my textwidth setting with a few keystrokes, but I was wondering 
if anyone knew of anything I could add to "mail.vim" to re-flow the 
quoted text automatically upon opening in vim?


I too would like this.

One caveat is that in format=flowed a line with no trailing space is actually 
not meant to be reflowed. Such as lines of code.


I have an ancient macro bound to F7 with reformats a paragraph, a lot like 
piping it through the fmt command. Maybe it is enough to have such a macro and 
just walk through the text pressing it on offending paragraphs?


Alternatively, one might only reflow lines not indented.

Just random thoughts, happy to hear better ones.

Cheers,
Cameron Simpson 


Re: add the content of another email to new message

2016-08-17 Thread cs

On 17Aug2016 19:32, Erik Christiansen  wrote:

On 16.08.16 19:58, Jethro Tull wrote:

I'm using vim as editor in mutt. I would like to find a way to dump
the content of another email or part to a new message while being
composed. Of course without running a new instance of mutt.


The most convenient technique for including parts of other/multiple
emails in a new composition varies with use-case. If the text is not to
be quoted, but re-used as original text, then there are several methods:

a) Within vim, use ":r filename" to include the file containing the
  desired email, then edit. If there are thousands of emails in the
  mailbox, then you're not holding your mouth right, and will have to
  delete large slabs of text, but cpu cycles are cheap.


Or just :n to the mailbox file, yank the desired text (eg mark top line "ma", 
go to bottom line, yank "y'a"), return to compose file ":n #", paste "p".



b) Within vim: ":w", then ": e filename", then find the text you want,
  and yank it, "^" back to the composition, and paste.


Essentially the above I now realise.


c) If desiring to make it a bit more complicated, in a separate instance
  of vim, ": e filename", then find the text you want, and highlight it
  with the rodent. In the vim instance within mutt, you'll be in insert
  mode, and move the cursor into that window, then whack the middle mouse
  button.


Shrug. I recently started using vim's multiwindow stuff: open mailbox file in 
separate window, yank text, paste in compose window. Might feel easier.



Alternatively, when needing to quote parts of multiple posts for use in
a single reply to them all, it is convenient to tag them, perform a ';'
reply, then edit each of the quotes in vim within mutt, replying in-line
to the parts retained.


That'd be my preferred route if I knew all the relevant messages ahead of time.  
The OP might be discovering a desire to cite later.


Cheers,
Cameron Simpson 


Re: add the content of another email to new message

2016-08-16 Thread cs

On 16Aug2016 19:13, Tom Fowle  wrote:

How about simply hitting "f" while in the original message (forward),
you're then dumpped into a new message containing your original and can edit
away.


 breaks In-Reply-To:.

Cheers,
Cameron Simpson 


Re: need some help about organize message in mutt

2016-08-04 Thread cs

On 04Aug2016 12:44, Yubin Ruan  wrote:

On Thu, Aug 04, 2016 at 10:38:49AM +1000, c...@zip.com.au wrote:

On 04Aug2016 07:52, Yubin Ruan  wrote:
>Fortunately, after a few googling and combining all those info I
>have gathered,
>I find something like this:
>
>push 
'~cmutt-us...@mutt.org;simaps://ablacktsh...@imap.gmail.com/mutt-usersy'

I would be inclined to replace the ";" with "" and the
"s" with "". Just to make it all clear, and to avoid
damage by any macro definition you might make. I tend to either
spell it all out with  or (for very short macros) to be
entirely keystrokes (I have a couple of macros for the "message"
view that are just bound to "q" and the same thing in the index view
i.e. "quit the message view and do what would happen in the index
view".

>I put this in my .muttrc, and every time I open mutt, it would automatically
>move all the messages which are `To: mutt-users@mutt.org` or `Cc:
>mutt-users@mutt.org` to the mutt-users folder. Although it does it remotely,
>which would slow thing down when the network connection is not so good,

You might be surprised. If all the work is being done by the imap
server and the messages are not being pulled down to mutt and pushed
back up things should be pretty fast even on a poor connection.


That trick did work, but there still exists some problems when I put more than
one `push` command in my .muttrc:
   push 
'~cmutt-us...@mutt.org;simaps://ablacktsh...@imap.gmail.com/mutt-usersy'
   push 
'~cmutt-...@mutt.org;simaps://ablacktsh...@imap.gmail.com/mutt-devy'
   push '~f'
   ...
   (just as an example)
It seem like that the `push` command would not block when the preceding one is
not finished, which result in that those tagged message would NOT be saved to
the appropriate folder. That means, for example, those mails that
belong to `mutt-users`
folder would now be saved to the `mutt-dev` folder, which is probably because
the second `push` take effect before the first one can finish and the first
 never get a chance to take effect.

any idea?


Two issues to be aware of:

 - the entire muttrc runs before the keyboard stream starts being processed, 
   and push just inserts text into the front of that stream. So the push 
   command does not act until the muttrc has been processed.


 - each push command pushes onto the _front_ of the keyboard stream

That second part is important: _after_ the above push commands your keyboard 
stream looks like this:


   ~f
   
~cmutt-...@mutt.org;simaps://ablacktsh...@imap.gmail.com/mutt-devy
   
~cmutt-us...@mutt.org;simaps://ablacktsh...@imap.gmail.com/mutt-usersy

because the last push command to execute as your:

   push '~f'

This means that your "~f" is the first thing to happen. Mutt 
_does_ wait for each command, but they aren't happening in the order you 
expected.


Cheers,
Cameron Simpson 


Re: need some help about organize message in mutt

2016-08-03 Thread cs

On 04Aug2016 07:52, Yubin Ruan  wrote:
Fortunately, after a few googling and combining all those info I have 
gathered,

I find something like this:

push 
'~cmutt-us...@mutt.org;simaps://ablacktsh...@imap.gmail.com/mutt-usersy'


I would be inclined to replace the ";" with "" and the "s" with 
"". Just to make it all clear, and to avoid damage by any macro 
definition you might make. I tend to either spell it all out with  or 
(for very short macros) to be entirely keystrokes (I have a couple of macros 
for the "message" view that are just bound to "q" and the same thing in the 
index view i.e. "quit the message view and do what would happen in the index 
view".



I put this in my .muttrc, and every time I open mutt, it would automatically
move all the messages which are `To: mutt-users@mutt.org` or `Cc:
mutt-users@mutt.org` to the mutt-users folder. Although it does it remotely,
which would slow thing down when the network connection is not so good,


You might be surprised. If all the work is being done by the imap server and 
the messages are not being pulled down to mutt and pushed back up things should 
be pretty fast even on a poor connection.



I pretty
satisfied with this. Although something like procmail of offline-mail would make
thing faster, that would make it much complicated for now, so I would rather
settle down.


Indeed. Get comfortable before making your life even more complex.

Cheers,
Cameron Simpson 


Re: need some help about organize message in mutt

2016-08-02 Thread cs

On 02Aug2016 08:05, Yubin Ruan  wrote:

really appreciate your help.


If you want to be more precise, you can use a modifier such as:

 ~C mutt-users@mutt.org

to match messages with that in the To or CC headers.


I have tried that, but when I press that ~ key, mutt give me some "key is not
bound. Press ? for help" message.(when I say I press the ~ key, I mean I press
~ , which would give you a ~ when you do normal typing, otherwise it's
just a ` )


Ah. The string above is a pattern expression. It is only meaningful at the 
prompt for  or  or searching. So what I should have asked 
you to type was:


 T~C mutt-users@mutt.org

so that the "T" () opens the prompt requesting a pattern, and only 
_then_ do you type the pattern "~C mutt-users@mutt.org".


You might also want to experiment with "l" (), which restricts your view 
of the mailbox to just the messages matching a pattern. This will give you an 
easy way to experiment with patterns, and is also a handy way to locate 
particular messages in a large mailbox. Use the pattern "." to undo a "limit": 
that is a regexp for "any character", and effectively matches every message.



That's weird. I have no idea why, but I guess maybe that's because of
my configuration setting, part of which I copy directly from other's blog:

   set index_format='%-20.20L %4C [%Z] %{%b %d} %-15.15F (%?l?%4l&%4c?) %s'
   color index green  default ~N # new
   color index red default ~D# deleted
   color index brightmagenta default ~T  # tagged
   color index brightyellow default ~F   # flagged
   set pager_index_lines=10
   bind index,pager \Ck  sidebar-prev  #previous folder in sidebar
   bind index,pager \Cj  sidebar-next  #next folder in sidebar
   bind index,pager \CO  sidebar-open  #open selected folder in sidebar
   macro index  b'toggle sidebar_visible'
   macro index  \cb  'toggle sidebar_visible'
   bind index   ddisplay-message
   bind index   gg   first-entry
   bind index   Glast-entry
   bind index   hnoop
   bind index   lnoop

that's all of my conf that are related to index view. Anything wrong ?


There's nothing wrong there, but I would feel unhappy about the "d" macro 
above. Normally "d" is bound to , so if you every open someone 
else's mutt, or open your own but bypassing the configuration above (which 
sometimes one wants to do), then "d" can easily lead to accidental deletion of 
messages.


Normally  will display a message, and i would advocate removing your "d" 
macro and just using . Safer all around.



>   Can anyone tell me,
>   ** How can I have that Thunderbird message filtering in mutt?(i.e., moving
>   some messages from inbox to other mailbox according to the `To` field or 
`Cc`
>   field)


The simplest way to do that would be as you imagined:

 - tag the messages you want to move, for example by typing:

 T~C mutt-users@mutt.org

 - move ("save" in mutt parlance) these messages to another folder.

The key "s" is bound to . Normally that operates on the current 
message. What you want is to operate on all the tagged messages. This is done 
by prefixing the command with ";" which is bound to . You can do 
this with many operations (copy, delete, etc). So type:


 ;s

meaning . This will prompt you for a folder name for the 
messages.



>   ** Is those ~ in mutt's manual(~e, ~T, ~B, etc.) stand for the 
>   key?(I guess so because I have tried both `~T` and `T`, and only 
`T`
>   have some effect.) If that is, seriously, why can't the author just place
>   something like  or  in the manual? and what does the =, % prefix 
mean?

No, the "~" is a literal tilde character. It does _not_ mean
. The ~T, ~B etc operators are "pattern modifiers" for use in
expressions which match messages.  So:

 ~f c...@zip.com.au

would match any message from me ("c...@zip.com.au" in the From:
header). They are case insensitive: "~t" and "~T" do different
things;>


~f doesn't work either, because the ~ is not bound(as described above)


As discussed above, ~ only has meaning at a prompt asking for a pattern 
expression.  You need to type "T" or "l" first to get such a prompt.



Normal practice for mutt users is to file messages with a separate
program as they are collected. This works best with local storage:
we collect our email from the server with POP or IMAP and store in
local folders on our computers.  We can walk you through setting up
such an arrangement if you decide you want to go this way.


If there's some common practice I would really appreciate to hear some. Figuring
it out myself is kind of hard.


The practice varies very widely.

Many people use mutt to connect directly to IMAP servers such as GMail.

Alternatively, you arrange to collect your email from such servers (or your 
ISP's POP service, etc) and store it locally. Then use mutt to browse the local 
folders. Note here that mutt tends not to do the collecting, though it has pop 
and imap 

Re: need some help about organize message in mutt

2016-08-01 Thread cs

On 01Aug2016 21:18, Yubin Ruan  wrote:

   I think I must be a newbie in mutt-user community. So, hi all.


Hi, and welcome!


   I need some help here. I want to know how to organize all the message in 
gmail
inbox. I used to the Thunderbird email client. Frankly it's a pretty nice email
client, with a cool feature call `message-filter`. It can move some messages to
some mailbox according to the pattern you give it. For example, it can move all
the messages whose `To` field in header contains `mutt-users@mutt.org` to a
mailbox/folder call `mutt-user`. This can even automatically happed when I start
Thunderbird. This help me keep my inbox clean when I have subscribed to a lot of
mailing lists.


Yes, most of us do something similar.


   I know mutt can do pretty much the same things. But I don't know how to
exactly configure it. I try the instruction on the manual but thing just
doesn't work.
   For example, in the index mode, I press `T`, and then
`some-header-string`, trying to tagged all the message that are sent to
`mutt-users@mutt.org`. But that doesn't work. So bad. I try some others, can't
make it yet.


"T" (upper case "t" == T) is bound to the  command.  
Tagging is briefly described in the "Using Tags" section:


 http://www.mutt.org/doc/manual/#tags

With , the string you type at its prompt is a pattern, documented 
here:


 http://www.mutt.org/doc/manual/#patterns

If you just type a simple string such as mutt-users@mutt.org then that is 
considered a "simple search". These are described in the section above, under 
the table of modifiers. If you want to be more precise, you can use a modifier 
such as:


 ~C mutt-users@mutt.org

to match messages with that in the To or CC headers.

All this does is _tag_ the matching messages. You can then move them by issuing 
a  command, bound to "s". That normally works on the current 
message, but you can have it work on all the tagged messages by issuing the 
 command first, bound to ";". So typing this:


 ;s

says to mutt that it should save all of the tagged messages to a folder. You 
will be proompted for that folder name.



   Can anyone tell me,
   ** How can I have that Thunderbird message filtering in mutt?(i.e., moving
   some messages from inbox to other mailbox according to the `To` field or `Cc`
   field)
   ** Is those ~ in mutt's manual(~e, ~T, ~B, etc.) stand for the 
   key?(I guess so because I have tried both `~T` and `T`, and only 
`T`
   have some effect.) If that is, seriously, why can't the author just place
   something like  or  in the manual? and what does the =, % prefix 
mean?


No, the "~" is a literal tilde character. It does _not_ mean . The ~T, 
~B etc operators are "pattern modifiers" for use in expressions which match 
messages.  So:


 ~f c...@zip.com.au

would match any message from me ("c...@zip.com.au" in the From: header). They are 
case insensitive: "~t" and "~T" do different things; see the table of pattern 
modifiers here:


 http://www.mutt.org/doc/manual/#tab-patterns

You can write arbitrary Boolean expressions with this stuff. Broadly:

 ~ introduces a pattern modifier expression, often it will accept a regular 
 expression as its argument


 = a few modifers come with "=", for expressions which search on the server 
 (== the IMAP server); they accept a fixed string, not a regular expression.


 % modifers which match against groups. You can define groups of mail 
 % addresses in mutt, and ask for messages which involve those addresses.


While all this lets you search for and optionally move or copy or delete etc 
messages, authomatic message filing is usually _not_ done by mutt itself. (Al 
though you could by running a few commands automatically when mutt commences, 
but managing that gets tedious very quickly).


Normal practice for mutt users is to file messages with a separate program as 
they are collected. This works best with local storage: we collect our email 
from the server with POP or IMAP and store in local folders on our computers.  
We can walk you through setting up such an arrangement if you decide you want 
to go this way.


If you're using GMail and wanting to keep your messages there I would recommend 
setting up filter rules in GMail itself: it is capable of autofiling new 
messages for you. The rules are a little crude, but they cover the common 
cases.


Cheers,
Cameron Simpson  (who is actually wearing a black t-shirt 
today)


Re: no MUTTRC environment variable?

2016-07-04 Thread cs

On 03Jul2016 00:50, Xu Wang  wrote:

Thank you very much for the replies, Will and Cameron.

Yes, these workarounds work fine for my personal setup. However, I am
working on scripts that I would like to release for other users to
use. I do not want to require other users to refactor their .muttrcs
just to use the scripts. Creating user-friendsly scripts is what
motivates me.


And fair enough too. I suspect then that you must explicitly invoke mutt as 
needed. This:


 mutt -F /dev/null -e 'source muttrc1' -e 'source muttrc2' ...

is probably the cleanest way to invoke mutt without reliance on the user's 
.muttrc, and to source whatever config you intend. You can add the "-n" option 
to also bypass and system muttrc file.


Does this help?

Cheers,
Cameron Simpson 


Re: [SPAM?] Re: no MUTTRC environment variable?

2016-07-02 Thread cs

On 02Jul2016 20:13, Xu Wang  wrote:

On Thu, Jun 30, 2016 at 9:10 PM, Will Yardley
 wrote:

On Thu, Jun 30, 2016 at 08:02:38PM -0400, Xu Wang wrote:

I have read the environment variables section in 'man mutt' and there
does not seem to be a MUTTRC environment variable. One can set using
-F option but sometime environment variable is nice.

Can someone confirm this is correct? Is there a reason for this?


What kind of uses did you have in mind?
You can use environment variables in config files, so you can always
work around this for most of the use cases I can think of by having

source ~/.muttrc-$FOO
in ~/.muttrc, and then define $FOO.


Thank you for responding. That is good tricky to know. You said "for
most of the use cases I can think of". What is the use case you can
think of where the tricky above will not function?

For me it is not ideal because when I execute
source ~/.muttrc-$FOO
then the rest of the .muttrc is still processed. I would like to
process only ~/.muttrc-$FOO.
I hope that has sense.


What about this:

 .muttrc
   source .muttrc-$FOO

 .muttrc-default
   all your normal settings

and set $FOO (well, probably something like $MUTT_PROFILE_NAME) to 'default' in 
your .profile.


That way your .muttrc runs only the .muttrc-whatever you ask for, and by 
default runs your normal settings.


Cheers,
Cameron Simpson 


[SPAM?] Re: [SPAM?] mutt deletes temporary HTML file before I can view it

2016-06-22 Thread cs

On 22Jun2016 02:08, Xu Wang  wrote:

I would like to be able to do
'v' and then 'm' to open an HTML email in my browser. I can succeed in
this regard by having the following entry in ~/.mailcap:
text/html; chromium-browser %s; description=HTML Text;

However, mutt will be unresponsive until I exit the browser. This is
not my work style. So I added & to detach. This is good in the sense
that mutt now does not wait for the browser. However, by the time my
browser opens, mutt has already deleted the .html temporary file
because after adding & the command returned immediately?

Has any one come across this situation and has a similar desire?

Is there a setting I can choose to ask mutt to not delete the
temporary files? They are stored in /tmp and space is cheap so I would
like to ask mutt to not worry about them.


This is something of a standard problem with popping up HTML in an external 
browser, for exactly the reasons you outline. Try something like this 
(untested):


 text/html; cp %s /tmp/$$.html && chromium-browser /tmp/$$.html &; 
description=HTML Text;

That is still one line in case it gets folded in email. Note the html on the 
temp file name, can help the browser decide how to treat it.


If you want something more elaborate (clean up the temp file after a delay) you 
would use withstdin:


 https://bitbucket.org/cameron_simpson/css/src/tip/bin/withstdin

Disclaimer: mine, all mine.

And try this:

 text/html; withstdin --ext=.html --keepfor=10 chromium-browser <%s &; 
description=HTML Text;

Cheers,
Cameron Simpson 


Re: Questions about gmail app passwords

2016-04-25 Thread cs

On 25Apr2016 19:45, Grant Edwards  wrote:

On 2016-04-25, David Champion  wrote:

* On 25 Apr 2016, Grant Edwards wrote:

[regarding Google "app passwords"]

Do you need different, unique passwords for mutt, imap, msmtp,
offlineimap, and all other IMAP or SMTP clients on a particular
machine?

Are you required to use the same password for mutt on all machines?


No. You can create as many application-specific passwords as you need
at https://security.google.com/settings/security/apppasswords.  Each
can be tagged with an application name and a device name to help you
remember where you're using that password, but they're all equivalent.
Google doesn't pick up on what each one is specifically being used from,
although they may track whether passwords are being used at all.

Choose your own granularity.


David, thank you for this information; I've been wondering exactly the same 
thing recently.



I'll probaby go with a single "app password" per account per physical
machine.  Next I suppose I should figure out how to use gpg-agent so I
don't store them in plaintext.  It would be nice if I could somehow
combine ssh-agent and gpg-agent so I don't have to enter a passphrase
twice...


A shell wrapper using expect might to the trick. Personally I'm going to enter 
my passphrase twice.


Gpg-agent does work; I used to use it and intend to fix it up again (I forget 
what troubles I had, they probably revolved around poor agent setup on my 
part).


Cheers,
Cameron Simpson 


Re: My print command cannot use "read -p"

2016-04-22 Thread cs

On 22Apr2016 15:04, Jon LaBadie  wrote:

On Fri, Apr 22, 2016 at 12:34:48AM -0700, David Champion wrote:

* On 21 Apr 2016, Jon LaBadie wrote:
> Unless it has changed recently, bash runs redirected read
> commands in a sub-process.  Thus the variable fn would not
> get set in the main process.

I haven't run into this (that I recall) with regular input redirection.
It does happen with piped input redirection (to a read) because the
pipeline terminal isn't the current shell.

yes:
read fn 

Thanks for the correction David.
My negative bash experience was with pipes as in:

 date | read wday mon day time zone yr

which works fine in ksh and zsh.  I badly assumed
the limitation was to any redirection.


Yah, the active thing is not the readirect, it is that a pipeline needs to put 
at least all but one command as separate processes, and most shells will make 
all the commands separate processes (including the final "read" from your 
example).


I usually do this:

 date \
 | { read wday mon day time zone yr
 ... use $wday etc here - in the same shell as the "read" ...
   }

Cheers,
Cameron Simpson 


Re: Show output (and place for extra input) from sendmail command

2016-04-22 Thread cs

On 21Apr2016 23:38, Xu Wang  wrote:

On Wed, Apr 20, 2016 at 6:03 AM,   wrote:

On 19Apr2016 20:30, Xu Wang  wrote:

I use a custom sendmail command. I would like to have my script (that
I set to 'sendmail' muttrc variable) ask some questions from to the
user and also give feedback to the user directly. But mutt does not
run the process in the foreground so it seems impossible.

[...]

Could it pop up a separate terminal window to run the commands? [...]

Thank you for this idea.

It is a possibility. However I would like to use mutt through ssh. I
think thus I cannot do this.


Ok, then the next alternative is to use tmux (or screen, but I think tmux is a 
far superior tool - if you have it, use it). [Thinks...] Actually, this is 
better than firing up an xterm anyway!


Currently I imagine you go:

 ssh -t host run-mutt...

If you invoke it this way:

 ssh -t host tmux new-session run-mutt...

that will get you a mutt runnning inside tmux. Note that "run-mutt..." is a 
shell command string, not separate command words, so it might look like this:


 ssh -t host tmux new-session "mutt folder-name"

It is then possible to spawn a new pane within the tmux session for your 
interaction, thus:


 tmux split-window -v -l 8 'script-to-ask-questions-and-then-send.sh "$tmpf"'

to make a new "pane" in the window running your interactive script. When the 
script finishes, the pane will close. Note again that the command argument to 
split-window is a shell command, not separate words.


You'd put that "tmux split-window" incantation in the script exactly where I 
had the "xterm" incantation, for example (untested):


 tmux split-window -v -l 8 "script-to-ask-questions-and-then-send.sh '$tmpf'"

Experimentation suggests that the cursor focus will be in the new pane 
immediately, ready to interact. However if not then the key sequence "control-b 
o" will move the focus from one pane to the next.


Cheers,
Cameron Simpson 


Re: How to just view the email constructed by mutt without sending it?

2016-04-20 Thread cs

On 20Apr2016 14:39, Peng Yu  wrote:

Hi, I use the following command to send email with mutt. But
sometimes, I want to inspect the email body constructed by mutt. Is
there a way to do so? Thanks.

echo "This is the message body" | mutt -s "subject of message" --
a...@domain.com


You could set $sendmail to be a script that just took a copy of the message and 
did not send it. Then look at the copy. You can also resent such a copy later 
by handing it directly to sendmail (or whatever your mutt is currently using), 
or by handing it to mutt again with the -H option.


Cheers,
Cameron Simpson 


Re: Show output (and place for extra input) from sendmail command

2016-04-20 Thread cs

Oh yes, you will want to pass any arguments received on to your inner script:

 xterm -e script-to-ask-questions-and-then-send.sh "$tmpf" ${1+"$@"}

Cheers,
Cameron Simpson 

On 20Apr2016 20:03, Cameron Simpson  wrote:

On 19Apr2016 20:30, Xu Wang  wrote:

I use a custom sendmail command. I would like to have my script (that
I set to 'sendmail' muttrc variable) ask some questions from to the
user and also give feedback to the user directly. But mutt does not
run the process in the foreground so it seems impossible.

Is there an approach?


Could it pop up a separate terminal window to run the commands? For 
example, untested, make your $sendmail setting point at a shell script 
like this:


#!/bin/sh
set -ue
tmpf=${TMPDIR:-/tmp}/sendmail.$$
cat >"$tmpf"
xterm -e script-to-ask-questions-and-then-send.sh "$tmpf"
rm "$tmpf"

You see we pass in the temp file to your ask-questions-and-send script 
so it can feed the message to sendmail (or whatever), and then remove 
it after xterm returns (which will be after your innner script has 
finished).


Just one idea.

Cheers,
Cameron Simpson 


--


Re: Show output (and place for extra input) from sendmail command

2016-04-20 Thread cs

On 19Apr2016 20:30, Xu Wang  wrote:

I use a custom sendmail command. I would like to have my script (that
I set to 'sendmail' muttrc variable) ask some questions from to the
user and also give feedback to the user directly. But mutt does not
run the process in the foreground so it seems impossible.

Is there an approach?


Could it pop up a separate terminal window to run the commands? For example, 
untested, make your $sendmail setting point at a shell script like this:


 #!/bin/sh
 set -ue
 tmpf=${TMPDIR:-/tmp}/sendmail.$$
 cat >"$tmpf"
 xterm -e script-to-ask-questions-and-then-send.sh "$tmpf"
 rm "$tmpf"

You see we pass in the temp file to your ask-questions-and-send script so it 
can feed the message to sendmail (or whatever), and then remove it after xterm 
returns (which will be after your innner script has finished).


Just one idea.

Cheers,
Cameron Simpson 


Re: Mark threads as read for the future

2016-04-15 Thread cs

On 14Apr2016 18:15, Francesco Ariis  wrote:

On Thu, Apr 14, 2016 at 05:47:48PM +0200, Andreas Doll wrote:

I'm using mutt in conjunction with offlineimap to filter mailinglists into
separate folders. Usually I decide quickly if I'm interested in a thread or
not - if not I press Ctrl-r to mark this thread as read and move on.

The "problem" with this is, that subsequent replies to this thread will marked
as new again. Is there a way (flagging?) such that subsequent replies to this
thread will be marked also as read, maybe utilizing offlineimap (which is able
to mark mails as read)?


Hey Andreas,
   I wrote a small folder-hook pattern which accomplishes a similar task
(deletes instead 'mark as read') [1]. I suspect it can be modified to
suit your needs (tag-pattern + tag-prefix maybe?).
Fire again if you need help

[1] http://ariis.it/static/articles/mutt-ml/page.html


TL;DR: Francesco' pattern is:

 ~l~N(!~(!~x.+))(!~(~F))

which matches list messages where the whole thread is (N)ew, where no message 
in the thread lacks a Reply-To: or References, where no message in the thread 
is (F)lagged. Ergo, list message replies to threads whose starting message has 
been removed (as uninteresting).


That is very clever!

(BTW, the ~x pattern only needs to be present, not match the whole line, so you 
can use "~x." instead of "~x.+".)


I'm about to adopt that here with small tweaks based on my own 
behaviour/desires:


I am dropping the ~l, I do not use the list mutt settings.

I am going to require matching threads to have no Subject lines which do not 
commence with "^(\[[^]]*\]  *)?Re:" (subjects starting with "Re:", allow for 
list subject tags like "[spinx-users]"; some brief tests in my python folder 
found some shiny new subjects like this:


 blah (was: blah-old)

and of course rampant thread hijacking by naive users. I am prepared to 
consider them "new threads", at least wanting reexamination.


So I'm testing with this at present:

 macro index l '~N(!~(!~x.))(!~(~F))(!~(!~s"(\\[[^]]*\] 
*)?[Rr][Ee]:"))' 'tag unflagged all-new replies to deleted threads'

and it definitely seems to be showing only boring stuff. I may combine it with 
~= (duplicate message id - multiple delivery of the same message) and consider 
it a tidy-this-folder tool. And eventually run it by default on folder entry, 
maybe.


I can see I will need to teach myself to ^R (mark whole thread read) instead of 
^D (delete/archive whole thread) for discussions I _do_ intend to follow.  
Fortunately I already bind ^R to:


 

which folds such things away quietly for me.

Thank you Francesco!

Cheers,
Cameron Simpson 


Re: How do you survive without notmuch?

2016-04-15 Thread cs

On 14Apr2016 12:23, derek martin  wrote:
[...snip...]

IIRC there's a terminal-based web browser that has the ability to
display web pages, including images, in your terminal window--though
it may require the use of some specific terminal program, I can't
recall.


I'm using iTerm 3 beta on OSX, and it is capable of displaying images. Mutt 
would probably need to allow certain extra ANSI-like codes through in the 
pager, _and_ grow some special support for recognising such things.


Displaying web pages had traditionally been handled by handing the page content 
off to an external view "pop this message text up in firefox" for example. That 
could be made easier or better supported: all such actions require writing the 
message text (and possibly assets, such at attached images) into a temporary 
file or directory and calling the external viewer with the pathname in some 
fashion eg a "file:///" URL. The catch is that mutt normally removes such 
things when done, and with an asynchronous tool like a browser "done" is ill 
defined. So a facility for mutt to spawn a helper process to track this and 
then clean up, or not clean up, might be useful; then one could package some 
default behaviours with mutt built on such a thing.



So even better HTML mail support should be doable in Mutt
without making it a GUI...


Having mutt ship with more flexible default configurations would help. There 
are plenty of recipes floating around for "use w3m or lynx to render HTML as 
plain text and page that", but they don't ship with mutt itself - every user 
must pick a recipe and implement it.



But I would frankly like to see a GUI
option as well; I think it would be great if Mutt could switch back
and forth and have a relatively consistent UI in both cases.  It's
totally doable.  This is the kind of stuff that a modern mailer is
expected to have...


Doable portably would imply shipping an optional GUI kit with mutt; and X11 is 
not the only desktop environment; while I can run X11 on this Mac it is more 
seamless with native apps. So a toolkit which knew about multiple platforms 
migh be necessary eg Qt; IIRC there are licencing issues there in addition to 
the loud debate about the GUI kit and whether to ship it at all.


For many of us mutt is text, letting us remain in our flexible terminal 
environments without the mouse happy glaring white hassle of a GUI, and it 
might be an anathema to give mutt any kind of "native" GUI facility.


I had the unpleasant experience of finding an Emoji rendered in my mutt index 
listing a week or so ago, and I thought the End Times had come. Thank you, 
Unicode Consortium.


But I agree it would be good if more of the "extension" facilities we use with 
mutt were available _easily_ to new users.


Cheers,
Cameron Simpson 

Nothing is impossible for the man who doesn't have to do it.


message matching as the index cursor moves

2016-04-10 Thread cs
I've got a macro whose action I would like to adjust according the to status of 
the current message. Thus:


 message-hook . 'macro index,pager F 
"+spool-to-phone" "Flag message 
(copy to phone also)."'

 message-hook ~F 'macro index,pager F "" "Unlag 
message."'

This does not do what I want. What I want is to adjust the definition of the 
"F" macro as I move through messages in the index. Reading the doco, I see that 
message-hook is fired when mutt is deciding how to format a message for the 
pager. (BTW, the exact times various hooks are fired seems rather vague in the 
doco.)


Anyway, is there a way to do what I want, either to fire hooks as I step 
through the index (in index view, not pager view), _or_ to adjust the action of 
a macro according the the flags of the message (or other status - generally any 
pattern I might use in  I suppose).


The reason I want this is that I have "F" bound to both set the (F)lagged 
status _and_ to bounce a copy of the message to my phone (where I keep a 
"shortlist" of important messages). But I want "F" on an already flagged 
message to undo the (F)lagged status and _not_ bounce an additional copy to my 
phone.


Cheers,
Cameron Simpson 


New messages in folders not noticed

2001-06-07 Thread CS/MATH stud.

Hello everyone --
I am using mutt to read mail on a NFS mounted home mail directory.  This works
fine, except that when I start mutt, it doesn't notice that I have new mail in
the folders listed in my mailboxes.   For example, I'll start mutt knowing that
there are new messages in +IN.mutt (because I read that there were in the
procmail log) and when I enter into mutt and hit 'c', it doesn't automatically
choose =IN.mutt for me.  If I hit tab a couple times to get my mailboxes, it
doesn't show that it's new with the 'N' in the margin there either.  However,
when I enter into the mailbox =IN.mutt, it does correctly identify new messages.
I have tried compiling with --enable-nfs-fix, --enable-fcntl, --disable-fcntl,
--enable-flock, in many combinations.  None of them fix the problem.  I even
tried mounting the NFS direcotry with '-o nolock'.  Does anyone have a solution
to this problem, or is it a bug of some kind.   I'm running on a Debian sid
machine mounting nfs version 3.

Here's my mutt -v: 
System: Linux 2.4.5 [using ncurses 5.2]
Compile options:
-DOMAIN
+DEBUG
-HOMESPOOL  -USE_SETGID  -USE_DOTLOCK  -DL_STANDALONE  
+USE_FCNTL  -USE_FLOCK
+USE_POP  +USE_IMAP  -USE_GSS  -USE_SSL  +USE_SASL  
+HAVE_REGCOMP  -USE_GNU_REGEX  
+HAVE_COLOR  +HAVE_START_COLOR  +HAVE_TYPEAHEAD  +HAVE_BKGDSET  
+HAVE_CURS_SET  +HAVE_META  +HAVE_RESIZETERM  
+HAVE_PGP  -BUFFY_SIZE -EXACT_ADDRESS  -SUN_ATTACHMENT  
+ENABLE_NLS  -LOCALES_HACK  +COMPRESSED  +HAVE_WC_FUNCS  +HAVE_LANGINFO_CODESET
+HAVE_LANGINFO_YESEXPR  
+HAVE_ICONV  -ICONV_NONTRANS  +HAVE_GETSID  +HAVE_GETADDRINFO  
ISPELL=/usr/bin/ispell
SENDMAIL=/usr/sbin/sendmail
MAILPATH=~
SHAREDIR=/usr/share/mutt
SYSCONFDIR=/etc
EXECSHELL=/bin/sh
MIXMASTER=mixmaster
To contact the developers, please mail to [EMAIL PROTECTED].
To report a bug, please use the flea(1) utility.

-- 
Michael Janssen - Jamuraa - [EMAIL PROTECTED] - [EMAIL PROTECTED]
GPG Fingerprint: 87F1 92C4 44AA 4105 B1C4  EDEC D995 9620 C00E 9159

 PGP signature