[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: An easy defun
Re: An easy defun
Sun, 07 Oct 2007 20:53:53 -0400
Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux)
Sven Bretfeld <address@hidden> wrote:
> I want to define a funtion called start-mutt, which does:
> - open an ansi term
> - rename it to *Mutt*
> - start Mutt within the ansi-term
> - if the ansi-term already exists and has Mutt running, switch to that
> Can anybody help me?
Perhaps something like this? Substitute the correct path to your mutt in the
(defun start-mutt (&optional bg)
"Start an ansi-term running the mutt mailreader, in a buffer called \"*Mutt*\"
Given an argument (assuming the buffer called \"*Mutt*\" doesn't already exist),
will start in the background"
(if (get-buffer "*Mutt*")
(let ((buf (current-buffer)))
(ansi-term "/usr/bin/mutt" "Mutt")
(if bg (switch-to-buffer buf)))))
Some useful information to know in the future:
- Press "C-h f ansi-term" to read the documentation for the function
ansi-term (or substitute some other function you're curious about), a
function I had never used previously but which I found out takes two
arguments: the program to run and the name of the buffer, to which it
will pre-pend and append asterices.
- Most of the time you won't use (switch-to-buffer) in elisp programs (see
its documentation, as above).
- (interactive) can be called with a wide array of arguments; see its
documentation for more information.
- Consider checking out the Emacs Lisp Intro., which if you're running a
recent emacs I'm pretty sure should be included.
- Try to go through this code and understand it, one step at a time.
Anyway, I hope that's helpful.
"The History of every major Galactic Civilization tends to pass through
three distinct and recognizable phases, those of Survival, Inquiry and
Sophistication, otherwise known as the How, Why and Where phases.
"For instance, the first phase is characterized by the question 'How can
we eat?' the second by the question 'Why do we eat?' and the third by the
question 'Where shall we have lunch?'"
-- Hitchhiker's Guide to the Galaxy
Description: PGP signature
- An easy defun, Sven Bretfeld, 2007/10/07
- Re: An easy defun,
Amy Templeton <=