annotate src/buffer.c @ 278:90d73dddcdc4 r21-0b37

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