]> code.delx.au - gnu-emacs/blobdiff - lisp/mh-e/mh-compat.el
Update copyright year to 2016
[gnu-emacs] / lisp / mh-e / mh-compat.el
index a96d2786cc9a891c3ba3ef4e57a9753b25546dfd..10a8b6e219c21a2916e4b85be5664d424e499ef2 100644 (file)
@@ -1,7 +1,6 @@
-;;; 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, 2007, 2008, 2009, 2010, 2011, 2012
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 2006-2016 Free Software Foundation, Inc.
 
 ;; Author: Bill Wohler <wohler@newt.com>
 ;; Maintainer: Bill Wohler <wohler@newt.com>
@@ -76,6 +75,12 @@ introduced in Emacs 22."
       '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'
@@ -91,12 +96,18 @@ expected to return an integer."
 (defmacro mh-display-completion-list (completions &optional common-substring)
   "Display the list of COMPLETIONS.
 See documentation for `display-completion-list' for a description of the
-arguments COMPLETIONS and perhaps COMMON-SUBSTRING.
-This macro is used by Emacs versions that lack a COMMON-SUBSTRING
-argument, introduced in Emacs 22."
-  (if (< emacs-major-version 22)
-      `(display-completion-list ,completions)
-    `(display-completion-list ,completions ,common-substring)))
+arguments COMPLETIONS.
+The optional argument COMMON-SUBSTRING, if non-nil, should be a string
+specifying a common substring for adding the faces
+`completions-first-difference' and `completions-common-part' to
+the completions."
+  (cond ((< emacs-major-version 22) `(display-completion-list ,completions))
+        ((fboundp 'completion-hilit-commonality) ; Emacs 23.1 and later
+         `(display-completion-list
+           (completion-hilit-commonality ,completions
+                                         ,(length common-substring) nil)))
+        (t                              ; Emacs 22
+         `(display-completion-list ,completions ,common-substring))))
 
 (defmacro mh-face-foreground (face &optional frame inherit)
   "Return the foreground color name of FACE, or nil if unspecified.
@@ -151,7 +162,7 @@ compatibility with versions of Emacs that lack the variable
 
     (let* ((load-path (image-load-path-for-library \"mh-e\" \"mh-logo.xpm\"))
            (image-load-path (cons (car load-path)
-                                  (when (boundp 'image-load-path)
+                                  (when (boundp \\='image-load-path)
                                     image-load-path))))
       (mh-tool-bar-folder-buttons-init))"
   (unless library (error "No library specified"))
@@ -175,7 +186,7 @@ compatibility with versions of Emacs that lack the variable
                 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'.
@@ -206,7 +217,7 @@ compatibility with versions of Emacs that lack the variable
               ;; 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
@@ -243,6 +254,40 @@ This function returns nil on those systems."
 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.
@@ -261,6 +306,12 @@ The arguments FIXEDCASE, SUBEXP, and START, used by
 `replace-in-string' are ignored."
   (replace-in-string string regexp rep literal))
 
+(defun-mh mh-test-completion
+  test-completion (string collection &optional predicate)
+  "Return non-nil if STRING is a valid completion.
+XEmacs does not have `test-completion'. This function returns nil
+on that system." nil)
+
 ;; Copy of constant from url-util.el in Emacs 22; needed by Emacs 21.
 (if (not (boundp 'url-unreserved-chars))
     (defconst mh-url-unreserved-chars
@@ -297,6 +348,16 @@ The arguments RETURN-TO and EXIT-ACTION are ignored."
   (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'.
@@ -315,5 +376,4 @@ XEmacs."
 ;; sentence-end-double-space: nil
 ;; End:
 
-;; arch-tag: 577b0eab-a5cd-45e1-8d9f-c1a426f4d73c
 ;;; mh-compat.el ends here