|
13 | 13 | ;; Package-Requires: ((emacs "25.2"))
|
14 | 14 | ;; License: GPL-3.0-or-later
|
15 | 15 |
|
16 |
| -(defconst php-mode-version-number "1.24.1" |
17 |
| - "PHP Mode version number.") |
| 16 | +(eval-and-compile |
| 17 | + (make-obsolete-variable |
| 18 | + (defconst php-mode-version-number "1.24.1" "PHP Mode version number.") |
| 19 | + "Please call (php-mode-version :as-number t) for compatibility." "1.24.2")) |
18 | 20 |
|
19 | 21 | ;; This program is free software; you can redistribute it and/or modify
|
20 | 22 | ;; it under the terms of the GNU General Public License as published by
|
|
86 | 88 | (defvar c-vsemi-status-unknown-p)
|
87 | 89 | (defvar syntax-propertize-via-font-lock))
|
88 | 90 |
|
| 91 | +(defconst php-mode-version-id |
| 92 | + (eval-when-compile |
| 93 | + (let ((fallback-version (format "%s-non-vcs" (with-no-warnings php-mode-version-number)))) |
| 94 | + (if (locate-dominating-file default-directory ".git") |
| 95 | + (save-match-data |
| 96 | + (let ((tag (replace-regexp-in-string |
| 97 | + (rx bos "v") "" |
| 98 | + (shell-command-to-string "git describe --tags"))) |
| 99 | + (pattern (rx (group (+ any)) eol))) |
| 100 | + (if (string-match pattern tag) |
| 101 | + (match-string 0 tag) |
| 102 | + (error "Faild to obtain git tag")))) |
| 103 | + fallback-version))) |
| 104 | + "PHP Mode build ID. |
| 105 | +
|
| 106 | +The format is follows: |
| 107 | +
|
| 108 | +\"1.23.4\": Tagged revision, compiled under Git VCS. |
| 109 | +\"1.23.4-56-xxxxxx\": 56 commits after the last tag release, compiled under Git. |
| 110 | +\"1.23.4-non-vcs\": Compiled in an environment not managed by Git VCS.") |
| 111 | + |
89 | 112 | (autoload 'php-mode-debug "php-mode-debug"
|
90 | 113 | "Display informations useful for debugging PHP Mode." t)
|
91 | 114 |
|
@@ -288,17 +311,20 @@ In that case set to `NIL'."
|
288 | 311 | (defconst php-mode-cc-vertion
|
289 | 312 | (eval-when-compile c-version))
|
290 | 313 |
|
291 |
| -(defun php-mode-version () |
292 |
| - "Display string describing the version of PHP Mode." |
293 |
| - (interactive) |
294 |
| - (let ((fmt (eval-when-compile (let ((id "$Id$")) |
295 |
| - (concat "PHP Mode %s" |
296 |
| - (if (string= id (concat [?$ ?I ?d ?$])) |
297 |
| - "" |
298 |
| - (concat " " id))))))) |
| 314 | +(cl-defun php-mode-version (&key as-number) |
| 315 | + "Display string describing the version of PHP Mode. |
| 316 | +
|
| 317 | +Although this is an interactive command, it returns a string when called |
| 318 | +as a function. Call with AS-NUMBER keyword to compare by `version<'. |
| 319 | +
|
| 320 | +\(version<= \"1.24.1\" (php-mode-version :as-number t))" |
| 321 | + (interactive (list :as-number nil)) |
| 322 | + (if as-number |
| 323 | + (save-match-data (and (string-match (rx (group (+ (in ".0-9")))) php-mode-version-id) |
| 324 | + (match-string 0 php-mode-version-id))) |
299 | 325 | (funcall
|
300 | 326 | (if (called-interactively-p 'interactive) #'message #'format)
|
301 |
| - fmt php-mode-version-number))) |
| 327 | + "PHP Mode v%s" php-mode-version-id))) |
302 | 328 |
|
303 | 329 | ;;;###autoload
|
304 | 330 | (define-obsolete-variable-alias 'php-available-project-root-files 'php-project-available-root-files "1.19.0")
|
|
0 commit comments