help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

moving text from one buffer to another


From: drain
Subject: moving text from one buffer to another
Date: Fri, 18 Jan 2013 00:39:59 -0800 (PST)

I'd like to know how I could structure this function more elegantly. It
was designed to:

(1) insert the e-mail address and topic of a mail recipient.
(2) insert the body of a message written in my org-mode mail archive.

This is what I have thus far:

(defun custom-compose-mail ()
  (interactive)
  (let ((contact (completing-read 
                  "To: "
                  '(("Foo1" 1) ("Foo2" 2) ("Foo3" 3)
                    ("Foo4" 4) ("Foo5" 5) ("Foo6" 6)
                    ("Foo7" 7) ("Foo8" 8))
                  nil t )))
    (let* ((names '(("Foo1" "foo.bar@aol.com")
                    ("Foo2" "foo2@gmail.com")
                    ("Foo3" "foo3@gmail.com")
                    ("Foo4" "foo4@gmail.com")
                    ("Foo5" "foo5@yahoo.com")
                    ("Foo6" "foo6@gmail.com")
                    ("Foo7" "foo7@yahoo.com")
                    ("Foo8" "foo8@aol.com"))))
                (setq contact (second (assoc contact names))
                      topic (read-from-minibuffer "Topic: "))
                (compose-mail contact topic)
                (end-of-buffer)
                (newline 1)
                (insert (current-kill 2)))))

When I am done writing a message, I copy it with kill-ring-save. Then a
call the above function interactively with a shortcut. It prompts me for
the name and topic, inserts them into the appropriate fields, then pastes
the copied text into the message body.

I'm comfortable with most of the code, but the way I copy text from the org
archive seems somewhat messy. After a bunch of Google searches,
"current-kill" was the first function that helped me reach my functionality
goals. But it was hardly a learned choice.



--
View this message in context: 
http://emacs.1067599.n5.nabble.com/moving-text-from-one-buffer-to-another-tp275785.html
Sent from the Emacs - Help mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]