dot/emacs, el/dot-emacs.el: Better Emacs version checking.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 20 Mar 2016 17:41:10 +0000 (17:41 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 20 Mar 2016 17:41:10 +0000 (17:41 +0000)
Sometimes we must check the minor version number.

dot/emacs
el/dot-emacs.el

index 04c8189..708ea7b 100644 (file)
--- a/dot/emacs
+++ b/dot/emacs
@@ -84,7 +84,7 @@
 
 (require 'paren)
 (trap (show-paren-mode t))
-(or window-system (>= emacs-major-version 22) (menu-bar-mode -1))
+(or window-system (mdw-emacs-version-p 22) (menu-bar-mode -1))
 
 ;; Multiple cursors.
 
 
 ;; Emacs server behaviour.
 
-(and (or window-system (>= emacs-major-version 23))
+(and (or window-system (mdw-emacs-version-p 23))
      (progn (setq server-temp-file-regexp (concat "^" tmpdir "\\|/draft$")
                  edit-server-new-frame nil
                  gnuserv-frame t)
index 11be2ac..f4a33d8 100644 (file)
@@ -57,6 +57,12 @@ This may be at the expense of cool features.")
   (interactive)
   (error "wrong button"))
 
+(defun mdw-emacs-version-p (major &optional minor)
+  "Return non-nil if the running Emacs is at least version MAJOR.MINOR."
+  (or (> emacs-major-version major)
+      (and (= emacs-major-version major)
+          (>= emacs-minor-version (or minor 0)))))
+
 ;; Some error trapping.
 ;;
 ;; If individual bits of this file go tits-up, we don't particularly want
@@ -189,8 +195,7 @@ fringes is not taken out of the allowance for WIDTH, unlike
   "Split a wide window into appropriate widths."
   (interactive "P")
   (setq width (cond (width (prefix-numeric-value width))
-                   ((and window-system
-                         (>= emacs-major-version 22))
+                   ((and window-system (mdw-emacs-version-p 22))
                     77)
                    (t 78)))
   (let* ((win (selected-window))
@@ -1014,7 +1019,7 @@ doesn't match any of the regular expressions in
   (((type w32)) :family "courier new" :height 85)
   (((type x)) :family "6x13" :foundry "trad" :height 130)
   (t :foreground "white" :background "black"))
-(if (>= emacs-major-version 23)
+(if (mdw-emacs-version-p 23)
     (mdw-define-face variable-pitch
       (((type x)) :family "sans" :height 100))
   (mdw-define-face variable-pitch