* [patch] alist option for add-log-mailing-address
@ 2007-03-28 17:47 Bradley M. Kuhn
2007-03-28 21:03 ` Thien-Thi Nguyen
0 siblings, 1 reply; 2+ messages in thread
From: Bradley M. Kuhn @ 2007-03-28 17:47 UTC (permalink / raw)
To: bug-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 996 bytes --]
Attached please find a patch that adds a feature to add-log.el. I often
want to chose which email address I use for a changelog entry based on
what directory I am working in.
I've added a feature allowing the add-log-mailing-address to be an alist,
which is a list of regular expressions and addresses to use for those
regular expressions.
The patch is cvs diff'ed against the CVS head.
It's been many many years since I gave a patch to Emacs, so I don't know
the proper procedure these days, I hope sending it to this address is
right.
BTW, I am (obviously) quite familiar with FSF's copyright assignment
process, but I don't know the Emacs' team particular procedure for when
they want copyright assignments for a given patch. I am of course willing
to assign past and future changes and to get an employer disclaimer. Let
me know if I should contact <copyright@fsf.org> directly about that.
Finally, let me know if you like the patch or would like me to rewrite it
a bit differently!
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: add-log-alist.patch --]
[-- Type: text/x-patch, Size: 3434 bytes --]
Index: lisp/ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.10886
diff -u -r1.10886 ChangeLog
--- lisp/ChangeLog 28 Mar 2007 13:24:21 -0000 1.10886
+++ lisp/ChangeLog 28 Mar 2007 17:41:25 -0000
@@ -1,3 +1,10 @@
+2007-03-28 Bradley M. Kuhn <bkuhn@softwarefreedom.org>
+
+ * add-log.el (add-log-mailing-address): Added alist option. Made
+ tags more specific.
+ (add-change-log-entry): Added code to handle alist setting on
+ add-log-mailing-address.
+
2007-03-28 Richard Stallman <rms@gnu.org>
* emacs-lisp/edebug.el (edebug-display): Don't go to
Index: lisp/add-log.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/add-log.el,v
retrieving revision 1.184
diff -u -r1.184 add-log.el
--- lisp/add-log.el 27 Jan 2007 19:53:25 -0000 1.184
+++ lisp/add-log.el 28 Mar 2007 17:41:25 -0000
@@ -72,13 +72,23 @@
;;;###autoload
(defcustom add-log-mailing-address nil
"Email addresses of user, for inclusion in ChangeLog headers.
-This defaults to the value of `user-mail-address'. In addition to
-being a simple string, this value can also be a list. All elements
-will be recognized as referring to the same user; when creating a new
-ChangeLog entry, one element will be chosen at random."
+This defaults to the value of `user-mail-address'. This value
+can be a simple string; setting it as such will always use that
+string in ChangeLog headers. If the value is instead a list of
+strings, when creating a new ChangeLog entry, one element will be
+chosen at random. If the value is an alist, the keys will be
+considered regular expressions compared against the
+`buffer-file-name' of the ChangeLog file, and the values will be
+email address used when the expression matches. If you set the
+value to an alist, but no regular expressions match the
+`buffer-file-name' of the ChangeLog, `user-mail-address' is used
+instead."
:type '(choice (const :tag "Default" nil)
- (string :tag "String")
- (repeat :tag "List of Strings" string))
+ (string :tag "Mailing Address")
+ (repeat :tag "List of Mailing Addresses" string)
+ (alist :key-type (string :tag "Regular Expression")
+ :value-type (string :tag "Mailing address"))
+ )
:group 'change-log)
(defcustom add-log-time-format 'add-log-iso8601-time-string
@@ -553,7 +563,16 @@
" " full-name
" <" addr ">"))
(if (consp mailing-address)
- mailing-address
+ (if (consp (car mailing-address)) ; it's an alist
+ (let ( (changelog-buffer (buffer-file-name))
+ (preferred-addr user-mail-address) )
+ (mapc (lambda (regex-email-pair)
+ (if (string-match
+ (car regex-email-pair) changelog-buffer)
+ (setq preferred-addr (cdr regex-email-pair))))
+ add-log-mailing-address)
+ (list preferred-addr))
+ mailing-address)
(list mailing-address)))))
(if (and (not add-log-always-start-new-record)
(let ((hit nil))
[-- Attachment #3: Type: text/plain, Size: 18 bytes --]
--
-- bkuhn
[-- Attachment #4: Type: text/plain, Size: 149 bytes --]
_______________________________________________
bug-gnu-emacs mailing list
bug-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [patch] alist option for add-log-mailing-address
2007-03-28 17:47 [patch] alist option for add-log-mailing-address Bradley M. Kuhn
@ 2007-03-28 21:03 ` Thien-Thi Nguyen
0 siblings, 0 replies; 2+ messages in thread
From: Thien-Thi Nguyen @ 2007-03-28 21:03 UTC (permalink / raw)
To: Bradley M. Kuhn; +Cc: bug-gnu-emacs
() "Bradley M. Kuhn" <bkuhn@softwarefreedom.org>
() Wed, 28 Mar 2007 13:47:31 -0400
Finally, let me know if you like the patch or would like me to rewrite it
a bit differently!
+ * add-log.el (add-log-mailing-address): Added alist option. Made
+ tags more specific.
+ (add-change-log-entry): Added code to handle alist setting on
+ add-log-mailing-address.
s/Added/Add;s/Made/Make;
context diff preferred.
+This defaults to the value of `user-mail-address'. This value
+can be a simple string; setting it as such will always use that
+string in ChangeLog headers. If the value is instead a list of
+strings, when creating a new ChangeLog entry, one element will be
+chosen at random. If the value is an alist, the keys will be
+considered regular expressions compared against the
+`buffer-file-name' of the ChangeLog file, and the values will be
+email address used when the expression matches. If you set the
+value to an alist, but no regular expressions match the
+`buffer-file-name' of the ChangeLog, `user-mail-address' is used
+instead."
i would move this documentation into the `add-change-log-entry'
docstring, including suitable cross references. also, i would
restructure "foo will do bar" to be "foo bars" and factor "list of
elements where each element can be" idiom towards the front. also, i
would not use "you", prefering to take `add-change-log-entry' pov.
(if (consp mailing-address)
- mailing-address
+ (if (consp (car mailing-address)) ; it's an alist
+ (let ( (changelog-buffer (buffer-file-name))
+ (preferred-addr user-mail-address) )
+ (mapc (lambda (regex-email-pair)
+ (if (string-match
+ (car regex-email-pair) changelog-buffer)
+ (setq preferred-addr (cdr regex-email-pair))))
+ add-log-mailing-address)
+ (list preferred-addr))
+ mailing-address)
IMHO, a `cond' expression is clearer than a nested-`if' here. also,
extra space between parens is disturbing...
thi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-03-28 21:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-28 17:47 [patch] alist option for add-log-mailing-address Bradley M. Kuhn
2007-03-28 21:03 ` Thien-Thi Nguyen
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.