Mercurial > emacs
annotate lisp/mh-e/mh-compat.el @ 102147:4112729ac2e4
Minor updates for mbox rather than Babyl.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Fri, 20 Feb 2009 06:18:51 +0000 |
parents | 0b2aa9c7a50b |
children | 1d1d5d9bd884 |
rev | line source |
---|---|
68465 | 1 ;;; mh-compat.el --- make MH-E compatibile with various versions of Emacs |
2 | |
101469
0b2aa9c7a50b
Follow Glenn's lead and update format of Copyright.
Bill Wohler <wohler@newt.com>
parents:
100908
diff
changeset
|
3 ;; Copyright (C) 2006, 2007, 2008, 2009 |
0b2aa9c7a50b
Follow Glenn's lead and update format of Copyright.
Bill Wohler <wohler@newt.com>
parents:
100908
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
68465 | 5 |
6 ;; Author: Bill Wohler <wohler@newt.com> | |
7 ;; Maintainer: Bill Wohler <wohler@newt.com> | |
8 ;; Keywords: mail | |
9 ;; See: mh-e.el | |
10 | |
11 ;; This file is part of GNU Emacs. | |
12 | |
94663
90c9ebd43589
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
13 ;; GNU Emacs is free software: you can redistribute it and/or modify |
68465 | 14 ;; it under the terms of the GNU General Public License as published by |
94663
90c9ebd43589
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
15 ;; the Free Software Foundation, either version 3 of the License, or |
90c9ebd43589
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
16 ;; (at your option) any later version. |
68465 | 17 |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
94663
90c9ebd43589
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
68465 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;;; Change Log: | |
29 | |
30 ;;; Code: | |
31 | |
32 ;; This is a good place to gather code that is used for compatibility | |
33 ;; between different versions of Emacs. Please document which versions | |
34 ;; of Emacs that the defsubst, defalias, or defmacro applies. That | |
35 ;; way, it's easy to occasionally go through this file and see which | |
36 ;; macros we can retire. | |
37 | |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
38 ;; Please use mh-gnus.el when providing compatibility with different |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
39 ;; versions of Gnus. |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
40 |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
41 ;; Items are listed alphabetically (except for mh-require which is |
70026
a0de53f6c617
* mh-compat.el (mh-font-lock-add-keywords): New alias for
Bill Wohler <wohler@newt.com>
parents:
69570
diff
changeset
|
42 ;; needed sooner it would normally appear). |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
43 |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
44 (require 'mh-acros) |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
45 |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
46 (mh-do-in-gnu-emacs |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
47 (defalias 'mh-require 'require)) |
68465 | 48 |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
49 (mh-do-in-xemacs |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
50 (defun mh-require (feature &optional filename noerror) |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
51 "If feature FEATURE is not loaded, load it from FILENAME. |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
52 If FEATURE is not a member of the list `features', then the feature |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
53 is not loaded; so load the file FILENAME. |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
54 If FILENAME is omitted, the printname of FEATURE is used as the file name. |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
55 If the optional third argument NOERROR is non-nil, |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
56 then return nil if the file is not found instead of signaling an error. |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
57 |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
58 Simulate NOERROR argument in XEmacs which lacks it." |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
59 (if (not (featurep feature)) |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
60 (if filename |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
61 (load filename noerror t) |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
62 (load (format "%s" feature) noerror t))))) |
68465 | 63 |
70061
b3ab71ac7f4e
* mh-acros.el (mh-defun-compat): Rename to defun-mh in order that
Bill Wohler <wohler@newt.com>
parents:
70033
diff
changeset
|
64 (defun-mh mh-assoc-string assoc-string (key list case-fold) |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
65 "Like `assoc' but specifically for strings. |
68465 | 66 Case is ignored if CASE-FOLD is non-nil. |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
67 This function is used by Emacs versions that lack `assoc-string', |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
68 introduced in Emacs 22." |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
69 (if case-fold |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
70 (assoc-ignore-case key list) |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
71 (assoc key list))) |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
72 |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
73 ;; For XEmacs. |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
74 (defalias 'mh-cancel-timer |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
75 (if (fboundp 'cancel-timer) |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
76 'cancel-timer |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
77 'delete-itimer)) |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
78 |
81809
d95a0f76740e
(mh-display-color-cells): Fix on XEmacs 21.5b28. Thanks to Henrique
Bill Wohler <wohler@newt.com>
parents:
75347
diff
changeset
|
79 (defun mh-display-color-cells (&optional display) |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
80 "Return the number of color cells supported by DISPLAY. |
81809
d95a0f76740e
(mh-display-color-cells): Fix on XEmacs 21.5b28. Thanks to Henrique
Bill Wohler <wohler@newt.com>
parents:
75347
diff
changeset
|
81 This function is used by XEmacs to return 2 when `device-color-cells' |
d95a0f76740e
(mh-display-color-cells): Fix on XEmacs 21.5b28. Thanks to Henrique
Bill Wohler <wohler@newt.com>
parents:
75347
diff
changeset
|
82 or `display-color-cells' returns nil. This happens when compiling or |
69186
4eb7009c53f4
* mh-compat.el (mh-display-color-cells): Return 2 if
Bill Wohler <wohler@newt.com>
parents:
68929
diff
changeset
|
83 running on a tty and causes errors since `display-color-cells' is |
4eb7009c53f4
* mh-compat.el (mh-display-color-cells): Return 2 if
Bill Wohler <wohler@newt.com>
parents:
68929
diff
changeset
|
84 expected to return an integer." |
81809
d95a0f76740e
(mh-display-color-cells): Fix on XEmacs 21.5b28. Thanks to Henrique
Bill Wohler <wohler@newt.com>
parents:
75347
diff
changeset
|
85 (cond ((fboundp 'display-color-cells) ; GNU Emacs, XEmacs 21.5b28 |
d95a0f76740e
(mh-display-color-cells): Fix on XEmacs 21.5b28. Thanks to Henrique
Bill Wohler <wohler@newt.com>
parents:
75347
diff
changeset
|
86 (or (display-color-cells display) 2)) |
d95a0f76740e
(mh-display-color-cells): Fix on XEmacs 21.5b28. Thanks to Henrique
Bill Wohler <wohler@newt.com>
parents:
75347
diff
changeset
|
87 ((fboundp 'device-color-cells) ; XEmacs 21.4 |
d95a0f76740e
(mh-display-color-cells): Fix on XEmacs 21.5b28. Thanks to Henrique
Bill Wohler <wohler@newt.com>
parents:
75347
diff
changeset
|
88 (or (device-color-cells display) 2)) |
d95a0f76740e
(mh-display-color-cells): Fix on XEmacs 21.5b28. Thanks to Henrique
Bill Wohler <wohler@newt.com>
parents:
75347
diff
changeset
|
89 (t 2))) |
68465 | 90 |
91 (defmacro mh-display-completion-list (completions &optional common-substring) | |
92 "Display the list of COMPLETIONS. | |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
93 See documentation for `display-completion-list' for a description of the |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
94 arguments COMPLETIONS and perhaps COMMON-SUBSTRING. |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
95 This macro is used by Emacs versions that lack a COMMON-SUBSTRING |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
96 argument, introduced in Emacs 22." |
68465 | 97 (if (< emacs-major-version 22) |
98 `(display-completion-list ,completions) | |
99 `(display-completion-list ,completions ,common-substring))) | |
100 | |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
101 (defmacro mh-face-foreground (face &optional frame inherit) |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
102 "Return the foreground color name of FACE, or nil if unspecified. |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
103 See documentation for `face-foreground' for a description of the |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
104 arguments FACE, FRAME, and perhaps INHERIT. |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
105 This macro is used by Emacs versions that lack an INHERIT argument, |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
106 introduced in Emacs 22." |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
107 (if (< emacs-major-version 22) |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
108 `(face-foreground ,face ,frame) |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
109 `(face-foreground ,face ,frame ,inherit))) |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
110 |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
111 (defmacro mh-face-background (face &optional frame inherit) |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
112 "Return the background color name of face, or nil if unspecified. |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
113 See documentation for `back-foreground' for a description of the |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
114 arguments FACE, FRAME, and INHERIT. |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
115 This macro is used by Emacs versions that lack an INHERIT argument, |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
116 introduced in Emacs 22." |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
117 (if (< emacs-major-version 22) |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
118 `(face-background ,face ,frame) |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
119 `(face-background ,face ,frame ,inherit))) |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
120 |
70061
b3ab71ac7f4e
* mh-acros.el (mh-defun-compat): Rename to defun-mh in order that
Bill Wohler <wohler@newt.com>
parents:
70033
diff
changeset
|
121 (defun-mh mh-font-lock-add-keywords font-lock-add-keywords |
70026
a0de53f6c617
* mh-compat.el (mh-font-lock-add-keywords): New alias for
Bill Wohler <wohler@newt.com>
parents:
69570
diff
changeset
|
122 (mode keywords &optional how) |
70033
257bb51424b3
(mh-font-lock-add-keywords): Fix typo in docstring.
Bill Wohler <wohler@newt.com>
parents:
70026
diff
changeset
|
123 "XEmacs does not have `font-lock-add-keywords'. |
70026
a0de53f6c617
* mh-compat.el (mh-font-lock-add-keywords): New alias for
Bill Wohler <wohler@newt.com>
parents:
69570
diff
changeset
|
124 This function returns nil on that system.") |
a0de53f6c617
* mh-compat.el (mh-font-lock-add-keywords): New alias for
Bill Wohler <wohler@newt.com>
parents:
69570
diff
changeset
|
125 |
70061
b3ab71ac7f4e
* mh-acros.el (mh-defun-compat): Rename to defun-mh in order that
Bill Wohler <wohler@newt.com>
parents:
70033
diff
changeset
|
126 (defun-mh mh-image-load-path-for-library |
69364
4117123b24f3
(mh-image-load-path-for-library): Merged changes from Reiner. Add
Bill Wohler <wohler@newt.com>
parents:
69363
diff
changeset
|
127 image-load-path-for-library (library image &optional path no-error) |
69570
822a6a9bb8c9
(mh-image-load-path-for-library): Shorten first line in docstring.
Bill Wohler <wohler@newt.com>
parents:
69536
diff
changeset
|
128 "Return a suitable search path for images used by LIBRARY. |
69278
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
129 |
69536
052139add0ff
(mh-image-load-path-for-library): Minor docstring fix.
Bill Wohler <wohler@newt.com>
parents:
69518
diff
changeset
|
130 It searches for IMAGE in `image-load-path' (excluding |
69518
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
131 \"`data-directory'/images\") and `load-path', followed by a path |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
132 suitable for LIBRARY, which includes \"../../etc/images\" and |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
133 \"../etc/images\" relative to the library file itself, and then |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
134 in \"`data-directory'/images\". |
69278
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
135 |
69472
5259cc742763
* mh-compat.el (mh-image-load-path-for-library): Incorporate changes
Bill Wohler <wohler@newt.com>
parents:
69364
diff
changeset
|
136 Then this function returns a list of directories which contains |
5259cc742763
* mh-compat.el (mh-image-load-path-for-library): Incorporate changes
Bill Wohler <wohler@newt.com>
parents:
69364
diff
changeset
|
137 first the directory in which IMAGE was found, followed by the |
5259cc742763
* mh-compat.el (mh-image-load-path-for-library): Incorporate changes
Bill Wohler <wohler@newt.com>
parents:
69364
diff
changeset
|
138 value of `load-path'. If PATH is given, it is used instead of |
5259cc742763
* mh-compat.el (mh-image-load-path-for-library): Incorporate changes
Bill Wohler <wohler@newt.com>
parents:
69364
diff
changeset
|
139 `load-path'. |
69364
4117123b24f3
(mh-image-load-path-for-library): Merged changes from Reiner. Add
Bill Wohler <wohler@newt.com>
parents:
69363
diff
changeset
|
140 |
69472
5259cc742763
* mh-compat.el (mh-image-load-path-for-library): Incorporate changes
Bill Wohler <wohler@newt.com>
parents:
69364
diff
changeset
|
141 If NO-ERROR is non-nil and a suitable path can't be found, don't |
5259cc742763
* mh-compat.el (mh-image-load-path-for-library): Incorporate changes
Bill Wohler <wohler@newt.com>
parents:
69364
diff
changeset
|
142 signal an error. Instead, return a list of directories as before, |
5259cc742763
* mh-compat.el (mh-image-load-path-for-library): Incorporate changes
Bill Wohler <wohler@newt.com>
parents:
69364
diff
changeset
|
143 except that nil appears in place of the image directory. |
69278
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
144 |
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
145 Here is an example that uses a common idiom to provide |
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
146 compatibility with versions of Emacs that lack the variable |
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
147 `image-load-path': |
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
148 |
69492
6afc0d1f682b
* mh-compat.el (mh-image-load-path-for-library): Fix example by not
Bill Wohler <wohler@newt.com>
parents:
69472
diff
changeset
|
149 ;; Shush compiler. |
6afc0d1f682b
* mh-compat.el (mh-image-load-path-for-library): Fix example by not
Bill Wohler <wohler@newt.com>
parents:
69472
diff
changeset
|
150 (defvar image-load-path) |
69278
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
151 |
69472
5259cc742763
* mh-compat.el (mh-image-load-path-for-library): Incorporate changes
Bill Wohler <wohler@newt.com>
parents:
69364
diff
changeset
|
152 (let* ((load-path (image-load-path-for-library \"mh-e\" \"mh-logo.xpm\")) |
69492
6afc0d1f682b
* mh-compat.el (mh-image-load-path-for-library): Fix example by not
Bill Wohler <wohler@newt.com>
parents:
69472
diff
changeset
|
153 (image-load-path (cons (car load-path) |
6afc0d1f682b
* mh-compat.el (mh-image-load-path-for-library): Fix example by not
Bill Wohler <wohler@newt.com>
parents:
69472
diff
changeset
|
154 (when (boundp 'image-load-path) |
6afc0d1f682b
* mh-compat.el (mh-image-load-path-for-library): Fix example by not
Bill Wohler <wohler@newt.com>
parents:
69472
diff
changeset
|
155 image-load-path)))) |
69472
5259cc742763
* mh-compat.el (mh-image-load-path-for-library): Incorporate changes
Bill Wohler <wohler@newt.com>
parents:
69364
diff
changeset
|
156 (mh-tool-bar-folder-buttons-init))" |
69278
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
157 (unless library (error "No library specified")) |
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
158 (unless image (error "No image specified")) |
69518
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
159 (let (image-directory image-directory-load-path) |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
160 ;; Check for images in image-load-path or load-path. |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
161 (let ((img image) |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
162 (dir (or |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
163 ;; Images in image-load-path. |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
164 (mh-image-search-load-path image) |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
165 ;; Images in load-path. |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
166 (locate-library image))) |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
167 parent) |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
168 ;; Since the image might be in a nested directory (for |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
169 ;; example, mail/attach.pbm), adjust `image-directory' |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
170 ;; accordingly. |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
171 (when dir |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
172 (setq dir (file-name-directory dir)) |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
173 (while (setq parent (file-name-directory img)) |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
174 (setq img (directory-file-name parent) |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
175 dir (expand-file-name "../" dir)))) |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
176 (setq image-directory-load-path dir)) |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
177 |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
178 ;; If `image-directory-load-path' isn't Emacs' image directory, |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
179 ;; it's probably a user preference, so use it. Then use a |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
180 ;; relative setting if possible; otherwise, use |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
181 ;; `image-directory-load-path'. |
69278
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
182 (cond |
69518
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
183 ;; User-modified image-load-path? |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
184 ((and image-directory-load-path |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
185 (not (equal image-directory-load-path |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
186 (file-name-as-directory |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
187 (expand-file-name "images" data-directory))))) |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
188 (setq image-directory image-directory-load-path)) |
69278
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
189 ;; Try relative setting. |
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
190 ((let (library-name d1ei d2ei) |
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
191 ;; First, find library in the load-path. |
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
192 (setq library-name (locate-library library)) |
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
193 (if (not library-name) |
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
194 (error "Cannot find library %s in load-path" library)) |
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
195 ;; And then set image-directory relative to that. |
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
196 (setq |
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
197 ;; Go down 2 levels. |
69518
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
198 d2ei (file-name-as-directory |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
199 (expand-file-name |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
200 (concat (file-name-directory library-name) "../../etc/images"))) |
69278
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
201 ;; Go down 1 level. |
69518
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
202 d1ei (file-name-as-directory |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
203 (expand-file-name |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
204 (concat (file-name-directory library-name) "../etc/images")))) |
69278
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
205 (setq image-directory |
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
206 ;; Set it to nil if image is not found. |
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
207 (cond ((file-exists-p (expand-file-name image d2ei)) d2ei) |
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
208 ((file-exists-p (expand-file-name image d1ei)) d1ei))))) |
69518
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
209 ;; Use Emacs' image directory. |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
210 (image-directory-load-path |
2f7238ff01ad
(mh-image-load-path-for-library): Prefer user's images.
Bill Wohler <wohler@newt.com>
parents:
69492
diff
changeset
|
211 (setq image-directory image-directory-load-path)) |
69364
4117123b24f3
(mh-image-load-path-for-library): Merged changes from Reiner. Add
Bill Wohler <wohler@newt.com>
parents:
69363
diff
changeset
|
212 (no-error |
4117123b24f3
(mh-image-load-path-for-library): Merged changes from Reiner. Add
Bill Wohler <wohler@newt.com>
parents:
69363
diff
changeset
|
213 (message "Could not find image %s for library %s" image library)) |
69278
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
214 (t |
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
215 (error "Could not find image %s for library %s" image library))) |
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
216 |
69472
5259cc742763
* mh-compat.el (mh-image-load-path-for-library): Incorporate changes
Bill Wohler <wohler@newt.com>
parents:
69364
diff
changeset
|
217 ;; Return an augmented `path' or `load-path'. |
5259cc742763
* mh-compat.el (mh-image-load-path-for-library): Incorporate changes
Bill Wohler <wohler@newt.com>
parents:
69364
diff
changeset
|
218 (nconc (list image-directory) |
5259cc742763
* mh-compat.el (mh-image-load-path-for-library): Incorporate changes
Bill Wohler <wohler@newt.com>
parents:
69364
diff
changeset
|
219 (delete image-directory (copy-sequence (or path load-path)))))) |
69278
ade4a047af1b
* mh-compat.el (mh-image-load-path-for-library): Move here from
Bill Wohler <wohler@newt.com>
parents:
69186
diff
changeset
|
220 |
70061
b3ab71ac7f4e
* mh-acros.el (mh-defun-compat): Rename to defun-mh in order that
Bill Wohler <wohler@newt.com>
parents:
70033
diff
changeset
|
221 (defun-mh mh-image-search-load-path |
68929
3f537f106072
mh-compat.el (mh-image-search-load-path): Compatibility code. Emacs 21 and
Peter Galbraith <galbraith@mixing.qc.dfo.ca>
parents:
68746
diff
changeset
|
222 image-search-load-path (file &optional path) |
3f537f106072
mh-compat.el (mh-image-search-load-path): Compatibility code. Emacs 21 and
Peter Galbraith <galbraith@mixing.qc.dfo.ca>
parents:
68746
diff
changeset
|
223 "Emacs 21 and XEmacs don't have `image-search-load-path'. |
3f537f106072
mh-compat.el (mh-image-search-load-path): Compatibility code. Emacs 21 and
Peter Galbraith <galbraith@mixing.qc.dfo.ca>
parents:
68746
diff
changeset
|
224 This function returns nil on those systems." |
3f537f106072
mh-compat.el (mh-image-search-load-path): Compatibility code. Emacs 21 and
Peter Galbraith <galbraith@mixing.qc.dfo.ca>
parents:
68746
diff
changeset
|
225 nil) |
3f537f106072
mh-compat.el (mh-image-search-load-path): Compatibility code. Emacs 21 and
Peter Galbraith <galbraith@mixing.qc.dfo.ca>
parents:
68746
diff
changeset
|
226 |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
227 ;; For XEmacs. |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
228 (defalias 'mh-line-beginning-position |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
229 (if (fboundp 'line-beginning-position) |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
230 'line-beginning-position |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
231 'point-at-bol)) |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
232 |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
233 ;; For XEmacs. |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
234 (defalias 'mh-line-end-position |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
235 (if (fboundp 'line-end-position) |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
236 'line-end-position |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
237 'point-at-eol)) |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
238 |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
239 (mh-require 'mailabbrev nil t) |
70061
b3ab71ac7f4e
* mh-acros.el (mh-defun-compat): Rename to defun-mh in order that
Bill Wohler <wohler@newt.com>
parents:
70033
diff
changeset
|
240 (defun-mh mh-mail-abbrev-make-syntax-table |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
241 mail-abbrev-make-syntax-table () |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
242 "Emacs 21 and XEmacs don't have `mail-abbrev-make-syntax-table'. |
68929
3f537f106072
mh-compat.el (mh-image-search-load-path): Compatibility code. Emacs 21 and
Peter Galbraith <galbraith@mixing.qc.dfo.ca>
parents:
68746
diff
changeset
|
243 This function returns nil on those systems." |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
244 nil) |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
245 |
70061
b3ab71ac7f4e
* mh-acros.el (mh-defun-compat): Rename to defun-mh in order that
Bill Wohler <wohler@newt.com>
parents:
70033
diff
changeset
|
246 (defun-mh mh-match-string-no-properties |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
247 match-string-no-properties (num &optional string) |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
248 "Return string of text matched by last search, without text properties. |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
249 This function is used by XEmacs that lacks `match-string-no-properties'. |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
250 The function `buffer-substring-no-properties' is used instead. |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
251 The argument STRING is ignored." |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
252 (buffer-substring-no-properties |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
253 (match-beginning num) (match-end num))) |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
254 |
70061
b3ab71ac7f4e
* mh-acros.el (mh-defun-compat): Rename to defun-mh in order that
Bill Wohler <wohler@newt.com>
parents:
70033
diff
changeset
|
255 (defun-mh mh-replace-regexp-in-string replace-regexp-in-string |
68746
3741bfb4402f
(mh-replace-regexp-in-string): Add missing regexp argument.
Bill Wohler <wohler@newt.com>
parents:
68595
diff
changeset
|
256 (regexp rep string &optional fixedcase literal subexp start) |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
257 "Replace REGEXP with REP everywhere in STRING and return result. |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
258 This function is used by XEmacs that lacks `replace-regexp-in-string'. |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
259 The function `replace-in-string' is used instead. |
69363
7b2d244e58fe
(mh-replace-regexp-in-string): Pass the literal flag to
Bill Wohler <wohler@newt.com>
parents:
69278
diff
changeset
|
260 The arguments FIXEDCASE, SUBEXP, and START, used by |
7b2d244e58fe
(mh-replace-regexp-in-string): Pass the literal flag to
Bill Wohler <wohler@newt.com>
parents:
69278
diff
changeset
|
261 `replace-in-string' are ignored." |
7b2d244e58fe
(mh-replace-regexp-in-string): Pass the literal flag to
Bill Wohler <wohler@newt.com>
parents:
69278
diff
changeset
|
262 (replace-in-string string regexp rep literal)) |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
263 |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
264 ;; Copy of constant from url-util.el in Emacs 22; needed by Emacs 21. |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
265 (if (not (boundp 'url-unreserved-chars)) |
68595
37aca5dcac0c
(mh-url-unreserved-chars): Fix typo from `mh-url-unresrved-chars'.
Peter Galbraith <galbraith@mixing.qc.dfo.ca>
parents:
68529
diff
changeset
|
266 (defconst mh-url-unreserved-chars |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
267 '( |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
268 ?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 |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
269 ?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 |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
270 ?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9 |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
271 ?- ?_ ?. ?! ?~ ?* ?' ?\( ?\)) |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
272 "A list of characters that are _NOT_ reserved in the URL spec. |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
273 This is taken from RFC 2396.")) |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
274 |
70061
b3ab71ac7f4e
* mh-acros.el (mh-defun-compat): Rename to defun-mh in order that
Bill Wohler <wohler@newt.com>
parents:
70033
diff
changeset
|
275 (defun-mh mh-url-hexify-string url-hexify-string (str) |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
276 "Escape characters in a string. |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
277 This is a copy of `url-hexify-string' from url-util.el in Emacs |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
278 22; needed by Emacs 21." |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
279 (mapconcat |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
280 (lambda (char) |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
281 ;; Fixme: use a char table instead. |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
282 (if (not (memq char mh-url-unreserved-chars)) |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
283 (if (> char 255) |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
284 (error "Hexifying multibyte character %s" str) |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
285 (format "%%%02X" char)) |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
286 (char-to-string char))) |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
287 str "")) |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
288 |
70061
b3ab71ac7f4e
* mh-acros.el (mh-defun-compat): Rename to defun-mh in order that
Bill Wohler <wohler@newt.com>
parents:
70033
diff
changeset
|
289 (defun-mh mh-view-mode-enter |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
290 view-mode-enter (&optional return-to exit-action) |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
291 "Enter View mode. |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
292 This function is used by XEmacs that lacks `view-mode-enter'. |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
293 The function `view-mode' is used instead. |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
294 The arguments RETURN-TO and EXIT-ACTION are ignored." |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
295 ;; Shush compiler. |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
296 (if return-to nil) |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
297 (if exit-action nil) |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
298 (view-mode 1)) |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
299 |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
300 (defmacro mh-write-file-functions () |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
301 "Return `write-file-functions' if it exists. |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
302 Otherwise return `local-write-file-hooks'. |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
303 This macro exists purely for compatibility. The former symbol is used |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
304 in Emacs 22 onward while the latter is used in previous versions and |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
305 XEmacs." |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
306 (if (boundp 'write-file-functions) |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
307 ''write-file-functions ;Emacs 22 on |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
308 ''local-write-file-hooks)) ;XEmacs |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68470
diff
changeset
|
309 |
68465 | 310 (provide 'mh-compat) |
311 | |
312 ;; Local Variables: | |
313 ;; no-byte-compile: t | |
314 ;; indent-tabs-mode: nil | |
315 ;; sentence-end-double-space: nil | |
316 ;; End: | |
317 | |
68470 | 318 ;; arch-tag: 577b0eab-a5cd-45e1-8d9f-c1a426f4d73c |
68465 | 319 ;;; mh-compat.el ends here |