[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/why-this 82397f6a45 03/59: Add support for nick names
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/why-this 82397f6a45 03/59: Add support for nick names |
Date: |
Sun, 27 Nov 2022 16:02:46 -0500 (EST) |
branch: elpa/why-this
commit 82397f6a45bfddbb2e29e7cb82291d8919ade426
Author: Akib Azmain Turja <akib@disroot.org>
Commit: Akib Azmain Turja <akib@disroot.org>
Add support for nick names
---
why-this.el | 49 ++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 40 insertions(+), 9 deletions(-)
diff --git a/why-this.el b/why-this.el
index 9502f98315..86287579e8 100644
--- a/why-this.el
+++ b/why-this.el
@@ -30,16 +30,35 @@
(defcustom why-this-backends nil
"List of enabled backends."
- :type '(repeat function)
+ :type '(repeat (function :tag "Backend"))
:group 'why-this)
-(defcustom why-this-message-format " %a, %T * %i"
+(defcustom why-this-message-format " %A, %T * %i"
"Format string for formatting message.
-It can also be a function to do the formatting itself."
- :type '(choice string function)
+All characters are written as is, except certain constructs which are
+substituted by text describing the author, time or message:
+
+ %a Author name, as returned by the backend.
+ %A Author nick name.
+ %T Time when last changed, formatted as \"%d %B %Y\" (see
+ `format-time-string').
+ %i Message.
+
+The value can also be a function to do the formatting itself."
+ :type '(choice (string :tag "Format string")
+ (function :tag "Formatter function"))
:group 'why-this)
+(defcustom why-this-nick-name-alist nil
+ "Alist of nick name of authors.
+
+Each element is of the following form: (NICK . AUTHORS), where NICK is the
+nick name and AUTHORS is list of the name of authors corresponding to
+NICK."
+ :type '(repeat (cons (string :tag "Nick")
+ (repeat (string :tag "Author")))))
+
(defcustom why-this-idle-delay 0.5
"Idle delay for rendering."
:type 'number
@@ -61,21 +80,33 @@ It can also be a function to do the formatting itself."
(defvar-local why-this--backend nil
"Backend for current buffer.")
+(defun why-this-nick-name (author)
+ "Return nick name of AUTHOR."
+ (catch 'name
+ (dolist (nick why-this-nick-name-alist)
+ (when (member author (cdr nick))
+ (throw 'name (car nick))))
+ author))
+
(defun why-this-format-data (data)
"Format DATA."
(if (functionp why-this-message-format)
(funcall why-this-message-format data)
- (let ((alist `((?a . ,(plist-get data :author))
- (?T . ,(format-time-string "%d %B %Y"
- (plist-get data :time)))
- (?i . ,(plist-get data :message)))))
+ (let ((alist `((?a . (plist-get data :author))
+ (?A . (why-this-nick-name (plist-get data :author)))
+ (?T . (format-time-string "%d %B %Y"
+ (plist-get data :time)))
+ (?i . (plist-get data :message)))))
(replace-regexp-in-string
"%."
(lambda (str)
(let ((char (aref str 1)))
(if (eq char ?%)
"%"
- (or (cdr (assoc char alist)) str))))
+ (let ((sexp (cdr (assoc char alist))))
+ (if sexp
+ (eval sexp `((data . ,data)))
+ str)))))
why-this-message-format t t))))
(defvar why-this-mode)
- [nongnu] branch elpa/why-this created (now c914584833), ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this e89aabc765 02/59: (provide 'why-this), ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 961f84afc6 08/59: Fixed typo in the value of why-this-echo-format, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 2f714a9820 05/59: Add Git backend, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 82397f6a45 03/59: Add support for nick names,
ELPA Syncer <=
- [nongnu] elpa/why-this 3c252a6621 07/59: Allow showing last change manually, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this f62dccdd90 10/59: Add annonation support, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 340194b6d2 24/59: Calculate background for message, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 167397e7ad 25/59: Fix copyright year, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 9c0daa799c 28/59: Rename a variable, change backend API and update docs, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 53b2b803f0 22/59: Update commentary, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this d47f547250 39/59: Allow customization of executable paths, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 7f1ae28159 36/59: Fix Git backend, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 9f656b59dd 33/59: Change package summary, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 3497115c2b 35/59: Don't store unnecessary data, ELPA Syncer, 2022/11/27