version.el 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. ;;; version.el --- record version number of Emacs
  2. ;; Copyright (C) 1985, 1992, 1994-1995, 1999-2012
  3. ;; Free Software Foundation, Inc.
  4. ;; Maintainer: FSF
  5. ;; Keywords: internal
  6. ;; Package: emacs
  7. ;; This file is part of GNU Emacs.
  8. ;; GNU Emacs is free software: you can redistribute it and/or modify
  9. ;; it under the terms of the GNU General Public License as published by
  10. ;; the Free Software Foundation, either version 3 of the License, or
  11. ;; (at your option) any later version.
  12. ;; GNU Emacs is distributed in the hope that it will be useful,
  13. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ;; GNU General Public License for more details.
  16. ;; You should have received a copy of the GNU General Public License
  17. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  18. ;;; Commentary:
  19. ;; This file is loaded uncompiled when dumping Emacs.
  20. ;; Doc-strings should adhere to the conventions of make-docfile.
  21. ;;; Code:
  22. (defconst emacs-major-version (progn (string-match "^[0-9]+" emacs-version) (string-to-number (match-string 0 emacs-version))) "\
  23. Major version number of this version of Emacs.
  24. This variable first existed in version 19.23.")
  25. (defconst emacs-minor-version (progn (string-match "^[0-9]+\\.\\([0-9]+\\)" emacs-version) (string-to-number (match-string 1 emacs-version))) "\
  26. Minor version number of this version of Emacs.
  27. This variable first existed in version 19.23.")
  28. (defconst emacs-build-time (current-time) "\
  29. Time at which Emacs was dumped out.")
  30. (defconst emacs-build-system (system-name) "\
  31. Name of the system on which Emacs was built.")
  32. (defun emacs-version (&optional here) "\
  33. Return string describing the version of Emacs that is running.
  34. If optional argument HERE is non-nil, insert string at point.
  35. Don't use this function in programs to choose actions according
  36. to the system configuration; look at `system-configuration' instead."
  37. (interactive "P")
  38. (let ((version-string
  39. (format (if (not (called-interactively-p 'interactive))
  40. "GNU Emacs %s (%s%s%s)\n of %s on %s"
  41. "GNU Emacs %s (%s%s%s) of %s on %s")
  42. emacs-version
  43. system-configuration
  44. (cond ((featurep 'motif)
  45. (concat ", " (substring motif-version-string 4)))
  46. ((featurep 'gtk)
  47. (concat ", GTK+ Version " gtk-version-string))
  48. ((featurep 'x-toolkit) ", X toolkit")
  49. ((featurep 'ns)
  50. (format ", NS %s" ns-version-string))
  51. (t ""))
  52. (if (and (boundp 'x-toolkit-scroll-bars)
  53. (memq x-toolkit-scroll-bars '(xaw xaw3d)))
  54. (format ", %s scroll bars"
  55. (capitalize (symbol-name x-toolkit-scroll-bars)))
  56. "")
  57. (format-time-string "%Y-%m-%d" emacs-build-time)
  58. emacs-build-system)))
  59. (if here
  60. (insert version-string)
  61. (if (called-interactively-p 'interactive)
  62. (message "%s" version-string)
  63. version-string))))
  64. ;; We hope that this alias is easier for people to find.
  65. (defalias 'version 'emacs-version)
  66. ;; We put version info into the executable in the form that `ident' uses.
  67. (or (eq system-type 'windows-nt)
  68. (purecopy (concat "\n$Id: " (subst-char-in-string ?\n ?\s (emacs-version))
  69. " $\n")))
  70. ;; Local Variables:
  71. ;; version-control: never
  72. ;; no-byte-compile: t
  73. ;; End:
  74. ;;; version.el ends here