Mercurial > hg > xemacs-beta
comparison lisp/code-files.el @ 444:576fb035e263 r21-2-37
Import from CVS: tag r21-2-37
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:36:19 +0200 |
parents | abe6d1db359e |
children | 7039e6323819 |
comparison
equal
deleted
inserted
replaced
443:a8296e22da4e | 444:576fb035e263 |
---|---|
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | 15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 ;; General Public License for more details. | 17 ;; General Public License for more details. |
18 | 18 |
19 ;; You should have received a copy of the GNU General Public License | 19 ;; You should have received a copy of the GNU General Public License |
20 ;; along with XEmacs; see the file COPYING. If not, write to the | 20 ;; along with XEmacs; see the file COPYING. If not, write to the |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
22 ;; Boston, MA 02111-1307, USA. | 22 ;; Boston, MA 02111-1307, USA. |
23 | 23 |
24 ;;; Synched up with: Not synched. | 24 ;;; Synched up with: Not synched. |
25 | 25 |
203 | 203 |
204 ;(defun convert-mbox-coding-system (filename visit start end) | 204 ;(defun convert-mbox-coding-system (filename visit start end) |
205 ;... | 205 ;... |
206 | 206 |
207 (defun find-coding-system-magic-cookie () | 207 (defun find-coding-system-magic-cookie () |
208 "Look for the coding-system magic cookie in the current buffer.\n" | 208 "Look for the coding-system magic cookie in the current buffer. |
209 "The coding-system magic cookie is the exact string\n" | 209 The coding-system magic cookie is the exact string |
210 "\";;;###coding system: \" followed by a valid coding system symbol,\n" | 210 \";;;###coding system: \" followed by a valid coding system symbol, |
211 "somewhere within the first 3000 characters of the file. If found,\n" | 211 somewhere within the first 3000 characters of the file. If found, |
212 "the coding system symbol is returned; otherwise nil is returned.\n" | 212 the coding system symbol is returned; otherwise nil is returned. |
213 "Note that it is extremely unlikely that such a string would occur\n" | 213 Note that it is extremely unlikely that such a string would occur |
214 "coincidentally as the result of encoding some characters in a non-ASCII\n" | 214 coincidentally as the result of encoding some characters in a non-ASCII |
215 "charset, and that the spaces make it even less likely since the space\n" | 215 charset, and that the spaces make it even less likely since the space |
216 "character is not a valid octet in any ISO 2022 encoding of most non-ASCII\n" | 216 character is not a valid octet in any ISO 2022 encoding of most non-ASCII |
217 "charsets." | 217 charsets." |
218 (save-excursion | 218 (save-excursion |
219 (goto-char (point-min)) | 219 (goto-char (point-min)) |
220 (or (and (looking-at | 220 (or (and (looking-at |
221 "^[^\n]*-\\*-[^\n]*coding: \\([^ \t\n;]+\\)[^\n]*-\\*-") | 221 "^[^\n]*-\\*-[^\n]*coding: \\([^ \t\n;]+\\)[^\n]*-\\*-") |
222 (let ((codesys (intern (buffer-substring | 222 (let ((codesys (intern (buffer-substring |
351 corresponding arguments in the call to `insert-file-contents'), | 351 corresponding arguments in the call to `insert-file-contents'), |
352 CODING-SYSTEM (the actual coding system used to decode the file), and | 352 CODING-SYSTEM (the actual coding system used to decode the file), and |
353 a cons of absolute pathname and length of data inserted (the same | 353 a cons of absolute pathname and length of data inserted (the same |
354 thing as will be returned from `insert-file-contents').") | 354 thing as will be returned from `insert-file-contents').") |
355 | 355 |
356 (defun insert-file-contents (filename &optional visit beg end replace) | 356 (defun insert-file-contents (filename &optional visit start end replace) |
357 "Insert contents of file FILENAME after point. | 357 "Insert contents of file FILENAME after point. |
358 Returns list of absolute file name and length of data inserted. | 358 Returns list of absolute file name and length of data inserted. |
359 If second argument VISIT is non-nil, the buffer's visited filename | 359 If second argument VISIT is non-nil, the buffer's visited filename |
360 and last save file modtime are set, and it is marked unmodified. | 360 and last save file modtime are set, and it is marked unmodified. |
361 If visiting and the file does not exist, visiting is completed | 361 If visiting and the file does not exist, visiting is completed |
362 before the error is signaled. | 362 before the error is signaled. |
363 | 363 |
364 The optional third and fourth arguments BEG and END | 364 The optional third and fourth arguments START and END |
365 specify what portion of the file to insert. | 365 specify what portion of the file to insert. |
366 If VISIT is non-nil, BEG and END must be nil. | 366 If VISIT is non-nil, START and END must be nil. |
367 If optional fifth argument REPLACE is non-nil, | 367 If optional fifth argument REPLACE is non-nil, |
368 it means replace the current buffer contents (in the accessible portion) | 368 it means replace the current buffer contents (in the accessible portion) |
369 with the file contents. This is better than simply deleting and inserting | 369 with the file contents. This is better than simply deleting and inserting |
370 the whole thing because (1) it preserves some marker positions | 370 the whole thing because (1) it preserves some marker positions |
371 and (2) it puts less data in the undo list. | 371 and (2) it puts less data in the undo list. |
414 (message | 414 (message |
415 "Invalid coding-system (%s), using 'undecided" | 415 "Invalid coding-system (%s), using 'undecided" |
416 coding-system) | 416 coding-system) |
417 (setq coding-system 'undecided))) | 417 (setq coding-system 'undecided))) |
418 (setq return-val | 418 (setq return-val |
419 (insert-file-contents-internal filename visit beg end | 419 (insert-file-contents-internal filename visit start end |
420 replace coding-system | 420 replace coding-system |
421 ;; store here! | 421 ;; store here! |
422 'used-codesys)) | 422 'used-codesys)) |
423 )) | 423 )) |
424 (file-error | 424 (file-error |