annotate lisp/code-files.el @ 502:7039e6323819

[xemacs-hg @ 2001-05-04 22:41:46 by ben] ----------------------- byte-comp warning fixes ----------------- New functions for cleanly eliminating byte-compiler warnings. Their definitions require no changes at all in bytecomp.el, meaning that any package that wants to use them and be compatible with older versions of XEmacs need only copy the code and rename the functions (i.e. prefix them with the package name). Eliminate byte-compiler warnings using the new functions in bytecomp-runtime.el. Move coding-system-put,get,category, since they're not Mule-specific and are used in prefer-coding-system. font.el was incredibly ugly. Clean it up. Avoid using defsubst for any exported functions, to avoid possible compatibility problems if we later change the internal interface. (It happened before, with face accessors, between 19.8 and 19.9). Fix tons of warnings. Clean up (new function gpm-is-supported-p eliminates duplicate code in gpm-create/delete-device-hook) and eliminate warnings. ---------- make byte-recompile-directory work in the --------- core `lisp' dir, even in the absence of a Mule XEmacs (i.e. make it skip the Mule files rather than trying to compile them). now you should be able to do `touch *.el' in the `lisp' dir, then M-x byte-recompile-directory, and get no warnings. Avoid trying to compile Mule files in byte-recompile-directory when we're not in a Mule XEmacs, since we're highly likely to get syntax errors. Add a coding-system cookie to all Mule files so that byte-recompile-directory ignores them. Magic cookie function moved to files.el from code-files.el (for use by bytecomp even in a non-coding-system XEmacs), and changed names and semantics for use by bytecomp. NOTE: IMO this is an internal function that we can change as we like (and there is absolutely no code anywhere else using the function). ---------------- GUI improvements: menus, help ------------------- Rearrange order of keymap declarations to be alphabetical. Improve help on help to include all bindings, and group by category. Add bindings for new Info commands. Remove warnings. Use command-hyper-apropos in place of command-apropos. Add a function to do the equivalent of command-apropos. Evals its help-text argument so you can put expressions there. Used now by help-for-help. Add binding to continue text searches. Expand index searches to work over multiple info documents. Add commands to search text/index in User and Lispref. Add new entry, "Uncomment Region" (parallels "Comment Out Region"). Redo Help menu; add bindings for new Info commands to search the index or text of the User and Lispref manuals. Add command for mark-paragraph, activate-region. Make Edit->R accelerator be rectangle, not register (more commonly used), and put rectangle first. Fix the Edit Init File entry to never load the .elc file. Simplify the default-popup-menu. Add Cmds->Tabs menu. Use kp-left not kp_left, etc. ---------------- Miscellaneous bug fixes/cleanup ------------------- byte-compiler-options: Correct doc string. easy-menu-do-define: fix extra quote. fill-paragraph-or-region:Rewrite to be more correct -- use call-interactively so that we always get exactly the same behavior as if the functions were called directly. No need to fiddle with zmacs-region-stays, now that bogus clearing of it (2001-04-28 src/ChangeLog) is removed. Put dialog titles back in -- this time correctly. Fix various other problems with leaks and such. key-sequence-list-description: Clean up fun to always correctly canonicalize. Clean up Kinsoku comments, synch comment-region with FSF 20.7. * simple.el (region-exists-p): * simple.el (region-active-p): Add comment about which one is correct to use in menu specs. * sound.el (load-sound-file): Minor code clean up. * startup.el: * startup.el (command-line-early): * startup.el (initial-scratch-message): Comment changes. Add info about sample.init.el to splash screen. Improve initial-scratch-message and clarify purpose of Scratch buffer. Fix byte-compile warning. ------------------------ Added features ------------------------- Add new variable to control whether etags checks all parent directories for tag files. (On by default.) * hash-table.el: New file, useful utility functions. * dumped-lisp.el (preloaded-file-list): Dump hash-table.el. ------------ notable bug fix: Windows event code -------------- Get critical quit working. ------------ notable bug fix and new feature: regex code -------------- Shy groups were implemented in a horrible, half-assed way that would cause them to screw up regex searching in most cases. Fixed to work correctly. Also extended back-reference syntax past 9. Only is recognized as such if there are at least that many non-shy groups; and optionally will warn about such uses, to catch old code that might be using them differently. (Added variable to control this in search.c -- `warn-about-possibly-incompatible-back- references', on by default for the moment. Declared in lisp.h. ---------------- process/SIGIO improvements ------------------- define USE_GETADDRINFO to replace more complex conditional, and use it. the code conditionalized on this in unix_open_network_stream had *serious* problems handling errors. it's now fixed, and major amounts of duplicate code between the two versions were combined. don't disable SIGIO and other interrupts unless CONNECT_NEEDS_SLOWED_INTERRUPTS is defined -- don't penalize OS's without bugs. similarly for a freebsd bug that was affecting all OS's. * s\ultrix.h: define CONNECT_NEEDS_SLOWED_INTERRUPTS, since that's the OS mentioned as having a kernel bug. * sysdep.c (request_sigio_on_device): * sysdep.c (unrequest_sigio_on_device): fix SIGIO problems on Linux. add check for O_ASYNC in case it's defined and FASYNC isn't. add comment about other ways to do SIGIO on Linux. * callproc.c (Fold_call_process_internal): * process.c (Fstart_process_internal): Deal with the possibility that `default-directory' doesn't have terminating slash. Correct comments about vfork. ---------------- Miscellaneous bug fixes/cleanup ------------------- * callint.c (Finteractive): Add lots of documentation -- exactly what the Lisp equivalents of all the interactive specs are. * console.h (struct console): change type of quit_char to Emchar. * event-msw.c (lstream_type_create_mswindows_selectable): spacing change. Eliminate events-mod.h and combine into events.h. * emacs.c: * emacs.c (make_arg_list_1): * emacs.c (main_1): A couple of char->Extbyte changes, add a comment. * glyphs-msw.c: Correct indentation of function defns to not exceed 80 cols. Try (sort of) to fix some code that sets the colors of the progress gauge. (Commented out) * keymap.c (syms_of_keymap): use DEFSYMBOL. * process.c (read_process_output): No need to fiddle with zmacs_region_stays, now that bogus clearing of it (see below) is removed. * search.c (Freplace_match): warning fix.
author ben
date Fri, 04 May 2001 22:42:35 +0000
parents 576fb035e263
children 685b588e92d8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 ;;; code-files.el --- File I/O functions for XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 ;; Copyright (C) 1992,93,94,95 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995 Amdahl Corporation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 ;; Copyright (C) 1995 Sun Microsystems.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 ;; XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 ;; under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ;; any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 ;; XEmacs is distributed in the hope that it will be useful, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 ;; General Public License for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
20 ;; along with XEmacs; see the file COPYING. If not, write to the
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 ;; Boston, MA 02111-1307, USA.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 ;;; Synched up with: Not synched.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 ;;; Commentary:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 ;; Derived from mule.el in the original Mule but heavily modified
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 ;; by Ben Wing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 ;; 1997/3/11 modified by MORIOKA Tomohiko to sync with Emacs 20 API.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 ;; This file was derived from the former mule-files.el which has been removed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 ;; as of XEmacs 21.2.15.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 ;;; Code:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 (setq-default buffer-file-coding-system 'raw-text)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 (put 'buffer-file-coding-system 'permanent-local t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 (define-obsolete-variable-alias
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 'file-coding-system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 'buffer-file-coding-system)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 (define-obsolete-variable-alias
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 'overriding-file-coding-system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 'coding-system-for-read)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 (defvar buffer-file-coding-system-for-read 'undecided
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 "Coding system used when reading a file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 This provides coarse-grained control; for finer-grained control, use
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 `file-coding-system-alist'. From a Lisp program, if you wish to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 unilaterally specify the coding system used for one particular
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 operation, you should bind the variable `coding-system-for-read'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 rather than setting this variable, which is intended to be used for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 global environment specification.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 (define-obsolete-variable-alias
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 'file-coding-system-for-read
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 'buffer-file-coding-system-for-read)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 (defvar file-coding-system-alist
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 `(
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 ;; This must not be necessary, slb suggests -kkm
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 ;; ("loaddefs.el$" . (binary . binary))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 ,@(mapcar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 #'(lambda (regexp) (cons regexp 'binary)) binary-file-regexps)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 ("TUTORIAL\\.\\(?:hr\\|pl\\|ro\\)\\'" . iso-8859-2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 ;; ("\\.\\(el\\|emacs\\|info\\(-[0-9]+\\)?\\|texi\\)$" . iso-2022-8)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 ;; ("\\(ChangeLog\\|CHANGES-beta\\)$" . iso-2022-8)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
71
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
72 ;; This idea is totally broken, and the code didn't work anyway.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
73 ;; Mailboxes should be decoded by mail clients, who actually know
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
74 ;; how to deal with them. Otherwise, their contents should be
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
75 ;; treated as `binary'.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
76 ;("/spool/mail/.*$" . convert-mbox-coding-system)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
77 )
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 "Alist to decide a coding system to use for a file I/O operation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 The format is ((PATTERN . VAL) ...),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 where PATTERN is a regular expression matching a file name,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 VAL is a coding system, a cons of coding systems, or a function symbol.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 If VAL is a coding system, it is used for both decoding and encoding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 the file contents.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 If VAL is a cons of coding systems, the car part is used for decoding,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 and the cdr part is used for encoding.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 If VAL is a function symbol, the function must return a coding system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 or a cons of coding systems which are used as above.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 This overrides the more general specification in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 `buffer-file-coding-system-for-read', but is overridden by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 `coding-system-for-read'.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 (defun set-buffer-file-coding-system (coding-system &optional force)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 "Set buffer-file-coding-system of the current buffer to CODING-SYSTEM.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 If optional argument FORCE (interactively, the prefix argument) is not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 given, attempt to match the EOL type of the new coding system to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 the current value of `buffer-file-coding-system'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 (interactive "zFile coding system: \nP")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 (get-coding-system coding-system) ;; correctness check
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 (if (not force)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 (setq coding-system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 (subsidiary-coding-system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 coding-system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 (coding-system-eol-type buffer-file-coding-system))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 (setq buffer-file-coding-system coding-system)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 (redraw-modeline t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 (defun toggle-buffer-file-coding-system ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 "Set EOL type of buffer-file-coding-system of the current buffer to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 something other than what it is at the moment."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 (let ((eol-type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 (coding-system-eol-type buffer-file-coding-system)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 (setq buffer-file-coding-system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 (subsidiary-coding-system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 (coding-system-base buffer-file-coding-system)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 (cond ((eq eol-type 'lf) 'crlf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 ((eq eol-type 'crlf) 'lf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 ((eq eol-type 'cr) 'lf))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 (define-obsolete-function-alias
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 'set-file-coding-system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 'set-buffer-file-coding-system)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 (defun set-buffer-file-coding-system-for-read (coding-system)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 "Set the coding system used when reading in a file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 This is equivalent to setting the variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 `buffer-file-coding-system-for-read'. You can also use
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 `file-coding-system-alist' to specify the coding system for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 particular files."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 (interactive "zFile coding system for read: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 (get-coding-system coding-system) ;; correctness check
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 (setq buffer-file-coding-system-for-read coding-system))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 (define-obsolete-function-alias
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 'set-file-coding-system-for-read
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 'set-buffer-file-coding-system-for-read)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 (defun set-default-buffer-file-coding-system (coding-system)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 "Set the default value of `buffer-file-coding-system' to CODING-SYSTEM.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 The default value is used both for buffers without associated files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 and for files with no apparent coding system (i.e. primarily ASCII).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 See `buffer-file-coding-system' for more information."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 (interactive "zDefault file coding system: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 (setq-default buffer-file-coding-system coding-system)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 (redraw-modeline t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 (define-obsolete-function-alias
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 'set-default-file-coding-system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 'set-default-buffer-file-coding-system)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 (defun find-file-coding-system-for-read-from-filename (filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 "Look up coding system to read a file in `file-coding-system-alist'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 The return value will be nil (no applicable entry) or a coding system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 object (the entry specified a coding system)."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 (let ((alist file-coding-system-alist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 (found nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 (codesys nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 (let ((case-fold-search nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 (setq filename (file-name-sans-versions filename))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 (while (and (not found) alist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 (if (string-match (car (car alist)) filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 (setq codesys (cdr (car alist))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 found t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 (setq alist (cdr alist))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 (when codesys
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 (if (functionp codesys)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 (setq codesys (funcall codesys 'insert-file-contents filename))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 (cond ((consp codesys) (find-coding-system (car codesys)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 ((find-coding-system codesys))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 ))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 (define-obsolete-function-alias
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 'find-file-coding-system-from-filename
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 'find-file-coding-system-for-read-from-filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 (defun find-file-coding-system-for-write-from-filename (filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 "Look up coding system to write a file in `file-coding-system-alist'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 The return value will be nil (no applicable entry) or a coding system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 object (the entry specified a coding system)."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 (let ((alist file-coding-system-alist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 (found nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 (codesys nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 (let ((case-fold-search nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 (setq filename (file-name-sans-versions filename))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 (while (and (not found) alist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 (if (string-match (car (car alist)) filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 (setq codesys (cdr (car alist))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 found t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 (setq alist (cdr alist))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 (when codesys
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 (if (functionp codesys)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 (setq codesys (funcall codesys 'write-region filename))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 (cond ((consp codesys) (find-coding-system (cdr codesys)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 ((find-coding-system codesys))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 ))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
200 ;; This is completely broken, not only in implementation (does not
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
201 ;; understand MIME), but in concept -- such high-level decoding should
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
202 ;; be done by mail readers, not by IO code!
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
203
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
204 ;(defun convert-mbox-coding-system (filename visit start end)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
205 ;...
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 (defun load (file &optional noerror nomessage nosuffix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 "Execute a file of Lisp code named FILE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 First tries FILE with .elc appended, then tries with .el,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 then tries FILE unmodified. Searches directories in load-path.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 If optional second arg NOERROR is non-nil,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 report no error if FILE doesn't exist.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 Print messages at start and end of loading unless
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 optional third arg NOMESSAGE is non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 If optional fourth arg NOSUFFIX is non-nil, don't try adding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 suffixes .elc or .el to the specified name FILE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 Return t if file exists."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 (let* ((filename (substitute-in-file-name file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 (handler (find-file-name-handler filename 'load))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 (path nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 (if handler
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 (funcall handler 'load filename noerror nomessage nosuffix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 (if (or (<= (length filename) 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 (null (setq path
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 (locate-file filename load-path
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
226 (and (not nosuffix)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
227 '(".elc" ".el" ""))))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 (and (null noerror)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 (signal 'file-error (list "Cannot open load file" filename)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 ;; now use the internal load to actually load the file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 (load-internal
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 file noerror nomessage nosuffix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 (let ((elc ; use string= instead of string-match to keep match-data.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 (string= ".elc" (downcase (substring path -4)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 (or (and (not elc) coding-system-for-read) ; prefer for source file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 ;; find magic-cookie
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
237 (let ((codesys (find-coding-system-magic-cookie-in-file path)))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
238 (when codesys
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
239 (setq codesys (intern codesys))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
240 (if (find-coding-system codesys) codesys)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 (if elc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 ;; if reading a byte-compiled file and we didn't find
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 ;; a coding-system magic cookie, then use `binary'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 ;; We need to guarantee that we never do autodetection
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 ;; on byte-compiled files because confusion here would
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 ;; be a very bad thing. Pre-existing byte-compiled
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 ;; files are always in the `binary' coding system.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 ;; Also, byte-compiled files always use `lf' to terminate
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 ;; a line; don't risk confusion here either.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 'binary
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 (or (find-file-coding-system-for-read-from-filename path)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 ;; looking up in `file-coding-system-alist'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 ;; otherwise use `buffer-file-coding-system-for-read',
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 ;; as normal
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 buffer-file-coding-system-for-read)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 )))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 )))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 (defvar insert-file-contents-access-hook nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 "A hook to make a file accessible before reading it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 `insert-file-contents' calls this hook before doing anything else.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 Called with two arguments: FILENAME and VISIT, the same as the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 corresponding arguments in the call to `insert-file-contents'.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 (defvar insert-file-contents-pre-hook nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 "A special hook to decide the coding system used for reading in a file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 Before reading a file, `insert-file-contents' calls the functions on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 this hook with arguments FILENAME and VISIT, the same as the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 corresponding arguments in the call to `insert-file-contents'. In
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 these functions, you may refer to the global variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 `buffer-file-coding-system-for-read'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 The return value of the functions should be either
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 -- nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 -- A coding system or a symbol denoting it, indicating the coding system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 to be used for reading the file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 -- A list of two elements (absolute pathname and length of data inserted),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 which is used as the return value to `insert-file-contents'. In this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 case, `insert-file-contents' assumes that the function has inserted
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 the file for itself and suppresses further reading.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 If any function returns non-nil, the remaining functions are not called.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 (defvar insert-file-contents-error-hook nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 "A hook to set `buffer-file-coding-system' when a read error has occurred.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 When a file error (e.g. nonexistent file) occurs while read a file,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 `insert-file-contents' calls the functions on this hook with three
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 arguments: FILENAME and VISIT (the same as the corresponding arguments
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 in the call to `insert-file-contents') and a cons (SIGNALED-CONDITIONS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 . SIGNAL-DATA).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 After calling this hook, the error is signalled for real and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 propagates to the caller of `insert-file-contents'.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 (defvar insert-file-contents-post-hook nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 "A hook to set `buffer-file-coding-system' for the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 After successful reading, `insert-file-contents' calls the functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 on this hook with four arguments: FILENAME and VISIT (the same as the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 corresponding arguments in the call to `insert-file-contents'),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 CODING-SYSTEM (the actual coding system used to decode the file), and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 a cons of absolute pathname and length of data inserted (the same
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 thing as will be returned from `insert-file-contents').")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
308 (defun insert-file-contents (filename &optional visit start end replace)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 "Insert contents of file FILENAME after point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 Returns list of absolute file name and length of data inserted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 If second argument VISIT is non-nil, the buffer's visited filename
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 and last save file modtime are set, and it is marked unmodified.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 If visiting and the file does not exist, visiting is completed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 before the error is signaled.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
316 The optional third and fourth arguments START and END
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 specify what portion of the file to insert.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
318 If VISIT is non-nil, START and END must be nil.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 If optional fifth argument REPLACE is non-nil,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 it means replace the current buffer contents (in the accessible portion)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 with the file contents. This is better than simply deleting and inserting
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 the whole thing because (1) it preserves some marker positions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 and (2) it puts less data in the undo list.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 The coding system used for decoding the file is determined as follows:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 1. `coding-system-for-read', if non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 2. The result of `insert-file-contents-pre-hook', if non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 3. The matching value for this filename from
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 `file-coding-system-alist', if any.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 4. `buffer-file-coding-system-for-read', if non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 5. The coding system 'raw-text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 If a local value for `buffer-file-coding-system' in the current buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 does not exist, it is set to the coding system which was actually used
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 for reading.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 See also `insert-file-contents-access-hook',
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 `insert-file-contents-pre-hook', `insert-file-contents-error-hook',
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 and `insert-file-contents-post-hook'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 (let (return-val coding-system used-codesys)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 ;; OK, first load the file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 (condition-case err
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 (run-hook-with-args 'insert-file-contents-access-hook
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 filename visit)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 ;; determine the coding system to use, as described above.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 (setq coding-system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 (or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 ;; #1.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 coding-system-for-read
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 ;; #2.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 (run-hook-with-args-until-success
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 'insert-file-contents-pre-hook
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 filename visit)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 ;; #3.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 (find-file-coding-system-for-read-from-filename filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 ;; #4.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 buffer-file-coding-system-for-read
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 ;; #5.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 'raw-text))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 (if (consp coding-system)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 (setq return-val coding-system)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 (if (null (find-coding-system coding-system))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 (message
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 "Invalid coding-system (%s), using 'undecided"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 coding-system)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 (setq coding-system 'undecided)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 (setq return-val
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
371 (insert-file-contents-internal filename visit start end
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 replace coding-system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 ;; store here!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 'used-codesys))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 (file-error
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 (run-hook-with-args 'insert-file-contents-error-hook
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 filename visit err)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 (signal (car err) (cdr err))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 (setq coding-system used-codesys)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 ;; call any `post-read-conversion' for the coding system that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 ;; was used ...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 (let ((func
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 (coding-system-property coding-system 'post-read-conversion))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 (endmark (make-marker)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 (set-marker endmark (+ (point) (nth 1 return-val)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 (if func
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 (unwind-protect
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 (let (buffer-read-only)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 (funcall func (point) (marker-position endmark))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 (if visit
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 (set-buffer-auto-saved)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 (set-buffer-modified-p nil)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 (setcar (cdr return-val) (- (marker-position endmark) (point))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 ;; now finally set the buffer's `buffer-file-coding-system'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 (if (run-hook-with-args-until-success 'insert-file-contents-post-hook
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 filename visit return-val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 (if (local-variable-p 'buffer-file-coding-system (current-buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 ;; if buffer-file-coding-system is already local, just
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 ;; set its eol type to what was found, if it wasn't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 ;; set already.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 (set-buffer-file-coding-system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 (subsidiary-coding-system buffer-file-coding-system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 (coding-system-eol-type coding-system)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 ;; otherwise actually set buffer-file-coding-system.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 (set-buffer-file-coding-system coding-system)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 return-val))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 (defvar write-region-pre-hook nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 "A special hook to decide the coding system used for writing out a file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 Before writing a file, `write-region' calls the functions on this hook
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 with arguments START, END, FILENAME, APPEND, VISIT, and CODING-SYSTEM,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 the same as the corresponding arguments in the call to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 `write-region'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 The return value of the functions should be either
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 -- nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 -- A coding system or a symbol denoting it, indicating the coding system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 to be used for reading the file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 -- A list of two elements (absolute pathname and length of data written),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 which is used as the return value to `write-region'. In this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 case, `write-region' assumes that the function has written
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 the file for itself and suppresses further writing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 If any function returns non-nil, the remaining functions are not called.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 (defvar write-region-post-hook nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 "A hook called by `write-region' after a file has been written out.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 The functions on this hook are called with arguments START, END,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 FILENAME, APPEND, VISIT, and CODING-SYSTEM, the same as the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 corresponding arguments in the call to `write-region'.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 (defun write-region (start end filename &optional append visit lockname coding-system)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 "Write current region into specified file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 By default the file's existing contents are replaced by the specified region.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 When called from a program, takes three arguments:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 START, END and FILENAME. START and END are buffer positions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 Optional fourth argument APPEND if non-nil means
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 append to existing file contents (if any).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 Optional fifth argument VISIT if t means
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 set last-save-file-modtime of buffer to this file's modtime
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 and mark buffer not modified.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 If VISIT is a string, it is a second file name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 the output goes to FILENAME, but the buffer is marked as visiting VISIT.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 VISIT is also the file name to lock and unlock for clash detection.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 If VISIT is neither t nor nil nor a string,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 that means do not print the \"Wrote file\" message.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 The optional sixth arg LOCKNAME, if non-nil, specifies the name to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 use for locking and unlocking, overriding FILENAME and VISIT.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 Kludgy feature: if START is a string, then that string is written
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 to the file, instead of any buffer contents, and END is ignored.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 Optional seventh argument CODING-SYSTEM specifies the coding system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 used to encode the text when it is written out, and defaults to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 the value of `buffer-file-coding-system' in the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 Interactively, with a prefix arg, you will be prompted for the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 coding system.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 See also `write-region-pre-hook' and `write-region-post-hook'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 (interactive "r\nFWrite region to file: \ni\ni\ni\nZCoding-system: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 (setq coding-system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 (or coding-system-for-write
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 (run-hook-with-args-until-success
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 'write-region-pre-hook start end filename append visit lockname)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 coding-system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 buffer-file-coding-system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 (find-file-coding-system-for-write-from-filename filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 (if (consp coding-system)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 coding-system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 (let ((func
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 (coding-system-property coding-system 'pre-write-conversion)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 (if func
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 (let ((curbuf (current-buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 (tempbuf (generate-new-buffer " *temp-write-buffer*"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 (modif (buffer-modified-p)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 (unwind-protect
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 (set-buffer tempbuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 (erase-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 (insert-buffer-substring curbuf start end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 (funcall func (point-min) (point-max))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 (write-region-internal (point-min) (point-max) filename
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 append
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 (if (eq visit t) nil visit)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 lockname
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 coding-system))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 ;; leaving a buffer associated with file will cause problems
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 ;; when next visiting.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 (kill-buffer tempbuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 (if (or visit (null modif))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 (set-buffer-auto-saved)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 (set-buffer-modified-p nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 (if (buffer-file-name) (set-visited-file-modtime))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 (write-region-internal start end filename append visit lockname
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 coding-system)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 (run-hook-with-args 'write-region-post-hook
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 start end filename append visit lockname
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 coding-system)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 ;;; code-files.el ends here