[Top][All Lists]

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

Re: Email in emacs

From: Martin Slouf
Subject: Re: Email in emacs
Date: Wed, 10 Aug 2005 22:24:50 +0200
User-agent: Mutt/1.5.9i

ok, more info on mutt & emacs, as you requested:

the model situation is like this -- you turn on the emacs in X (and it stays so
for the rest of the day) and whenever you edit your mail message in mutt, new
emacs frame is created, you type your message, close the emacs's frame (using
'C-x #') and you are back in mutt.

nice side effect can be (if you set it up), that anytime your EDITOR env
variable is consulted for your preferable editor, emacs frame is created and
you are in your favourite environment :)

to achive this, only a little should be done:

1. edit .muttrc (easy)
2. edit .emacs (harder -- im not a elisp specialist)
3. (optional, for better message editing) install mutt-alias.el and
post-mode.el (easy)

reason you run with emacsclient and you dont launch new emacs process from mutt
directly (ie. setting mutt 'set editor = "emacs"') is that emacs' start up is
slow, if you turn on plenty of features in your .emacs (which is my case)

hope it will be clear.  i would also be thankfull for any comments from anyone
who has set up a better way to do what i describe below.

| 1. .muttrc part |

set editor     = "emacsclient"

| 2. .emacs part (remember, you should be in X session) |

;; this will start the emacs server
;; if you launch another emacs instance, ie. (run 'emacs &' from your terminal
;; more than once), problems can occure (but there is no need to do that)
;; especially i recommend to set EDITOR env variable to 'emacsclient'
;; EDITOR=emacsclient
;; and also (needed in case no emacs is running and so emacsclient cannot be
;; started)

;; this hook is run when emacsclient is launched (ie. buffer is opened using
;; emacsclient)
;; all it does is that it makes a new frame, resizes the frame a bit and raises
;; the frame (i like it this way)
(defun emacsclient-custom()
  "Pouziti v server-visit-hook"
  (if window-system
      (progn (set-frame-height (make-frame) 50)
(add-hook 'server-visit-hook '(lambda() (emacsclient-custom)))

;; this hook is run when emacsclient is closed (ie. buffer is closed)
;; remember to close the buffer with 'C-x #' (see emacs docs for details)
;; this just closes the opened frame
(defun emacsclient-custom2()
  "Pouziti v server-done-hook"
  (if window-system
      (progn (kill-buffer (buffer-name))
(add-hook 'server-done-hook '(lambda() (emacsclient-custom2)))

| 3. optional part -- setting up mutt-alias and post-mode |

download those files (google will help) and place them into your
~/.emacs.d/site-lisp/ for example

than place some init lines into your .emacs (one is shown below)

(add-to-list 'load-path "~/.emacs.d/site-lisp")

(load "post")
(defun post-custom()
  "Pouziti v post-hook"
  (load "mutt-alias")
  (local-set-key "\C-ci" 'mutt-alias-insert)
  (flyspell-mode 0))
(add-hook 'post-mode-hook '(lambda() (post-custom)))
(setq auto-mode-alist (cons '("mutt-" . post-mode) auto-mode-alist))

this code will turn on post-mode in any file which name contains 'mutt-' --
this is a name convention mutt uses, when it creates temporary file under your
/tmp dir when you edit your message, maybe there is a better way how to
identify a mutt buffer; i dont know.

| problems |

i do not know how to write good elisp code; such functions are the most complex
elisp i ever wrote :). 

i use several desktops (6) and my mail redaer (mutt) is on another desktop than
my main emacs buffers and frames, so i rarely run into this problem, but when
several opened emacs' frames are on your desktops and you open the 'emacsclient
buffer' on the same desktop, it is not risen up, instead the pre-existing frame
is risen (the emacsclient-custom does a wrong job :( ) -- dont know how to
handle this. so dont ask me :)

| final comments |

today, i do not use this set up for email editting :))

preferably, i use:

set editor      = "emacs -nw -q -l ~/.emacs_muttrc"

reason is, that this set up is consistent even in ssh session (which i use a
lot), though it is a bit less convenient (no X frame).

as one can see i launch separate emacs process with special init file -- the
emacs start is very fast, thanks to i turn only several fetaures nescessary for
mail edditting.

still my EDITOR variable is set up to 'emacsclient', so in other cases I use

- - - - .emacs_muttrc start
; Time-stamp: < .emacs_muttrc (16:54 5.6.2005) >
; specialni .emacs pro mutt

(add-to-list 'load-path "~/.emacs.d/site-lisp")

(display-time-mode 1)
(column-number-mode 1)
(global-font-lock-mode 1)
(transient-mark-mode 1)
(show-paren-mode 1)
(auto-fill-mode 1)

  ;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 '(fill-column 79)
 '(grep-command "grep -n -d recurse -e \"\" *")
 '(hippie-expand-try-functions-list (quote (try-expand-dabbrev 
try-expand-dabbrev-visible try-expand-dabbrev-all-buffers 
try-expand-dabbrev-from-kill try-complete-file-name-partially 
try-complete-file-name try-expand-whole-kill try-expand-list try-expand-line)))
 '(hippie-expand-verbose t)
 '(time-stamp-active t)
 '(time-stamp-format " %f (%02H:%02M %1d.%1m.%:y) "))

  ;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.

(load "hippie-exp")
(global-unset-key "\M-/")
(global-set-key "\M-/" 'hippie-expand)

(load "post")
(defun post-custom()
  "Pouziti v post-hook"
  (load "mutt-alias")
  (local-set-key "\C-ci" 'mutt-alias-insert)
  (flyspell-mode 0))
(add-hook 'post-mode-hook '(lambda() (post-custom)))
(setq auto-mode-alist (cons '("mutt-" . post-mode) auto-mode-alist))

- - - - .emacs_muttrc end

hope it was helpfull.

i will be happy for comments and any suggestions.

bye, m.

On Tue, Aug 09, 2005 at 07:56:51PM -0400, Rajiv Vyas wrote:
> I am debating between mutt and a an email tool within emacs. Goal is
> eventuall sync it with my gmail account and will be using it to
> send/recieve attachments and for user groups.
> Any suggestions?
> Rajiv
> _______________________________________________
> Help-gnu-emacs mailing list

reply via email to

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