Skip to content

Commit d4acdd2

Browse files
committed
Merge pull request #134 from elixir-lang/elixir-mode-version
refine the ability to show the current elixir-mode version
2 parents d52ccf1 + 9b56367 commit d4acdd2

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

Rakefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ end
2525

2626
def update_version(content, from, to)
2727
content = content.gsub("Version: #{from}", "Version: #{to}")
28-
content = content.gsub("elixir-mode--version \"#{from}\"", "elixir-mode--version \"#{to}\"")
2928
end
3029

3130
def run(command)

elixir-mode.el

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
;; URL: https://github.com/elixir-lang/emacs-elixir
99
;; Created: Mon Nov 7 2011
1010
;; Keywords: languages elixir
11-
;; Version: 1.3.0
11+
;; Version: 2.0.1
1212

1313
;; This file is not a part of GNU Emacs.
1414

@@ -136,8 +136,6 @@
136136

137137
(require 'elixir-smie) ; syntax and indentation support
138138

139-
(defvar elixir-mode--version "1.4.10")
140-
141139
(defvar elixir-mode--website-url
142140
"http://elixir-lang.org")
143141

@@ -541,10 +539,23 @@ Optional argument ARGS-P ."
541539
(browse-url (concat elixir-mode--website-url "/docs/stable/elixir")))
542540

543541
;;;###autoload
544-
(defun elixir-mode-show-version ()
545-
"Elixir mode print version."
546-
(interactive)
547-
(message (format "elixir-mode v%s" elixir-mode--version)))
542+
(defun elixir-mode-version (&optional show-version)
543+
"Get the Elixir-Mode version as string.
544+
545+
If called interactively or if SHOW-VERSION is non-nil, show the
546+
version in the echo area and the messages buffer.
547+
548+
The returned string includes both, the version from package.el
549+
and the library version, if both a present and different.
550+
551+
If the version number could not be determined, signal an error,
552+
if called interactively, or if SHOW-VERSION is non-nil, otherwise
553+
just return nil."
554+
(interactive (list t))
555+
(let ((version (pkg-info-version-info 'elixir-mode)))
556+
(when show-version
557+
(message "Elixir-Mode version: %s" version))
558+
version))
548559

549560
(defun elixir-mode--code-eval-string-command (file)
550561
(format "%s -e 'IO.puts inspect(elem(Code.eval_string(File.read!(\"%s\")), 0))'"
@@ -625,7 +636,7 @@ Argument END End of the region."
625636
"---"
626637
["elixir-mode on GitHub" elixir-mode-open-modegithub]
627638
["Elixir homepage" elixir-mode-open-elixirhome]
628-
["About" elixir-mode-show-version]
639+
["About" elixir-mode-version]
629640
))
630641

631642
;;;###autoload

0 commit comments

Comments
 (0)