Re: choices on reading HTML emails

2018-04-10 Thread Arkadiusz Drabczyk
On 2018-04-10, Brian Salter-Duke <brian.james.d...@gmail.com> wrote:
> On Tue, Apr 10, 2018 at 03:57:53PM +0800, Yubin Ruan wrote:
>> Hi,
>> 
>> Can anyone share some approaches for reading HTML emails.
>> Currenlty I use w3m:
>> 
>> text/html; w3m -I %{charset} -T text/html; copiousoutput;
>> 
>> But sometimes I receive some HTML mails which can not be handled that well by
>> w3m, so I want to open that html attachment in a browser. How can I switch
>> between?
>> 
>> Yubin
>
> I use
>
> text/html; /home/brian/bin/see_html %s

Notice that you don't have to use full paths in .mailcap.  As mutt
passes mailcap commands to sh you can use one of these 2 to make your
.mailcap more portable:

text/html; $HOME/bin/see_html %s
text/html; ~/bin/see_html %s

And if see_html is in your $PATH:

text/html; see_html %s

Personally, I use
https://raw.githubusercontent.com/tampakrap/bin/master/viewhtmlmail.py.
The good thing about it is that it can also display images embedded in
html messages.  I have this in my .muttrc:

macro  pager"~/bin/viewhtmlmail.py\n" "ViewHTML in 
browser"
-- 
Arkadiusz Drabczyk <arkadi...@drabczyk.org>



Re: reference the folder name in a folder-hook push command

2017-12-31 Thread Arkadiusz Drabczyk
On Sat, Dec 30, 2017 at 11:42:41PM +0300, Oleg A. Mamontov wrote:
> Thank you for suggestion and explanation, but do I understand right that
> there is no way to create internal mutt variable ($my_foo) as
> modification of another one ($my_bar)?

None that I'm aware of.
-- 
Arkadiusz Drabczyk <arkadi...@drabczyk.org>


Re: reference the folder name in a folder-hook push command

2017-12-28 Thread Arkadiusz Drabczyk
On Thu, Dec 28, 2017 at 07:07:57PM +0300, Oleg A. Mamontov wrote:
> Hello,
> 
> On Tue, Dec 26, 2017 at 03:23:50PM +, Arkadiusz Drabczyk wrote:
> > On Tue, Dec 26, 2017 at 06:36:20AM +0800, Yubin Ruan wrote:
> > > Hi,
> > > 
> > > I have a folder hook like this:
> > > 
> > > folder-hook =somembox 'push "!touch /tmp/\1-touched\n"'
> > > 
> > > where I would like to create a file "/tmp/somebox-touched" when I select 
> > > and
> > > enter a mailbox. As you can see, \1 here should represent the name of the 
> > > mbox
> > > (as in many Regex). Is there a way to do this so that I do not have to 
> > > write
> > > rules for all the mbox one by one?
> > 
> > Like that:
> > 
> > folder-hook . 'set my_oldrecord=$record; set record=^; set 
> > my_folder=$record; set record=$my_oldrecord'
> > folder-hook . 'push "!touch /tmp/${my_folder}-touched\n"'
> 
> Thanks for sharing such an interesting approach. How can it be extended to
> remove the '=' starting character? I've tried to do following:
> 
> folder-hook . 'set my_oldrecord=$record; set record=^; set my_folder=`echo 
> $record | sed s/=//`; set record=$my_oldrecord'
> 
> But unfortunately it doesn't work for some reason.

The best I could come up with:

folder-hook . 'set my_oldrecord=$record; set record=^; set my_folder=$record; 
set record=$my_oldrecord'
folder-hook . 'push "!touch /tmp/$(echo ${my_folder} | sed 's,^=,,)-touched\n"'

The reason the solution you tried doesn't work is probably because
mutt performs shell substitution before parsing the line as said in
the manual:

"It is also possible to substitute the output of a Unix command in an
initialization file. This is accomplished by enclosing the command in
backticks (``). In Example 3.5, "Using external command's output in
configuration files", the output of the Unix command "uname -a" will
be substituted before the line is parsed."

So what shell sees is:

$ echo | sed s/=//

-- 
Arkadiusz Drabczyk <arkadi...@drabczyk.org>


Re: reference the folder name in a folder-hook push command

2017-12-26 Thread Arkadiusz Drabczyk
On Tue, Dec 26, 2017 at 06:36:20AM +0800, Yubin Ruan wrote:
> Hi,
> 
> I have a folder hook like this:
> 
> folder-hook =somembox 'push "!touch /tmp/\1-touched\n"'
> 
> where I would like to create a file "/tmp/somebox-touched" when I select and
> enter a mailbox. As you can see, \1 here should represent the name of the mbox
> (as in many Regex). Is there a way to do this so that I do not have to write
> rules for all the mbox one by one?

Like that:

folder-hook . 'set my_oldrecord=$record; set record=^; set my_folder=$record; 
set record=$my_oldrecord'
folder-hook . 'push "!touch /tmp/${my_folder}-touched\n"'

-- 
Arkadiusz Drabczyk <arkadi...@drabczyk.org>


Re: Emacs automatic line wrapping

2017-08-12 Thread Arkadiusz Drabczyk
On 2017-08-12, Jason <elect...@emypeople.net> wrote:
>
> On Thu, Aug 03, 2017 at 12:36:21PM -0500, Luis Mochan wrote:
>> On Wed, Aug 02, 2017 at 08:49:30PM -0700, Ian Zimmerman wrote:
>> > On 2017-08-02 21:47, Jason wrote:
>> > 
>> > > I am using emacs24 for my text editor with mutt (in a terminal).
>> > > How can I set it to automatically wrap the lines at a certain number
>> > > of characters?
>> > 
>> > "M-x auto-fill-mode" will do it in a new buffer, provided you set your
>> > fill-column variable.
>> 
>> If you have already opened your buffer, you can wrap the lines of a 
>> paragraph with M-q.
>> 
>> You can set the fill column to say, 72 with C-u 7 2 C-x f
> Thank you for both replies. I am new to emacs and while I know it can do many
> different things, right now I would just like it to automatically wrap lines
> when using for composing messages. "M-x auto-fill-mode" works in the buffer 
> but
> I would like it to startup in that mode. Here's what's in my config file:
>
> (custom-set-variables
>  ;; custom-set-variables was added by Custom.
>  ;; If you edit it by hand, you could mess it up, so be careful.
>  ;; Your init file should contain only one such instance.
>  ;; If there is more than one, they won't work right.
>  '(auto-fill-mode t)
>  '(fill-column 80)
>  '(fill-nobreak-predicate nil))
> (custom-set-faces
>  ;; custom-set-faces was added by Custom.
>  ;; If you edit it by hand, you could mess it up, so be careful.
>  ;; Your init file should contain only one such instance.
>  ;; If there is more than one, they won't work right.
>  )
>
> What am I missing?
> Thanks.

Is that your *whole* Emacs config?

As said above you need at least one hook.  In order to easily use
Emacs in programs such as mutt or slrn I recommend mutt-mode.  I
cannot find on the net anywhere any more so I put it here
http://drabczyk.org/mutt.el.  mutt-mode will add several nice
keybindings such as C-c C-c to automatically save a message and exit
the current buffer or C-c C-i to automatically jump to the signature,
it will also color quotation and will of course enable auto-fill-mode
automatically.  To enable mutt-mode automatically when writing a
message in mutt or slrn put mutt.el in your load-path and add
something like this to your Emacs startup file:

(defun mutt-mode-hook ()
  (when
  (and
   (file-exists-p (buffer-file-name))
   (stringp buffer-file-name)
   (or (string-match (concat ".*mutt-comp-[0-9\-]+$") buffer-file-name)
   (string-match ".followup" buffer-file-name)
   (string-match ".article" buffer-file-name))
   (mutt-mode)
   )))

(add-hook 'find-file-hook 'mutt-mode-hook)

Replace `comp' with your hostname as by default mutt uses the hostname
to create a message template in /tmp.
-- 
Arkadiusz Drabczyk <arkadi...@drabczyk.org>



Re: Muttrc example needed POP3/SMTP

2017-02-03 Thread Arkadiusz Drabczyk
On 2017-02-03, sunrise <sunr...@emypeople.net> wrote:
> I would like to start using mutt but am somewhat intimidated by all the 
> possible options
> in the muttrc config file. Would someone be willing to provide me with a 
> basic muttrc I
> could use to get started?
>
> Here is what I'm looking for:
>
> * POP3 (one provider) for retrieving messages

I'd just like to add that these days you should give IMAP a try - I
find better than POP3 because it automatically synchronizes
everything.  It's easy to use with mutt as well.

For example, I use offlineimap as the IMAP client on my Slackware box
and K9Mail e-mail client on my phone.  When I mark a message as read
on my phone it's automatically marked as read when downloaded with
offlineimap in mutt, when I send a message on either device it's
automatically shown in Sent folder on both devices, and when I move a
a message to a given folder or delete a message it's automatically
synchronized on both devices.  It's very convenient, especially if get
a lot of mail.
-- 
Arkadiusz Drabczyk <arkadi...@drabczyk.org>



Re: How to move to a specific message or to the end in a long list?

2016-05-01 Thread Arkadiusz Drabczyk
On 2016-05-01, Chris Green <c...@isbd.net> wrote:
> I (rarely) have a long message list of some hundreds of messages.
> This occurs when I'm looking at old mailboxes, archives and similar. 
>
> How does one simply move to the last page/message or to a specific
> message number?

To move to a n-th message just start typing a number and mutt will say
`Jump to message: ' on the bottom.  To move to a last number
type `:' and then `:exec last-entry', or add a keybinding to
~/.muttrc:

macro index B ""

Now `B' will jump to the last message in the current mailbox.
-- 
Arkadiusz Drabczyk <arkadi...@drabczyk.org>



Re: select wrapped lines / click long url / bug 3453

2015-11-28 Thread Arkadiusz Drabczyk
On 2015-11-27, David Woodfall <d...@dawoodfall.net> wrote:
>>Hi!
>>
>>I'm currently using mutt in xterm, and I finally got tired of copy
>>long urls (wrapped in multiple lines) from mutt to browser. Ideally, I'd
>>like to be able to open urls by clicking them.
>>
>>It looks like xterm doesn't support clicking on urls, so I'm ready to
>>switch to any other terminal emulator which will support this feature.

It looks like it finally does (kinda).  From
http://lukas.zapletalovi.com/2013/07/hidden-gems-of-xterm.html:

UXTerm*VT100*translations: #override Shift : exec-formatted("firefox 
--new-tab '%t'", PRIMARY).

Select a link with a mouse and press Shift+click to open a link in
Firefox.  I tested this on a newest xterm compiled from
ftp://invisible-island.net/xterm/xterm.tar.gz and it works.  My way of
opening links is to use GNU screen without using a mouse:

bind f eval writebuf 'exec /bin/bash -c "firefox $(cat /tmp/screen-exchange)"'

However, both solutions require to mark the entire link (unlike
aforementioned Gnome terminal) before opening them so they are not
that comfortable if the link is very long.

-- 
Arkadiusz Drabczyk <arkadi...@drabczyk.org>



Re: viewing attachments with identical filenames

2015-11-19 Thread Arkadiusz Drabczyk
On 2015-11-18, Peter P. <peterpar...@fastmail.com> wrote:
> Hi list,
>
> I came across an annoying issue when viewing attached files in mutt.
> In order to view attachment "A" Mutt saves the file to /tmp/mutt and
> launches the appropriate viewer. When I want to see another attachment
> "B" which has an identical filename as "A" and ask mutt to display it,
> mutt will not overwrite the already stored "A" file in /tmp/mutt, and
> hence display "A" while I would expect to see "B".
>
> Is this a known issue, and could there be a workaround to this?

I must be missing something.  Mutt saves temporary files to $TMPDIR or
to /tmp if $TMPDIR is unset (TMPDIR is kinda standard
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03).
Did you set your $TMPDIR to /tmp/mutt?  Anyway, I cannot reproduce
this behavior - I sent two identically named .pdf files, opened them
in turn and both of them were saved to $TMPDIR before opening and
handled by mutt in accordance with ~/.mailcap.  What mutt version do
you use?  I tested it on both 1.5.21 and 1.5.24.

-- 
Arkadiusz Drabczyk <arkadi...@drabczyk.org>



Re: Is there a tool I can use to convert a whole email to webpage or something alike?

2015-11-16 Thread Arkadiusz Drabczyk
On 2015-11-16, Mick <michaelkintz...@gmail.com> wrote:
> On Monday 16 Nov 2015 07:00:05 Magicloud Magiclouds wrote:
>> Gary, very nice. Thank you.

>> Ian, Cameron, sorry I did not make myself clear. I need to exact the
>> rich-formated html as w3m not only does not display the pictures (and
>> viewing the picture files individually lost their position related to
>> text, either), but also hide some links if I need to click the button
>> in the page.
>
> You understand that opening complete HTML messages with images
> linked from remote servers and also clicking on links without
> knowing where they may take you, is potentially unsafe?

Yes, but in corporate environment (at least where I work) you often
get such e-mails.  Some of them are important, some are not but you
have to have a chance to follow important ones.  That being said, I
use viewhtmlmail.py for opening such e-mails;
https://github.com/tampakrap/bin/blob/master/viewhtmlmail.py.  I have
the following line in my ~/.muttrc:

macro  pager    "~/bin/viewhtmlmail.py\n" "View HTML in 
browser"

-- 
Arkadiusz Drabczyk <arkadi...@drabczyk.org>



Re: search for message id with $1

2015-11-02 Thread Arkadiusz Drabczyk
On 2015-11-01, Xu Wang <xuwang...@gmail.com> wrote:
> Hello,
>
> I am frequently using ~iMSGID to search for a message ID matching
> MSGID. However, if MSG contains '$1' then that does not work. Funnily,
> if it contains $abc then it is not a problem. I have tried escapes for
> '$' but it is not working.

Hi,

This is working for me on Linux:

~i '\$1'

The key is to put an entire expression in single quotes as by default
$ is used to expand variables.  The following fragments of man muttrc
mention this:

"Single quotes ("'") and double quotes (""") can be used to quote
strings which contain spaces or other special characters.  The
difference between the two types of quotes is similar to that of many
popular shell programs, namely that a single quote is used to specify
a literal string (one that is not interpreted for shell variables or
quoting with a backslash [see next paragraph]), while double quotes
indicate a string which should be evaluated.  For example, backticks
are evaluated inside of double quotes, but not single quotes.
(..)
UNIX environment variables can be accessed like the way it is done in
shells like sh and bash: Prepend the name of the variable by a dollar
("$") sign."

BTW,

~i $abc

doesn't work for me, I get `Empty expression',
~i \$abc
and
~i '$abc'
return no results,
~i '\$abc'
works correctly.

If I start mutt like this:

$ abc=abc mutt

then the following works for me because abc variable is expanded

~i $abc

-- 
Arkadiusz Drabczyk <arkadi...@drabczyk.org>