Skip to content

Commit db10caa

Browse files
committed
Enhance haskell-version to show more information
This commit marks `haskell-version` autoloaded and `M-x haskell-version` now echos more information, e.g. "haskell-mode version 2.9.1 (2.9.1-93-gb76e104-dirty @ /home/hvr/.emacs.d/elisp/haskell-mode/)" This style has been copied from Org mode's `org-version`.
1 parent b76e104 commit db10caa

File tree

2 files changed

+38
-20
lines changed

2 files changed

+38
-20
lines changed

Makefile

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
VERSION = $(shell git describe --tags --dirty | sed 's/_/\./g')
1+
VERSION = $(shell git describe --tags --abbrev=0 | sed 's/_/\./g')
2+
GIT_VERSION = $(shell git describe --tags --dirty | sed 's/_/\./g')
3+
24
EMACS = emacs
35
EFLAGS =
46
BATCH = $(EMACS) $(EFLAGS) --batch -Q -L .
@@ -35,7 +37,7 @@ ELCFILES = $(ELFILES:.el=.elc)
3537
AUTOLOADS = haskell-site-file.el
3638
DIST_FILES = $(ELFILES) $(ELCFILES) $(AUTOLOADS) logo.svg Makefile README.md NEWS
3739
DIST_FILES_EX = examples/init.el examples/fontlock.hs examples/indent.hs
38-
TGZ = haskell-mode-$(VERSION).tar.gz
40+
TGZ = haskell-mode-$(GIT_VERSION).tar.gz
3941

4042
%.elc: %.el
4143
@$(BATCH) -f batch-byte-compile $<
@@ -59,21 +61,22 @@ $(AUTOLOADS): $(ELFILES) haskell-mode.elc
5961

6062
# embed version number into .elc file
6163
haskell-mode.elc: haskell-mode.el
62-
sed -e 's/\$$Name: \$$/$(VERSION)/g' < haskell-mode.el > haskell-mode.tmp.el #NO_DIST
64+
sed -e 's/@GIT_VERSION@/$(GIT_VERSION)/g;s/@VERSION@/$(VERSION)/g' < haskell-mode.el > haskell-mode.tmp.el #NO_DIST
6365
@$(BATCH) -f batch-byte-compile haskell-mode.tmp.el #NO_DIST
6466
mv haskell-mode.tmp.elc haskell-mode.elc #NO_DIST
6567
$(RM) haskell-mode.tmp.el #NO_DIST
6668

6769
$(TGZ): $(DIST_FILES)
68-
rm -rf haskell-mode-$(VERSION)
69-
mkdir haskell-mode-$(VERSION)
70-
cp -p $(DIST_FILES) haskell-mode-$(VERSION)
71-
mkdir haskell-mode-$(VERSION)/examples
72-
cp -p $(DIST_FILES_EX) haskell-mode-$(VERSION)/examples
70+
rm -rf haskell-mode-$(GIT_VERSION)
71+
mkdir haskell-mode-$(GIT_VERSION)
72+
cp -p $(DIST_FILES) haskell-mode-$(GIT_VERSION)
73+
mkdir haskell-mode-$(GIT_VERSION)/examples
74+
cp -p $(DIST_FILES_EX) haskell-mode-$(GIT_VERSION)/examples
7375

74-
printf "1s/=.*/= $(VERSION)/\nw\n" | ed -s haskell-mode-$(VERSION)/Makefile #NO_DIST
75-
printf "g/NO_DIST/d\nw\n" | ed -s haskell-mode-$(VERSION)/Makefile #NO_DIST
76-
printf ',s/\$$Name: \$$/$(VERSION)/\nw\n' | ed -s haskell-mode-$(VERSION)/haskell-mode.el #NO_DIST
76+
printf "1s/=.*/= $(VERSION)/\nw\n" | ed -s haskell-mode-$(GIT_VERSION)/Makefile #NO_DIST
77+
printf "2s/=.*/= $(GIT_VERSION)/\nw\n" | ed -s haskell-mode-$(GIT_VERSION)/Makefile #NO_DIST
78+
printf "g/NO_DIST/d\nw\n" | ed -s haskell-mode-$(GIT_VERSION)/Makefile #NO_DIST
79+
printf ',s/@VERSION@/$(VERSION)/\nw\n' | ed -s haskell-mode-$(GIT_VERSION)/haskell-mode.el #NO_DIST
7780

78-
tar cvzf $(TGZ) haskell-mode-$(VERSION)
79-
rm -rf haskell-mode-$(VERSION)
81+
tar cvzf $(TGZ) haskell-mode-$(GIT_VERSION)
82+
rm -rf haskell-mode-$(GIT_VERSION)

haskell-mode.el

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
;; 2001-2002 Reuben Thomas (>=v1.4)
1010
;; 2003 Dave Love <[email protected]>
1111
;; Keywords: faces files Haskell
12-
;; Version: $Name: $
1312
;; URL: https://github.com/haskell/haskell-mode
1413

1514
;; This file is not part of GNU Emacs.
@@ -151,12 +150,28 @@
151150
;; All functions/variables start with `(literate-)haskell-'.
152151

153152
;; Version of mode.
154-
(defconst haskell-version "$Name: $"
155-
"`haskell-mode' version number.")
156-
(defun haskell-version ()
157-
"Echo the current version of `haskell-mode' in the minibuffer."
158-
(interactive)
159-
(message "Using haskell-mode version %s" haskell-version))
153+
(defconst haskell-version "@VERSION@"
154+
"The release version of `haskell-mode'.")
155+
156+
(defconst haskell-git-version "@GIT_VERSION@"
157+
"The Git version of org-mode `haskell-mode'.")
158+
159+
;;;###autoload
160+
(defun haskell-version (&optional here)
161+
"Show the `haskell-mode` version in the echo area.
162+
With prefix argument HERE, insert it at point.
163+
When FULL is non-nil, use a verbose version string.
164+
When MESSAGE is non-nil, display a message with the version."
165+
(interactive "P")
166+
(let* ((haskell-mode-dir (ignore-errors
167+
(file-name-directory (or (locate-library "haskell-mode") ""))))
168+
(_version (format "haskell-mode version %s (%s @ %s)"
169+
haskell-version
170+
haskell-git-version
171+
haskell-mode-dir)))
172+
(if here
173+
(insert _version)
174+
(message "%s" _version))))
160175

161176
(defgroup haskell nil
162177
"Major mode for editing Haskell programs."

0 commit comments

Comments
 (0)