-;;; mh-compat.el --- make MH-E compatibile with various versions of Emacs
+;;; mh-compat.el --- make MH-E compatible with various versions of Emacs
-;; Copyright (C) 2006-2011 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2013 Free Software Foundation, Inc.
;; Author: Bill Wohler <wohler@newt.com>
;; Maintainer: Bill Wohler <wohler@newt.com>
'cancel-timer
'delete-itimer))
+;; Emacs 24 renamed flet to cl-flet.
+(defalias 'mh-cl-flet
+ (if (fboundp 'cl-flet)
+ 'cl-flet
+ 'flet))
+
(defun mh-display-color-cells (&optional display)
"Return the number of color cells supported by DISPLAY.
This function is used by XEmacs to return 2 when `device-color-cells'
"XEmacs does not have `font-lock-add-keywords'.
This function returns nil on that system.")
-(defun-mh mh-window-full-height-p
- window-full-height-p (&optional WINDOW)
- "Return non-nil if WINDOW is not the result of a vertical split.
-This function is defined in XEmacs as it lacks
-`window-full-height-p'. The values of the functions
-`window-height' and `frame-height' are compared instead. The
-argument WINDOW is ignored."
- (= (1+ (window-height))
- (frame-height)))
-
(defun-mh mh-image-load-path-for-library
image-load-path-for-library (library image &optional path no-error)
"Return a suitable search path for images used by LIBRARY.
dir (expand-file-name "../" dir))))
(setq image-directory-load-path dir))
- ;; If `image-directory-load-path' isn't Emacs' image directory,
+ ;; If `image-directory-load-path' isn't Emacs's image directory,
;; it's probably a user preference, so use it. Then use a
;; relative setting if possible; otherwise, use
;; `image-directory-load-path'.
;; Set it to nil if image is not found.
(cond ((file-exists-p (expand-file-name image d2ei)) d2ei)
((file-exists-p (expand-file-name image d1ei)) d1ei)))))
- ;; Use Emacs' image directory.
+ ;; Use Emacs's image directory.
(image-directory-load-path
(setq image-directory image-directory-load-path))
(no-error
This function returns nil on those systems."
nil)
+(defmacro mh-define-obsolete-variable-alias
+ (obsolete-name current-name &optional when docstring)
+ "Make OBSOLETE-NAME a variable alias for CURRENT-NAME and mark it obsolete.
+See documentation for `define-obsolete-variable-alias' for a description
+of the arguments OBSOLETE-NAME, CURRENT-NAME, and perhaps WHEN
+and DOCSTRING. This macro is used by XEmacs that lacks WHEN and
+DOCSTRING arguments."
+ (if (featurep 'xemacs)
+ `(define-obsolete-variable-alias ,obsolete-name ,current-name)
+ `(define-obsolete-variable-alias ,obsolete-name ,current-name ,when ,docstring)))
+
+(defmacro mh-make-obsolete-variable (obsolete-name current-name &optional when access-type)
+ "Make the byte-compiler warn that OBSOLETE-NAME is obsolete.
+See documentation for `make-obsolete-variable' for a description
+of the arguments OBSOLETE-NAME, CURRENT-NAME, and perhaps WHEN
+and ACCESS-TYPE. This macro is used by XEmacs that lacks WHEN and
+ACCESS-TYPE arguments."
+ (if (featurep 'xemacs)
+ `(make-obsolete-variable ,obsolete-name ,current-name)
+ `(make-obsolete-variable ,obsolete-name ,current-name ,when ,access-type)))
+
+(defmacro mh-make-obsolete-variable (obsolete-name current-name &optional when access-type)
+ "Make the byte-compiler warn that OBSOLETE-NAME is obsolete.
+See documentation for `make-obsolete-variable' for a description
+of the arguments OBSOLETE-NAME, CURRENT-NAME, and perhaps WHEN
+and ACCESS-TYPE. This macro is used by XEmacs that lacks WHEN and
+ACCESS-TYPE arguments and by Emacs versions that lack ACCESS-TYPE,
+introduced in Emacs 24."
+ (if (featurep 'xemacs)
+ `(make-obsolete-variable ,obsolete-name ,current-name)
+ (if (< emacs-major-version 24)
+ `(make-obsolete-variable ,obsolete-name ,current-name ,when)
+ `(make-obsolete-variable ,obsolete-name ,current-name ,when ,access-type))))
+
(defun-mh mh-match-string-no-properties
match-string-no-properties (num &optional string)
"Return string of text matched by last search, without text properties.
(if exit-action nil)
(view-mode 1))
+(defun-mh mh-window-full-height-p
+ window-full-height-p (&optional WINDOW)
+ "Return non-nil if WINDOW is not the result of a vertical split.
+This function is defined in XEmacs as it lacks
+`window-full-height-p'. The values of the functions
+`window-height' and `frame-height' are compared instead. The
+argument WINDOW is ignored."
+ (= (1+ (window-height))
+ (frame-height)))
+
(defmacro mh-write-file-functions ()
"Return `write-file-functions' if it exists.
Otherwise return `local-write-file-hooks'.