[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/subed 8120fb429f 04/22: Use defalias for non-interactive f
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/subed 8120fb429f 04/22: Use defalias for non-interactive functions |
Date: |
Tue, 1 Feb 2022 14:05:33 -0500 (EST) |
branch: elpa/subed
commit 8120fb429fd535f08eff77817760b7998ffaa039
Author: Sacha Chua <sacha@sachachua.com>
Commit: Sacha Chua <sacha@sachachua.com>
Use defalias for non-interactive functions
* subed/subed-common.el (subed-define-generic-function): Use defalias
for non-interactive functions to simplify looking up a function.
---
subed/subed-common.el | 43 ++++++++++++++++++++++++++-----------------
1 file changed, 26 insertions(+), 17 deletions(-)
diff --git a/subed/subed-common.el b/subed/subed-common.el
index bfc3a46f0b..baaf723651 100644
--- a/subed/subed-common.el
+++ b/subed/subed-common.el
@@ -39,25 +39,34 @@
(defvar-local subed--regexp-separator nil "Regexp separating subtitles.")
(defvar-local subed--regexp-timestamp nil "Regexp matching timestamps.")
-(defmacro subed-define-generic-function (name args doc &rest body)
+(defmacro subed-define-generic-function (name args &rest body)
"Declare an object method and provide the old way of calling it."
(declare (indent 2))
- `(progn
- (cl-defgeneric ,(intern (concat "subed--" (symbol-name name)))
- ,args
- ,doc
- ,@(if (eq (caar body) 'interactive)
- (cdr body)
- body))
- (defun ,(intern (concat "subed-" (symbol-name name))) ,args
- ,doc
- ,(if (eq (caar body) 'interactive)
- (car body))
- (,(intern (concat "subed--" (symbol-name name)))
- ,@(delq nil (mapcar (lambda (a)
- (unless (string-match "^&" (symbol-name a))
- a))
- args))))))
+ (let (is-interactive
+ doc)
+ (when (stringp (car body))
+ (setq doc (pop body)))
+ (setq is-interactive (eq (caar body) 'interactive))
+ `(progn
+ (cl-defgeneric ,(intern (concat "subed--" (symbol-name name)))
+ ,args
+ ,doc
+ ,@(if is-interactive
+ (cdr body)
+ body))
+ ,(if is-interactive
+ `(defun ,(intern (concat "subed-" (symbol-name name))) ,args
+ ,(concat doc "\n\nThis function calls the generic function `"
+ (concat "subed--" (symbol-name name)) "' for the
actual implementation.")
+ ,(car body)
+ (,(intern (concat "subed--" (symbol-name name)))
+ ,@(delq nil (mapcar (lambda (a)
+ (unless (string-match "^&" (symbol-name
a))
+ a))
+ args))))
+ `(defalias (quote ,(intern (concat "subed-" (symbol-name name))))
+ (quote ,(intern (concat "subed--" (symbol-name name))))
+ ,doc)))))
(subed-define-generic-function timestamp-to-msecs (time-string)
"Find timestamp pattern in TIME-STRING and convert it to milliseconds.
- [nongnu] elpa/subed updated (f69c3e09f2 -> 3e99c6cb6f), ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed 8120fb429f 04/22: Use defalias for non-interactive functions,
ELPA Syncer <=
- [nongnu] elpa/subed 7a3eed2acf 14/22: New function subed-subtitle-list returns list, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed 8a9b219706 01/22: Create derived modes for the different types of subtitles., ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed 0264eb4ef1 08/22: Bump version to 0.1.0 and add missing undercover-init.el, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed a0d633d7ac 09/22: Fix spaces in Makefile, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed 4cab871f58 03/22: Add undercover support for coverage testing, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed 3c7ac78393 12/22: Define jump-to-subtitle-text-at-msecs, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed f1f8e2ad56 13/22: Bugfixes to make VTT editing work, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed d6b46496f8 11/22: Fix save hook name, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed e1b24bff31 05/22: Remove duplicate functions, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed 5c4ac92ddc 07/22: Add NEWS.org file, ELPA Syncer, 2022/02/01