radian-software / radian

🍉 Dotfiles that marry elegance and practicality.
MIT License
495 stars 47 forks source link

A slightly nicer (maybe) and automatic (definitely) version of your Org version hack #410

Closed jhenahan closed 6 years ago

jhenahan commented 6 years ago

I make heavy use of the "modern" libraries, so feel free to port the f and s bits to Emacs built-ins. Using git.el mainly takes the work of checking for the presence of git and running it and hands it off to a solid library so you don't have to do it.

(require 'git)
(require 'f)
(require 's)

(defun the-org-git-version ()
  (let ((git-repo
     (f-join user-emacs-directory "straight/repos/org")))
    (s-trim (git-run "describe"
             "--match=release\*"
             "--abbrev=6"
             "HEAD"))))

(defun the-org-release ()
  (let ((git-repo
     (f-join user-emacs-directory "straight/repos/org")))
    (s-trim (s-chop-prefix "release_"
               (git-run "describe"
                    "--match=release\*"
                    "--abbrev=0"
                    "HEAD")))))

The commands here are exactly the ones used by the Org build process (see mk/targets.mk lines 14 and 15), so this ought to give a string for org-version as if the user had actually performed the build themselves, which should make things a bit nicer for bug reports, and will behave as expected for packages which check org-version.

raxod502 commented 6 years ago

Thanks, see https://github.com/raxod502/radian/commit/afe2882e3eb85c3284d90fd374be4a5ef9c8775a.