branch: elpa/rpm-spec-mode
commit e87fc081c1608e9436a7d0d61c874933a314047d
Author: Björn Bidar <bjorn.bi...@thaodan.de>
Commit: Björn Bidar <bjorn.bi...@thaodan.de>

    Clarify the defaults of the user-name and mail settings
    
    The documentation string was wrong after my recent change and the
    meaning of the settings wasn't exactly clear.
    Now that the defaults are explicitly set from nil to the actual value
    used if not set otherwise.
    
    Also make it possible for both settings to be a function.
---
 rpm-spec-mode.el | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/rpm-spec-mode.el b/rpm-spec-mode.el
index 0608ae62ad..8618982798 100644
--- a/rpm-spec-mode.el
+++ b/rpm-spec-mode.el
@@ -184,19 +184,17 @@ the package."
   :type 'boolean
   :group 'rpm-spec)
 
-(defcustom rpm-spec-user-full-name nil
-  "*Full name of the user.
-This is used in the change log and the Packager tag.  It defaults to the
-value returned by function `user-full-name'."
-  :type '(choice (const :tag "Use `user-full-name'" nil)
-                 string)
+(defcustom rpm-spec-user-full-name user-full-name
+  "Full name of the user in the change log and Packager tag.
+Can be either a string or a function."
+  :type '(choice function
+                                string)
   :group 'rpm-spec)
 
-(defcustom rpm-spec-user-mail-address nil
-  "*Email address of the user.
-This is used in the change log and the Packager tag.  It defaults to the
-value returned by function `user-mail-address'."
-  :type '(choice (const :tag "Use `user-mail-address'" nil)
+(defcustom rpm-spec-user-mail-address user-mail-address
+  "Email address of the user used in the change log and the Packager tag.
+Can be either a string or a function."
+  :type '(choice function
                  string)
   :group 'rpm-spec)
 
@@ -830,9 +828,12 @@ If `rpm-change-log-uses-utc' is nil, \"today\" means the 
local time zone."
 (defun rpm-goto-add-change-log-header ()
   "Find change log and add header (if needed) for today."
     (rpm-goto-section "changelog")
-    (let* ((address (or rpm-spec-user-mail-address
-                        user-mail-address))
-           (fullname (or rpm-spec-user-full-name (user-full-name)))
+    (let* ((address (if (functionp rpm-spec-user-mail-address)
+                        (funcall rpm-spec-user-mail-address)
+                                         rpm-spec-user-mail-address))
+           (fullname (if (functionp rpm-spec-user-full-name)
+                                                (funcall 
rpm-spec-user-full-name)
+                                          rpm-spec-user-full-name))
            (system-time-locale "C")
            (string (concat "* " (rpm-change-log-date-string) " "
                            fullname " <" address ">"
@@ -1041,9 +1042,12 @@ WHAT is the tag used."
   "Insert Packager tag."
   (beginning-of-line)
   (insert (format "Packager: %s <%s>\n"
-                  (or rpm-spec-user-full-name (user-full-name))
-                  (or rpm-spec-user-mail-address
-                      user-mail-address))))
+                  (if (functionp rpm-spec-user-full-name)
+                                         (funcall rpm-spec-user-full-name)
+                                       rpm-spec-user-full-name)
+                  (if (functionp rpm-spec-user-mail-address)
+                      (funcall rpm-spec-user-mail-address)
+                                       rpm-spec-user-mail-address))))
 
 (defun rpm-change-packager ()
   "Update Packager tag."

Reply via email to