LCOV - code coverage report
Current view: top level - lisp - version.el (source / functions) Hit Total Coverage
Test: tramp-tests.info Lines: 25 44 56.8 %
Date: 2017-08-27 09:44:50 Functions: 1 3 33.3 %

          Line data    Source code
       1             : ;;; version.el --- record version number of Emacs
       2             : 
       3             : ;; Copyright (C) 1985, 1992, 1994-1995, 1999-2017 Free Software
       4             : ;; Foundation, Inc.
       5             : 
       6             : ;; Maintainer: emacs-devel@gnu.org
       7             : ;; Keywords: internal
       8             : ;; Package: emacs
       9             : 
      10             : ;; This file is part of GNU Emacs.
      11             : 
      12             : ;; GNU Emacs is free software: you can redistribute it and/or modify
      13             : ;; it under the terms of the GNU General Public License as published by
      14             : ;; the Free Software Foundation, either version 3 of the License, or
      15             : ;; (at your option) any later version.
      16             : 
      17             : ;; GNU Emacs is distributed in the hope that it will be useful,
      18             : ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
      19             : ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      20             : ;; GNU General Public License for more details.
      21             : 
      22             : ;; You should have received a copy of the GNU General Public License
      23             : ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
      24             : 
      25             : ;;; Commentary:
      26             : 
      27             : ;;; Code:
      28             : 
      29             : (defconst emacs-major-version
      30             :   (progn (string-match "^[0-9]+" emacs-version)
      31             :          (string-to-number (match-string 0 emacs-version)))
      32             :   "Major version number of this version of Emacs.
      33             : This variable first existed in version 19.23.")
      34             : 
      35             : (defconst emacs-minor-version
      36             :   (progn (string-match "^[0-9]+\\.\\([0-9]+\\)" emacs-version)
      37             :          (string-to-number (match-string 1 emacs-version)))
      38             :   "Minor version number of this version of Emacs.
      39             : This variable first existed in version 19.23.")
      40             : 
      41             : (defconst emacs-build-system (system-name)
      42             :   "Name of the system on which Emacs was built, or nil if not available.")
      43             : 
      44             : (defconst emacs-build-time (if emacs-build-system (current-time))
      45             :   "Time at which Emacs was dumped out, or nil if not available.")
      46             : 
      47             : (defconst emacs-build-number 1          ; loadup.el may increment this
      48             :   "The build number of this version of Emacs.
      49             : This is an integer that increments each time Emacs is built in a given
      50             : directory (without cleaning).  This is likely to only be relevant when
      51             : developing Emacs.")
      52             : 
      53             : (defvar motif-version-string)
      54             : (defvar gtk-version-string)
      55             : (defvar ns-version-string)
      56             : (defvar cairo-version-string)
      57             : 
      58             : (defun emacs-version (&optional here)
      59             :   "Return string describing the version of Emacs that is running.
      60             : If optional argument HERE is non-nil, insert string at point.
      61             : Don't use this function in programs to choose actions according
      62             : to the system configuration; look at `system-configuration' instead."
      63             :   (interactive "P")
      64           1 :   (let ((version-string
      65           1 :          (format "GNU Emacs %s (build %s, %s%s%s%s)%s"
      66           1 :                  emacs-version
      67           1 :                  emacs-build-number
      68           1 :                  system-configuration
      69           1 :                  (cond ((featurep 'motif)
      70           0 :                         (concat ", " (substring motif-version-string 4)))
      71           1 :                        ((featurep 'gtk)
      72           1 :                         (concat ", GTK+ Version " gtk-version-string))
      73           0 :                        ((featurep 'x-toolkit) ", X toolkit")
      74           0 :                        ((featurep 'ns)
      75           0 :                         (format ", NS %s" ns-version-string))
      76           1 :                        (t ""))
      77           1 :                  (if (featurep 'cairo)
      78           0 :                      (format ", cairo version %s" cairo-version-string)
      79           1 :                    "")
      80           1 :                  (if (and (boundp 'x-toolkit-scroll-bars)
      81           1 :                           (memq x-toolkit-scroll-bars '(xaw xaw3d)))
      82           0 :                      (format ", %s scroll bars"
      83           0 :                              (capitalize (symbol-name x-toolkit-scroll-bars)))
      84           1 :                    "")
      85           1 :                  (if emacs-build-time
      86           1 :                      (format-time-string (concat
      87           1 :                                           (if (called-interactively-p
      88           1 :                                                'interactive)
      89           1 :                                               "" "\n")
      90           1 :                                           " of %Y-%m-%d")
      91           1 :                                          emacs-build-time)
      92           1 :                    ""))))
      93           1 :     (if here
      94           0 :         (insert version-string)
      95           1 :       (if (called-interactively-p 'interactive)
      96           0 :           (message "%s" version-string)
      97           1 :         version-string))))
      98             : 
      99             : ;; We hope that this alias is easier for people to find.
     100             : (defalias 'version 'emacs-version)
     101             : 
     102             : ;; Set during dumping, this is a defvar so that it can be setq'd.
     103             : (defvar emacs-repository-version nil
     104             :   "String giving the repository revision from which this Emacs was built.
     105             : Value is nil if Emacs was not built from a repository checkout,
     106             : or if we could not determine the revision.")
     107             : 
     108             : (define-obsolete-variable-alias 'emacs-bzr-version
     109             :                                 'emacs-repository-version "24.4")
     110             : 
     111             : (define-obsolete-function-alias 'emacs-bzr-get-version
     112             :                                 'emacs-repository-get-version "24.4")
     113             : 
     114             : (defun emacs-repository-version-git (dir)
     115             :   "Ask git itself for the version information for directory DIR."
     116           0 :   (message "Waiting for git...")
     117           0 :   (with-temp-buffer
     118           0 :     (let ((default-directory (file-name-as-directory dir)))
     119           0 :       (and (eq 0
     120           0 :                (with-demoted-errors "Error running git rev-parse: %S"
     121           0 :                  (call-process "git" nil '(t nil) nil "rev-parse" "HEAD")))
     122           0 :            (progn (goto-char (point-min))
     123           0 :                   (looking-at "[0-9a-fA-F]\\{40\\}"))
     124           0 :            (match-string 0)))))
     125             : 
     126             : (defun emacs-repository-get-version (&optional dir external)
     127             :   "Try to return as a string the repository revision of the Emacs sources.
     128             : The format of the returned string is dependent on the VCS in use.
     129             : Value is nil if the sources do not seem to be under version
     130             : control, or if we could not determine the revision.  Note that
     131             : this reports on the current state of the sources, which may not
     132             : correspond to the running Emacs.
     133             : 
     134             : Optional argument DIR is a directory to use instead of `source-directory'.
     135             : Optional argument EXTERNAL is ignored."
     136           0 :   (emacs-repository-version-git (or dir source-directory)))
     137             : 
     138             : ;; We put version info into the executable in the form that `ident' uses.
     139             : (purecopy (concat "\n$Id: " (subst-char-in-string ?\n ?\s (emacs-version))
     140             :                   " $\n"))
     141             : 
     142             : ;;; version.el ends here

Generated by: LCOV version 1.12