all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Automatic inserting of M-x spook to then mail headers when emacs is only used as editor
@ 2011-01-17  5:42 DevZero
  2011-01-19  4:55 ` Kevin Rodgers
  0 siblings, 1 reply; 2+ messages in thread
From: DevZero @ 2011-01-17  5:42 UTC (permalink / raw)
  To: help-gnu-emacs

hello everybody

i like to insert the M-x spook into the mail headers to every outgoing message
but as i'm not using gnus but mutt as my mua this seemed to be a bit tricky,
but i finally managed it (learning quite some elisp on the way). Now i would
like to hear some comments/improvements from the gurus here if this is the
right way or something to avoid (and of course to share this maybe even useful
code snipped). Especially the inserting of the spook (with-temp-buffer) looks
suspicious to me - but i did not find any other way to do it...

first the function:

(defun replace-spook ()
  "Insert nsa-spook."
  (interactive "r")
  (save-excursion
    (goto-line 7)
    (let* ((spook (with-temp-buffer (spook) (buffer-string)))
	   (output (replace-regexp-in-string "\n" "" spook)))
      (insert (concat "Spook: " output "\n")))
    )
  )

then i set up emacs to start up mail-mode when a mutt-temp-file is opened:

(setq auto-mode-alist (cons '("/tmp/mutt-" . mail-mode) auto-mode-alist))
 
and finally the replacing

(add-hook 'mail-mode-hook 'replace-spook)

Improvements in which i failed up to now:
* add a search to insert spook after a special header (and skip it if not
  found) and not just hardcoded after line 7
* convince emacs that the buffer has not changed right after the mail-mode-hook
  has been executed (even if it has because of the new header - but that change
  is irrelevant at that time)

Greetz!
dz  
-- 
Apples  have  meant  trouble  since  eden.



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Automatic inserting of M-x spook to then mail headers when emacs is only used as editor
  2011-01-17  5:42 Automatic inserting of M-x spook to then mail headers when emacs is only used as editor DevZero
@ 2011-01-19  4:55 ` Kevin Rodgers
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Rodgers @ 2011-01-19  4:55 UTC (permalink / raw)
  To: help-gnu-emacs

On 1/16/11 10:42 PM, DevZero wrote:
> Improvements in which i failed up to now:
> * add a search to insert spook after a special header (and skip it if not
>    found) and not just hardcoded after line 7

C-h f mail-position-on-field

> * convince emacs that the buffer has not changed right after the mail-mode-hook
>    has been executed (even if it has because of the new header - but that change
>    is irrelevant at that time)

C-h f set-buffer-modified-p

-- 
Kevin Rodgers
Denver, Colorado, USA




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-01-19  4:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-17  5:42 Automatic inserting of M-x spook to then mail headers when emacs is only used as editor DevZero
2011-01-19  4:55 ` Kevin Rodgers

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.