branch: scratch/editorconfig-cc
commit 882e7f5fa023401b09c7c5ecb0268fc328e082d5
Author: 10sr <8.slas...@gmail.com>
Commit: Stefan Monnier <monn...@iro.umontreal.ca>

    Use API to get version info (#193)
---
 bin/editorconfig-el         |  5 +++--
 editorconfig-conf-mode.el   |  3 ---
 editorconfig-core-handle.el |  3 ---
 editorconfig-core.el        |  7 -------
 editorconfig-fnmatch.el     |  3 ---
 editorconfig.el             | 28 ++++++++++++++++++++++++++++
 6 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/bin/editorconfig-el b/bin/editorconfig-el
index fb3d4d41d8..7a559eef58 100755
--- a/bin/editorconfig-el
+++ b/bin/editorconfig-el
@@ -43,6 +43,7 @@
                 load-path)))
 
 (require 'cl-lib)
+(require 'editorconfig)  ; For `editorconfig-version'
 (require 'editorconfig-core)
 
 (defconst editorconfig-bin-help-message
@@ -80,8 +81,8 @@ with required output."
      (message editorconfig-bin-help-message)
      (kill-emacs 0))
     ((-v --version)
-     (princ (format "EditorConfig-Core-EmacsLisp Version %s\n"
-                    editorconfig-core-version))
+     (princ (format "EditorConfig-EmacsLisp Version %s\n"
+                    (editorconfig-version)))
      (kill-emacs 0))
 
     (otherwise
diff --git a/editorconfig-conf-mode.el b/editorconfig-conf-mode.el
index 2a114e3bad..dd3964fa60 100644
--- a/editorconfig-conf-mode.el
+++ b/editorconfig-conf-mode.el
@@ -3,9 +3,6 @@
 ;; Copyright (C) 2011-2019 EditorConfig Team
 
 ;; Author: EditorConfig Team <editorcon...@googlegroups.com>
-;; URL: https://github.com/editorconfig/editorconfig-emacs#readme
-;; Version: 0.7.14
-;; Package-Requires: ((emacs "24"))
 
 ;; See
 ;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors
diff --git a/editorconfig-core-handle.el b/editorconfig-core-handle.el
index 9685cc002b..bb152364d4 100644
--- a/editorconfig-core-handle.el
+++ b/editorconfig-core-handle.el
@@ -3,9 +3,6 @@
 ;; Copyright (C) 2011-2019 EditorConfig Team
 
 ;; Author: EditorConfig Team <editorcon...@googlegroups.com>
-;; URL: https://github.com/editorconfig/editorconfig-emacs#readme
-;; Version: 0.7.14
-;; Package-Requires: ((emacs "24"))
 
 ;; See
 ;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors
diff --git a/editorconfig-core.el b/editorconfig-core.el
index ca19226ffd..1f06130579 100644
--- a/editorconfig-core.el
+++ b/editorconfig-core.el
@@ -3,9 +3,6 @@
 ;; Copyright (C) 2011-2019 EditorConfig Team
 
 ;; Author: EditorConfig Team <editorcon...@googlegroups.com>
-;; URL: https://github.com/editorconfig/editorconfig-emacs#readme
-;; Version: 0.7.14
-;; Package-Requires: ((emacs "24"))
 
 ;; See
 ;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors
@@ -72,10 +69,6 @@
 (require 'editorconfig-core-handle)
 
 
-(defconst editorconfig-core-version
-  "0.7.14"
-  "EditorConfig core version.")
-
 (defun editorconfig-core--get-handles (dir confname &optional result)
   "Get list of EditorConfig handlers for DIR from CONFNAME.
 
diff --git a/editorconfig-fnmatch.el b/editorconfig-fnmatch.el
index 42dbd474c1..68727e5e24 100644
--- a/editorconfig-fnmatch.el
+++ b/editorconfig-fnmatch.el
@@ -3,9 +3,6 @@
 ;; Copyright (C) 2011-2019 EditorConfig Team
 
 ;; Author: EditorConfig Team <editorcon...@googlegroups.com>
-;; URL: https://github.com/editorconfig/editorconfig-emacs#readme
-;; Version: 0.7.14
-;; Package-Requires: ((emacs "24"))
 
 ;; See
 ;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors
diff --git a/editorconfig.el b/editorconfig.el
index 453c8cd36b..b3f15b6e1e 100644
--- a/editorconfig.el
+++ b/editorconfig.el
@@ -577,6 +577,34 @@ To disable EditorConfig in some buffers, modify
   'editorconfig-display-current-properties)
 
 
+
+;; (defconst editorconfig--version
+;;   (eval-when-compile
+;;     (require 'lisp-mnt)
+;;     (declare-function lm-version "lisp-mnt" nil)
+;;     (lm-version))
+;;   "EditorConfig version.")
+
+(declare-function find-library-name "find-func" (library))
+(declare-function lm-version "lisp-mnt" nil)
+
+;;;###autoload
+(defun  editorconfig-version (&optional show-version)
+  "Get EditorConfig version as string.
+
+If called interactively or if SHOW-VERSION is non-nil, show the
+version in the echo area and the messages buffer."
+  (interactive (list t))
+  (with-temp-buffer
+    (require 'find-func)
+    (insert-file-contents (find-library-name "editorconfig"))
+    (require 'lisp-mnt)
+    (let ((version (lm-version)))
+      (when show-version
+        (message "EditorConfig Emacs v%s"
+                 version))
+      version)))
+
 (provide 'editorconfig)
 
 ;;; editorconfig.el ends here

Reply via email to