branch: elpa/d-mode
commit bc725ef54e39c1d75307ca012af57f9ae1fa536a
Author: Vladimir Panteleev <[email protected]>
Commit: Vladimir Panteleev <[email protected]>
Use a conditional compilation macro for version checks
---
d-mode.el | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/d-mode.el b/d-mode.el
index 280fdd9..1e7f067 100644
--- a/d-mode.el
+++ b/d-mode.el
@@ -7,7 +7,7 @@
;; Maintainer: Russel Winder <[email protected]>
;; Vladimir Panteleev <[email protected]>
;; Created: March 2007
-;; Version: 201911111516
+;; Version: 201911111704
;; Keywords: D programming language emacs cc-mode
;; Package-Requires: ((emacs "25.1"))
@@ -422,6 +422,16 @@ operators."
"Helper to precompute regular expressions for inline keyword lists." ;;
checkdoc-params: (adorn list)
(eval `(c-make-keywords-re ,adorn ,list 'd)))
+(defmacro d--if-version>= (min-version new-form &optional old-form)
+ "Conditional compilation based on the current Emacs version.
+
+Evaluate OLD-FORM if the Emacs version is older than MIN-VERSION,
+ otherwise NEW-FORM."
+ (declare (indent 2))
+ (if (version<= min-version emacs-version)
+ new-form
+ old-form))
+
;;----------------------------------------------------------------------------
;;; Workaround for special case of 'else static if' not being handled properly
(defun d-special-case-looking-at (orig-fun &rest args)
@@ -451,10 +461,6 @@ operators."
;;----------------------------------------------------------------------------
-(defconst d--long-cfdoc1-ret
- (version<= "26.0" emacs-version)
- "Whether `c-forward-decl-or-cast-1' returns a 5-element list in the current
cc-mode version.")
-
(defun d-forward-decl-or-cast-1 (preceding-token-end context last-cast-end)
"D version of `c-forward-decl-or-cast-1'." ;; checkdoc-params:
(preceding-token-end context last-cast-end)
;; (message "(d-forward-decl-or-cast-1 %S %S %S) @ %S" preceding-token-end
context last-cast-end (point))
@@ -634,7 +640,7 @@ operators."
(c-forward-sexp)
(c-forward-syntactic-ws)))
- (if d--long-cfdoc1-ret
+ (d--if-version>= "26.0"
(list id-start
nil
nil