Add gist to store the Git revision of the Emacs config in a constant
This commit is contained in:
parent
e4c92482b8
commit
421dcf67e5
23
gists.org
23
gists.org
|
@ -361,6 +361,29 @@ Used [[https://github.com/purcell/emacs.d/blob/master/lisp/init-paredit.el][Purc
|
|||
(bind-key (kbd "RET") #'paredit-newline paredit-mode-map)))
|
||||
#+end_src
|
||||
|
||||
* Store revision of Emacs configuration in a constant
|
||||
|
||||
#+begin_src elisp :tangle gists/store-configuration-revision-in-constant.el
|
||||
;; Store the Git revision of your Emacs configuration at the moment
|
||||
;; Emacs started.
|
||||
|
||||
(defconst my/has-git-p (if (executable-find "git") t nil)
|
||||
"Indicates if git is in your PATH.")
|
||||
|
||||
(defun my/configuration-revision ()
|
||||
"Retrieve the current Git revision of the Emacs configuration."
|
||||
(when my/has-git-p
|
||||
(with-temp-buffer
|
||||
(cd user-emacs-directory)
|
||||
(when (eql 0 (call-process "git" nil (current-buffer) nil
|
||||
"describe" "--all" "--long" "--dirty"))
|
||||
(string-trim (buffer-string))))))
|
||||
|
||||
(defconst my/configuration-revision
|
||||
(my/configuration-revision)
|
||||
"Contains the Git revision of the configuration at the moment Emacs started.")
|
||||
#+end_src
|
||||
|
||||
|
||||
* Meta
|
||||
** License
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
;; Store the Git revision of your Emacs configuration at the moment
|
||||
;; Emacs started.
|
||||
|
||||
(defconst my/has-git-p (if (executable-find "git") t nil)
|
||||
"Indicates if git is in your PATH.")
|
||||
|
||||
(defun my/configuration-revision ()
|
||||
"Retrieve the current Git revision of the Emacs configuration."
|
||||
(when my/has-git-p
|
||||
(with-temp-buffer
|
||||
(cd user-emacs-directory)
|
||||
(when (eql 0 (call-process "git" nil (current-buffer) nil
|
||||
"describe" "--all" "--long" "--dirty"))
|
||||
(string-trim (buffer-string))))))
|
||||
|
||||
(defconst my/configuration-revision
|
||||
(my/configuration-revision)
|
||||
"Contains the Git revision of the configuration at the moment Emacs started.")
|
Loading…
Reference in New Issue