branch: externals/compat commit 51417c4b968ba30d9633c389d425eeb4715698cf Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
Remove :realname --- compat-26.el | 12 +++--------- compat-29.el | 3 +-- compat-macs.el | 53 +++++++++++++++++++---------------------------------- 3 files changed, 23 insertions(+), 45 deletions(-) diff --git a/compat-26.el b/compat-26.el index bffee6473b..c0b6e42aa7 100644 --- a/compat-26.el +++ b/compat-26.el @@ -35,7 +35,6 @@ Equality is defined by the function TESTFN, defaulting to element and KEY. With no optional argument, the function behaves just like `assoc'." :explicit t - :realname compat--internal-assoc (if testfn (catch 'found (dolist (ent alist) @@ -89,7 +88,7 @@ from the absolute start of the buffer, disregarding the narrowing." (lambda (do key alist &optional default remove testfn) (macroexp-let2 macroexp-copyable-p k key (gv-letplace (getter setter) alist - (macroexp-let2 nil p `(compat--internal-assoc ,k ,getter ,testfn) + (macroexp-let2 nil p `(compat--assoc ,k ,getter ,testfn) (funcall do (if (null default) `(cdr ,p) `(if ,p (cdr ,p) ,default)) (lambda (v) @@ -118,7 +117,6 @@ from the absolute start of the buffer, disregarding the narrowing." "Trim STRING of leading string matching REGEXP. REGEXP defaults to \"[ \\t\\n\\r]+\"." - :realname compat--internal-string-trim-left :explicit t (if (string-match (concat "\\`\\(?:" (or regexp "[ \t\n\r]+") "\\)") string) (substring string (match-end 0)) @@ -128,7 +126,6 @@ REGEXP defaults to \"[ \\t\\n\\r]+\"." "Trim STRING of trailing string matching REGEXP. REGEXP defaults to \"[ \\t\\n\\r]+\"." - :realname compat--internal-string-trim-right :explicit t (let ((i (string-match-p (concat "\\(?:" (or regexp "[ \t\n\r]+") "\\)\\'") @@ -140,11 +137,8 @@ REGEXP defaults to \"[ \\t\\n\\r]+\"." TRIM-LEFT and TRIM-RIGHT default to \"[ \\t\\n\\r]+\"." :explicit t - ;; `string-trim-left' and `string-trim-right' were moved from subr-x - ;; to subr in Emacs 27, so to avoid loading subr-x we use the - ;; compatibility function here: - (compat--internal-string-trim-left - (compat--internal-string-trim-right + (compat--string-trim-left + (compat--string-trim-right string trim-right) trim-left)) diff --git a/compat-29.el b/compat-29.el index 0d3b5b5cae..7bb0a6f25a 100644 --- a/compat-29.el +++ b/compat-29.el @@ -211,7 +211,6 @@ the parent, and with a nil DEF, the lookups will return nil. If KEYMAP is a sparse keymap with a binding for KEY, the existing binding is altered. If there is no binding for KEY, the new pair binding KEY to DEF is added at the front of KEYMAP." - :realname compat--define-key-with-remove :explicit t (if remove (let ((prev (lookup-key keymap key)) @@ -759,7 +758,7 @@ parent keymap. Removing the binding will allow the key in the parent keymap to be used." (unless (key-valid-p key) (error "%S is not a valid key definition; see `key-valid-p'" key)) - (compat--define-key-with-remove keymap (key-parse key) nil remove)) + (compat--define-key keymap (key-parse key) nil remove)) (compat-defun keymap-global-set (key command) ;; <UNTESTED> "Give KEY a global binding as COMMAND. diff --git a/compat-macs.el b/compat-macs.el index 880f71cd7a..ff623887c5 100644 --- a/compat-macs.el +++ b/compat-macs.el @@ -63,16 +63,17 @@ If this is not documented on yourself system, you can check \ "Check that version constraints specified by ATTRS are satisfied." (let ((min-version (plist-get attrs :min-version)) (max-version (plist-get attrs :max-version)) - (cond (plist-get attrs :cond)) - (realname (plist-get attrs :realname))) + (cond (plist-get attrs :cond))) + ;; Min/max version bounds must be satisfied. (and ;; Min/max version bounds must be satisfied. (or (not min-version) (version<= min-version emacs-version)) (or (not max-version) (version< emacs-version max-version)) ;; If a condition is specified, it must be satisfied. (or (not cond) (eval cond t)) - ;; :realname specified or version constraint satisfied. - (or realname (version< emacs-version compat--current-version))))) + ;; The current Emacs must be older than the current declared Compat + ;; version, see `compat-declare-version'. + (version< emacs-version compat--current-version)))) (defun compat--guarded-definition (attrs args fun) "Guard compatibility definition generation. @@ -100,8 +101,8 @@ ARGS is a list of keywords which are looked up and passed to FUN." (defun compat--function-definition (type name arglist docstring rest) "Define function NAME of TYPE with ARGLIST and DOCSTRING. REST are attributes and the function BODY." - (compat--guarded-definition rest '(:explicit :realname :body) - (lambda (explicit realname body) + (compat--guarded-definition rest '(:explicit :body) + (lambda (explicit body) ;; Remove unsupported declares. It might be possible to set these ;; properties otherwise. That should be looked into and implemented ;; if it is the case. @@ -109,21 +110,10 @@ REST are attributes and the function BODY." (when (version<= emacs-version "25") (delq (assq 'side-effect-free (car body)) (car body)) (delq (assq 'pure (car body)) (car body)))) - ;; Ensure that :realname is not the same as compat--<name>, - ;; since this is the compat-call/compat-function naming convention. - (when (and realname - (or (string= realname explicit) - (not (string-prefix-p - "compat--" (symbol-name realname))))) - (error "%s: Invalid :realname name" realname)) - (let* ((defname ;; Name of the definition. May be nil -> no definition. - (if (not (fboundp name)) ;; If not bound, `name' should be bound. - name - ;; Use `:explicit' name if the function is already defined, - ;; and if version constraint is satisfied. - (and explicit - (version< emacs-version compat--current-version) - (intern (format "compat--%s" name))))) + ;; Use `:explicit' name if the function is already defined. + (let* ((defname (if (and explicit (fboundp name)) + (intern (format "compat--%s" name)) + name)) (def `(,(if (eq type 'macro) 'defmacro 'defun) ,defname ,arglist ,(compat--format-docstring type name docstring) @@ -131,16 +121,14 @@ REST are attributes and the function BODY." ;; An additional fboundp check is performed at runtime to make ;; sure that we never redefine an existing definition if Compat ;; is loaded on a newer Emacs version. - `(,@(if (eq defname name) - ;; Declare the function in a non-existing compat-declare - ;; feature, such that the byte compiler does not complain - ;; about possibly missing functions at runtime. The warnings - ;; are generated due to the unless fboundp check. - `((declare-function ,name "ext:compat-declare") - (unless (fboundp ',name) ,def)) - (and defname (list def))) - ,@(when realname - `((defalias ',realname ',(or defname name))))))))) + (if (eq defname name) + ;; Declare the function in a non-existing compat-declare + ;; feature, such that the byte compiler does not complain + ;; about possibly missing functions at runtime. The warnings + ;; are generated due to the unless fboundp check. + `((declare-function ,name "ext:compat-declare") + (unless (fboundp ',name) ,def)) + (list def)))))) (defmacro compat-defalias (name def &rest attrs) "Define compatibility alias NAME as DEF. @@ -173,9 +161,6 @@ attribute plist followed by the function body. The attributes specify the conditions under which the compatiblity function is defined. -- :realname :: Additionally install the definition under the - given name. - - :explicit :: Make the definition available such that it can be called explicitly via `compat-call'.