bug-gnu-emacs
[Top][All Lists]
Advanced

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

[patch] alist option for add-log-mailing-address


From: Bradley M. Kuhn
Subject: [patch] alist option for add-log-mailing-address
Date: Wed, 28 Mar 2007 13:47:31 -0400
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.91 (gnu/linux)

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!
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))
-- 

   -- bkuhn

reply via email to

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