(defun dot () (point)) (defun pow (x y) "Raise X to the Y power. Uses expt directly, i.e., it's just an alias for expt." (interactive "nx: ny: ") (expt x y) ; (if (= y 0) ; 1 ; (* x (pow x (- y 1))) ; ) ) (defun emacs-version-compare (major minor compare-func) "Compare the value of (emacs-version) with argments. First arg is major version, second arg minor version, and third arg the comparision function. E.g., (emacs-version-compare 19 27 '>=) returns true if (emacs-version) is >= 19.27." (interactive "nMajor version: nMinor version: xCompare function: ") (temp-switch-to-buffer "TEMP") (beginning-of-buffer) (setq d (dot)) (end-of-buffer) (kill-region d (dot)) (insert-string (emacs-version)) (beginning-of-buffer) (search-forward ".") (setq d (dot)) (backward-word 1) (setq major1 (string-to-int (buffer-substring (dot) d))) (search-forward ".") (forward-word 1) (setq minor1 (string-to-int (buffer-substring d (dot)))) (switch-back-from-temp-buffer) (setq l (max (length (int-to-string minor)) (length (int-to-string minor1)))) (setq v (+ (* major (pow 10 l)) minor)) (setq v1 (+ (* major1 (pow 10 l)) minor1)) (setq r (apply compare-func (list v1 v))) (if (interactive-p) (message (if r "yes" "no"))) r )