From: "Peter Münster" <pmlists@free.fr>
To: info-gnus-english@gnu.org
Subject: Re: Posting styles, identities... and my stupdity
Date: Wed, 01 Oct 2014 22:48:55 +0200 [thread overview]
Message-ID: <87iok3cy88.fsf@micropit.roche-blanche.homenet.org> (raw)
In-Reply-To: <87wq8kz3fh.fsf@gmail.com>
On Wed, Oct 01 2014, Igor Sosa Mayor wrote:
> And yes: there are some cases in which I want to change the identity on
> the fly.
Perhaps the following code snippets could help (it's about using "roles"
and cycling signatures):
--8<---------------cut here---------------start------------->8---
(defvar pm/role-history nil
"History list for roles.")
(defvar pm/role "private")
(make-variable-buffer-local 'pm/role)
(defvar pm/sig-level 0)
(make-variable-buffer-local 'pm/sig-level)
(defun pm/addr->role (address)
(cl-loop for item in pm/roles
when (string-equal (plist-get item :address) address)
return (plist-get item :id)))
(defun pm/role->addr (role)
(cl-loop for item in pm/roles
when (string-equal (plist-get item :id) role)
return (plist-get item :address)))
(defun pm/update-role ()
"Check current buffer and update pm/role accordingly."
(let* ((address (mail-strip-quoted-names
(message-fetch-field "From")))
(role (pm/addr->role address)))
(when role (setq pm/role role))))
(defun pm/phone ()
(cl-case (intern pm/language)
('fr "Tél.: 01 23 45 67 89")
(t "Tel.: +33/0 123 456 789")))
(defun pm/address (prefix)
(let ((address
(cl-case (intern pm/role)
('private '("My Street" "12345 My Town"))
('company '("My Company" "My Street" "12345 My Town"))
('otherrole '("ABC" "My Street" "12345 My Town"))
('yetanotherrole '("XYZ" "My Street" "12345 My Town")))))
(setq address (append address
(cl-case (intern pm/language)
('en '("France"))
('de '("Frankreich")))))
(cl-loop for l in address concat prefix concat l concat "\n")))
(defun pm/make-signature ()
"Check role, lang and level."
(cl-case pm/sig-level
(0 nil)
(1 " Peter")
(2 " Peter Münster")
(3 (concat " Peter Münster\n " (pm/phone)))
(4 (concat " Peter Münster\n"
(pm/address " ")
" " (pm/phone)))
(t
(setq pm/sig-level 0)
(pm/make-signature))))
(defun pm/cycle-sigs ()
(interactive)
(save-excursion
(when (message-goto-signature)
(forward-line -1)
(delete-region (1- (point)) (point-max)))
(incf pm/sig-level)
(message-insert-signature)))
(defun pm/ask-role ()
(let ((new-role
(completing-read
(format "Role [%s]: " pm/role)
(mapcar (lambda (x) (plist-get x :id)) pm/roles)
nil t nil 'pm/role-history pm/role)))
(when (not (string-equal pm/role new-role))
(setq pm/role new-role)
(message-replace-header
"From"
(message-make-from nil (pm/role->addr pm/role))))))
(defun pm/message-setup ()
(cond (gnus-article-reply
(pm/update-role)
(pm/update-lang)
(incf pm/sig-level)
(save-excursion
(message-insert-signature)))
((save-excursion (message-goto-signature))
(pm/update-role)
(pm/update-lang))
(t
(pm/ask-role)
(let ((message-signature-insert-empty-line t))
(incf pm/sig-level)
(save-excursion
(message-insert-signature))))))
--8<---------------cut here---------------end--------------->8---
HTH,
--
Peter
_______________________________________________
info-gnus-english mailing list
info-gnus-english@gnu.org
https://lists.gnu.org/mailman/listinfo/info-gnus-english
next prev parent reply other threads:[~2014-10-01 20:48 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.10045.1412071233.1147.info-gnus-english@gnu.org>
2014-09-30 21:23 ` Emanuel Berg
2014-09-30 23:40 ` Rasmus
[not found] ` <mailman.10123.1412120483.1147.info-gnus-english@gnu.org>
2014-09-30 23:51 ` Emanuel Berg
2014-10-01 5:47 ` Adam Sjøgren
[not found] ` <mailman.10135.1412142496.1147.info-gnus-english@gnu.org>
2014-10-02 0:17 ` Emanuel Berg
2014-10-02 14:27 ` Adam Sjøgren
[not found] ` <mailman.10278.1412260103.1147.info-gnus-english@gnu.org>
2014-10-03 0:59 ` Emanuel Berg
2014-10-12 16:57 ` Adam Sjøgren
[not found] ` <mailman.11046.1413133054.1147.info-gnus-english@gnu.org>
2014-10-12 18:36 ` Emanuel Berg
2014-10-12 19:05 ` Adam Sjøgren
2014-10-01 6:53 ` Igor Sosa Mayor
2014-10-01 20:48 ` Peter Münster [this message]
2014-10-03 12:21 ` Igor Sosa Mayor
[not found] ` <mailman.10136.1412146351.1147.info-gnus-english@gnu.org>
2014-10-02 0:06 ` Emanuel Berg
2014-09-30 9:51 Igor Sosa Mayor
2014-10-03 15:06 ` Igor Sosa Mayor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87iok3cy88.fsf@micropit.roche-blanche.homenet.org \
--to=pmlists@free.fr \
--cc=info-gnus-english@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).