[Top][All Lists]

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

Re: Gnus: How to easily change "From:" from the default to a second acco

From: Teemu Likonen
Subject: Re: Gnus: How to easily change "From:" from the default to a second account's address?
Date: Sat, 03 Dec 2011 21:17:37 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

* 2011-11-23T17:24:49+01:00 * Marius Hofert wrote:

> If I want to create a new message with "m", it shows my default email
> address in "From:" [...] every once in a while I would like to hav
> "From:" instead of "From:". So
> far, I deleted the entry and typed in my gmail account's address. Is
> there a simpler way?

Here's my solution for (1) setting up Gnus for several mail addresses
and (2) cycling them easily in a message-mode buffer (using F9 key).

    (setq user-full-name "User Name")

    (defvar my-email-addresses

    ;; Set important variables

    (let ((addr my-email-addresses))
       user-mail-address (car addr)
       message-alternative-emails (regexp-opt (cdr addr) 'words)
       message-dont-reply-to-names (regexp-opt addr 'words)
       gnus-ignored-from-addresses message-dont-reply-to-names))

    ;; The cycling functionality
    (add-hook 'message-mode-hook 'my-message-mode-hook)

    (defun my-message-mode-hook ()
      (define-key message-mode-map (kbd "<f9>")

    (defun my-message-toggle-from ()
      (require 'mail-extr)
      (let* ((current (nth 1 (mail-extract-address-components
                              (message-fetch-field "From"))))
             (next (or (nth 1 (member current my-email-addresses))
                       (nth 0 my-email-addresses))))

        (when (and current next)
                (when (re-search-forward "^From: " nil t)
                  (delete-region (point-min) (point-max))
                  (insert "From: " user-full-name " <" next ">\n"))))))))

reply via email to

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