annotate src/buffer.c @ 446:1ccc32a20af4 r21-2-38

Import from CVS: tag r21-2-38
author cvs
date Mon, 13 Aug 2007 11:37:21 +0200
parents 576fb035e263
children 3078fd1074e8
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 /* Buffer manipulation primitives for XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1985-1989, 1992-1995 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Copyright (C) 1995 Sun Microsystems, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 Copyright (C) 1995, 1996 Ben Wing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 /* Synched up with: Mule 2.0, FSF 19.30. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 /* Authorship:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 FSF: long ago.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 JWZ: some changes for Lemacs, long ago. (e.g. separate buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 list per frame.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 Mly: a few changes for buffer-local vars, 19.8 or 19.9.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 Ben Wing: some changes and cleanups for Mule, 19.12.
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 /* This file contains functions that work with buffer objects.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 Functions that manipulate a buffer's text, however, are not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 in this file:
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 1) The low-level functions that actually know about the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 implementation of a buffer's text are located in insdel.c.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 2) The higher-level (mostly Lisp) functions that manipulate a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 buffer's text are in editfns.c.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 3) The highest-level Lisp commands are in cmds.c.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 However:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 -- Functions that know about syntax tables (forward-word,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 scan-sexps, etc.) are in syntax.c, as are functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 that manipulate syntax tables.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 -- Functions that know about case tables (upcase, downcase,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 etc.) are in casefiddle.c. Functions that manipulate
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 case tables (case-table-p, set-case-table, etc.) are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 in casetab.c.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 -- Functions that do searching and replacing are in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 search.c. The low-level functions that implement
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 regular expressions are in regex.c.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 Also:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 -- Some file and process functions (in fileio.c and process.c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 copy text from or insert text into a buffer; they call
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 low-level functions in insdel.c to do this.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 -- insdel.c calls low-level functions in undo.c and extents.c
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 to record buffer modifications for undoing and to handle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 extent adjustment and extent-data creation and insertion.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 #include "buffer.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 #include "chartab.h"
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
73 #include "casetab.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 #include "commands.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 #include "elhash.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 #include "extents.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 #include "faces.h"
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
78 #ifdef FILE_CODING
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
79 #include "file-coding.h"
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
80 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 #include "frame.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 #include "insdel.h"
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
83 #include "lstream.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 #include "process.h" /* for kill_buffer_processes */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 #ifdef REGION_CACHE_NEEDS_WORK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 #include "region-cache.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 #endif
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
88 #include "select.h" /* for select_notify_buffer_kill */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 #include "specifier.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 #include "syntax.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 #include "sysdep.h" /* for getwd */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 #include "window.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 #include "sysfile.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 struct buffer *current_buffer; /* the current buffer */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 /* This structure holds the default values of the buffer-local variables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 defined with DEFVAR_BUFFER_LOCAL, that have special slots in each buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 The default value occupies the same slot in this structure
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 as an individual buffer's value occupies in that buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 Setting the default value also goes through the alist of buffers
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 and stores into each buffer that does not say it has a local value. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 Lisp_Object Vbuffer_defaults;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 static void *buffer_defaults_saved_slots;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 /* This structure marks which slots in a buffer have corresponding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 default values in Vbuffer_defaults.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 Each such slot has a nonzero value in this structure.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 The value has only one nonzero bit.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 When a buffer has its own local value for a slot,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 the bit for that slot (found in the same slot in this structure)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 is turned on in the buffer's local_var_flags slot.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 If a slot in this structure is 0, then there is a DEFVAR_BUFFER_LOCAL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 for the slot, but there is no default value for it; the corresponding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 slot in Vbuffer_defaults is not used except to initialize newly-created
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 buffers.
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 If a slot is -1, then there is a DEFVAR_BUFFER_LOCAL for it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 as well as a default value which is used to initialize newly-created
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 buffers and as a reset-value when local-vars are killed.
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 If a slot is -2, there is no DEFVAR_BUFFER_LOCAL for it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 (The slot is always local, but there's no lisp variable for it.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 The default value is only used to initialize newly-creation buffers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 If a slot is -3, then there is no DEFVAR_BUFFER_LOCAL for it but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 there is a default which is used to initialize newly-creation
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 buffers and as a reset-value when local-vars are killed. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 struct buffer buffer_local_flags;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 /* This is the initial (startup) directory, as used for the *scratch* buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 We're making this a global to make others aware of the startup directory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 `initial_directory' is stored in external format.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 char initial_directory[MAXPATHLEN+1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 /* This structure holds the names of symbols whose values may be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 buffer-local. It is indexed and accessed in the same way as the above. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 static Lisp_Object Vbuffer_local_symbols;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 static void *buffer_local_symbols_saved_slots;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 /* Alist of all buffer names vs the buffers. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 /* This used to be a variable, but is no longer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 to prevent lossage due to user rplac'ing this alist or its elements.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 Note that there is a per-frame copy of this as well; the frame slot
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 and the global variable contain the same data, but possibly in different
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 orders, so that the buffer ordering can be per-frame.
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 Lisp_Object Vbuffer_alist;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 /* Functions to call before and after each text change. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 Lisp_Object Qbefore_change_functions;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 Lisp_Object Qafter_change_functions;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 Lisp_Object Vbefore_change_functions;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 Lisp_Object Vafter_change_functions;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 /* #### Obsolete, for compatibility */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 Lisp_Object Qbefore_change_function;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 Lisp_Object Qafter_change_function;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 Lisp_Object Vbefore_change_function;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 Lisp_Object Vafter_change_function;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 #if 0 /* FSFmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 Lisp_Object Vtransient_mark_mode;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 #endif
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 /* t means ignore all read-only text properties.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 A list means ignore such a property if its value is a member of the list.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 Any non-nil value means ignore buffer-read-only. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 Lisp_Object Vinhibit_read_only;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 /* List of functions to call that can query about killing a buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 If any of these functions returns nil, we don't kill it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 Lisp_Object Vkill_buffer_query_functions;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 /* Non-nil means delete a buffer's auto-save file when the buffer is saved. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 int delete_auto_save_files;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 Lisp_Object Qbuffer_live_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 Lisp_Object Qbuffer_or_string_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 /* List of functions to call before changing an unmodified buffer. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 Lisp_Object Vfirst_change_hook;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 Lisp_Object Qfirst_change_hook;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 Lisp_Object Qfundamental_mode;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 Lisp_Object Qmode_class;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 Lisp_Object Qpermanent_local;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 Lisp_Object Qprotected_field;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 Lisp_Object QSFundamental; /* A string "Fundamental" */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 Lisp_Object QSscratch; /* "*scratch*" */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 Lisp_Object Qdefault_directory;
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 Lisp_Object Qkill_buffer_hook;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 Lisp_Object Qrename_auto_save_file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 Lisp_Object Qget_file_buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 Lisp_Object Qchange_major_mode_hook, Vchange_major_mode_hook;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 Lisp_Object Qfind_file_compare_truenames;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 Lisp_Object Qswitch_to_buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 /* Two thresholds controlling how much undo information to keep. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 int undo_threshold;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 int undo_high_threshold;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 int find_file_compare_truenames;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 int find_file_use_truenames;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 static void reset_buffer_local_variables (struct buffer *, int first_time);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 static void nuke_all_buffer_slots (struct buffer *b, Lisp_Object zap);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 make_buffer (struct buffer *buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 Lisp_Object obj;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 XSETBUFFER (obj, buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 return obj;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 mark_buffer (Lisp_Object obj)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 struct buffer *buf = XBUFFER (obj);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 /* Truncate undo information. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 buf->undo_list = truncate_undo_list (buf->undo_list,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 undo_threshold,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 undo_high_threshold);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 #define MARKED_SLOT(x) mark_object (buf->x)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 #include "bufslots.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 #undef MARKED_SLOT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 mark_object (buf->extent_info);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 if (buf->text)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 mark_object (buf->text->line_number_cache);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 /* Don't mark normally through the children slot.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 (Actually, in this case, it doesn't matter.) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 if (! EQ (buf->indirect_children, Qnull_pointer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 mark_conses_in_list (buf->indirect_children);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 return buf->base_buffer ? make_buffer (buf->base_buffer) : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 print_buffer (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
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 struct buffer *b = XBUFFER (obj);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 if (print_readably)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 if (!BUFFER_LIVE_P (b))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 error ("printing unreadable object #<killed buffer>");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 error ("printing unreadable object #<buffer %s>",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 XSTRING_DATA (b->name));
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 else if (!BUFFER_LIVE_P (b))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 write_c_string ("#<killed buffer>", printcharfun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 else if (escapeflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 write_c_string ("#<buffer ", printcharfun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 print_internal (b->name, printcharfun, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 write_c_string (">", printcharfun);
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 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 print_internal (b->name, printcharfun, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 /* We do not need a finalize method to handle a buffer's children list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 because all buffers have `kill-buffer' applied to them before
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 they disappear, and the children removal happens then. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 DEFINE_LRECORD_IMPLEMENTATION ("buffer", buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 mark_buffer, print_buffer, 0, 0, 0, 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 struct buffer);
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 DEFUN ("bufferp", Fbufferp, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 Return t if OBJECT is an editor buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 (object))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 return BUFFERP (object) ? Qt : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 DEFUN ("buffer-live-p", Fbuffer_live_p, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 Return t if OBJECT is an editor buffer that has not been deleted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 (object))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 return BUFFERP (object) && BUFFER_LIVE_P (XBUFFER (object)) ? Qt : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 nsberror (Lisp_Object spec)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 if (STRINGP (spec))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 error ("No buffer named %s", XSTRING_DATA (spec));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 signal_simple_error ("Invalid buffer argument", spec);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 DEFUN ("buffer-list", Fbuffer_list, 0, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 Return a list of all existing live buffers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 The order is specific to the selected frame; if the optional FRAME
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 argument is provided, the ordering for that frame is returned instead.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 If the FRAME argument is t, then the global (non-frame) ordering is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 returned instead.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 (frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 return Fmapcar (Qcdr,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 EQ (frame, Qt) ? Vbuffer_alist :
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 decode_frame (frame)->buffer_alist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 }
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 Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 get_buffer (Lisp_Object name, int error_if_deleted_or_does_not_exist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 if (BUFFERP (name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 if (!BUFFER_LIVE_P (XBUFFER (name)))
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 (error_if_deleted_or_does_not_exist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 nsberror (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 return Qnil;
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 return name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 Lisp_Object buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 struct gcpro gcpro1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 CHECK_STRING (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 name = LISP_GETTEXT (name); /* I18N3 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 GCPRO1 (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 buf = Fcdr (Fassoc (name, Vbuffer_alist));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 if (NILP (buf) && error_if_deleted_or_does_not_exist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 nsberror (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 return buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 struct buffer *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 decode_buffer (Lisp_Object buffer, int allow_string)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 if (NILP (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 return current_buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 if (allow_string && STRINGP (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 return XBUFFER (get_buffer (buffer, 1));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 CHECK_LIVE_BUFFER (buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 return XBUFFER (buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 DEFUN ("decode-buffer", Fdecode_buffer, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 Validate BUFFER or if BUFFER is nil, return the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 If BUFFER is a valid buffer or a string representing a valid buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 the corresponding buffer object will be returned. Otherwise an error
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 will be signaled.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 struct buffer *b = decode_buffer (buffer, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 XSETBUFFER (buffer, b);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 return buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 #if 0 /* FSFmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 /* bleagh!!! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 /* Like Fassoc, but use Fstring_equal to compare
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 (which ignores text properties),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 and don't ever QUIT. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 assoc_ignore_text_properties (REGISTER Lisp_Object key, Lisp_Object list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 REGISTER Lisp_Object tail;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 for (tail = list; !NILP (tail); tail = Fcdr (tail))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 REGISTER Lisp_Object elt, tem;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 elt = Fcar (tail);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 tem = Fstring_equal (Fcar (elt), key);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 if (!NILP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 return elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 #endif /* FSFmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 DEFUN ("get-buffer", Fget_buffer, 1, 1, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
406 Return the buffer named BUFFER-NAME (a string), or nil if there is none.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
407 BUFFER-NAME may also be a buffer; if so, the value is that buffer.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
409 (buffer_name))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 #ifdef I18N3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 /* #### Doc string should indicate that the buffer name will get
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 translated. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 /* #### This might return a dead buffer. This is gross. This is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 called FSF compatibility. */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
418 if (BUFFERP (buffer_name))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
419 return buffer_name;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
420 return get_buffer (buffer_name, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 /* FSFmacs 19.29 calls assoc_ignore_text_properties() here.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 Bleagh!! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 DEFUN ("get-file-buffer", Fget_file_buffer, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 Return the buffer visiting file FILENAME (a string).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 The buffer's `buffer-file-name' must match exactly the expansion of FILENAME.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 If there is no such live buffer, return nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 Normally, the comparison is done by canonicalizing FILENAME (using
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 `expand-file-name') and comparing that to the value of `buffer-file-name'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 for each existing buffer. However, If `find-file-compare-truenames' is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 non-nil, FILENAME will be converted to its truename and the search will be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 done on each buffer's value of `buffer-file-truename' instead of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 `buffer-file-name'. Otherwise, if `find-file-use-truenames' is non-nil,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 FILENAME will be converted to its truename and used for searching, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 the search will still be done on `buffer-file-name'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 (filename))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
442 /* This function can GC. GC checked and fixed 7-11-2000 ben. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 REGISTER Lisp_Object buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 struct gcpro gcpro1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 #ifdef I18N3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 /* DO NOT translate the filename. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 GCPRO1 (filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 CHECK_STRING (filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 filename = Fexpand_file_name (filename, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 /* If the file name has special constructs in it,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 call the corresponding file handler. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 Lisp_Object handler = Ffind_file_name_handler (filename, Qget_file_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 if (!NILP (handler))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 return call2 (handler, Qget_file_buffer, filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 if (find_file_compare_truenames || find_file_use_truenames)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 struct gcpro ngcpro1, ngcpro2, ngcpro3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 Lisp_Object fn = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 Lisp_Object dn = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 NGCPRO3 (fn, dn, filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 fn = Ffile_truename (filename, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 if (NILP (fn))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 dn = Ffile_name_directory (filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 fn = Ffile_truename (dn, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 if (! NILP (fn)) dn = fn;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
477 /* Formerly the two calls below were combined, but that is
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
478 not GC-safe because the first call returns unprotected
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
479 data and the second call can GC. --ben */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
480 fn = Ffile_name_nondirectory (filename);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
481 fn = Fexpand_file_name (fn, dn);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 filename = fn;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 NUNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 LIST_LOOP_2 (elt, Vbuffer_alist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 buf = Fcdr (elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 if (!BUFFERP (buf)) continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 if (!STRINGP (XBUFFER (buf)->filename)) continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 if (!NILP (Fstring_equal (filename,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 (find_file_compare_truenames
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 ? XBUFFER (buf)->file_truename
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 : XBUFFER (buf)->filename))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 return buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 push_buffer_alist (Lisp_Object name, Lisp_Object buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 Lisp_Object cons = Fcons (name, buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 Lisp_Object frmcons, devcons, concons;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (cons, Qnil));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 FRAME_LOOP_NO_BREAK (frmcons, devcons, concons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 struct frame *f;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 f = XFRAME (XCAR (frmcons));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 f->buffer_alist = nconc2 (f->buffer_alist, Fcons (cons, Qnil));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 delete_from_buffer_alist (Lisp_Object buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 Lisp_Object cons = Frassq (buf, Vbuffer_alist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 Lisp_Object frmcons, devcons, concons;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 if (NILP (cons))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 return; /* abort() ? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 Vbuffer_alist = delq_no_quit (cons, Vbuffer_alist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 FRAME_LOOP_NO_BREAK (frmcons, devcons, concons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 struct frame *f;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 f = XFRAME (XCAR (frmcons));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 f->buffer_alist = delq_no_quit (cons, f->buffer_alist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 get_truename_buffer (REGISTER Lisp_Object filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
539 /* This function can GC. GC correct 7-11-00 ben */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 /* FSFmacs has its own code here and doesn't call get-file-buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 That's because their equivalent of find-file-compare-truenames
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 (find-file-existing-other-name) isn't looked at in get-file-buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 This way is more correct. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 int count = specpdl_depth ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 specbind (Qfind_file_compare_truenames, Qt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 return unbind_to (count, Fget_file_buffer (filename));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 static struct buffer *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 allocate_buffer (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 struct buffer *b = alloc_lcrecord_type (struct buffer, &lrecord_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 copy_lcrecord (b, XBUFFER (Vbuffer_defaults));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 return b;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 finish_init_buffer (struct buffer *b, Lisp_Object name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 Lisp_Object buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 XSETBUFFER (buf, b);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 name = Fcopy_sequence (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 /* #### This really does not need to be called. We already
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 initialized the buffer-local variables in allocate_buffer().
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 local_var_alist is set to Qnil at the same point, in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 nuke_all_buffer_slots(). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 reset_buffer_local_variables (b, 1);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
573 b->directory = current_buffer ? current_buffer->directory : Qnil;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 b->last_window_start = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 b->name = name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 if (string_byte (XSTRING (name), 0) != ' ')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 b->undo_list = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 b->undo_list = Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 /* initialize the extent list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 init_buffer_extents (b);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 /* Put this in the alist of all live buffers. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 push_buffer_alist (name, buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 init_buffer_markers (b);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 b->generated_modeline_string = Fmake_string (make_int (84), make_int (' '));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 b->modeline_extent_table = make_lisp_hash_table (20, HASH_TABLE_KEY_WEAK,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 HASH_TABLE_EQ);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 return buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 DEFUN ("get-buffer-create", Fget_buffer_create, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 Return the buffer named NAME, or create such a buffer and return it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 A new buffer is created if there is no live buffer named NAME.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 If NAME starts with a space, the new buffer does not keep undo information.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 If NAME is a buffer instead of a string, then it is the value returned.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 The value is never nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 (name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 Lisp_Object buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 REGISTER struct buffer *b;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 #ifdef I18N3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 /* #### Doc string should indicate that the buffer name will get
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 translated. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 name = LISP_GETTEXT (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 buf = Fget_buffer (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 if (!NILP (buf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 return buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 if (XSTRING_LENGTH (name) == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 error ("Empty string for buffer name is not allowed");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 b = allocate_buffer ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 b->text = &b->own_text;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 b->base_buffer = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 b->indirect_children = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 init_buffer_text (b);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 return finish_init_buffer (b, name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 DEFUN ("make-indirect-buffer", Fmake_indirect_buffer, 2, 2,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 "bMake indirect buffer (to buffer): \nBName of indirect buffer: ", /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
636 Create and return an indirect buffer for buffer BASE-BUFFER, named NAME.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
637 BASE-BUFFER should be an existing buffer (or buffer name).
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 NAME should be a string which is not the name of an existing buffer.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
639
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
640 If BASE-BUFFER is itself an indirect buffer, the base buffer for that buffer
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 is made the base buffer for the newly created buffer. (Thus, there will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 never be indirect buffers whose base buffers are themselves indirect.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 (base_buffer, name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 /* #### The above interactive specification is totally bogus,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 because it offers an existing buffer as default answer to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 second question. However, the second argument may not BE an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 existing buffer! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 struct buffer *b;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 base_buffer = get_buffer (base_buffer, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 #ifdef I18N3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 /* #### Doc string should indicate that the buffer name will get
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 translated. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 CHECK_STRING (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 name = LISP_GETTEXT (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 if (!NILP (Fget_buffer (name)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 signal_simple_error ("Buffer name already in use", name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 if (XSTRING_LENGTH (name) == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 error ("Empty string for buffer name is not allowed");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 b = allocate_buffer ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 b->base_buffer = BUFFER_BASE_BUFFER (XBUFFER (base_buffer));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 /* Use the base buffer's text object. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 b->text = b->base_buffer->text;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 b->indirect_children = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 b->base_buffer->indirect_children =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 Fcons (make_buffer (b), b->base_buffer->indirect_children);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 init_buffer_text (b);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 return finish_init_buffer (b, name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 reset_buffer_local_variables (struct buffer *b, int first_time)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 struct buffer *def = XBUFFER (Vbuffer_defaults);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 b->local_var_flags = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 /* For each slot that has a default value,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 copy that into the slot. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 #define MARKED_SLOT(slot) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 { int mask = XINT (buffer_local_flags.slot); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 if ((mask > 0 || mask == -1 || mask == -3) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 && (first_time \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 || NILP (Fget (XBUFFER (Vbuffer_local_symbols)->slot, \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 Qpermanent_local, Qnil)))) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 b->slot = def->slot; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 #include "bufslots.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 #undef MARKED_SLOT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 /* We split this away from generate-new-buffer, because rename-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 and set-visited-file-name ought to be able to use this to really
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 rename the buffer properly. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 DEFUN ("generate-new-buffer-name", Fgenerate_new_buffer_name, 1, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 Return a string that is the name of no existing buffer based on NAME.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 If there is no live buffer named NAME, then return NAME.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 Otherwise modify name by appending `<NUMBER>', incrementing NUMBER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 until an unused name is found, and then return that name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 Optional second argument IGNORE specifies a name that is okay to use
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 \(if it is in the sequence to be tried)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 even if a buffer with that name exists.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 (name, ignore))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 REGISTER Lisp_Object gentemp, tem;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 int count;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 char number[10];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 CHECK_STRING (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 name = LISP_GETTEXT (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 #ifdef I18N3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 /* #### Doc string should indicate that the buffer name will get
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 translated. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 tem = Fget_buffer (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 if (NILP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 return name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 count = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 sprintf (number, "<%d>", ++count);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 gentemp = concat2 (name, build_string (number));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 if (!NILP (ignore))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 tem = Fstring_equal (gentemp, ignore);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 if (!NILP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 return gentemp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 tem = Fget_buffer (gentemp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 if (NILP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 return gentemp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 DEFUN ("buffer-name", Fbuffer_name, 0, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 Return the name of BUFFER, as a string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 With no argument or nil as argument, return the name of the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 /* For compatibility, we allow a dead buffer here.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 Earlier versions of Emacs didn't provide buffer-live-p. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 if (NILP (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 return current_buffer->name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 CHECK_BUFFER (buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 return XBUFFER (buffer)->name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 DEFUN ("buffer-file-name", Fbuffer_file_name, 0, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 Return name of file BUFFER is visiting, or nil if none.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 No argument or nil as argument means use the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 /* For compatibility, we allow a dead buffer here. Yuck! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 if (NILP (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 return current_buffer->filename;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 CHECK_BUFFER (buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 return XBUFFER (buffer)->filename;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 DEFUN ("buffer-base-buffer", Fbuffer_base_buffer, 0, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 Return the base buffer of indirect buffer BUFFER.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 If BUFFER is not indirect, return nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 struct buffer *buf = decode_buffer (buffer, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 return buf->base_buffer ? make_buffer (buf->base_buffer) : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 DEFUN ("buffer-indirect-children", Fbuffer_indirect_children, 0, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 Return a list of all indirect buffers whose base buffer is BUFFER.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 If BUFFER is indirect, the return value will always be nil; see
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 `make-indirect-buffer'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 struct buffer *buf = decode_buffer (buffer, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 return Fcopy_sequence (buf->indirect_children);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 DEFUN ("buffer-local-variables", Fbuffer_local_variables, 0, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 Return an alist of variables that are buffer-local in BUFFER.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 Most elements look like (SYMBOL . VALUE), describing one variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 For a symbol that is locally unbound, just the symbol appears in the value.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 Note that storing new VALUEs in these elements doesn't change the variables.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 No argument or nil as argument means use current buffer as BUFFER.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 struct buffer *buf = decode_buffer (buffer, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 Lisp_Object result = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 Lisp_Object tail;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 for (tail = buf->local_var_alist; CONSP (tail); tail = XCDR (tail))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 Lisp_Object elt = XCAR (tail);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 /* Reference each variable in the alist in buf.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 If inquiring about the current buffer, this gets the current values,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 so store them into the alist so the alist is up to date.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 If inquiring about some other buffer, this swaps out any values
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 for that buffer, making the alist up to date automatically. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 Lisp_Object val = find_symbol_value (XCAR (elt));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 /* Use the current buffer value only if buf is the current buffer. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 if (buf != current_buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 val = XCDR (elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 /* If symbol is unbound, put just the symbol in the list. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 if (UNBOUNDP (val))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 result = Fcons (XCAR (elt), result);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 /* Otherwise, put (symbol . value) in the list. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 result = Fcons (Fcons (XCAR (elt), val), result);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 /* Add on all the variables stored in special slots. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 struct buffer *syms = XBUFFER (Vbuffer_local_symbols);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 #define MARKED_SLOT(slot) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 { int mask = XINT (buffer_local_flags.slot); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 if (mask == 0 || mask == -1 \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 || ((mask > 0) && (buf->local_var_flags & mask))) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 result = Fcons (Fcons (syms->slot, buf->slot), result); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 #include "bufslots.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 #undef MARKED_SLOT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 DEFUN ("buffer-modified-p", Fbuffer_modified_p, 0, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 Return t if BUFFER was modified since its file was last read or saved.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 No argument or nil as argument means use current buffer as BUFFER.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 struct buffer *buf = decode_buffer (buffer, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863 return BUF_SAVE_MODIFF (buf) < BUF_MODIFF (buf) ? Qt : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 DEFUN ("set-buffer-modified-p", Fset_buffer_modified_p, 1, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867 Mark BUFFER as modified or unmodified according to FLAG.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 A non-nil FLAG means mark the buffer modified. No argument or nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 as BUFFER means use current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 (flag, buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 struct buffer *buf = decode_buffer (buffer, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 #ifdef CLASH_DETECTION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 /* If buffer becoming modified, lock the file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 If buffer becoming unmodified, unlock the file. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 Lisp_Object fn = buf->file_truename;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 if (!NILP (fn))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 int already = BUF_SAVE_MODIFF (buf) < BUF_MODIFF (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 if (already == NILP (flag))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 int count = specpdl_depth ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 /* lock_file() and unlock_file() currently use current_buffer */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 /* #### - dmoore, what if lock_file or unlock_file kill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 the current buffer? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 set_buffer_internal (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 if (!already && !NILP (flag))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893 lock_file (fn);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 else if (already && NILP (flag))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 unlock_file (fn);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 unbind_to (count, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 #endif /* CLASH_DETECTION */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 /* This is often called when the buffer contents are altered but we
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 don't want to treat the changes that way (e.g. selective
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 display). We still need to make sure redisplay realizes that the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 contents have potentially altered and it needs to do some
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 work. */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
906 buf = decode_buffer (buffer, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 BUF_MODIFF (buf)++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 BUF_SAVE_MODIFF (buf) = NILP (flag) ? BUF_MODIFF (buf) : 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 MARK_MODELINE_CHANGED;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 return flag;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 DEFUN ("buffer-modified-tick", Fbuffer_modified_tick, 0, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 Return BUFFER's tick counter, incremented for each change in text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 Each buffer has a tick counter which is incremented each time the text in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 that buffer is changed. It wraps around occasionally.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 No argument or nil as argument means use current buffer as BUFFER.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 struct buffer *buf = decode_buffer (buffer, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 return make_int (BUF_MODIFF (buf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 DEFUN ("rename-buffer", Frename_buffer, 1, 2,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 "sRename buffer (to new name): \nP", /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 Change current buffer's name to NEWNAME (a string).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 If second arg UNIQUE is nil or omitted, it is an error if a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 buffer named NEWNAME already exists.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 If UNIQUE is non-nil, come up with a new name using
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 `generate-new-buffer-name'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 Interactively, one can set UNIQUE with a prefix argument.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 Returns the name we actually gave the buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 This does not change the name of the visited file (if any).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 (newname, unique))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 Lisp_Object tem, buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 #ifdef I18N3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 /* #### Doc string should indicate that the buffer name will get
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945 translated. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 CHECK_STRING (newname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 newname = LISP_GETTEXT (newname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 if (XSTRING_LENGTH (newname) == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 error ("Empty string is invalid as a buffer name");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 tem = Fget_buffer (newname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 /* Don't short-circuit if UNIQUE is t. That is a useful way to rename
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 the buffer automatically so you can create another with the original name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 It makes UNIQUE equivalent to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957 (rename-buffer (generate-new-buffer-name NEWNAME)). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 /* XEmacs change: added check for nil */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 if (NILP (unique) && !NILP (tem) && XBUFFER (tem) == current_buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960 return current_buffer->name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 if (!NILP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 if (!NILP (unique))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 newname = Fgenerate_new_buffer_name (newname, current_buffer->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 error ("Buffer name \"%s\" is in use",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967 XSTRING_DATA (newname));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970 current_buffer->name = newname;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 /* Catch redisplay's attention. Unless we do this, the modelines for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 any windows displaying current_buffer will stay unchanged. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 MARK_MODELINE_CHANGED;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 buf = Fcurrent_buffer ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 /* The aconses in the Vbuffer_alist are shared with frame->buffer_alist,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 so this will change it in the per-frame ordering as well. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 Fsetcar (Frassq (buf, Vbuffer_alist), newname);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
981
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 if (NILP (current_buffer->filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 && !NILP (current_buffer->auto_save_file_name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 call0 (Qrename_auto_save_file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 /* refetch since that last call may have done GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 /* (hypothetical relocating GC) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987 return current_buffer->name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 DEFUN ("other-buffer", Fother_buffer, 0, 3, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 Return most recently selected buffer other than BUFFER.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 Buffers not visible in windows are preferred to visible buffers,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 unless optional third argument VISIBLE-OK is non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 If no other buffer exists, the buffer `*scratch*' is returned.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 If BUFFER is omitted or nil, some interesting buffer is returned.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 The ordering is for this frame; If second optional argument FRAME
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 is provided, then the ordering is for that frame. If the second arg
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 is t, then the global ordering is returned.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 Note: In FSF Emacs, this function takes two arguments: BUFFER and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 VISIBLE-OK.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 (buffer, frame, visible_ok))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 Lisp_Object tail, buf, notsogood, tem;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 Lisp_Object alist;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 notsogood = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 if (EQ (frame, Qt))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 alist = Vbuffer_alist;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 struct frame *f = decode_frame (frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 XSETFRAME (frame, f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019 alist = f->buffer_alist;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 for (tail = alist; !NILP (tail); tail = Fcdr (tail))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 buf = Fcdr (Fcar (tail));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 if (EQ (buf, buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 if (string_byte (XSTRING (XBUFFER (buf)->name), 0) == ' ')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 /* If FRAME has a buffer_predicate,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 disregard buffers that don't fit the predicate. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 if (FRAMEP (frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 tem = XFRAME (frame)->buffer_predicate;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 if (!NILP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 tem = call1 (tem, buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 if (NILP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 if (NILP (visible_ok))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 /* get-buffer-window will handle nil or t frame */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 tem = Fget_buffer_window (buf, frame, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 tem = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 if (NILP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 return buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 if (NILP (notsogood))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 notsogood = buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054 if (!NILP (notsogood))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 return notsogood;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 return Fget_buffer_create (QSscratch);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 DEFUN ("buffer-disable-undo", Fbuffer_disable_undo, 0, 1, "", /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1060 Stop keeping undo information for BUFFER.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 Any undo records it already has are discarded.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 No argument or nil as argument means do this for the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 /* Allowing nil is an RMSism */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067 struct buffer *real_buf = decode_buffer (buffer, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068 real_buf->undo_list = Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 DEFUN ("buffer-enable-undo", Fbuffer_enable_undo, 0, 1, "", /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1073 Start keeping undo information for BUFFER.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 No argument or nil as argument means do this for the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078 /* Allowing nil is an RMSism */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079 struct buffer *real_buf = decode_buffer (buffer, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 if (EQ (real_buf->undo_list, Qt))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 real_buf->undo_list = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086 DEFUN ("kill-buffer", Fkill_buffer, 1, 1, "bKill buffer: ", /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087 Kill the buffer BUFFER.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 The argument may be a buffer or may be the name of a buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089 An argument of nil means kill the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091 Value is t if the buffer is actually killed, nil if user says no.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093 The value of `kill-buffer-hook' (which may be local to that buffer),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094 if not void, is a list of functions to be called, with no arguments,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095 before the buffer is actually killed. The buffer to be killed is current
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 when the hook functions are called.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098 Any processes that have this buffer as the `process-buffer' are killed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099 with `delete-process'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103 /* This function can call lisp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 Lisp_Object buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 REGISTER struct buffer *b;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106 struct gcpro gcpro1, gcpro2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 if (NILP (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 buf = Fcurrent_buffer ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 else if (BUFFERP (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111 buf = buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 buf = get_buffer (buffer, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 if (NILP (buf)) nsberror (buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1116 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118 b = XBUFFER (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120 /* OK to delete an already-deleted buffer. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121 if (!BUFFER_LIVE_P (b))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1122 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124 /* Don't kill the minibuffer now current. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 if (EQ (buf, Vminibuffer_zero))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1127
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 /* Or the echo area. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129 if (EQ (buf, Vecho_area_buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132 /* Query if the buffer is still modified. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 if (INTERACTIVE && !NILP (b->filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 && BUF_MODIFF (b) > BUF_SAVE_MODIFF (b))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 Lisp_Object killp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137 GCPRO1 (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 killp = call1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 (Qyes_or_no_p,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140 (emacs_doprnt_string_c
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1141 ((const Bufbyte *) GETTEXT ("Buffer %s modified; kill anyway? "),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142 Qnil, -1, XSTRING_DATA (b->name))));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144 if (NILP (killp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 b = XBUFFER (buf); /* Hypothetical relocating GC. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 /* Run hooks with the buffer to be killed temporarily selected,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150 unless the buffer is already dead (could have been deleted
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151 in the question above).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153 if (BUFFER_LIVE_P (b))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 int speccount = specpdl_depth ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156 Lisp_Object tail = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 GCPRO2 (buf, tail);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159 record_unwind_protect (save_excursion_restore, save_excursion_save ());
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 Fset_buffer (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162 /* First run the query functions; if any query is answered no,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1163 don't kill the buffer. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164 EXTERNAL_LIST_LOOP (tail, Vkill_buffer_query_functions)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166 if (NILP (call0 (Fcar (tail))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1169 return unbind_to (speccount, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1171 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1173 /* Then run the hooks. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174 run_hook (Qkill_buffer_hook);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1175
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1176 /* Inform the selection code that a buffer just got killed.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1177 We do this in C because (a) it's faster, and (b) it needs
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1178 to access data internal to select.c that can't be seen from
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1179 Lisp (so the Lisp code would just call into C anyway. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1180 select_notify_buffer_kill (buf);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1181
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1182 unbind_to (speccount, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 b = XBUFFER (buf); /* Hypothetical relocating GC. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1185 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1186
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187 /* We have no more questions to ask. Verify that it is valid
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 to kill the buffer. This must be done after the questions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 since anything can happen within yes-or-no-p. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191 /* Might have been deleted during the last question above */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192 if (!BUFFER_LIVE_P (b))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1194
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1195 /* Don't kill the minibuffer now current. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1196 if (EQ (buf, XWINDOW (minibuf_window)->buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1197 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1198
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1199 /* When we kill a base buffer, kill all its indirect buffers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1200 We do it at this stage so nothing terrible happens if they
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1201 ask questions or their hooks get errors. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1202 if (! b->base_buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 Lisp_Object rest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206 GCPRO1 (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208 LIST_LOOP (rest, b->indirect_children)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1210 Fkill_buffer (XCAR (rest));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1211 /* Keep indirect_children updated in case a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1212 query-function/hook throws. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213 b->indirect_children = XCDR (rest);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1214 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1215
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219 /* Make this buffer not be current.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1220 In the process, notice if this is the sole visible buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1221 and give up if so. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222 if (b == current_buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1223 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224 Fset_buffer (Fother_buffer (buf, Qnil, Qnil));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1225 if (b == current_buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1226 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1227 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1228
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229 /* Now there is no question: we can kill the buffer. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1230
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1231 #ifdef CLASH_DETECTION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1232 /* Unlock this buffer's file, if it is locked. unlock_buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233 can both GC and kill the current buffer, and wreak general
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1234 havok by running lisp code. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235 GCPRO1 (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236 unlock_buffer (b);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 b = XBUFFER (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1240 if (!BUFFER_LIVE_P (b))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1242
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1243 if (b == current_buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1244 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1245 Fset_buffer (Fother_buffer (buf, Qnil, Qnil));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1246 if (b == current_buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1247 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1248 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1249 #endif /* CLASH_DETECTION */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1250
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1251 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1252 int speccount = specpdl_depth ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1253 specbind (Qinhibit_quit, Qt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1254
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255 kill_buffer_processes (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1256
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1257 delete_from_buffer_alist (buf);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1258
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1259 /* #### This is a problem if this buffer is in a dedicated window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1260 Need to undedicate any windows of this buffer first (and delete them?)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1261 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1262 Freplace_buffer_in_windows (buf, Qnil, Qnil);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1263
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1264 font_lock_buffer_was_killed (b);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1265
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1266 /* Delete any auto-save file, if we saved it in this session. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1267 if (STRINGP (b->auto_save_file_name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1268 && b->auto_save_modified != 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1269 && BUF_SAVE_MODIFF (b) < b->auto_save_modified)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1270 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1271 if (delete_auto_save_files != 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1272 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1273 /* deleting the auto save file might kill b! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1274 /* #### dmoore - fix this crap, we do this same gcpro and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275 buffer liveness check multiple times. Let's get a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276 macro or something for it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1277 GCPRO1 (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1278 internal_delete_file (b->auto_save_file_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1279 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1280 b = XBUFFER (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1281
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1282 if (!BUFFER_LIVE_P (b))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1283 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1284
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1285 if (b == current_buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1286 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1287 Fset_buffer (Fother_buffer (buf, Qnil, Qnil));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1288 if (b == current_buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1289 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1290 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1291 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1292 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1293
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1294 uninit_buffer_markers (b);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1295
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1296 kill_buffer_local_variables (b);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1297
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1298 b->name = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1299 uninit_buffer_text (b);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1300 b->undo_list = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1301 uninit_buffer_extents (b);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1302 if (b->base_buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1303 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1304 #ifdef ERROR_CHECK_BUFPOS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1305 assert (!NILP (memq_no_quit (buf, b->base_buffer->indirect_children)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1306 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1307 b->base_buffer->indirect_children =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1308 delq_no_quit (buf, b->base_buffer->indirect_children);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1309 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1310
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1311 /* Clear away all Lisp objects, so that they
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1312 won't be protected from GC. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1313 nuke_all_buffer_slots (b, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1314
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1315 unbind_to (speccount, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1316 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1317 return Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1318 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1319
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1320 DEFUN ("record-buffer", Frecord_buffer, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1321 Place buffer BUFFER first in the buffer order.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1322 Call this function when a buffer is selected "visibly".
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1323
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1324 This function changes the global buffer order and the per-frame buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1325 order for the selected frame. The buffer order keeps track of recency
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1326 of selection so that `other-buffer' will return a recently selected
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1327 buffer. See `other-buffer' for more information.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1328 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1329 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1330 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1331 REGISTER Lisp_Object lynk, prev;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1332 struct frame *f = selected_frame ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1333
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1334 prev = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1335 for (lynk = Vbuffer_alist; CONSP (lynk); lynk = XCDR (lynk))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1336 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1337 if (EQ (XCDR (XCAR (lynk)), buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1338 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1339 prev = lynk;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1340 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1341 /* Effectively do Vbuffer_alist = delq_no_quit (lynk, Vbuffer_alist) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1342 if (NILP (prev))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1343 Vbuffer_alist = XCDR (Vbuffer_alist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1344 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1345 XCDR (prev) = XCDR (XCDR (prev));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1346 XCDR (lynk) = Vbuffer_alist;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1347 Vbuffer_alist = lynk;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1348
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1349 /* That was the global one. Now do the same thing for the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1350 per-frame buffer-alist. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1351 prev = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1352 for (lynk = f->buffer_alist; CONSP (lynk); lynk = XCDR (lynk))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1354 if (EQ (XCDR (XCAR (lynk)), buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1355 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1356 prev = lynk;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1358 /* Effectively do f->buffer_alist = delq_no_quit (lynk, f->buffer_alist) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1359 if (NILP (prev))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1360 f->buffer_alist = XCDR (f->buffer_alist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1361 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1362 XCDR (prev) = XCDR (XCDR (prev));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1363 XCDR (lynk) = f->buffer_alist;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1364 f->buffer_alist = lynk;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1365
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1366 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1367 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1368
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1369 DEFUN ("set-buffer-major-mode", Fset_buffer_major_mode, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1370 Set an appropriate major mode for BUFFER, according to `default-major-mode'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1371 Use this function before selecting the buffer, since it may need to inspect
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1372 the current buffer's major mode.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1373 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1374 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1376 int speccount = specpdl_depth ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1377 Lisp_Object function = XBUFFER (Vbuffer_defaults)->major_mode;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1378
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379 if (NILP (function))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1380 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1381 Lisp_Object tem = Fget (current_buffer->major_mode, Qmode_class, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1382 if (NILP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1383 function = current_buffer->major_mode;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1384 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1385
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1386 if (NILP (function) || EQ (function, Qfundamental_mode))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1387 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1388
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1389 /* To select a nonfundamental mode,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1390 select the buffer temporarily and then call the mode function. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1391
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1392 record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1393
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1394 Fset_buffer (buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1395 call0 (function);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1396
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1397 return unbind_to (speccount, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1398 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1399
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1400 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1401 switch_to_buffer (Lisp_Object bufname, Lisp_Object norecord)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1402 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1403 call2 (Qswitch_to_buffer, bufname, norecord);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1404 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1405
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1406
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1407 DEFUN ("current-buffer", Fcurrent_buffer, 0, 0, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1408 Return the current buffer as a Lisp object.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1409 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1410 ())
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1411 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1412 Lisp_Object buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413 XSETBUFFER (buffer, current_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1414 return buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1415 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1416
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1417 /* Set the current buffer to B. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1418
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1419 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1420 set_buffer_internal (struct buffer *b)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1421 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1422 REGISTER struct buffer *old_buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1423 REGISTER Lisp_Object tail;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1424
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1425 if (current_buffer == b)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1426 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1427
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1428 INVALIDATE_PIXEL_TO_GLYPH_CACHE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1429
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1430 old_buf = current_buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1431 current_buffer = b;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1432 invalidate_current_column (); /* invalidate indentation cache */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1433
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1434 if (old_buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1435 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1436 /* Put the undo list back in the base buffer, so that it appears
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1437 that an indirect buffer shares the undo list of its base. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1438 if (old_buf->base_buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1439 old_buf->base_buffer->undo_list = old_buf->undo_list;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1440 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1441
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1442 /* Get the undo list from the base buffer, so that it appears
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1443 that an indirect buffer shares the undo list of its base. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1444 if (b->base_buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1445 b->undo_list = b->base_buffer->undo_list;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1446
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1447 /* Look down buffer's list of local Lisp variables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1448 to find and update any that forward into C variables. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1449
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1450 LIST_LOOP (tail, b->local_var_alist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1451 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1452 Lisp_Object sym = XCAR (XCAR (tail));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1453 Lisp_Object valcontents = XSYMBOL (sym)->value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1454 if (SYMBOL_VALUE_MAGIC_P (valcontents))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1455 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1456 /* Just reference the variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1457 to cause it to become set for this buffer. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1458 /* Use find_symbol_value_quickly to avoid an unnecessary O(n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1459 lookup. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1460 (void) find_symbol_value_quickly (XCAR (tail), 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1461 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1462 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1463
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1464 /* Do the same with any others that were local to the previous buffer */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1465
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1466 if (old_buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1467 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1468 LIST_LOOP (tail, old_buf->local_var_alist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1469 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1470 Lisp_Object sym = XCAR (XCAR (tail));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1471 Lisp_Object valcontents = XSYMBOL (sym)->value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1472
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1473 if (SYMBOL_VALUE_MAGIC_P (valcontents))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1474 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1475 /* Just reference the variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1476 to cause it to become set for this buffer. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1477 /* Use find_symbol_value_quickly with find_it_p as 0 to avoid an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1478 unnecessary O(n) lookup which is guaranteed to be worst case.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1479 Any symbols which are local are guaranteed to have been
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1480 handled in the previous loop, above. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1481 (void) find_symbol_value_quickly (sym, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1482 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1483 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1484 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1485 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1486
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1487 DEFUN ("set-buffer", Fset_buffer, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1488 Make the buffer BUFFER current for editing operations.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1489 BUFFER may be a buffer or the name of an existing buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1490 See also `save-excursion' when you want to make a buffer current temporarily.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1491 This function does not display the buffer, so its effect ends
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1492 when the current command terminates.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1493 Use `switch-to-buffer' or `pop-to-buffer' to switch buffers permanently.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1494 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1495 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1496 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1497 buffer = get_buffer (buffer, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1498 if (NILP (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1499 error ("Selecting deleted or non-existent buffer");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1500 set_buffer_internal (XBUFFER (buffer));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1501 return buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1502 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1503
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1504
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1505 DEFUN ("barf-if-buffer-read-only", Fbarf_if_buffer_read_only, 0, 3, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1506 Signal a `buffer-read-only' error if BUFFER is read-only.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1507 Optional argument BUFFER defaults to the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1508
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1509 If optional argument START is non-nil, all extents in the buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1510 which overlap that part of the buffer are checked to ensure none has a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1511 `read-only' property. (Extents that lie completely within the range,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1512 however, are not checked.) END defaults to the value of START.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1513
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1514 If START and END are equal, the range checked is [START, END] (i.e.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1515 closed on both ends); otherwise, the range checked is (START, END)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1516 \(open on both ends), except that extents that lie completely within
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1517 [START, END] are not checked. See `extent-in-region-p' for a fuller
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1518 discussion.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1519 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1520 (buffer, start, end))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1521 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1522 struct buffer *b = decode_buffer (buffer, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1523 Bufpos s, e;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1524
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1525 if (NILP (start))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1526 s = e = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1527 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1528 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1529 if (NILP (end))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1530 end = start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1531 get_buffer_range_char (b, start, end, &s, &e, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1532 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1533 barf_if_buffer_read_only (b, s, e);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1534
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1535 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1536 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1537
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1538 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1539 bury_buffer_1 (Lisp_Object buffer, Lisp_Object before,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1540 Lisp_Object *buffer_alist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1541 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1542 Lisp_Object aelt = rassq_no_quit (buffer, *buffer_alist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1543 Lisp_Object lynk = memq_no_quit (aelt, *buffer_alist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1544 Lisp_Object iter, before_before;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1545
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1546 *buffer_alist = delq_no_quit (aelt, *buffer_alist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1547 for (before_before = Qnil, iter = *buffer_alist;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1548 !NILP (iter) && !EQ (XCDR (XCAR (iter)), before);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1549 before_before = iter, iter = XCDR (iter))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1550 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1551 XCDR (lynk) = iter;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1552 if (!NILP (before_before))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1553 XCDR (before_before) = lynk;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1554 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1555 *buffer_alist = lynk;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1556 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1557
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1558 DEFUN ("bury-buffer", Fbury_buffer, 0, 2, "", /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1559 Put BUFFER at the end of the list of all buffers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1560 There it is the least likely candidate for `other-buffer' to return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1561 thus, the least likely buffer for \\[switch-to-buffer] to select by default.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1562 If BUFFER is nil or omitted, bury the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1563 Also, if BUFFER is nil or omitted, remove the current buffer from the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1564 selected window if it is displayed there.
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1565 Because of this, you may need to specify (current-buffer) as
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1566 BUFFER when calling from minibuffer.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1567 If BEFORE is non-nil, it specifies a buffer before which BUFFER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1568 will be placed, instead of being placed at the end.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1569 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1570 (buffer, before))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1571 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1572 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1573 struct buffer *buf = decode_buffer (buffer, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1574 /* If we're burying the current buffer, unshow it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1575 /* Note that the behavior of (bury-buffer nil) and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1576 (bury-buffer (current-buffer)) is not the same.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1577 This is illogical but is historical. Changing it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1578 breaks mh-e and TeX and such packages. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1579 if (NILP (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1580 switch_to_buffer (Fother_buffer (Fcurrent_buffer (), Qnil, Qnil), Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1581 XSETBUFFER (buffer, buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1582
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1583 if (!NILP (before))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1584 before = get_buffer (before, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1585
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1586 if (EQ (before, buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1587 error ("Cannot place a buffer before itself");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1588
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1589 bury_buffer_1 (buffer, before, &Vbuffer_alist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1590 bury_buffer_1 (buffer, before, &selected_frame ()->buffer_alist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1591
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1592 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1593 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1594
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1595
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1596 DEFUN ("erase-buffer", Ferase_buffer, 0, 1, "*", /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1597 Delete the entire contents of the BUFFER.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1598 Any clipping restriction in effect (see `narrow-to-region') is removed,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1599 so the buffer is truly empty after this.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1600 BUFFER defaults to the current buffer if omitted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1601 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1602 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1603 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1604 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1605 struct buffer *b = decode_buffer (buffer, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1606 /* #### yuck yuck yuck. This is gross. The old echo-area code,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1607 however, was the only place that called erase_buffer() with a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1608 non-zero NO_CLIP argument.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1609
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1610 Someone needs to fix up the redisplay code so it is smarter
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1611 about this, so that the NO_CLIP junk isn't necessary. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1612 int no_clip = (b == XBUFFER (Vecho_area_buffer));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1613
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1614 INVALIDATE_PIXEL_TO_GLYPH_CACHE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1615
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1616 widen_buffer (b, no_clip);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1617 buffer_delete_range (b, BUF_BEG (b), BUF_Z (b), 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1618 b->last_window_start = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1619
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1620 /* Prevent warnings, or suspension of auto saving, that would happen
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1621 if future size is less than past size. Use of erase-buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1622 implies that the future text is not really related to the past text. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1623 b->saved_size = Qzero;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1624
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1625 zmacs_region_stays = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1626 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1627 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1628
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1629
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1630
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1631 DEFUN ("kill-all-local-variables", Fkill_all_local_variables, 0, 0, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1632 Switch to Fundamental mode by killing current buffer's local variables.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1633 Most local variable bindings are eliminated so that the default values
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1634 become effective once more. Also, the syntax table is set from
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1635 `standard-syntax-table', the category table is set from
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1636 `standard-category-table' (if support for Mule exists), local keymap is set
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1637 to nil, the abbrev table is set from `fundamental-mode-abbrev-table',
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1638 and all specifier specifications whose locale is the current buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1639 are removed. This function also forces redisplay of the modeline.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1640
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1641 Every function to select a new major mode starts by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1642 calling this function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1643
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1644 As a special exception, local variables whose names have
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1645 a non-nil `permanent-local' property are not eliminated by this function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1646
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1647 The first thing this function does is run
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1648 the normal hook `change-major-mode-hook'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1649 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1650 ())
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1651 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1652 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1653 run_hook (Qchange_major_mode_hook);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1654
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1655 reset_buffer_local_variables (current_buffer, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1656
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1657 kill_buffer_local_variables (current_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1658
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1659 kill_specifier_buffer_locals (Fcurrent_buffer ());
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1660
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1661 /* Force modeline redisplay. Useful here because all major mode
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1662 commands call this function. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1663 MARK_MODELINE_CHANGED;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1664
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1665 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1666 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1667
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1668 #ifdef MEMORY_USAGE_STATS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1669
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1670 struct buffer_stats
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1671 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1672 int text;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1673 int markers;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1674 int extents;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1675 int other;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1676 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1677
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1678 static size_t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1679 compute_buffer_text_usage (struct buffer *b, struct overhead_stats *ovstats)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1680 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1681 int was_requested = b->text->z - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1682 size_t gap = b->text->gap_size + b->text->end_gap_size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1683 size_t malloc_use = malloced_storage_size (b->text->beg, was_requested + gap, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1684
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1685 ovstats->gap_overhead += gap;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1686 ovstats->was_requested += was_requested;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1687 ovstats->malloc_overhead += malloc_use - (was_requested + gap);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1688 return malloc_use;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1689 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1690
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1691 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1692 compute_buffer_usage (struct buffer *b, struct buffer_stats *stats,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1693 struct overhead_stats *ovstats)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1694 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1695 xzero (*stats);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1696 stats->other += malloced_storage_size (b, sizeof (*b), ovstats);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1697 stats->text += compute_buffer_text_usage (b, ovstats);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1698 stats->markers += compute_buffer_marker_usage (b, ovstats);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1699 stats->extents += compute_buffer_extent_usage (b, ovstats);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1700 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1701
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1702 DEFUN ("buffer-memory-usage", Fbuffer_memory_usage, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1703 Return stats about the memory usage of buffer BUFFER.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1704 The values returned are in the form of an alist of usage types and byte
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1705 counts. The byte counts attempt to encompass all the memory used
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1706 by the buffer (separate from the memory logically associated with a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1707 buffer or frame), including internal structures and any malloc()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1708 overhead associated with them. In practice, the byte counts are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1709 underestimated because certain memory usage is very hard to determine
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1710 \(e.g. the amount of memory used inside the Xt library or inside the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1711 X server) and because there is other stuff that might logically
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1712 be associated with a window, buffer, or frame (e.g. window configurations,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1713 glyphs) but should not obviously be included in the usage counts.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1714
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1715 Multiple slices of the total memory usage may be returned, separated
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1716 by a nil. Each slice represents a particular view of the memory, a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1717 particular way of partitioning it into groups. Within a slice, there
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1718 is no overlap between the groups of memory, and each slice collectively
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1719 represents all the memory concerned.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1720 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1721 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1722 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1723 struct buffer_stats stats;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1724 struct overhead_stats ovstats;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1725 Lisp_Object val = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1726
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1727 CHECK_BUFFER (buffer); /* dead buffers should be allowed, no? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1728 xzero (ovstats);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1729 compute_buffer_usage (XBUFFER (buffer), &stats, &ovstats);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1730
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1731 val = acons (Qtext, make_int (stats.text), val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1732 val = acons (Qmarkers, make_int (stats.markers), val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1733 val = acons (Qextents, make_int (stats.extents), val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1734 val = acons (Qother, make_int (stats.other), val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1735 val = Fcons (Qnil, val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1736 val = acons (Qactually_requested, make_int (ovstats.was_requested), val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1737 val = acons (Qmalloc_overhead, make_int (ovstats.malloc_overhead), val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1738 val = acons (Qgap_overhead, make_int (ovstats.gap_overhead), val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1739 val = acons (Qdynarr_overhead, make_int (ovstats.dynarr_overhead), val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1740
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1741 return Fnreverse (val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1742 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1743
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1744 #endif /* MEMORY_USAGE_STATS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1745
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1746
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1747 /************************************************************************/
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1748 /* Implement TO_EXTERNAL_FORMAT, TO_INTERNAL_FORMAT */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1749 /************************************************************************/
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1750
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1751 /* This implementation should probably be elsewhere, but it can't be
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1752 in file-coding.c since that file is only available if FILE_CODING
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1753 is defined. */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1754 #ifdef FILE_CODING
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1755 static int
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1756 coding_system_is_binary (Lisp_Object coding_system)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1757 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1758 Lisp_Coding_System *cs = XCODING_SYSTEM (coding_system);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1759 return
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1760 (CODING_SYSTEM_TYPE (cs) == CODESYS_NO_CONVERSION &&
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1761 CODING_SYSTEM_EOL_TYPE (cs) == EOL_LF &&
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1762 EQ (CODING_SYSTEM_POST_READ_CONVERSION (cs), Qnil) &&
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1763 EQ (CODING_SYSTEM_PRE_WRITE_CONVERSION (cs), Qnil));
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1764 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1765 #else
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1766 #define coding_system_is_binary(coding_system) 1
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1767 #endif
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1768
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1769 typedef struct
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1770 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1771 Dynarr_declare (Bufbyte_dynarr *);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1772 } Bufbyte_dynarr_dynarr;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1773
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1774 typedef struct
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1775 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1776 Dynarr_declare (Extbyte_dynarr *);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1777 } Extbyte_dynarr_dynarr;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1778
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1779 static Extbyte_dynarr_dynarr *conversion_out_dynarr_list;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1780 static Bufbyte_dynarr_dynarr *conversion_in_dynarr_list;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1781
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1782 static int dfc_convert_to_external_format_in_use;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1783 static int dfc_convert_to_internal_format_in_use;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1784
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1785 static Lisp_Object
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1786 dfc_convert_to_external_format_reset_in_use (Lisp_Object value)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1787 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1788 dfc_convert_to_external_format_in_use = XINT (value);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1789 return Qnil;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1790 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1791
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1792 static Lisp_Object
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1793 dfc_convert_to_internal_format_reset_in_use (Lisp_Object value)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1794 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1795 dfc_convert_to_internal_format_in_use = XINT (value);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1796 return Qnil;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1797 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1798
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1799 void
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1800 dfc_convert_to_external_format (dfc_conversion_type source_type,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1801 dfc_conversion_data *source,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1802 #ifdef FILE_CODING
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1803 Lisp_Object coding_system,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1804 #endif
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1805 dfc_conversion_type sink_type,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1806 dfc_conversion_data *sink)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1807 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1808 int count = specpdl_depth ();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1809 Extbyte_dynarr *conversion_out_dynarr;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1810
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1811 type_checking_assert
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1812 (((source_type == DFC_TYPE_DATA) ||
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1813 (source_type == DFC_TYPE_LISP_LSTREAM && LSTREAMP (source->lisp_object)) ||
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1814 (source_type == DFC_TYPE_LISP_STRING && STRINGP (source->lisp_object)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1815 &&
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1816 ((sink_type == DFC_TYPE_DATA) ||
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1817 (sink_type == DFC_TYPE_LISP_LSTREAM && LSTREAMP (source->lisp_object))));
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1818
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1819 record_unwind_protect (dfc_convert_to_external_format_reset_in_use,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1820 make_int (dfc_convert_to_external_format_in_use));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1821 if (Dynarr_length (conversion_out_dynarr_list) <=
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1822 dfc_convert_to_external_format_in_use)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1823 Dynarr_add (conversion_out_dynarr_list, Dynarr_new (Extbyte));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1824 conversion_out_dynarr = Dynarr_at (conversion_out_dynarr_list,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1825 dfc_convert_to_external_format_in_use);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1826 dfc_convert_to_external_format_in_use++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1827 Dynarr_reset (conversion_out_dynarr);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1828
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1829 #ifdef FILE_CODING
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1830 coding_system = Fget_coding_system (coding_system);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1831 #endif
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1832
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1833 /* Here we optimize in the case where the coding system does no
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1834 conversion. However, we don't want to optimize in case the source
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1835 or sink is an lstream, since writing to an lstream can cause a
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1836 garbage collection, and this could be problematic if the source
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1837 is a lisp string. */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1838 if (source_type != DFC_TYPE_LISP_LSTREAM &&
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1839 sink_type != DFC_TYPE_LISP_LSTREAM &&
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1840 coding_system_is_binary (coding_system))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1841 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1842 const Bufbyte *ptr;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1843 Bytecount len;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1844
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1845 if (source_type == DFC_TYPE_LISP_STRING)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1846 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1847 ptr = XSTRING_DATA (source->lisp_object);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1848 len = XSTRING_LENGTH (source->lisp_object);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1849 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1850 else
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1851 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1852 ptr = (Bufbyte *) source->data.ptr;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1853 len = source->data.len;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1854 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1855
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1856 #ifdef MULE
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1857 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1858 const Bufbyte *end;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1859 for (end = ptr + len; ptr < end;)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1860 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1861 Bufbyte c =
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1862 (BYTE_ASCII_P (*ptr)) ? *ptr :
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1863 (*ptr == LEADING_BYTE_CONTROL_1) ? (*(ptr+1) - 0x20) :
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1864 (*ptr == LEADING_BYTE_LATIN_ISO8859_1) ? (*(ptr+1)) :
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1865 '~';
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1866
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1867 Dynarr_add (conversion_out_dynarr, (Extbyte) c);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1868 INC_CHARPTR (ptr);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1869 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1870 bufpos_checking_assert (ptr == end);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1871 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1872 #else
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1873 Dynarr_add_many (conversion_out_dynarr, ptr, len);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1874 #endif
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1875
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1876 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1877 else
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1878 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1879 Lisp_Object streams_to_delete[3];
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1880 int delete_count = 0;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1881 Lisp_Object instream, outstream;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1882 Lstream *reader, *writer;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1883 struct gcpro gcpro1, gcpro2;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1884
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1885 if (source_type == DFC_TYPE_LISP_LSTREAM)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1886 instream = source->lisp_object;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1887 else if (source_type == DFC_TYPE_DATA)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1888 streams_to_delete[delete_count++] = instream =
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1889 make_fixed_buffer_input_stream (source->data.ptr, source->data.len);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1890 else
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1891 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1892 type_checking_assert (source_type == DFC_TYPE_LISP_STRING);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1893 streams_to_delete[delete_count++] = instream =
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1894 make_lisp_string_input_stream (source->lisp_object, 0, -1);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1895 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1896
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1897 if (sink_type == DFC_TYPE_LISP_LSTREAM)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1898 outstream = sink->lisp_object;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1899 else
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1900 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1901 type_checking_assert (sink_type == DFC_TYPE_DATA);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1902 streams_to_delete[delete_count++] = outstream =
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1903 make_dynarr_output_stream
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1904 ((unsigned_char_dynarr *) conversion_out_dynarr);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1905 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1906
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1907 #ifdef FILE_CODING
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1908 streams_to_delete[delete_count++] = outstream =
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1909 make_encoding_output_stream (XLSTREAM (outstream), coding_system);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1910 #endif
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1911
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1912 reader = XLSTREAM (instream);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1913 writer = XLSTREAM (outstream);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1914 /* decoding_stream will gc-protect outstream */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1915 GCPRO2 (instream, outstream);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1916
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1917 while (1)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1918 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1919 ssize_t size_in_bytes;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1920 char tempbuf[1024]; /* some random amount */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1921
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1922 size_in_bytes = Lstream_read (reader, tempbuf, sizeof (tempbuf));
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1923
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1924 if (size_in_bytes == 0)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1925 break;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1926 else if (size_in_bytes < 0)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1927 error ("Error converting to external format");
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1928
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1929 size_in_bytes = Lstream_write (writer, tempbuf, size_in_bytes);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1930
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1931 if (size_in_bytes <= 0)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1932 error ("Error converting to external format");
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1933 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1934
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1935 /* Closing writer will close any stream at the other end of writer. */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1936 Lstream_close (writer);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1937 Lstream_close (reader);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1938 UNGCPRO;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1939
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1940 /* The idea is that this function will create no garbage. */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1941 while (delete_count)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1942 Lstream_delete (XLSTREAM (streams_to_delete [--delete_count]));
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1943 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1944
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1945 unbind_to (count, Qnil);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1946
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1947 if (sink_type != DFC_TYPE_LISP_LSTREAM)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1948 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1949 sink->data.len = Dynarr_length (conversion_out_dynarr);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1950 Dynarr_add (conversion_out_dynarr, '\0'); /* NUL-terminate! */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1951 sink->data.ptr = Dynarr_atp (conversion_out_dynarr, 0);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1952 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1953 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1954
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1955 void
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1956 dfc_convert_to_internal_format (dfc_conversion_type source_type,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1957 dfc_conversion_data *source,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1958 #ifdef FILE_CODING
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1959 Lisp_Object coding_system,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1960 #endif
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1961 dfc_conversion_type sink_type,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1962 dfc_conversion_data *sink)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1963 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1964 int count = specpdl_depth ();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1965 Bufbyte_dynarr *conversion_in_dynarr;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1966
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1967 type_checking_assert
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1968 ((source_type == DFC_TYPE_DATA ||
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1969 source_type == DFC_TYPE_LISP_LSTREAM)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1970 &&
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1971 (sink_type == DFC_TYPE_DATA ||
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1972 sink_type == DFC_TYPE_LISP_LSTREAM));
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1973
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1974 record_unwind_protect (dfc_convert_to_internal_format_reset_in_use,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1975 make_int (dfc_convert_to_internal_format_in_use));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1976 if (Dynarr_length (conversion_in_dynarr_list) <=
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1977 dfc_convert_to_internal_format_in_use)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1978 Dynarr_add (conversion_in_dynarr_list, Dynarr_new (Bufbyte));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1979 conversion_in_dynarr = Dynarr_at (conversion_in_dynarr_list,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1980 dfc_convert_to_internal_format_in_use);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1981 dfc_convert_to_internal_format_in_use++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1982 Dynarr_reset (conversion_in_dynarr);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1983
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1984 #ifdef FILE_CODING
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1985 coding_system = Fget_coding_system (coding_system);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1986 #endif
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1987
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1988 if (source_type != DFC_TYPE_LISP_LSTREAM &&
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1989 sink_type != DFC_TYPE_LISP_LSTREAM &&
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1990 coding_system_is_binary (coding_system))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1991 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1992 #ifdef MULE
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1993 const Bufbyte *ptr = (const Bufbyte *) source->data.ptr;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1994 Bytecount len = source->data.len;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1995 const Bufbyte *end = ptr + len;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1996
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1997 for (; ptr < end; ptr++)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1998 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1999 Bufbyte c = *ptr;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2000
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2001 if (BYTE_ASCII_P (c))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2002 Dynarr_add (conversion_in_dynarr, c);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2003 else if (BYTE_C1_P (c))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2004 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2005 Dynarr_add (conversion_in_dynarr, LEADING_BYTE_CONTROL_1);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2006 Dynarr_add (conversion_in_dynarr, c + 0x20);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2007 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2008 else
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2009 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2010 Dynarr_add (conversion_in_dynarr, LEADING_BYTE_LATIN_ISO8859_1);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2011 Dynarr_add (conversion_in_dynarr, c);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2012 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2013 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2014 #else
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2015 Dynarr_add_many (conversion_in_dynarr, source->data.ptr, source->data.len);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2016 #endif
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2017 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2018 else
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2019 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2020 Lisp_Object streams_to_delete[3];
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2021 int delete_count = 0;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2022 Lisp_Object instream, outstream;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2023 Lstream *reader, *writer;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2024 struct gcpro gcpro1, gcpro2;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2025
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2026 if (source_type == DFC_TYPE_LISP_LSTREAM)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2027 instream = source->lisp_object;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2028 else
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2029 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2030 type_checking_assert (source_type == DFC_TYPE_DATA);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2031 streams_to_delete[delete_count++] = instream =
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2032 make_fixed_buffer_input_stream (source->data.ptr, source->data.len);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2033 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2034
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2035 if (sink_type == DFC_TYPE_LISP_LSTREAM)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2036 outstream = sink->lisp_object;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2037 else
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2038 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2039 type_checking_assert (sink_type == DFC_TYPE_DATA);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2040 streams_to_delete[delete_count++] = outstream =
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2041 make_dynarr_output_stream
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2042 ((unsigned_char_dynarr *) conversion_in_dynarr);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2043 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2044
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2045 #ifdef FILE_CODING
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2046 streams_to_delete[delete_count++] = outstream =
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2047 make_decoding_output_stream (XLSTREAM (outstream), coding_system);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2048 #endif
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2049
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2050 reader = XLSTREAM (instream);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2051 writer = XLSTREAM (outstream);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2052 /* outstream will gc-protect its sink stream, if necessary */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2053 GCPRO2 (instream, outstream);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2054
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2055 while (1)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2056 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2057 ssize_t size_in_bytes;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2058 char tempbuf[1024]; /* some random amount */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2059
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2060 size_in_bytes = Lstream_read (reader, tempbuf, sizeof (tempbuf));
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2061
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2062 if (size_in_bytes == 0)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2063 break;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2064 else if (size_in_bytes < 0)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2065 error ("Error converting to internal format");
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2066
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2067 size_in_bytes = Lstream_write (writer, tempbuf, size_in_bytes);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2068
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2069 if (size_in_bytes <= 0)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2070 error ("Error converting to internal format");
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2071 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2072
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2073 /* Closing writer will close any stream at the other end of writer. */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2074 Lstream_close (writer);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2075 Lstream_close (reader);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2076 UNGCPRO;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2077
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2078 /* The idea is that this function will create no garbage. */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2079 while (delete_count)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2080 Lstream_delete (XLSTREAM (streams_to_delete [--delete_count]));
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2081 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2082
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2083 unbind_to (count, Qnil);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2084
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2085 if (sink_type != DFC_TYPE_LISP_LSTREAM)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2086 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2087 sink->data.len = Dynarr_length (conversion_in_dynarr);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2088 Dynarr_add (conversion_in_dynarr, '\0'); /* NUL-terminate! */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2089 sink->data.ptr = Dynarr_atp (conversion_in_dynarr, 0);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2090 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2091 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2092
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2093
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2094 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2095 syms_of_buffer (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2096 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2097 INIT_LRECORD_IMPLEMENTATION (buffer);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2098
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2099 defsymbol (&Qbuffer_live_p, "buffer-live-p");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2100 defsymbol (&Qbuffer_or_string_p, "buffer-or-string-p");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2101 defsymbol (&Qmode_class, "mode-class");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2102 defsymbol (&Qrename_auto_save_file, "rename-auto-save-file");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2103 defsymbol (&Qkill_buffer_hook, "kill-buffer-hook");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2104 defsymbol (&Qpermanent_local, "permanent-local");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2105
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2106 defsymbol (&Qfirst_change_hook, "first-change-hook");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2107 defsymbol (&Qbefore_change_functions, "before-change-functions");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2108 defsymbol (&Qafter_change_functions, "after-change-functions");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2109
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2110 /* #### Obsolete, for compatibility */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2111 defsymbol (&Qbefore_change_function, "before-change-function");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2112 defsymbol (&Qafter_change_function, "after-change-function");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2113
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2114 defsymbol (&Qdefault_directory, "default-directory");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2115
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2116 defsymbol (&Qget_file_buffer, "get-file-buffer");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2117 defsymbol (&Qchange_major_mode_hook, "change-major-mode-hook");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2118
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2119 defsymbol (&Qfundamental_mode, "fundamental-mode");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2120
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2121 defsymbol (&Qfind_file_compare_truenames, "find-file-compare-truenames");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2122
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2123 defsymbol (&Qswitch_to_buffer, "switch-to-buffer");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2125 DEFSUBR (Fbufferp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2126 DEFSUBR (Fbuffer_live_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2127 DEFSUBR (Fbuffer_list);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2128 DEFSUBR (Fdecode_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2129 DEFSUBR (Fget_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2130 DEFSUBR (Fget_file_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2131 DEFSUBR (Fget_buffer_create);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2132 DEFSUBR (Fmake_indirect_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2133
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2134 DEFSUBR (Fgenerate_new_buffer_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2135 DEFSUBR (Fbuffer_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2136 DEFSUBR (Fbuffer_file_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2137 DEFSUBR (Fbuffer_base_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2138 DEFSUBR (Fbuffer_indirect_children);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2139 DEFSUBR (Fbuffer_local_variables);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2140 DEFSUBR (Fbuffer_modified_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2141 DEFSUBR (Fset_buffer_modified_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2142 DEFSUBR (Fbuffer_modified_tick);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2143 DEFSUBR (Frename_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2144 DEFSUBR (Fother_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2145 DEFSUBR (Fbuffer_disable_undo);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2146 DEFSUBR (Fbuffer_enable_undo);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2147 DEFSUBR (Fkill_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2148 DEFSUBR (Ferase_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2149 DEFSUBR (Frecord_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2150 DEFSUBR (Fset_buffer_major_mode);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2151 DEFSUBR (Fcurrent_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2152 DEFSUBR (Fset_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2153 DEFSUBR (Fbarf_if_buffer_read_only);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2154 DEFSUBR (Fbury_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2155 DEFSUBR (Fkill_all_local_variables);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2156 #ifdef MEMORY_USAGE_STATS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2157 DEFSUBR (Fbuffer_memory_usage);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2158 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2159
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2160 DEFERROR (Qprotected_field, "Attempt to modify a protected field",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2161 Qinvalid_change);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2162 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2163
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2164 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2165 reinit_vars_of_buffer (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2166 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2167 conversion_in_dynarr_list = Dynarr_new2 (Bufbyte_dynarr_dynarr,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2168 Bufbyte_dynarr *);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2169 conversion_out_dynarr_list = Dynarr_new2 (Extbyte_dynarr_dynarr,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2170 Extbyte_dynarr *);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2171
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2172 staticpro_nodump (&Vbuffer_alist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2173 Vbuffer_alist = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2174 current_buffer = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2175 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2176
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2177 /* initialize the buffer routines */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2178 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2179 vars_of_buffer (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2180 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2181 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2182 reinit_vars_of_buffer ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2183
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2184 staticpro (&QSFundamental);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2185 staticpro (&QSscratch);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2186
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2187 QSFundamental = build_string ("Fundamental");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2188 QSscratch = build_string (DEFER_GETTEXT ("*scratch*"));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2189
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2190 DEFVAR_LISP ("change-major-mode-hook", &Vchange_major_mode_hook /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2191 List of hooks to be run before killing local variables in a buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2192 This should be used by any mode that temporarily alters the contents or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2193 the read-only state of the buffer. See also `kill-all-local-variables'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2194 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2195 Vchange_major_mode_hook = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2196
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2197 DEFVAR_BOOL ("find-file-compare-truenames", &find_file_compare_truenames /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2198 If this is true, then the `find-file' command will check the truenames
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2199 of all visited files when deciding whether a given file is already in
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2200 a buffer, instead of just `buffer-file-name'. This means that if you
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2201 attempt to visit another file which is a symbolic link to a file which
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2202 is already in a buffer, the existing buffer will be found instead of a
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2203 newly-created one. This works if any component of the pathname
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2204 (including a non-terminal component) is a symbolic link as well, but
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2205 doesn't work with hard links (nothing does).
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2206
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2207 See also the variable `find-file-use-truenames'.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2208 */ );
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
2209 #if defined(CYGWIN) || defined(WIN32_NATIVE)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
2210 find_file_compare_truenames = 1;
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
2211 #else
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2212 find_file_compare_truenames = 0;
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
2213 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2214
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2215 DEFVAR_BOOL ("find-file-use-truenames", &find_file_use_truenames /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2216 If this is true, then a buffer's visited file-name will always be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2217 chased back to the real file; it will never be a symbolic link, and there
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2218 will never be a symbolic link anywhere in its directory path.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2219 That is, the buffer-file-name and buffer-file-truename will be equal.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2220 This doesn't work with hard links.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2221
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2222 See also the variable `find-file-compare-truenames'.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2223 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2224 find_file_use_truenames = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2225
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2226 DEFVAR_LISP ("before-change-functions", &Vbefore_change_functions /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2227 List of functions to call before each text change.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2228 Two arguments are passed to each function: the positions of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2229 the beginning and end of the range of old text to be changed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2230 \(For an insertion, the beginning and end are at the same place.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2231 No information is given about the length of the text after the change.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2232
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2233 Buffer changes made while executing the `before-change-functions'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2234 don't call any before-change or after-change functions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2235 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2236 Vbefore_change_functions = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2237
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2238 /* FSF Emacs has the following additional doc at the end of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2239 before-change-functions and after-change-functions:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2240
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2241 That's because these variables are temporarily set to nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2242 As a result, a hook function cannot straightforwardly alter the value of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2243 these variables. See the Emacs Lisp manual for a way of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2244 accomplishing an equivalent result by using other variables.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2245
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2246 But this doesn't apply under XEmacs because things are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2247 handled better. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2248
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2249 DEFVAR_LISP ("after-change-functions", &Vafter_change_functions /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2250 List of functions to call after each text change.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2251 Three arguments are passed to each function: the positions of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2252 the beginning and end of the range of changed text,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2253 and the length of the pre-change text replaced by that range.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2254 \(For an insertion, the pre-change length is zero;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2255 for a deletion, that length is the number of characters deleted,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2256 and the post-change beginning and end are at the same place.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2257
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2258 Buffer changes made while executing `after-change-functions'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2259 don't call any before-change or after-change functions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2260 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2261 Vafter_change_functions = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2262
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2263 DEFVAR_LISP ("before-change-function", &Vbefore_change_function /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2264
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2265 */ ); /* obsoleteness will be documented */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2266 Vbefore_change_function = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2267
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2268 DEFVAR_LISP ("after-change-function", &Vafter_change_function /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2269
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2270 */ ); /* obsoleteness will be documented */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2271 Vafter_change_function = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2272
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2273 DEFVAR_LISP ("first-change-hook", &Vfirst_change_hook /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2274 A list of functions to call before changing a buffer which is unmodified.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2275 The functions are run using the `run-hooks' function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2276 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2277 Vfirst_change_hook = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2278
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2279 #if 0 /* FSFmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2280 xxDEFVAR_LISP ("transient-mark-mode", &Vtransient_mark_mode /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2281 *Non-nil means deactivate the mark when the buffer contents change.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2282 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2283 Vtransient_mark_mode = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2284 #endif /* FSFmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2285
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2286 DEFVAR_INT ("undo-threshold", &undo_threshold /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2287 Keep no more undo information once it exceeds this size.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2288 This threshold is applied when garbage collection happens.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2289 The size is counted as the number of bytes occupied,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2290 which includes both saved text and other data.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2291 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2292 undo_threshold = 20000;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2293
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2294 DEFVAR_INT ("undo-high-threshold", &undo_high_threshold /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2295 Don't keep more than this much size of undo information.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2296 A command which pushes past this size is itself forgotten.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2297 This threshold is applied when garbage collection happens.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2298 The size is counted as the number of bytes occupied,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2299 which includes both saved text and other data.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2300 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2301 undo_high_threshold = 30000;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2302
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2303 DEFVAR_LISP ("inhibit-read-only", &Vinhibit_read_only /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2304 *Non-nil means disregard read-only status of buffers or characters.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2305 If the value is t, disregard `buffer-read-only' and all `read-only'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2306 text properties. If the value is a list, disregard `buffer-read-only'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2307 and disregard a `read-only' extent property or text property if the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2308 property value is a member of the list.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2309 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2310 Vinhibit_read_only = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2311
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2312 DEFVAR_LISP ("kill-buffer-query-functions", &Vkill_buffer_query_functions /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2313 List of functions called with no args to query before killing a buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2314 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2315 Vkill_buffer_query_functions = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2316
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2317 DEFVAR_BOOL ("delete-auto-save-files", &delete_auto_save_files /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2318 *Non-nil means delete auto-save file when a buffer is saved or killed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2319 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2320 delete_auto_save_files = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2321 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2322
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2323 /* The docstrings for DEFVAR_* are recorded externally by make-docfile. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2324
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2325 /* Renamed from DEFVAR_PER_BUFFER because FSFmacs D_P_B takes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2326 a bogus extra arg, which confuses an otherwise identical make-docfile.c */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2327 #define DEFVAR_BUFFER_LOCAL_1(lname, field_name, forward_type, magicfun) do { \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2328 static const struct symbol_value_forward I_hate_C = \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2329 { /* struct symbol_value_forward */ \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2330 { /* struct symbol_value_magic */ \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2331 { /* struct lcrecord_header */ \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2332 { /* struct lrecord_header */ \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2333 lrecord_type_symbol_value_forward, /* lrecord_type_index */ \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2334 1, /* mark bit */ \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2335 1, /* c_readonly bit */ \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2336 1 /* lisp_readonly bit */ \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2337 }, \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2338 0, /* next */ \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2339 0, /* uid */ \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2340 0 /* free */ \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2341 }, \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2342 &(buffer_local_flags.field_name), \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2343 forward_type \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2344 }, \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2345 magicfun \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2346 }; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2347 \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2348 { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2349 int offset = ((char *)symbol_value_forward_forward (&I_hate_C) - \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2350 (char *)&buffer_local_flags); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2351 defvar_magic (lname, &I_hate_C); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2352 \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2353 *((Lisp_Object *)(offset + (char *)XBUFFER (Vbuffer_local_symbols))) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2354 = intern (lname); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2355 } \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2356 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2357
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2358 #define DEFVAR_BUFFER_LOCAL_MAGIC(lname, field_name, magicfun) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2359 DEFVAR_BUFFER_LOCAL_1 (lname, field_name, \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2360 SYMVAL_CURRENT_BUFFER_FORWARD, magicfun)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2361 #define DEFVAR_BUFFER_LOCAL(lname, field_name) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2362 DEFVAR_BUFFER_LOCAL_MAGIC (lname, field_name, 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2363 #define DEFVAR_CONST_BUFFER_LOCAL_MAGIC(lname, field_name, magicfun) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2364 DEFVAR_BUFFER_LOCAL_1 (lname, field_name, \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2365 SYMVAL_CONST_CURRENT_BUFFER_FORWARD, magicfun)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2366 #define DEFVAR_CONST_BUFFER_LOCAL(lname, field_name) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2367 DEFVAR_CONST_BUFFER_LOCAL_MAGIC (lname, field_name, 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2368
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2369 #define DEFVAR_BUFFER_DEFAULTS_MAGIC(lname, field_name, magicfun) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2370 DEFVAR_SYMVAL_FWD (lname, &(buffer_local_flags.field_name), \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2371 SYMVAL_DEFAULT_BUFFER_FORWARD, magicfun)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2372 #define DEFVAR_BUFFER_DEFAULTS(lname, field_name) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2373 DEFVAR_BUFFER_DEFAULTS_MAGIC (lname, field_name, 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2374
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2375 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2376 nuke_all_buffer_slots (struct buffer *b, Lisp_Object zap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2377 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2378 zero_lcrecord (b);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2379
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2380 b->extent_info = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2381 b->indirect_children = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2382 b->own_text.line_number_cache = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2383
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2384 #define MARKED_SLOT(x) b->x = zap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2385 #include "bufslots.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2386 #undef MARKED_SLOT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2387 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2388
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2389 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2390 common_init_complex_vars_of_buffer (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2391 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2392 /* Make sure all markable slots in buffer_defaults
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2393 are initialized reasonably, so mark_buffer won't choke. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2394 struct buffer *defs = alloc_lcrecord_type (struct buffer, &lrecord_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2395 struct buffer *syms = alloc_lcrecord_type (struct buffer, &lrecord_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2396
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2397 staticpro_nodump (&Vbuffer_defaults);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2398 staticpro_nodump (&Vbuffer_local_symbols);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2399 XSETBUFFER (Vbuffer_defaults, defs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2400 XSETBUFFER (Vbuffer_local_symbols, syms);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2401
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2402 nuke_all_buffer_slots (syms, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2403 nuke_all_buffer_slots (defs, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2404 defs->text = &defs->own_text;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2405 syms->text = &syms->own_text;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2406
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2407 /* Set up the non-nil default values of various buffer slots.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2408 Must do these before making the first buffer. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2409 defs->major_mode = Qfundamental_mode;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2410 defs->mode_name = QSFundamental;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2411 defs->abbrev_table = Qnil; /* real default setup by Lisp code */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2412
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
2413 defs->case_table = Vstandard_case_table;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2414 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2415 defs->category_table = Vstandard_category_table;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2416 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2417 defs->syntax_table = Vstandard_syntax_table;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2418 defs->mirror_syntax_table =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2419 XCHAR_TABLE (Vstandard_syntax_table)->mirror_table;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2420 defs->modeline_format = build_string ("%-"); /* reset in loaddefs.el */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2421 defs->case_fold_search = Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2422 defs->selective_display_ellipses = Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2423 defs->tab_width = make_int (8);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2424 defs->ctl_arrow = Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2425 defs->fill_column = make_int (70);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2426 defs->left_margin = Qzero;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2427 defs->saved_size = Qzero; /* lisp code wants int-or-nil */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2428 defs->modtime = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2429 defs->auto_save_modified = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2430 defs->auto_save_failure_time = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2431 defs->invisibility_spec = Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2432
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2433 defs->indirect_children = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2434 syms->indirect_children = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2435
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2436 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2437 /* 0 means var is always local. Default used only at creation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2438 * -1 means var is always local. Default used only at reset and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2439 * creation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2440 * -2 means there's no lisp variable corresponding to this slot
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2441 * and the default is only used at creation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2442 * -3 means no Lisp variable. Default used only at reset and creation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2443 * >0 is mask. Var is local if ((buffer->local_var_flags & mask) != 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2444 * Otherwise default is used.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2445 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2446 Lisp_Object always_local_no_default = make_int (0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2447 Lisp_Object always_local_resettable = make_int (-1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2448 Lisp_Object resettable = make_int (-3);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2449
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2450 /* Assign the local-flags to the slots that have default values.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2451 The local flag is a bit that is used in the buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2452 to say that it has its own local value for the slot.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2453 The local flag bits are in the local_var_flags slot of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2454 buffer. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2455
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2456 nuke_all_buffer_slots (&buffer_local_flags, make_int (-2));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2457 buffer_local_flags.filename = always_local_no_default;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2458 buffer_local_flags.directory = always_local_no_default;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2459 buffer_local_flags.backed_up = always_local_no_default;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2460 buffer_local_flags.saved_size = always_local_no_default;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2461 buffer_local_flags.auto_save_file_name = always_local_no_default;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2462 buffer_local_flags.read_only = always_local_no_default;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2463
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2464 buffer_local_flags.major_mode = always_local_resettable;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2465 buffer_local_flags.mode_name = always_local_resettable;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2466 buffer_local_flags.undo_list = always_local_no_default;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2467 #if 0 /* FSFmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2468 buffer_local_flags.mark_active = always_local_resettable;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2469 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2470 buffer_local_flags.point_before_scroll = always_local_resettable;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2471 buffer_local_flags.file_truename = always_local_no_default;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2472 buffer_local_flags.invisibility_spec = always_local_resettable;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2473 buffer_local_flags.file_format = always_local_resettable;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2474 buffer_local_flags.generated_modeline_string = always_local_no_default;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2475
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2476 buffer_local_flags.keymap = resettable;
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
2477 buffer_local_flags.case_table = resettable;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2478 buffer_local_flags.syntax_table = resettable;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2479 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2480 buffer_local_flags.category_table = resettable;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2481 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2482
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2483 buffer_local_flags.modeline_format = make_int (1<<0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2484 buffer_local_flags.abbrev_mode = make_int (1<<1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2485 buffer_local_flags.overwrite_mode = make_int (1<<2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2486 buffer_local_flags.case_fold_search = make_int (1<<3);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2487 buffer_local_flags.auto_fill_function = make_int (1<<4);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2488 buffer_local_flags.selective_display = make_int (1<<5);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2489 buffer_local_flags.selective_display_ellipses = make_int (1<<6);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2490 buffer_local_flags.tab_width = make_int (1<<7);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2491 buffer_local_flags.truncate_lines = make_int (1<<8);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2492 buffer_local_flags.ctl_arrow = make_int (1<<9);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2493 buffer_local_flags.fill_column = make_int (1<<10);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2494 buffer_local_flags.left_margin = make_int (1<<11);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2495 buffer_local_flags.abbrev_table = make_int (1<<12);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2496 #ifdef REGION_CACHE_NEEDS_WORK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2497 buffer_local_flags.cache_long_line_scans = make_int (1<<13);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2498 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2499 #ifdef FILE_CODING
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2500 buffer_local_flags.buffer_file_coding_system = make_int (1<<14);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2501 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2502
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2503 /* #### Warning: 1<<31 is the largest number currently allowable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2504 due to the XINT() handling of this value. With some
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2505 rearrangement you can get 3 more bits. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2506 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2507 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2508
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2509 #define BUFFER_SLOTS_SIZE (offsetof (struct buffer, BUFFER_SLOTS_LAST_NAME) - offsetof (struct buffer, BUFFER_SLOTS_FIRST_NAME) + sizeof (Lisp_Object))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2510 #define BUFFER_SLOTS_COUNT (BUFFER_SLOTS_SIZE / sizeof (Lisp_Object))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2511
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2512 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2513 reinit_complex_vars_of_buffer (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2514 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2515 struct buffer *defs, *syms;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2516
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2517 common_init_complex_vars_of_buffer ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2518
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2519 defs = XBUFFER (Vbuffer_defaults);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2520 syms = XBUFFER (Vbuffer_local_symbols);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2521 memcpy (&defs->BUFFER_SLOTS_FIRST_NAME,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2522 buffer_defaults_saved_slots,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2523 BUFFER_SLOTS_SIZE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2524 memcpy (&syms->BUFFER_SLOTS_FIRST_NAME,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2525 buffer_local_symbols_saved_slots,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2526 BUFFER_SLOTS_SIZE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2527 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2528
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2529
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2530 static const struct lrecord_description buffer_slots_description_1[] = {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2531 { XD_LISP_OBJECT_ARRAY, 0, BUFFER_SLOTS_COUNT },
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2532 { XD_END }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2533 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2534
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2535 static const struct struct_description buffer_slots_description = {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2536 BUFFER_SLOTS_SIZE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2537 buffer_slots_description_1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2538 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2539
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2540 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2541 complex_vars_of_buffer (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2542 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2543 struct buffer *defs, *syms;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2544
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2545 common_init_complex_vars_of_buffer ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2546
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2547 defs = XBUFFER (Vbuffer_defaults);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2548 syms = XBUFFER (Vbuffer_local_symbols);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2549 buffer_defaults_saved_slots = &defs->BUFFER_SLOTS_FIRST_NAME;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2550 buffer_local_symbols_saved_slots = &syms->BUFFER_SLOTS_FIRST_NAME;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2551 dumpstruct (&buffer_defaults_saved_slots, &buffer_slots_description);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2552 dumpstruct (&buffer_local_symbols_saved_slots, &buffer_slots_description);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
2553
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2554 DEFVAR_BUFFER_DEFAULTS ("default-modeline-format", modeline_format /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2555 Default value of `modeline-format' for buffers that don't override it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2556 This is the same as (default-value 'modeline-format).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2557 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2558
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2559 DEFVAR_BUFFER_DEFAULTS ("default-abbrev-mode", abbrev_mode /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2560 Default value of `abbrev-mode' for buffers that do not override it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2561 This is the same as (default-value 'abbrev-mode).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2562 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2563
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2564 DEFVAR_BUFFER_DEFAULTS ("default-ctl-arrow", ctl_arrow /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2565 Default value of `ctl-arrow' for buffers that do not override it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2566 This is the same as (default-value 'ctl-arrow).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2567 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2568
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2569 #if 0 /* #### make this a specifier! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2570 DEFVAR_BUFFER_DEFAULTS ("default-display-direction", display_direction /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2571 Default display-direction for buffers that do not override it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2572 This is the same as (default-value 'display-direction).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2573 Note: This is not yet implemented.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2574 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2575 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2576
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2577 DEFVAR_BUFFER_DEFAULTS ("default-truncate-lines", truncate_lines /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2578 Default value of `truncate-lines' for buffers that do not override it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2579 This is the same as (default-value 'truncate-lines).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2580 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2581
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2582 DEFVAR_BUFFER_DEFAULTS ("default-fill-column", fill_column /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2583 Default value of `fill-column' for buffers that do not override it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2584 This is the same as (default-value 'fill-column).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2585 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2586
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2587 DEFVAR_BUFFER_DEFAULTS ("default-left-margin", left_margin /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2588 Default value of `left-margin' for buffers that do not override it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2589 This is the same as (default-value 'left-margin).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2590 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2591
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2592 DEFVAR_BUFFER_DEFAULTS ("default-tab-width", tab_width /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2593 Default value of `tab-width' for buffers that do not override it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2594 This is the same as (default-value 'tab-width).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2595 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2596
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2597 DEFVAR_BUFFER_DEFAULTS ("default-case-fold-search", case_fold_search /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2598 Default value of `case-fold-search' for buffers that don't override it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2599 This is the same as (default-value 'case-fold-search).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2600 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2601
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2602 DEFVAR_BUFFER_LOCAL ("modeline-format", modeline_format /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2603 Template for displaying modeline for current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2604 Each buffer has its own value of this variable.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2605 Value may be a string, symbol, glyph, generic specifier, list or cons cell.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2606 For a symbol, its value is processed (but it is ignored if t or nil).
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2607 A string appearing directly as the value of a symbol is processed verbatim
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2608 in that the %-constructs below are not recognized.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2609 For a glyph, it is inserted as is.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2610 For a generic specifier (i.e. a specifier of type `generic'), its instance
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2611 is computed in the current window using the equivalent of `specifier-instance'
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2612 and the value is processed.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2613 For a list whose car is a symbol, the symbol's value is taken,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2614 and if that is non-nil, the cadr of the list is processed recursively.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2615 Otherwise, the caddr of the list (if there is one) is processed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2616 For a list whose car is a string or list, each element is processed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2617 recursively and the results are effectively concatenated.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2618 For a list whose car is an integer, the cdr of the list is processed
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2619 and padded (if the number is positive) or truncated (if negative)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2620 to the width specified by that number.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2621 For a list whose car is an extent, the cdr of the list is processed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2622 normally but the results are displayed using the face of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2623 extent, and mouse clicks over this section are processed using the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2624 keymap of the extent. (In addition, if the extent has a help-echo
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2625 property, that string will be echoed when the mouse moves over this
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2626 section.) If extents are nested, all keymaps are properly consulted
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2627 when processing mouse clicks, but multiple faces are not correctly
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2628 merged (only the first face is used), and lists of faces are not
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2629 correctly handled. See `generated-modeline-string' for more information.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2630 A string is printed verbatim in the modeline except for %-constructs:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2631 (%-constructs are processed when the string is the entire modeline-format
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2632 or when it is found in a cons-cell or a list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2633 %b -- print buffer name. %c -- print the current column number.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2634 %f -- print visited file name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2635 %* -- print %, * or hyphen. %+ -- print *, % or hyphen.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2636 % means buffer is read-only and * means it is modified.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2637 For a modified read-only buffer, %* gives % and %+ gives *.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2638 %s -- print process status. %l -- print the current line number.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2639 %S -- print name of selected frame (only meaningful under X Windows).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2640 %p -- print percent of buffer above top of window, or Top, Bot or All.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2641 %P -- print percent of buffer above bottom of window, perhaps plus Top,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2642 or print Bottom or All.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2643 %n -- print Narrow if appropriate.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2644 %C -- under XEmacs/mule, print the mnemonic for `buffer-file-coding-system'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2645 %[ -- print one [ for each recursive editing level. %] similar.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2646 %% -- print %. %- -- print infinitely many dashes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2647 Decimal digits after the % specify field width to which to pad.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2648 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2649
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2650 DEFVAR_BUFFER_DEFAULTS ("default-major-mode", major_mode /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2651 *Major mode for new buffers. Defaults to `fundamental-mode'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2652 nil here means use current buffer's major mode.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2653 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2654
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2655 DEFVAR_BUFFER_DEFAULTS ("fundamental-mode-abbrev-table", abbrev_table /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2656 The abbrev table of mode-specific abbrevs for Fundamental Mode.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2657 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2658
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2659 DEFVAR_BUFFER_LOCAL ("major-mode", major_mode /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2660 Symbol for current buffer's major mode.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2661 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2662
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2663 DEFVAR_BUFFER_LOCAL ("mode-name", mode_name /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2664 Pretty name of current buffer's major mode (a string).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2665 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2666
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2667 DEFVAR_BUFFER_LOCAL ("abbrev-mode", abbrev_mode /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2668 Non-nil turns on automatic expansion of abbrevs as they are inserted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2669 Automatically becomes buffer-local when set in any fashion.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2670 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2671
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2672 DEFVAR_BUFFER_LOCAL ("case-fold-search", case_fold_search /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2673 *Non-nil if searches should ignore case.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2674 Automatically becomes buffer-local when set in any fashion.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2675
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2676 BUG: Under XEmacs/Mule, translations to or from non-ASCII characters
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2677 (this includes chars in the range 128 - 255) are ignored by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2678 the string/buffer-searching routines. Thus, `case-fold-search'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2679 will not correctly conflate a-umlaut and A-umlaut even if the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2680 case tables call for this.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2681 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2682
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2683 DEFVAR_BUFFER_LOCAL ("fill-column", fill_column /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2684 *Column beyond which automatic line-wrapping should happen.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2685 Automatically becomes buffer-local when set in any fashion.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2686 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2687
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2688 DEFVAR_BUFFER_LOCAL ("left-margin", left_margin /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2689 *Column for the default indent-line-function to indent to.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2690 Linefeed indents to this column in Fundamental mode.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2691 Automatically becomes buffer-local when set in any fashion.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2692 Do not confuse this with the specifier `left-margin-width';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2693 that controls the size of a margin that is displayed outside
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2694 of the text area.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2695 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2696
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2697 DEFVAR_BUFFER_LOCAL_MAGIC ("tab-width", tab_width /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2698 *Distance between tab stops (for display of tab characters), in columns.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2699 Automatically becomes buffer-local when set in any fashion.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2700 */ , redisplay_variable_changed);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2701
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2702 DEFVAR_BUFFER_LOCAL_MAGIC ("ctl-arrow", ctl_arrow /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2703 *Non-nil means display control chars with uparrow.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2704 Nil means use backslash and octal digits.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2705 An integer means characters >= ctl-arrow are assumed to be printable, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2706 will be displayed as a single glyph.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2707 Any other value is the same as 160 - the code SPC with the high bit on.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2708
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2709 The interpretation of this variable is likely to change in the future.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2710
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2711 Automatically becomes buffer-local when set in any fashion.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2712 This variable does not apply to characters whose display is specified
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2713 in the current display table (if there is one).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2714 */ , redisplay_variable_changed);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2715
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2716 #if 0 /* #### Make this a specifier! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2717 xxDEFVAR_BUFFER_LOCAL ("display-direction", display_direction /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2718 *Non-nil means lines in the buffer are displayed right to left.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2719 Nil means left to right. (Not yet implemented.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2720 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2721 #endif /* Not yet implemented */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2722
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2723 DEFVAR_BUFFER_LOCAL_MAGIC ("truncate-lines", truncate_lines /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2724 *Non-nil means do not display continuation lines;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2725 give each line of text one frame line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2726 Automatically becomes buffer-local when set in any fashion.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2727
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2728 Note that this is overridden by the variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2729 `truncate-partial-width-windows' if that variable is non-nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2730 and this buffer is not full-frame width.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2731 */ , redisplay_variable_changed);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2732
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2733 DEFVAR_BUFFER_LOCAL ("default-directory", directory /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2734 Name of default directory of current buffer. Should end with slash.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2735 Each buffer has its own value of this variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2736 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2737
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2738 #ifdef FILE_CODING
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2739 DEFVAR_BUFFER_DEFAULTS ("default-buffer-file-coding-system", buffer_file_coding_system /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2740 Default value of `buffer-file-coding-system' for buffers that do not override it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2741 This is the same as (default-value 'buffer-file-coding-system).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2742 This value is used both for buffers without associated files and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2743 for buffers whose files do not have any apparent coding system.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2744 See `buffer-file-coding-system'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2745 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2746
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2747 DEFVAR_BUFFER_LOCAL ("buffer-file-coding-system", buffer_file_coding_system /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2748 *Current coding system for the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2749 When the buffer is written out into a file, this coding system will be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2750 used for the encoding. Automatically buffer-local when set in any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2751 fashion. This is normally set automatically when a file is loaded in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2752 based on the determined coding system of the file (assuming that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2753 `buffer-file-coding-system-for-read' is set to `undecided', which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2754 calls for automatic determination of the file's coding system).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2755 Normally the modeline indicates the current file coding system using
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2756 its mnemonic abbreviation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2757
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2758 The default value for this variable (which is normally used for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2759 buffers without associated files) is also used when automatic
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2760 detection of a file's encoding is called for and there was no
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2761 discernible encoding in the file (i.e. it was entirely or almost
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2762 entirely ASCII). The default value should generally *not* be set to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2763 nil (equivalent to `no-conversion'), because if extended characters
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2764 are ever inserted into the buffer, they will be lost when the file is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2765 written out. A good choice is `iso-2022-8' (the simple ISO 2022 8-bit
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2766 encoding), which will write out ASCII and Latin-1 characters in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2767 standard (and highly portable) fashion and use standard escape
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2768 sequences for other charsets. Another reasonable choice is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2769 `escape-quoted', which is equivalent to `iso-2022-8' but prefixes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2770 certain control characters with ESC to make sure they are not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2771 interpreted as escape sequences when read in. This latter coding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2772 system results in more "correct" output in the presence of control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2773 characters in the buffer, in the sense that when read in again using
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2774 the same coding system, the result will virtually always match the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2775 original contents of the buffer, which is not the case with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2776 `iso-2022-8'; but the output is less portable when dealing with binary
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2777 data -- there may be stray ESC characters when the file is read by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2778 another program.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2779
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2780 `buffer-file-coding-system' does *not* control the coding system used when
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2781 a file is read in. Use the variables `buffer-file-coding-system-for-read'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2782 and `buffer-file-coding-system-alist' for that. From a Lisp program, if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2783 you wish to unilaterally specify the coding system used for one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2784 particular operation, you should bind the variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2785 `coding-system-for-read' rather than changing the other two
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2786 variables just mentioned, which are intended to be used for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2787 global environment specification.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2788 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2789 #endif /* FILE_CODING */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2790
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2791 DEFVAR_BUFFER_LOCAL ("auto-fill-function", auto_fill_function /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2792 Function called (if non-nil) to perform auto-fill.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2793 It is called after self-inserting a space at a column beyond `fill-column'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2794 Each buffer has its own value of this variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2795 NOTE: This variable is not an ordinary hook;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2796 It may not be a list of functions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2797 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2798
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2799 DEFVAR_BUFFER_LOCAL ("buffer-file-name", filename /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2800 Name of file visited in current buffer, or nil if not visiting a file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2801 Each buffer has its own value of this variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2802 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2803
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2804 #if 0 /* FSFmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2805 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2806 Abbreviated truename of file visited in current buffer, or nil if none.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2807 The truename of a file is calculated by `file-truename'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2808 and then abbreviated with `abbreviate-file-name'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2809 Each buffer has its own value of this variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2810 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2811 #endif /* FSFmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2812
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2813 DEFVAR_BUFFER_LOCAL ("buffer-file-truename", file_truename /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2814 The real name of the file visited in the current buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2815 or nil if not visiting a file. This is the result of passing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2816 buffer-file-name to the `file-truename' function. Every buffer has
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2817 its own value of this variable. This variable is automatically
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2818 maintained by the functions that change the file name associated
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2819 with a buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2820 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2821
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2822 DEFVAR_BUFFER_LOCAL ("buffer-auto-save-file-name", auto_save_file_name /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2823 Name of file for auto-saving current buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2824 or nil if buffer should not be auto-saved.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2825 Each buffer has its own value of this variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2826 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2827
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2828 DEFVAR_BUFFER_LOCAL ("buffer-read-only", read_only /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2829 Non-nil if this buffer is read-only.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2830 Each buffer has its own value of this variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2831 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2832
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2833 DEFVAR_BUFFER_LOCAL ("buffer-backed-up", backed_up /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2834 Non-nil if this buffer's file has been backed up.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2835 Backing up is done before the first time the file is saved.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2836 Each buffer has its own value of this variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2837 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2838
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2839 DEFVAR_BUFFER_LOCAL ("buffer-saved-size", saved_size /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2840 Length of current buffer when last read in, saved or auto-saved.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2841 0 initially.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2842 Each buffer has its own value of this variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2843 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2844
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2845 DEFVAR_BUFFER_LOCAL_MAGIC ("selective-display", selective_display /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2846 Non-nil enables selective display:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2847 Integer N as value means display only lines
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2848 that start with less than n columns of space.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2849 A value of t means, after a ^M, all the rest of the line is invisible.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2850 Then ^M's in the file are written into files as newlines.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2851
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2852 Automatically becomes buffer-local when set in any fashion.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2853 */, redisplay_variable_changed);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2854
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2855 #ifndef old
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2856 DEFVAR_BUFFER_LOCAL_MAGIC ("selective-display-ellipses",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2857 selective_display_ellipses /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2858 t means display ... on previous line when a line is invisible.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2859 Automatically becomes buffer-local when set in any fashion.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2860 */, redisplay_variable_changed);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2861 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2862
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2863 DEFVAR_BUFFER_LOCAL ("local-abbrev-table", abbrev_table /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2864 Local (mode-specific) abbrev table of current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2865 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2866
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2867 DEFVAR_BUFFER_LOCAL ("overwrite-mode", overwrite_mode /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2868 Non-nil if self-insertion should replace existing text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2869 The value should be one of `overwrite-mode-textual',
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2870 `overwrite-mode-binary', or nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2871 If it is `overwrite-mode-textual', self-insertion still
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2872 inserts at the end of a line, and inserts when point is before a tab,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2873 until the tab is filled in.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2874 If `overwrite-mode-binary', self-insertion replaces newlines and tabs too.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2875 Automatically becomes buffer-local when set in any fashion.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2876
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2877 Normally, you shouldn't modify this variable by hand, but use the functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2878 `overwrite-mode' and `binary-overwrite-mode' instead. However, you can
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2879 customize the default value from the options menu.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2880 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2881
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2882 #if 0 /* FSFmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2883 /* Adds the following to the doc string for buffer-undo-list:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2884
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2885 An entry (nil PROPERTY VALUE BEG . END) indicates that a text property
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2886 was modified between BEG and END. PROPERTY is the property name,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2887 and VALUE is the old value.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2888 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2889 #endif /* FSFmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2890
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2891 DEFVAR_BUFFER_LOCAL ("buffer-undo-list", undo_list /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2892 List of undo entries in current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2893 Recent changes come first; older changes follow newer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2894
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2895 An entry (START . END) represents an insertion which begins at
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2896 position START and ends at position END.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2897
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2898 An entry (TEXT . POSITION) represents the deletion of the string TEXT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2899 from (abs POSITION). If POSITION is positive, point was at the front
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2900 of the text being deleted; if negative, point was at the end.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2901
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2902 An entry (t HIGH . LOW) indicates that the buffer previously had
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2903 "unmodified" status. HIGH and LOW are the high and low 16-bit portions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2904 of the visited file's modification time, as of that time. If the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2905 modification time of the most recent save is different, this entry is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2906 obsolete.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2907
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2908 An entry of the form EXTENT indicates that EXTENT was attached in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2909 the buffer. Undoing an entry of this form detaches EXTENT.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2910
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2911 An entry of the form (EXTENT START END) indicates that EXTENT was
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2912 detached from the buffer. Undoing an entry of this form attaches
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2913 EXTENT from START to END.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2914
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2915 An entry of the form POSITION indicates that point was at the buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2916 location given by the integer. Undoing an entry of this form places
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2917 point at POSITION.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2918
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2919 nil marks undo boundaries. The undo command treats the changes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2920 between two undo boundaries as a single step to be undone.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2921
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2922 If the value of the variable is t, undo information is not recorded.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2923 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2924
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2925 #if 0 /* FSFmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2926 xxDEFVAR_BUFFER_LOCAL ("mark-active", mark_active /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2927 Non-nil means the mark and region are currently active in this buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2928 Automatically local in all buffers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2929 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2930 #endif /* FSFmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2931
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2932 #ifdef REGION_CACHE_NEEDS_WORK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2933 xxDEFVAR_BUFFER_LOCAL ("cache-long-line-scans", cache_long_line_scans /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2934 Non-nil means that Emacs should use caches to handle long lines more quickly.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2935 This variable is buffer-local, in all buffers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2936
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2937 Normally, the line-motion functions work by scanning the buffer for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2938 newlines. Columnar operations (like move-to-column and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2939 compute-motion) also work by scanning the buffer, summing character
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2940 widths as they go. This works well for ordinary text, but if the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2941 buffer's lines are very long (say, more than 500 characters), these
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2942 motion functions will take longer to execute. Emacs may also take
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2943 longer to update the display.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2944
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2945 If cache-long-line-scans is non-nil, these motion functions cache the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2946 results of their scans, and consult the cache to avoid rescanning
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2947 regions of the buffer until the text is modified. The caches are most
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2948 beneficial when they prevent the most searching---that is, when the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2949 buffer contains long lines and large regions of characters with the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2950 same, fixed screen width.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2951
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2952 When cache-long-line-scans is non-nil, processing short lines will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2953 become slightly slower (because of the overhead of consulting the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2954 cache), and the caches will use memory roughly proportional to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2955 number of newlines and characters whose screen width varies.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2956
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2957 The caches require no explicit maintenance; their accuracy is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2958 maintained internally by the Emacs primitives. Enabling or disabling
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2959 the cache should not affect the behavior of any of the motion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2960 functions; it should only affect their performance.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2961 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2962 #endif /* REGION_CACHE_NEEDS_WORK */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2963
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2964 DEFVAR_BUFFER_LOCAL ("point-before-scroll", point_before_scroll /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2965 Value of point before the last series of scroll operations, or nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2966 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2967
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2968 DEFVAR_BUFFER_LOCAL ("buffer-file-format", file_format /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2969 List of formats to use when saving this buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2970 Formats are defined by `format-alist'. This variable is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2971 set when a file is visited. Automatically local in all buffers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2972 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2973
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2974 DEFVAR_BUFFER_LOCAL_MAGIC ("buffer-invisibility-spec", invisibility_spec /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2975 Invisibility spec of this buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2976 The default is t, which means that text is invisible
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2977 if it has (or is covered by an extent with) a non-nil `invisible' property.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2978 If the value is a list, a text character is invisible if its `invisible'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2979 property is an element in that list.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2980 If an element is a cons cell of the form (PROPERTY . ELLIPSIS),
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
2981 then characters with property value PROPERTY are invisible,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2982 and they have an ellipsis as well if ELLIPSIS is non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2983 Note that the actual characters used for the ellipsis are controllable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2984 using `invisible-text-glyph', and default to "...".
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2985 */, redisplay_variable_changed);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2986
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2987 DEFVAR_CONST_BUFFER_LOCAL ("generated-modeline-string",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2988 generated_modeline_string /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2989 String of characters in this buffer's modeline as of the last redisplay.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2990 Each time the modeline is recomputed, the resulting characters are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2991 stored in this string, which is resized as necessary. You may not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2992 set this variable, and modifying this string will not change the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2993 modeline; you have to change `modeline-format' if you want that.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2994
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2995 For each extent in `modeline-format' that is encountered when
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2996 processing the modeline, a corresponding extent is placed in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2997 `generated-modeline-string' and covers the text over which the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2998 extent in `modeline-format' applies. The extent in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2999 `generated-modeline-string' is made a child of the extent in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3000 `modeline-format', which means that it inherits all properties from
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3001 that extent. Note that the extents in `generated-modeline-string'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3002 are managed automatically. You should not explicitly put any extents
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3003 in `generated-modeline-string'; if you do, they will disappear the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3004 next time the modeline is processed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3005
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3006 For extents in `modeline-format', the following properties are currently
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3007 handled:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3008
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3009 `face'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3010 Affects the face of the modeline text. Currently, faces do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3011 not merge properly; only the most recently encountered face
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3012 is used. This is a bug.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3013
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3014 `keymap'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3015 Affects the disposition of button events over the modeline
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3016 text. Multiple applicable keymaps *are* handled properly,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3017 and `modeline-map' still applies to any events that don't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3018 have bindings in extent-specific keymaps.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3019
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3020 `help-echo'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3021 If a string, causes the string to be displayed when the mouse
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3022 moves over the text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3023 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3024
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3025 /* Check for DEFVAR_BUFFER_LOCAL without initializing the corresponding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3026 slot of buffer_local_flags and vice-versa. Must be done after all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3027 DEFVAR_BUFFER_LOCAL() calls. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3028 #define MARKED_SLOT(slot) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3029 if ((XINT (buffer_local_flags.slot) != -2 && \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3030 XINT (buffer_local_flags.slot) != -3) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3031 != !(NILP (XBUFFER (Vbuffer_local_symbols)->slot))) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3032 abort ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3033 #include "bufslots.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3034 #undef MARKED_SLOT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3035
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3036 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3037 Lisp_Object scratch = Fget_buffer_create (QSscratch);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3038 Fset_buffer (scratch);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3039 /* Want no undo records for *scratch* until after Emacs is dumped */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3040 Fbuffer_disable_undo (scratch);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3041 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3042 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3043
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3044 #ifndef WIN32_NATIVE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3045 /* Is PWD another name for `.' ? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3046 static int
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
3047 directory_is_current_directory (Extbyte *pwd)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3048 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3049 Bufbyte *pwd_internal;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
3050 Bytecount pwd_internal_len;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3051 struct stat dotstat, pwdstat;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3052
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
3053 TO_INTERNAL_FORMAT (DATA, (pwd, strlen ((char *)pwd) + 1),
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
3054 ALLOCA, (pwd_internal, pwd_internal_len),
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
3055 Qfile_name);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3056
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3057 return (IS_DIRECTORY_SEP (*pwd_internal)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3058 && xemacs_stat ((char *) pwd_internal, &pwdstat) == 0
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3059 && xemacs_stat (".", &dotstat) == 0
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3060 && dotstat.st_ino == pwdstat.st_ino
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3061 && dotstat.st_dev == pwdstat.st_dev
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
3062 && pwd_internal_len < MAXPATHLEN);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3063 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3064 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3065
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3066 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3067 init_initial_directory (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3068 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3069 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3070
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3071 #ifndef WIN32_NATIVE
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
3072 Extbyte *pwd;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3073 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3074
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3075 initial_directory[0] = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3076
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3077 /* If PWD is accurate, use it instead of calling getcwd. This is faster
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3078 when PWD is right, and may avoid a fatal error. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3079 #ifndef WIN32_NATIVE
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
3080 if ((pwd = (Extbyte *) getenv ("PWD")) != NULL
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3081 && directory_is_current_directory (pwd))
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
3082 strcpy (initial_directory, (char *) pwd);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3083 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3084 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3085 if (getcwd (initial_directory, MAXPATHLEN) == NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3086 fatal ("`getcwd' failed: %s\n", strerror (errno));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3087
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3088 /* Make sure pwd is DIRECTORY_SEP-terminated.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3089 Maybe this should really use some standard subroutine
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3090 whose definition is filename syntax dependent. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3091 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3092 int len = strlen (initial_directory);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3093
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3094 if (! IS_DIRECTORY_SEP (initial_directory[len - 1]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3095 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3096 initial_directory[len] = DIRECTORY_SEP;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3097 initial_directory[len + 1] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3098 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3099 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3100
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3101 #ifdef CORRECT_DIR_SEPS
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3102 CORRECT_DIR_SEPS (initial_directory);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3103 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3104 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3105
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3106 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3107 init_buffer (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3108 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3109 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3110
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3111 Fset_buffer (Fget_buffer_create (QSscratch));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3112
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3113 current_buffer->directory =
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
3114 build_ext_string (initial_directory, Qfile_name);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3115
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3116 #if 0 /* FSFmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3117 /* #### is this correct? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3118 temp = get_minibuffer (0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3119 XBUFFER (temp)->directory = current_buffer->directory;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3120 #endif /* FSFmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3121 }