* A valid example of kbd macros - take that, Emanuel! ;-)
@ 2015-07-28 8:42 Marcin Borkowski
2015-07-29 2:04 ` Emanuel Berg
0 siblings, 1 reply; 4+ messages in thread
From: Marcin Borkowski @ 2015-07-28 8:42 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
Hi all,
hi Emanuel!
The last exchange about F3 and macros reminded me that you wanted an
example of valid kbd macro usage, not easily accomplished by writing
Elisp. So here you are. Some time ago I had to send 15 emails to 15
different people. (You can imagine 150 instead of 15.) I had their
addresses in an Org table, and in another column I had some data which
should be present in the emails. (See
https://en.wikipedia.org/wiki/Mail_merge.) You could find the Elisp
functions related to Org and mu4e (or Gnus, or whatever you use), but it
was *a lot* faster to record a kbd macro copying some fragments from the
table, starting mu4e, inserting the letter template, yanking the data in
right positions and stopping for me to review the email (I had to
manually change a few of them). It took me 5 minutes (including
preparing the template and recording the macro!) to send
(semi-)personalized messages to 15 people. It would be even faster if
I didn't want to review each email and edit some of them, of course.
Take that! :-)
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: A valid example of kbd macros - take that, Emanuel! ;-)
2015-07-28 8:42 A valid example of kbd macros - take that, Emanuel! ;-) Marcin Borkowski
@ 2015-07-29 2:04 ` Emanuel Berg
2015-07-29 7:12 ` Marcin Borkowski
0 siblings, 1 reply; 4+ messages in thread
From: Emanuel Berg @ 2015-07-29 2:04 UTC (permalink / raw)
To: help-gnu-emacs
Marcin Borkowski <mbork@mbork.pl> writes:
> The last exchange ... reminded me that you wanted an
> example of valid kbd macro usage, not easily
> accomplished by writing Elisp. ... Some time ago
> I had to send 15 emails to 15 different people. (You
> can imagine 150 instead of 15.) ... You could find
> the Elisp functions related to ... Gnus
You better believe it.
(require 'cl-macs)
(require 'gnus-msg)
(require 'message)
(cl-dolist (to '("Emanuel Berg <embe8573@student.uu.se>"
"Manny <embe8573@student.uu.se>") )
(gnus-post-news 'post "")
(message-goto-to) (insert to)
(message-goto-subject) (insert "Get ready for a surprise")
(message-goto-body) (insert "You are not you. You are me!")
(message-send-and-exit) )
So better luck next time. However, the master is
pleased that you take this so seriously.
:)
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: A valid example of kbd macros - take that, Emanuel! ;-)
2015-07-29 2:04 ` Emanuel Berg
@ 2015-07-29 7:12 ` Marcin Borkowski
2015-07-29 22:34 ` Emanuel Berg
0 siblings, 1 reply; 4+ messages in thread
From: Marcin Borkowski @ 2015-07-29 7:12 UTC (permalink / raw)
To: help-gnu-emacs
On 2015-07-29, at 04:04, Emanuel Berg <embe8573@student.uu.se> wrote:
> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> The last exchange ... reminded me that you wanted an
>> example of valid kbd macro usage, not easily
>> accomplished by writing Elisp. ... Some time ago
>> I had to send 15 emails to 15 different people. (You
>> can imagine 150 instead of 15.) ... You could find
>> the Elisp functions related to ... Gnus
>
> You better believe it.
>
> (require 'cl-macs)
> (require 'gnus-msg)
> (require 'message)
>
> (cl-dolist (to '("Emanuel Berg <embe8573@student.uu.se>"
> "Manny <embe8573@student.uu.se>") )
> (gnus-post-news 'post "")
> (message-goto-to) (insert to)
> (message-goto-subject) (insert "Get ready for a surprise")
> (message-goto-body) (insert "You are not you. You are me!")
> (message-send-and-exit) )
>
> So better luck next time. However, the master is
> pleased that you take this so seriously.
>
> :)
:-) :-) :-)
Well, I /know/ it can be done, obviously. The question is: how much
time does it take to find all these Elisp functions? (Unless you /know/
them already. (And you cheated a bit: I didn't have my data in a Lisp
list, but in an Org table. Next level of function-searching.) And more
importantly: /why/ do it if you don't have to? ("Fun", "learning" and
"this I may need in the future" are legitimiate responses, of course,
but "No need to" is, too.)
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: A valid example of kbd macros - take that, Emanuel! ;-)
2015-07-29 7:12 ` Marcin Borkowski
@ 2015-07-29 22:34 ` Emanuel Berg
0 siblings, 0 replies; 4+ messages in thread
From: Emanuel Berg @ 2015-07-29 22:34 UTC (permalink / raw)
To: help-gnu-emacs
Marcin Borkowski <mbork@mbork.pl> writes:
> Well, I know it can be done, obviously. The question
> is: how much time does it take to find all these
> Elisp functions? (Unless you know them already.)
I always do things, or try to do them, the *right*
way. Sometimes the inferior way is indeed faster.
If you are in a cabin and you need to hit a nail into
a wall, but you don't have a hammer, instead of using
the back side of the ax, I go to the other cabin and
get the hammer. It is more enjoyable, more precise,
and even tho in that particular case the ax solution
would be more quick, in the end the right way (get the
hammer) will be even quicker because then I will
realize I need a hammer in *both* cabins!
Correspondingly, now I have
(require 'gnus-msg)
(require 'cl-macs)
(require 'message)
(defun mail-to-many (to subject body)
(cl-dolist (this-to to)
(gnus-post-news 'post "")
(message-goto-to) (insert this-to)
(message-goto-subject) (insert subject)
(message-goto-body) (insert body)
(message-send-and-exit) ))
so the next time I want it (or someone on this list
wants it) I can use/share it in one second.
And even if I never use or share it again, I may
encounter a situation that is similar - then I'll
bring up the code, be reminded of say those
message-goto's, and I'll be able to solve the
other problem - faster, and better.
So no - I don't focus on speed per se, but still, in
time speed will enter through the back door.
(In this case I actually think using a "To:" header
with commas is the right way to send the same mail to
several persons, but nevermind.)
> (And you cheated a bit: I didn't have my data in
> a Lisp list, but in an Org table. Next level of
> function-searching.)
I don't use Org but if there isn't a way already to
extract data into a list then it is terribly
disorganized despite its name. But I don't think it
is: more likely the data is already in a list!
> And more importantly: /why/ do it if you don't have
> to? ("Fun", "learning" and "this I may need in the
> future" are legitimiate responses, of course, but
> "No need to" is, too.)
What you mention, yes. But also enjoyment, and how to
deal with the outcome, be it good or bad. If I hit the
nail with the ax and the nail bends, or the ax breaks,
I'll be angry and disappointed at myself. If that
happens with the hammer: so what? Even the master
carpenter breaks his tools when they are worn out!
On the other hand, with the ax, say every thing works
perfectly, and then some guys come my way and say this
cabin looks amazing. Then I don't want to look down
the floor knowing I actually used an ax for all the
nails, hoping they won't notice!
With mechanics, cabin work, etc. sometimes the right
tools are too expensive, too big and heavy, lost, or
whatever. But with Emacs and Elisp programming that is
never a problem. So I'm in a real good place to have
this attitude. But even with computers, you have to be
well-organized yourself even tho it is much easier
than in the workshop or forest :)
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-07-29 22:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-28 8:42 A valid example of kbd macros - take that, Emanuel! ;-) Marcin Borkowski
2015-07-29 2:04 ` Emanuel Berg
2015-07-29 7:12 ` Marcin Borkowski
2015-07-29 22:34 ` Emanuel Berg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).