Mercurial > emacs
comparison lisp/mh-e/mh-compat.el @ 68529:7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
instead of replace-regexp-in-string.
(crm, multi-prompt): Use mh-require instead of require.
(mh-goto-address-find-address-at-point): Use
mh-line-beginning-position and mh-line-end-position instead of
line-beginning-position and line-end-position. Use
mh-match-string-no-properties instead of match-string-no-properties.
* mh-comp.el (mh-modify-header-field): Use mh-line-beginning-position
and mh-line-end-position instead of line-beginning-position and
line-end-position.
* mh-compat.el (mailabbrev): Use mh-require instead of require.
(mh-assoc-string, mh-display-completion-list, mh-face-foreground)
(mh-face-background): Make docstring consistent.
(mh-require, mh-cancel-timer, mh-display-color-cells)
(mh-line-beginning-position, mh-line-end-position)
(mh-match-string-no-properties, mh-replace-regexp-in-string)
(mh-view-mode-enter): Move definition here from mh-xemacs.el and add
mh- prefix since compatibility functions should have our package
prefix (mh-) by Emacs convention and to avoid messing up checks for
the same functions in other packages.
* mh-e.el (mh-compiling-flag): Move mh-xemacs-compiling-flag here from
mh-xemacs.el and rename.
(mh-xargs): Use mh-line-beginning-position and mh-line-end-position
instead of line-beginning-position and line-end-position.
(mh-defface-compat): Use mh-display-color-cells instead of
display-color-cells.
* mh-folder.el (which-func): Use mh-require instead of require.
* mh-funcs.el (mh-list-folders): Use mh-view-mode-enter instead of
view-mode-enter.
* mh-gnus.el (gnus-util, mm-bodies, mm-decode, mm-view, mml): Use
mh-require instead of require.
* mh-letter.el (mh-letter-header-end, mh-letter-mode)
(mh-letter-next-header-field): Use mh-line-beginning-position and
mh-line-end-position instead of line-beginning-position and
line-end-position.
* mh-limit.el (mh-subject-to-sequence-unthreaded): Use
mh-match-string-no-properties instead of match-string-no-properties.
(mh-narrow-to-header-field): Use mh-line-beginning-position and
mh-line-end-position instead of line-beginning-position and
line-end-position.
* mh-mime.el (mh-mime-inline-part, mh-mm-display-part)
(mh-mh-quote-unescaped-sharp, mh-mh-directive-present-p): Use
mh-line-beginning-position and mh-line-end-position instead of
line-beginning-position and line-end-position.
* mh-search.el (which-func): Use mh-require instead of require.
(mh-make-pick-template, mh-index-visit-folder)
(mh-pick-parse-search-buffer, mh-swish-next-result)
(mh-mairix-next-result, mh-namazu-next-result)
(mh-pick-next-result, mh-grep-next-result)
(mh-index-create-imenu-index, mh-index-match-checksum)
(mh-md5sum-parser, mh-openssl-parser, mh-index-update-maps): Use
mh-line-beginning-position and mh-line-end-position instead of
line-beginning-position and line-end-position.
* mh-seq.el (mh-list-sequences): Use mh-view-mode-enter instead of
view-mode-enter.
(mh-folder-size-flist, mh-parse-flist-output-line)
(mh-add-sequence-notation): Use mh-line-beginning-position and
mh-line-end-position instead of line-beginning-position and
line-end-position.
* mh-show.el (mh-show-addr): Use mh-require instead of require.
* mh-speed.el (mh-folder-speedbar-menu-items, mh-speed-toggle)
(mh-speed-view, mh-folder-speedbar-buttons)
(mh-speed-highlight, mh-speed-goto-folder)
(mh-speed-add-buttons, mh-speed-parse-flists-output)
(mh-speed-invalidate-map, mh-speedbar-change-expand-button-char)
(mh-speed-add-folder): Use mh-line-beginning-position and
mh-line-end-position instead of line-beginning-position and
line-end-position.
(mh-speed-flists): Use mh-cancel-timer instead of cancel-timer.
* mh-thread.el (mh-thread-find-children)
(mh-thread-parse-scan-line, mh-thread-generate): Use
mh-line-beginning-position and mh-line-end-position instead of
line-beginning-position and line-end-position.
* mh-utils.el (mh-colors-available-p): Use mh-display-color-cells
instead of display-color-cells.
(mh-folder-list): Use mh-replace-regexp-in-string instead of
replace-regexp-in-string.
(mh-sub-folders-actual, mh-letter-toggle-header-field-display): Use
mh-line-beginning-position and mh-line-end-position instead of
line-beginning-position and line-end-position.
* mh-comp.el (mh-send-sub): Don't find components file in current
directory--this seems to have been a side-effect of commenting out the
use of an old mh-etc variable. Improve error message.
author | Bill Wohler <wohler@newt.com> |
---|---|
date | Wed, 01 Feb 2006 23:24:34 +0000 |
parents | 6a7173abcf59 |
children | 37aca5dcac0c |
comparison
equal
deleted
inserted
replaced
68528:bd5e46db392c | 68529:7daec5f4a289 |
---|---|
35 ;; of Emacs that the defsubst, defalias, or defmacro applies. That | 35 ;; of Emacs that the defsubst, defalias, or defmacro applies. That |
36 ;; way, it's easy to occasionally go through this file and see which | 36 ;; way, it's easy to occasionally go through this file and see which |
37 ;; macros we can retire. | 37 ;; macros we can retire. |
38 | 38 |
39 ;; Please use mh-gnus.el when providing compatibility with different | 39 ;; Please use mh-gnus.el when providing compatibility with different |
40 ;; versions of Gnus and mh-xemacs.el for compatibility with XEmacs. | 40 ;; versions of Gnus. |
41 | 41 |
42 ;; Items are listed alphabetically. | 42 ;; Items are listed alphabetically (except for mh-require which is |
43 ;; needed by a lesser character). | |
44 | |
45 (require 'mh-acros) | |
46 | |
47 (mh-do-in-gnu-emacs | |
48 (defalias 'mh-require 'require)) | |
49 | |
50 (mh-do-in-xemacs | |
51 (defun mh-require (feature &optional filename noerror) | |
52 "If feature FEATURE is not loaded, load it from FILENAME. | |
53 If FEATURE is not a member of the list `features', then the feature | |
54 is not loaded; so load the file FILENAME. | |
55 If FILENAME is omitted, the printname of FEATURE is used as the file name. | |
56 If the optional third argument NOERROR is non-nil, | |
57 then return nil if the file is not found instead of signaling an error. | |
58 | |
59 Simulate NOERROR argument in XEmacs which lacks it." | |
60 (if (not (featurep feature)) | |
61 (if filename | |
62 (load filename noerror t) | |
63 (load (format "%s" feature) noerror t))))) | |
43 | 64 |
44 (mh-defun-compat mh-assoc-string assoc-string (key list case-fold) | 65 (mh-defun-compat mh-assoc-string assoc-string (key list case-fold) |
45 "Like `assoc' but specifically for strings. | 66 "Like `assoc' but specifically for strings. |
46 Case is ignored if CASE-FOLD is non-nil. | 67 Case is ignored if CASE-FOLD is non-nil. |
47 This function added by MH-E for Emacs versions that lack | 68 This function is used by Emacs versions that lack `assoc-string', |
48 `assoc-string', introduced in Emacs 22." | 69 introduced in Emacs 22." |
49 (if case-fold | 70 (if case-fold |
50 (assoc-ignore-case key list) | 71 (assoc-ignore-case key list) |
51 (assoc key list))) | 72 (assoc key list))) |
52 | 73 |
53 (require 'mailabbrev nil t) | 74 ;; For XEmacs. |
54 (mh-defun-compat mh-mail-abbrev-make-syntax-table | 75 (defalias 'mh-cancel-timer |
55 mail-abbrev-make-syntax-table () | 76 (if (fboundp 'cancel-timer) |
56 "Emacs 21 and XEmacs don't have this function." | 77 'cancel-timer |
57 nil) | 78 'delete-itimer)) |
79 | |
80 (mh-defun-compat mh-display-color-cells display-color-cells (&optional display) | |
81 "Return the number of color cells supported by DISPLAY. | |
82 This function is used by XEmacs to always return 0 when compiling | |
83 to avoid compiling errors. Otherwise uses `device-color-cells'." | |
84 (if mh-compiling-flag | |
85 0 | |
86 (device-color-cells display))) | |
58 | 87 |
59 (defmacro mh-display-completion-list (completions &optional common-substring) | 88 (defmacro mh-display-completion-list (completions &optional common-substring) |
60 "Display the list of COMPLETIONS. | 89 "Display the list of COMPLETIONS. |
61 See documentation for `display-completion-list' for a description of the | 90 See documentation for `display-completion-list' for a description of the |
62 arguments COMPLETIONS and perhaps COMMON-SUBSTRING. | 91 arguments COMPLETIONS and perhaps COMMON-SUBSTRING. |
63 This macro added by MH-E for Emacs versions that lack a | 92 This macro is used by Emacs versions that lack a COMMON-SUBSTRING |
64 COMMON-SUBSTRING argument, introduced in Emacs 22." | 93 argument, introduced in Emacs 22." |
65 (if (< emacs-major-version 22) | 94 (if (< emacs-major-version 22) |
66 `(display-completion-list ,completions) | 95 `(display-completion-list ,completions) |
67 `(display-completion-list ,completions ,common-substring))) | 96 `(display-completion-list ,completions ,common-substring))) |
68 | 97 |
69 (defmacro mh-face-foreground (face &optional frame inherit) | 98 (defmacro mh-face-foreground (face &optional frame inherit) |
70 "Return the foreground color name of FACE, or nil if unspecified. | 99 "Return the foreground color name of FACE, or nil if unspecified. |
71 See documentation for `face-foreground' for a description of the | 100 See documentation for `face-foreground' for a description of the |
72 arguments FACE, FRAME, and perhaps INHERIT. | 101 arguments FACE, FRAME, and perhaps INHERIT. |
73 This macro added by MH-E for Emacs versions that lack an INHERIT | 102 This macro is used by Emacs versions that lack an INHERIT argument, |
74 argument, introduced in Emacs 22." | 103 introduced in Emacs 22." |
75 (if (< emacs-major-version 22) | 104 (if (< emacs-major-version 22) |
76 `(face-foreground ,face ,frame) | 105 `(face-foreground ,face ,frame) |
77 `(face-foreground ,face ,frame ,inherit))) | 106 `(face-foreground ,face ,frame ,inherit))) |
78 | 107 |
79 (defmacro mh-face-background (face &optional frame inherit) | 108 (defmacro mh-face-background (face &optional frame inherit) |
80 "Return the background color name of face, or nil if unspecified. | 109 "Return the background color name of face, or nil if unspecified. |
81 See documentation for `back-foreground' for a description of the | 110 See documentation for `back-foreground' for a description of the |
82 arguments FACE, FRAME, and INHERIT. | 111 arguments FACE, FRAME, and INHERIT. |
83 This macro added by MH-E for Emacs versions that lack an INHERIT | 112 This macro is used by Emacs versions that lack an INHERIT argument, |
84 argument, introduced in Emacs 22." | 113 introduced in Emacs 22." |
85 (if (< emacs-major-version 22) | 114 (if (< emacs-major-version 22) |
86 `(face-background ,face ,frame) | 115 `(face-background ,face ,frame) |
87 `(face-background ,face ,frame ,inherit))) | 116 `(face-background ,face ,frame ,inherit))) |
117 | |
118 ;; For XEmacs. | |
119 (defalias 'mh-line-beginning-position | |
120 (if (fboundp 'line-beginning-position) | |
121 'line-beginning-position | |
122 'point-at-bol)) | |
123 | |
124 ;; For XEmacs. | |
125 (defalias 'mh-line-end-position | |
126 (if (fboundp 'line-end-position) | |
127 'line-end-position | |
128 'point-at-eol)) | |
129 | |
130 (mh-require 'mailabbrev nil t) | |
131 (mh-defun-compat mh-mail-abbrev-make-syntax-table | |
132 mail-abbrev-make-syntax-table () | |
133 "Emacs 21 and XEmacs don't have `mail-abbrev-make-syntax-table'. | |
134 This function does nothing on those systems." | |
135 nil) | |
136 | |
137 (mh-defun-compat mh-match-string-no-properties | |
138 match-string-no-properties (num &optional string) | |
139 "Return string of text matched by last search, without text properties. | |
140 This function is used by XEmacs that lacks `match-string-no-properties'. | |
141 The function `buffer-substring-no-properties' is used instead. | |
142 The argument STRING is ignored." | |
143 (buffer-substring-no-properties | |
144 (match-beginning num) (match-end num))) | |
145 | |
146 (mh-defun-compat mh-replace-regexp-in-string replace-regexp-in-string | |
147 (rep string &optional fixedcase literal subexp start) | |
148 "Replace REGEXP with REP everywhere in STRING and return result. | |
149 This function is used by XEmacs that lacks `replace-regexp-in-string'. | |
150 The function `replace-in-string' is used instead. | |
151 The arguments FIXEDCASE, LITERAL, SUBEXP, and START are ignored." | |
152 (replace-in-string string regexp rep)) | |
88 | 153 |
89 ;; Copy of constant from url-util.el in Emacs 22; needed by Emacs 21. | 154 ;; Copy of constant from url-util.el in Emacs 22; needed by Emacs 21. |
90 (if (not (boundp 'url-unreserved-chars)) | 155 (if (not (boundp 'url-unreserved-chars)) |
91 (defconst mh-url-unresrved-chars | 156 (defconst mh-url-unresrved-chars |
92 '( | 157 '( |
109 (error "Hexifying multibyte character %s" str) | 174 (error "Hexifying multibyte character %s" str) |
110 (format "%%%02X" char)) | 175 (format "%%%02X" char)) |
111 (char-to-string char))) | 176 (char-to-string char))) |
112 str "")) | 177 str "")) |
113 | 178 |
179 (mh-defun-compat mh-view-mode-enter | |
180 view-mode-enter (&optional return-to exit-action) | |
181 "Enter View mode. | |
182 This function is used by XEmacs that lacks `view-mode-enter'. | |
183 The function `view-mode' is used instead. | |
184 The arguments RETURN-TO and EXIT-ACTION are ignored." | |
185 ;; Shush compiler. | |
186 (if return-to nil) | |
187 (if exit-action nil) | |
188 (view-mode 1)) | |
189 | |
114 (defmacro mh-write-file-functions () | 190 (defmacro mh-write-file-functions () |
115 "Return `write-file-functions' if it exists. | 191 "Return `write-file-functions' if it exists. |
116 Otherwise return `local-write-file-hooks'. | 192 Otherwise return `local-write-file-hooks'. |
117 This macro exists purely for compatibility. The former symbol is used | 193 This macro exists purely for compatibility. The former symbol is used |
118 in Emacs 22 onward while the latter is used in previous versions and | 194 in Emacs 22 onward while the latter is used in previous versions and |