Mercurial > emacs
diff lisp/mh-e/mh-compat.el @ 90291:d6f8fe3307c8
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-11
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 34-42)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 14-17)
- Update from CVS
- Merge from emacs--devo--0
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sat, 04 Feb 2006 01:01:38 +0000 |
parents | 37aca5dcac0c |
children | 3741bfb4402f |
line wrap: on
line diff
--- a/lisp/mh-e/mh-compat.el Fri Feb 03 07:38:00 2006 +0000 +++ b/lisp/mh-e/mh-compat.el Sat Feb 04 01:01:38 2006 +0000 @@ -37,31 +37,60 @@ ;; macros we can retire. ;; Please use mh-gnus.el when providing compatibility with different -;; versions of Gnus and mh-xemacs.el for compatibility with XEmacs. +;; versions of Gnus. + +;; Items are listed alphabetically (except for mh-require which is +;; needed by a lesser character). + +(require 'mh-acros) + +(mh-do-in-gnu-emacs + (defalias 'mh-require 'require)) -;; Items are listed alphabetically. +(mh-do-in-xemacs + (defun mh-require (feature &optional filename noerror) + "If feature FEATURE is not loaded, load it from FILENAME. +If FEATURE is not a member of the list `features', then the feature +is not loaded; so load the file FILENAME. +If FILENAME is omitted, the printname of FEATURE is used as the file name. +If the optional third argument NOERROR is non-nil, +then return nil if the file is not found instead of signaling an error. + +Simulate NOERROR argument in XEmacs which lacks it." + (if (not (featurep feature)) + (if filename + (load filename noerror t) + (load (format "%s" feature) noerror t))))) (mh-defun-compat mh-assoc-string assoc-string (key list case-fold) "Like `assoc' but specifically for strings. Case is ignored if CASE-FOLD is non-nil. -This function added by MH-E for Emacs versions that lack -`assoc-string', introduced in Emacs 22." +This function is used by Emacs versions that lack `assoc-string', +introduced in Emacs 22." (if case-fold (assoc-ignore-case key list) (assoc key list))) -(require 'mailabbrev nil t) -(mh-defun-compat mh-mail-abbrev-make-syntax-table - mail-abbrev-make-syntax-table () - "Emacs 21 and XEmacs don't have this function." - nil) +;; For XEmacs. +(defalias 'mh-cancel-timer + (if (fboundp 'cancel-timer) + 'cancel-timer + 'delete-itimer)) + +(mh-defun-compat mh-display-color-cells display-color-cells (&optional display) + "Return the number of color cells supported by DISPLAY. +This function is used by XEmacs to always return 0 when compiling +to avoid compiling errors. Otherwise uses `device-color-cells'." + (if mh-compiling-flag + 0 + (device-color-cells display))) (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 added by MH-E for Emacs versions that lack a -COMMON-SUBSTRING argument, introduced in Emacs 22." +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))) @@ -70,8 +99,8 @@ "Return the foreground color name of FACE, or nil if unspecified. See documentation for `face-foreground' for a description of the arguments FACE, FRAME, and perhaps INHERIT. -This macro added by MH-E for Emacs versions that lack an INHERIT -argument, introduced in Emacs 22." +This macro is used by Emacs versions that lack an INHERIT argument, +introduced in Emacs 22." (if (< emacs-major-version 22) `(face-foreground ,face ,frame) `(face-foreground ,face ,frame ,inherit))) @@ -80,15 +109,51 @@ "Return the background color name of face, or nil if unspecified. See documentation for `back-foreground' for a description of the arguments FACE, FRAME, and INHERIT. -This macro added by MH-E for Emacs versions that lack an INHERIT -argument, introduced in Emacs 22." +This macro is used by Emacs versions that lack an INHERIT argument, +introduced in Emacs 22." (if (< emacs-major-version 22) `(face-background ,face ,frame) `(face-background ,face ,frame ,inherit))) +;; For XEmacs. +(defalias 'mh-line-beginning-position + (if (fboundp 'line-beginning-position) + 'line-beginning-position + 'point-at-bol)) + +;; For XEmacs. +(defalias 'mh-line-end-position + (if (fboundp 'line-end-position) + 'line-end-position + 'point-at-eol)) + +(mh-require 'mailabbrev nil t) +(mh-defun-compat mh-mail-abbrev-make-syntax-table + mail-abbrev-make-syntax-table () + "Emacs 21 and XEmacs don't have `mail-abbrev-make-syntax-table'. +This function does nothing on those systems." + nil) + +(mh-defun-compat mh-match-string-no-properties + match-string-no-properties (num &optional string) + "Return string of text matched by last search, without text properties. +This function is used by XEmacs that lacks `match-string-no-properties'. +The function `buffer-substring-no-properties' is used instead. +The argument STRING is ignored." + (buffer-substring-no-properties + (match-beginning num) (match-end num))) + +(mh-defun-compat mh-replace-regexp-in-string replace-regexp-in-string + (rep string &optional fixedcase literal subexp start) + "Replace REGEXP with REP everywhere in STRING and return result. +This function is used by XEmacs that lacks `replace-regexp-in-string'. +The function `replace-in-string' is used instead. +The arguments FIXEDCASE, LITERAL, SUBEXP, and START are ignored." + (replace-in-string string regexp rep)) + ;; Copy of constant from url-util.el in Emacs 22; needed by Emacs 21. (if (not (boundp 'url-unreserved-chars)) - (defconst mh-url-unresrved-chars + (defconst mh-url-unreserved-chars '( ?a ?b ?c ?d ?e ?f ?g ?h ?i ?j ?k ?l ?m ?n ?o ?p ?q ?r ?s ?t ?u ?v ?w ?x ?y ?z ?A ?B ?C ?D ?E ?F ?G ?H ?I ?J ?K ?L ?M ?N ?O ?P ?Q ?R ?S ?T ?U ?V ?W ?X ?Y ?Z @@ -111,6 +176,17 @@ (char-to-string char))) str "")) +(mh-defun-compat mh-view-mode-enter + view-mode-enter (&optional return-to exit-action) + "Enter View mode. +This function is used by XEmacs that lacks `view-mode-enter'. +The function `view-mode' is used instead. +The arguments RETURN-TO and EXIT-ACTION are ignored." + ;; Shush compiler. + (if return-to nil) + (if exit-action nil) + (view-mode 1)) + (defmacro mh-write-file-functions () "Return `write-file-functions' if it exists. Otherwise return `local-write-file-hooks'.