emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Enhancing (?) `emacs-version'


From: Kaushal Modi
Subject: Re: Enhancing (?) `emacs-version'
Date: Wed, 10 Feb 2016 17:30:06 -0500

I use this function to get the emacs dev version. 

(defun emacs-version-dev (here)
  "Display emacs build info and also save it to the kill-ring.
If HERE is non-nil, also insert the string at point."
  (interactive "P")
  (let ((emacs-build-info
         (concat "Emacs version: " (emacs-version) ","
                 " built using commit " emacs-repository-version ".\n\n"
                 "./configure options:\n " system-configuration-options "\n\n"
                 "Features:\n " system-configuration-features "\n")))
    (kill-new emacs-build-info)
    (message emacs-build-info)
    (when here
      (insert emacs-build-info))
    emacs-build-info))

AFAIK there is no definitive way to get the branch name because branches are ephemeral. But the below hack works for me. 

(defvar emacs-git-branch
  (when (and emacs-repository-version
             (file-exists-p source-directory))
    (let ((shell-return
           (replace-regexp-in-string
            "[\n)]" " " ; Replace newline and ) chars with spaces
            (shell-command-to-string
             (concat "cd " source-directory " && "
                     "git branch --contains "
                     emacs-repository-version)))))
      ;; Below regexp is tested for following "git branch --contains" values
      ;; Output for a commit in master branch too
      ;; "* (HEAD detached at origin/emacs-25)
      ;; master
      ;; "
      ;; Output for a commit only in emacs-25 branch
      ;; "* (HEAD detached at origin/emacs-25)
      ;; "
      ;; (message "%S" shell-return)
      (string-match ".*[/ ]\\([^ ]+?\\)\\s-*$" shell-return)
      (match-string-no-properties 1 shell-return)))
  "Name of git branch from which the current emacs is built.")



--

--
Kaushal Modi


reply via email to

[Prev in Thread] Current Thread [Next in Thread]