Mercurial > emacs
annotate lisp/gnus/mm-util.el @ 32531:2555cdee2fed
(jit-lock-after-change): If we're in text that
matches a multi-line font-lock pattern, make sure the whole text
will be redisplayed.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Mon, 16 Oct 2000 13:04:34 +0000 |
parents | cbdba3c57536 |
children | aa9dc4e7c5ac |
rev | line source |
---|---|
31717 | 1 ;;; mm-util.el --- Utility functions for MIME things |
2 ;; Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. | |
3 | |
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> | |
5 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp> | |
6 ;; This file is part of GNU Emacs. | |
7 | |
8 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
9 ;; it under the terms of the GNU General Public License as published by | |
10 ;; the Free Software Foundation; either version 2, or (at your option) | |
11 ;; any later version. | |
12 | |
13 ;; GNU Emacs is distributed in the hope that it will be useful, | |
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 ;; GNU General Public License for more details. | |
17 | |
18 ;; You should have received a copy of the GNU General Public License | |
19 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
20 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
21 ;; Boston, MA 02111-1307, USA. | |
22 | |
23 ;;; Commentary: | |
24 | |
25 ;;; Code: | |
26 | |
27 (require 'mail-prsvr) | |
28 | |
29 (defvar mm-mime-mule-charset-alist | |
30 '((us-ascii ascii) | |
31 (iso-8859-1 latin-iso8859-1) | |
32 (iso-8859-2 latin-iso8859-2) | |
33 (iso-8859-3 latin-iso8859-3) | |
34 (iso-8859-4 latin-iso8859-4) | |
35 (iso-8859-5 cyrillic-iso8859-5) | |
36 ;; Non-mule (X)Emacs uses the last mule-charset for 8bit characters. | |
37 ;; The fake mule-charset, gnus-koi8-r, tells Gnus that the default | |
38 ;; charset is koi8-r, not iso-8859-5. | |
39 (koi8-r cyrillic-iso8859-5 gnus-koi8-r) | |
40 (iso-8859-6 arabic-iso8859-6) | |
41 (iso-8859-7 greek-iso8859-7) | |
42 (iso-8859-8 hebrew-iso8859-8) | |
43 (iso-8859-9 latin-iso8859-9) | |
32414
cbdba3c57536
(mm-charset-synonym-alist): Add windows-1252.
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
44 (iso-8859-14 latin-iso8859-14) |
cbdba3c57536
(mm-charset-synonym-alist): Add windows-1252.
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
45 (iso-8859-15 latin-iso8859-15) |
31717 | 46 (viscii vietnamese-viscii-lower) |
47 (iso-2022-jp latin-jisx0201 japanese-jisx0208 japanese-jisx0208-1978) | |
48 (euc-kr korean-ksc5601) | |
49 (cn-gb-2312 chinese-gb2312) | |
50 (cn-big5 chinese-big5-1 chinese-big5-2) | |
51 (tibetan tibetan) | |
52 (thai-tis620 thai-tis620) | |
53 (iso-2022-7bit ethiopic arabic-1-column arabic-2-column) | |
54 (iso-2022-jp-2 latin-iso8859-1 greek-iso8859-7 | |
55 latin-jisx0201 japanese-jisx0208-1978 | |
56 chinese-gb2312 japanese-jisx0208 | |
57 korean-ksc5601 japanese-jisx0212 | |
58 katakana-jisx0201) | |
59 (iso-2022-int-1 latin-iso8859-1 greek-iso8859-7 | |
60 latin-jisx0201 japanese-jisx0208-1978 | |
61 chinese-gb2312 japanese-jisx0208 | |
62 korean-ksc5601 japanese-jisx0212 | |
63 chinese-cns11643-1 chinese-cns11643-2) | |
64 (iso-2022-int-1 latin-iso8859-1 latin-iso8859-2 | |
65 cyrillic-iso8859-5 greek-iso8859-7 | |
66 latin-jisx0201 japanese-jisx0208-1978 | |
67 chinese-gb2312 japanese-jisx0208 | |
68 korean-ksc5601 japanese-jisx0212 | |
69 chinese-cns11643-1 chinese-cns11643-2 | |
70 chinese-cns11643-3 chinese-cns11643-4 | |
71 chinese-cns11643-5 chinese-cns11643-6 | |
72 chinese-cns11643-7) | |
73 (utf-8 unicode-a unicode-b unicode-c unicode-d unicode-e)) | |
74 "Alist of MIME-charset/MULE-charsets.") | |
75 | |
76 (eval-and-compile | |
77 (mapcar | |
78 (lambda (elem) | |
79 (let ((nfunc (intern (format "mm-%s" (car elem))))) | |
80 (if (fboundp (car elem)) | |
81 (defalias nfunc (car elem)) | |
82 (defalias nfunc (cdr elem))))) | |
83 '((decode-coding-string . (lambda (s a) s)) | |
84 (encode-coding-string . (lambda (s a) s)) | |
85 (encode-coding-region . ignore) | |
86 (coding-system-list . ignore) | |
87 (decode-coding-region . ignore) | |
88 (char-int . identity) | |
89 (device-type . ignore) | |
90 (coding-system-equal . equal) | |
91 (annotationp . ignore) | |
92 (set-buffer-file-coding-system . ignore) | |
93 (make-char | |
94 . (lambda (charset int) | |
95 (int-to-char int))) | |
96 (read-coding-system | |
97 . (lambda (prompt) | |
98 "Prompt the user for a coding system." | |
99 (completing-read | |
100 prompt (mapcar (lambda (s) (list (symbol-name (car s)))) | |
101 mm-mime-mule-charset-alist)))) | |
102 (read-charset | |
103 . (lambda (prompt) | |
104 "Return a charset." | |
105 (intern | |
106 (completing-read | |
107 prompt | |
108 (mapcar (lambda (e) (list (symbol-name (car e)))) | |
109 mm-mime-mule-charset-alist) | |
110 nil t))))))) | |
111 | |
112 (eval-and-compile | |
113 (defalias 'mm-char-or-char-int-p | |
114 (cond | |
115 ((fboundp 'char-or-char-int-p) 'char-or-char-int-p) | |
116 ((fboundp 'char-valid-p) 'char-valid-p) | |
117 (t 'identity)))) | |
118 | |
119 (defvar mm-coding-system-list nil) | |
120 (defun mm-get-coding-system-list () | |
121 "Get the coding system list." | |
122 (or mm-coding-system-list | |
123 (setq mm-coding-system-list (mm-coding-system-list)))) | |
124 | |
125 (defvar mm-charset-synonym-alist | |
32414
cbdba3c57536
(mm-charset-synonym-alist): Add windows-1252.
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
126 `((big5 . cn-big5) |
31717 | 127 (gb2312 . cn-gb-2312) |
32414
cbdba3c57536
(mm-charset-synonym-alist): Add windows-1252.
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
128 ;; Windows-1252 is actually a superset of Latin-1. See also |
cbdba3c57536
(mm-charset-synonym-alist): Add windows-1252.
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
129 ;; `gnus-article-dumbquotes-map'. |
cbdba3c57536
(mm-charset-synonym-alist): Add windows-1252.
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
130 (unless (mm-coding-system-p 'windows-1252) ; should be defined eventually |
cbdba3c57536
(mm-charset-synonym-alist): Add windows-1252.
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
131 (windows-1252 . iso-8859-1)) |
31717 | 132 (x-ctext . ctext)) |
133 "A mapping from invalid charset names to the real charset names.") | |
134 | |
135 (defun mm-coding-system-p (sym) | |
136 "Return non-nil if SYM is a coding system." | |
137 (or (and (fboundp 'coding-system-p) (coding-system-p sym)) | |
138 (memq sym (mm-get-coding-system-list)))) | |
139 | |
140 (defvar mm-binary-coding-system | |
141 (cond | |
142 ((mm-coding-system-p 'binary) 'binary) | |
143 ((mm-coding-system-p 'no-conversion) 'no-conversion) | |
144 (t nil)) | |
145 "100% binary coding system.") | |
146 | |
147 (defvar mm-text-coding-system | |
148 (or (if (memq system-type '(windows-nt ms-dos ms-windows)) | |
149 (and (mm-coding-system-p 'raw-text-dos) 'raw-text-dos) | |
150 (and (mm-coding-system-p 'raw-text) 'raw-text)) | |
151 mm-binary-coding-system) | |
152 "Text-safe coding system (For removing ^M).") | |
153 | |
154 (defvar mm-text-coding-system-for-write nil | |
155 "Text coding system for write.") | |
156 | |
157 (defvar mm-auto-save-coding-system | |
158 (cond | |
159 ((mm-coding-system-p 'emacs-mule) | |
160 (if (memq system-type '(windows-nt ms-dos ms-windows)) | |
161 (if (mm-coding-system-p 'emacs-mule-dos) | |
162 'emacs-mule-dos mm-binary-coding-system) | |
163 'emacs-mule)) | |
164 ((mm-coding-system-p 'escape-quoted) 'escape-quoted) | |
165 (t mm-binary-coding-system)) | |
166 "Coding system of auto save file.") | |
167 | |
168 ;;; Internal variables: | |
169 | |
170 ;;; Functions: | |
171 | |
172 (defun mm-mule-charset-to-mime-charset (charset) | |
173 "Return the MIME charset corresponding to MULE CHARSET." | |
174 (let ((alist mm-mime-mule-charset-alist) | |
175 out) | |
176 (while alist | |
177 (when (memq charset (cdar alist)) | |
178 (setq out (caar alist) | |
179 alist nil)) | |
180 (pop alist)) | |
181 out)) | |
182 | |
183 (defun mm-charset-to-coding-system (charset &optional lbt) | |
184 "Return coding-system corresponding to CHARSET. | |
185 CHARSET is a symbol naming a MIME charset. | |
186 If optional argument LBT (`unix', `dos' or `mac') is specified, it is | |
187 used as the line break code type of the coding system." | |
188 (when (stringp charset) | |
189 (setq charset (intern (downcase charset)))) | |
190 (setq charset | |
191 (or (cdr (assq charset mm-charset-synonym-alist)) | |
192 charset)) | |
193 (when lbt | |
194 (setq charset (intern (format "%s-%s" charset lbt)))) | |
195 (cond | |
196 ;; Running in a non-MULE environment. | |
197 ((null (mm-get-coding-system-list)) | |
198 charset) | |
199 ;; ascii | |
200 ((eq charset 'us-ascii) | |
201 'ascii) | |
202 ;; Check to see whether we can handle this charset. | |
203 ((memq charset (mm-get-coding-system-list)) | |
204 charset) | |
205 ;; Nope. | |
206 (t | |
207 nil))) | |
208 | |
209 (if (fboundp 'subst-char-in-string) | |
210 (defsubst mm-replace-chars-in-string (string from to) | |
211 (subst-char-in-string from to string)) | |
212 (defun mm-replace-chars-in-string (string from to) | |
213 "Replace characters in STRING from FROM to TO." | |
214 (let ((string (substring string 0)) ;Copy string. | |
215 (len (length string)) | |
216 (idx 0)) | |
217 ;; Replace all occurrences of FROM with TO. | |
218 (while (< idx len) | |
219 (when (= (aref string idx) from) | |
220 (aset string idx to)) | |
221 (setq idx (1+ idx))) | |
222 string))) | |
223 | |
224 (defsubst mm-enable-multibyte () | |
225 "Enable multibyte in the current buffer." | |
226 (when (and (fboundp 'set-buffer-multibyte) | |
227 (boundp 'enable-multibyte-characters) | |
228 (default-value 'enable-multibyte-characters)) | |
229 (set-buffer-multibyte t))) | |
230 | |
231 (defsubst mm-disable-multibyte () | |
232 "Disable multibyte in the current buffer." | |
233 (when (fboundp 'set-buffer-multibyte) | |
234 (set-buffer-multibyte nil))) | |
235 | |
236 (defun mm-preferred-coding-system (charset) | |
237 ;; A typo in some Emacs versions. | |
238 (or (get-charset-property charset 'prefered-coding-system) | |
239 (get-charset-property charset 'preferred-coding-system))) | |
240 | |
241 (defun mm-charset-after (&optional pos) | |
242 "Return charset of a character in current buffer at position POS. | |
243 If POS is nil, it defauls to the current point. | |
244 If POS is out of range, the value is nil. | |
245 If the charset is `composition', return the actual one." | |
246 (let ((charset (cond | |
247 ((fboundp 'charset-after) | |
248 (charset-after pos)) | |
249 ((fboundp 'char-charset) | |
250 (char-charset (char-after pos))) | |
251 ((< (mm-char-int (char-after pos)) 128) | |
252 'ascii) | |
253 (mail-parse-mule-charset ;; cached mule-charset | |
254 mail-parse-mule-charset) | |
255 ((boundp 'current-language-environment) | |
256 (let ((entry (assoc current-language-environment | |
257 language-info-alist))) | |
258 (setq mail-parse-mule-charset | |
259 (or (car (last (assq 'charset entry))) | |
260 'latin-iso8859-1)))) | |
261 (t ;; figure out the charset | |
262 (setq mail-parse-mule-charset | |
263 (or (car (last (assq mail-parse-charset | |
264 mm-mime-mule-charset-alist))) | |
265 'latin-iso8859-1)))))) | |
266 (if (eq charset 'composition) | |
267 (let ((p (or pos (point)))) | |
268 (cadr (find-charset-region p (1+ p)))) | |
269 charset))) | |
270 | |
271 (defun mm-mime-charset (charset) | |
272 "Return the MIME charset corresponding to the MULE CHARSET." | |
32414
cbdba3c57536
(mm-charset-synonym-alist): Add windows-1252.
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
273 (if (and (fboundp 'coding-system-get) |
cbdba3c57536
(mm-charset-synonym-alist): Add windows-1252.
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
274 (fboundp 'get-charset-property)) |
31717 | 275 ;; This exists in Emacs 20. |
276 (or | |
277 (and (mm-preferred-coding-system charset) | |
278 (coding-system-get | |
279 (mm-preferred-coding-system charset) 'mime-charset)) | |
280 (and (eq charset 'ascii) | |
281 'us-ascii) | |
282 (mm-preferred-coding-system charset) | |
283 (mm-mule-charset-to-mime-charset charset)) | |
284 ;; This is for XEmacs. | |
285 (mm-mule-charset-to-mime-charset charset))) | |
286 | |
287 (defun mm-delete-duplicates (list) | |
288 "Simple substitute for CL `delete-duplicates', testing with `equal'." | |
289 (let (result head) | |
290 (while list | |
291 (setq head (car list)) | |
292 (setq list (delete head list)) | |
293 (setq result (cons head result))) | |
294 (nreverse result))) | |
295 | |
296 (defun mm-find-mime-charset-region (b e) | |
297 "Return the MIME charsets needed to encode the region between B and E." | |
298 (let ((charsets (mapcar 'mm-mime-charset | |
299 (delq 'ascii | |
300 (mm-find-charset-region b e))))) | |
301 (when (memq 'iso-2022-jp-2 charsets) | |
302 (setq charsets (delq 'iso-2022-jp charsets))) | |
303 (setq charsets (mm-delete-duplicates charsets)) | |
304 (if (and (> (length charsets) 1) | |
305 (fboundp 'find-coding-systems-region) | |
306 (memq 'utf-8 (find-coding-systems-region b e))) | |
307 '(utf-8) | |
308 charsets))) | |
309 | |
310 (defsubst mm-multibyte-p () | |
311 "Say whether multibyte is enabled." | |
312 (or (featurep 'xemacs) | |
313 (and (boundp 'enable-multibyte-characters) | |
314 enable-multibyte-characters))) | |
315 | |
316 (defmacro mm-with-unibyte-buffer (&rest forms) | |
317 "Create a temporary buffer, and evaluate FORMS there like `progn'. | |
318 See also `with-temp-file' and `with-output-to-string'." | |
319 (let ((temp-buffer (make-symbol "temp-buffer")) | |
320 (multibyte (make-symbol "multibyte"))) | |
321 `(if (or (string-match "XEmacs\\|Lucid" emacs-version) | |
322 (not (boundp 'enable-multibyte-characters))) | |
323 (with-temp-buffer ,@forms) | |
324 (let ((,multibyte (default-value 'enable-multibyte-characters)) | |
325 ,temp-buffer) | |
326 (unwind-protect | |
327 (progn | |
328 (setq-default enable-multibyte-characters nil) | |
329 (setq ,temp-buffer | |
330 (get-buffer-create (generate-new-buffer-name " *temp*"))) | |
331 (unwind-protect | |
332 (with-current-buffer ,temp-buffer | |
333 (let ((buffer-file-coding-system mm-binary-coding-system) | |
334 (coding-system-for-read mm-binary-coding-system) | |
335 (coding-system-for-write mm-binary-coding-system)) | |
336 ,@forms)) | |
337 (and (buffer-name ,temp-buffer) | |
338 (kill-buffer ,temp-buffer)))) | |
339 (setq-default enable-multibyte-characters ,multibyte)))))) | |
340 (put 'mm-with-unibyte-buffer 'lisp-indent-function 0) | |
341 (put 'mm-with-unibyte-buffer 'edebug-form-spec '(body)) | |
342 | |
343 (defmacro mm-with-unibyte-current-buffer (&rest forms) | |
344 "Evaluate FORMS there like `progn' in current buffer." | |
345 (let ((multibyte (make-symbol "multibyte"))) | |
346 `(if (or (featurep 'xemacs) | |
347 (not (fboundp 'set-buffer-multibyte))) | |
348 (progn | |
349 ,@forms) | |
350 (let ((,multibyte (default-value 'enable-multibyte-characters))) | |
351 (unwind-protect | |
352 (let ((buffer-file-coding-system mm-binary-coding-system) | |
353 (coding-system-for-read mm-binary-coding-system) | |
354 (coding-system-for-write mm-binary-coding-system)) | |
355 (set-buffer-multibyte nil) | |
356 (setq-default enable-multibyte-characters nil) | |
357 ,@forms) | |
358 (setq-default enable-multibyte-characters ,multibyte) | |
359 (set-buffer-multibyte ,multibyte)))))) | |
360 (put 'mm-with-unibyte-current-buffer 'lisp-indent-function 0) | |
361 (put 'mm-with-unibyte-current-buffer 'edebug-form-spec '(body)) | |
362 | |
363 (defmacro mm-with-unibyte (&rest forms) | |
364 "Set default `enable-multibyte-characters' to `nil', eval the FORMS." | |
365 (let ((multibyte (make-symbol "multibyte"))) | |
366 `(if (or (featurep 'xemacs) | |
367 (not (boundp 'enable-multibyte-characters))) | |
368 (progn ,@forms) | |
369 (let ((,multibyte (default-value 'enable-multibyte-characters))) | |
370 (unwind-protect | |
371 (progn | |
372 (setq-default enable-multibyte-characters nil) | |
373 ,@forms) | |
374 (setq-default enable-multibyte-characters ,multibyte)))))) | |
375 (put 'mm-with-unibyte 'lisp-indent-function 0) | |
376 (put 'mm-with-unibyte 'edebug-form-spec '(body)) | |
377 | |
378 (defun mm-find-charset-region (b e) | |
379 "Return a list of charsets in the region." | |
380 (cond | |
381 ((and (mm-multibyte-p) | |
382 (fboundp 'find-charset-region)) | |
383 ;; Remove composition since the base charsets have been included. | |
384 (delq 'composition (find-charset-region b e))) | |
385 ((not (boundp 'current-language-environment)) | |
386 (save-excursion | |
387 (save-restriction | |
388 (narrow-to-region b e) | |
389 (goto-char (point-min)) | |
390 (skip-chars-forward "\0-\177") | |
391 (if (eobp) | |
392 '(ascii) | |
393 (delq nil (list 'ascii | |
394 (or (car (last (assq mail-parse-charset | |
395 mm-mime-mule-charset-alist))) | |
396 'latin-iso8859-1))))))) | |
397 (t | |
398 ;; We are in a unibyte buffer, so we futz around a bit. | |
399 (save-excursion | |
400 (save-restriction | |
401 (narrow-to-region b e) | |
402 (goto-char (point-min)) | |
403 (let ((entry (assoc current-language-environment | |
404 language-info-alist))) | |
405 (skip-chars-forward "\0-\177") | |
406 (if (eobp) | |
407 '(ascii) | |
408 (delq nil (list 'ascii | |
409 (or (car (last (assq 'charset entry))) | |
410 'latin-iso8859-1)))))))))) | |
411 | |
412 (if (fboundp 'shell-quote-argument) | |
413 (defalias 'mm-quote-arg 'shell-quote-argument) | |
414 (defun mm-quote-arg (arg) | |
415 "Return a version of ARG that is safe to evaluate in a shell." | |
416 (let ((pos 0) new-pos accum) | |
417 ;; *** bug: we don't handle newline characters properly | |
418 (while (setq new-pos (string-match "[]*[;!'`\"$\\& \t{} |()<>]" arg pos)) | |
419 (push (substring arg pos new-pos) accum) | |
420 (push "\\" accum) | |
421 (push (list (aref arg new-pos)) accum) | |
422 (setq pos (1+ new-pos))) | |
423 (if (= pos 0) | |
424 arg | |
425 (apply 'concat (nconc (nreverse accum) (list (substring arg pos)))))))) | |
426 | |
427 (defun mm-auto-mode-alist () | |
428 "Return an `auto-mode-alist' with only the .gz (etc) thingies." | |
429 (let ((alist auto-mode-alist) | |
430 out) | |
431 (while alist | |
432 (when (listp (cdar alist)) | |
433 (push (car alist) out)) | |
434 (pop alist)) | |
435 (nreverse out))) | |
436 | |
437 (defvar mm-inhibit-file-name-handlers | |
438 '(jka-compr-handler) | |
439 "A list of handlers doing (un)compression (etc) thingies.") | |
440 | |
441 (defun mm-insert-file-contents (filename &optional visit beg end replace | |
442 inhibit) | |
443 "Like `insert-file-contents', q.v., but only reads in the file. | |
444 A buffer may be modified in several ways after reading into the buffer due | |
445 to advanced Emacs features, such as file-name-handlers, format decoding, | |
446 find-file-hooks, etc. | |
447 If INHIBIT is non-nil, inhibit mm-inhibit-file-name-handlers. | |
448 This function ensures that none of these modifications will take place." | |
449 (let ((format-alist nil) | |
450 (auto-mode-alist (if inhibit nil (mm-auto-mode-alist))) | |
451 (default-major-mode 'fundamental-mode) | |
452 (enable-local-variables nil) | |
453 (after-insert-file-functions nil) | |
454 (enable-local-eval nil) | |
455 (find-file-hooks nil) | |
456 (inhibit-file-name-operation (if inhibit | |
457 'insert-file-contents | |
458 inhibit-file-name-operation)) | |
459 (inhibit-file-name-handlers | |
460 (if inhibit | |
461 (append mm-inhibit-file-name-handlers | |
462 inhibit-file-name-handlers) | |
463 inhibit-file-name-handlers))) | |
464 (insert-file-contents filename visit beg end replace))) | |
465 | |
466 (defun mm-append-to-file (start end filename &optional codesys inhibit) | |
467 "Append the contents of the region to the end of file FILENAME. | |
468 When called from a function, expects three arguments, | |
469 START, END and FILENAME. START and END are buffer positions | |
470 saying what text to write. | |
471 Optional fourth argument specifies the coding system to use when | |
472 encoding the file. | |
473 If INHIBIT is non-nil, inhibit mm-inhibit-file-name-handlers." | |
474 (let ((coding-system-for-write | |
475 (or codesys mm-text-coding-system-for-write | |
476 mm-text-coding-system)) | |
477 (inhibit-file-name-operation (if inhibit | |
478 'append-to-file | |
479 inhibit-file-name-operation)) | |
480 (inhibit-file-name-handlers | |
481 (if inhibit | |
482 (append mm-inhibit-file-name-handlers | |
483 inhibit-file-name-handlers) | |
484 inhibit-file-name-handlers))) | |
485 (append-to-file start end filename))) | |
486 | |
487 (defun mm-write-region (start end filename &optional append visit lockname | |
488 coding-system inhibit) | |
489 | |
490 "Like `write-region'. | |
491 If INHIBIT is non-nil, inhibit mm-inhibit-file-name-handlers." | |
492 (let ((coding-system-for-write | |
493 (or coding-system mm-text-coding-system-for-write | |
494 mm-text-coding-system)) | |
495 (inhibit-file-name-operation (if inhibit | |
496 'write-region | |
497 inhibit-file-name-operation)) | |
498 (inhibit-file-name-handlers | |
499 (if inhibit | |
500 (append mm-inhibit-file-name-handlers | |
501 inhibit-file-name-handlers) | |
502 inhibit-file-name-handlers))) | |
503 (write-region start end filename append visit lockname))) | |
504 | |
505 (provide 'mm-util) | |
506 | |
507 ;;; mm-util.el ends here |