Mercurial > emacs
comparison src/buffer.c @ 91041:bdb3fe0ba9fa
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 866-879)
- Merge multi-tty branch
- Update from CVS
- Merge from emacs--rel--22
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-257
| author | Miles Bader <miles@gnu.org> |
|---|---|
| date | Thu, 11 Oct 2007 16:22:07 +0000 |
| parents | 539530fa389c 5039706521c9 |
| children | a0e466c4d599 |
comparison
equal
deleted
inserted
replaced
| 91040:14c4a6aac623 | 91041:bdb3fe0ba9fa |
|---|---|
| 214 in the proper order for that frame: the buffers in FRAME's `buffer-list' | 214 in the proper order for that frame: the buffers in FRAME's `buffer-list' |
| 215 frame parameter come first, followed by the rest of the buffers. */) | 215 frame parameter come first, followed by the rest of the buffers. */) |
| 216 (frame) | 216 (frame) |
| 217 Lisp_Object frame; | 217 Lisp_Object frame; |
| 218 { | 218 { |
| 219 Lisp_Object framelist, general; | 219 Lisp_Object general; |
| 220 general = Fmapcar (Qcdr, Vbuffer_alist); | 220 general = Fmapcar (Qcdr, Vbuffer_alist); |
| 221 | 221 |
| 222 if (FRAMEP (frame)) | 222 if (FRAMEP (frame)) |
| 223 { | 223 { |
| 224 Lisp_Object tail; | 224 Lisp_Object framelist, prevlist, tail; |
| 225 Lisp_Object args[3]; | |
| 225 | 226 |
| 226 CHECK_FRAME (frame); | 227 CHECK_FRAME (frame); |
| 227 | 228 |
| 228 framelist = Fcopy_sequence (XFRAME (frame)->buffer_list); | 229 framelist = Fcopy_sequence (XFRAME (frame)->buffer_list); |
| 229 | 230 prevlist = Fnreverse (Fcopy_sequence (XFRAME (frame)->buried_buffer_list)); |
| 230 /* Remove from GENERAL any buffer that duplicates one in FRAMELIST. */ | 231 |
| 232 /* Remove from GENERAL any buffer that duplicates one in | |
| 233 FRAMELIST or PREVLIST. */ | |
| 231 tail = framelist; | 234 tail = framelist; |
| 232 while (! NILP (tail)) | 235 while (CONSP (tail)) |
| 233 { | 236 { |
| 234 general = Fdelq (XCAR (tail), general); | 237 general = Fdelq (XCAR (tail), general); |
| 235 tail = XCDR (tail); | 238 tail = XCDR (tail); |
| 236 } | 239 } |
| 237 return nconc2 (framelist, general); | 240 tail = prevlist; |
| 241 while (CONSP (tail)) | |
| 242 { | |
| 243 general = Fdelq (XCAR (tail), general); | |
| 244 tail = XCDR (tail); | |
| 245 } | |
| 246 | |
| 247 args[0] = framelist; | |
| 248 args[1] = general; | |
| 249 args[2] = prevlist; | |
| 250 return Fnconc (3, args); | |
| 238 } | 251 } |
| 239 | 252 |
| 240 return general; | 253 return general; |
| 241 } | 254 } |
| 242 | 255 |
| 415 b->mark = Fmake_marker (); | 428 b->mark = Fmake_marker (); |
| 416 BUF_MARKERS (b) = NULL; | 429 BUF_MARKERS (b) = NULL; |
| 417 b->name = name; | 430 b->name = name; |
| 418 | 431 |
| 419 /* Put this in the alist of all live buffers. */ | 432 /* Put this in the alist of all live buffers. */ |
| 433 XSETPVECTYPE (b, PVEC_BUFFER); | |
| 420 XSETBUFFER (buf, b); | 434 XSETBUFFER (buf, b); |
| 421 Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil)); | 435 Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil)); |
| 422 | 436 |
| 423 /* An error in calling the function here (should someone redefine it) | 437 /* An error in calling the function here (should someone redefine it) |
| 424 can lead to infinite regress until you run out of stack. rms | 438 can lead to infinite regress until you run out of stack. rms |
| 1582 XSETCDR (prev, XCDR (XCDR (prev))); | 1596 XSETCDR (prev, XCDR (XCDR (prev))); |
| 1583 | 1597 |
| 1584 XSETCDR (link, Vbuffer_alist); | 1598 XSETCDR (link, Vbuffer_alist); |
| 1585 Vbuffer_alist = link; | 1599 Vbuffer_alist = link; |
| 1586 | 1600 |
| 1601 /* Effectively do a delq on buried_buffer_list. */ | |
| 1602 | |
| 1603 prev = Qnil; | |
| 1604 for (link = XFRAME (frame)->buried_buffer_list; CONSP (link); | |
| 1605 link = XCDR (link)) | |
| 1606 { | |
| 1607 if (EQ (XCAR (link), buf)) | |
| 1608 { | |
| 1609 if (NILP (prev)) | |
| 1610 XFRAME (frame)->buried_buffer_list = XCDR (link); | |
| 1611 else | |
| 1612 XSETCDR (prev, XCDR (XCDR (prev))); | |
| 1613 break; | |
| 1614 } | |
| 1615 prev = link; | |
| 1616 } | |
| 1617 | |
| 1587 /* Now move this buffer to the front of frame_buffer_list also. */ | 1618 /* Now move this buffer to the front of frame_buffer_list also. */ |
| 1588 | 1619 |
| 1589 prev = Qnil; | 1620 prev = Qnil; |
| 1590 for (link = frame_buffer_list (frame); CONSP (link); | 1621 for (link = frame_buffer_list (frame); CONSP (link); |
| 1591 link = XCDR (link)) | 1622 link = XCDR (link)) |
| 2064 link = Fmemq (aelt, Vbuffer_alist); | 2095 link = Fmemq (aelt, Vbuffer_alist); |
| 2065 Vbuffer_alist = Fdelq (aelt, Vbuffer_alist); | 2096 Vbuffer_alist = Fdelq (aelt, Vbuffer_alist); |
| 2066 XSETCDR (link, Qnil); | 2097 XSETCDR (link, Qnil); |
| 2067 Vbuffer_alist = nconc2 (Vbuffer_alist, link); | 2098 Vbuffer_alist = nconc2 (Vbuffer_alist, link); |
| 2068 | 2099 |
| 2069 /* Removing BUFFER from frame-specific lists | 2100 XFRAME (selected_frame)->buffer_list |
| 2070 has the effect of putting BUFFER at the end | 2101 = Fdelq (buffer, XFRAME (selected_frame)->buffer_list); |
| 2071 of the combined list in each frame. */ | 2102 XFRAME (selected_frame)->buried_buffer_list |
| 2072 frames_discard_buffer (buffer); | 2103 = Fcons (buffer, Fdelq (buffer, XFRAME (selected_frame)->buried_buffer_list)); |
| 2073 } | 2104 } |
| 2074 | 2105 |
| 2075 return Qnil; | 2106 return Qnil; |
| 2076 } | 2107 } |
| 2077 | 2108 |
| 3951 return Fcopy_sequence (XOVERLAY (overlay)->plist); | 3982 return Fcopy_sequence (XOVERLAY (overlay)->plist); |
| 3952 } | 3983 } |
| 3953 | 3984 |
| 3954 | 3985 |
| 3955 DEFUN ("overlays-at", Foverlays_at, Soverlays_at, 1, 1, 0, | 3986 DEFUN ("overlays-at", Foverlays_at, Soverlays_at, 1, 1, 0, |
| 3956 doc: /* Return a list of the overlays that contain position POS. */) | 3987 doc: /* Return a list of the overlays that contain the character at POS. */) |
| 3957 (pos) | 3988 (pos) |
| 3958 Lisp_Object pos; | 3989 Lisp_Object pos; |
| 3959 { | 3990 { |
| 3960 int noverlays; | 3991 int noverlays; |
| 3961 Lisp_Object *overlay_vec; | 3992 Lisp_Object *overlay_vec; |
| 5020 /* Prevent GC from getting confused. */ | 5051 /* Prevent GC from getting confused. */ |
| 5021 buffer_defaults.text = &buffer_defaults.own_text; | 5052 buffer_defaults.text = &buffer_defaults.own_text; |
| 5022 buffer_local_symbols.text = &buffer_local_symbols.own_text; | 5053 buffer_local_symbols.text = &buffer_local_symbols.own_text; |
| 5023 BUF_INTERVALS (&buffer_defaults) = 0; | 5054 BUF_INTERVALS (&buffer_defaults) = 0; |
| 5024 BUF_INTERVALS (&buffer_local_symbols) = 0; | 5055 BUF_INTERVALS (&buffer_local_symbols) = 0; |
| 5056 XSETPVECTYPE (&buffer_defaults, PVEC_BUFFER); | |
| 5025 XSETBUFFER (Vbuffer_defaults, &buffer_defaults); | 5057 XSETBUFFER (Vbuffer_defaults, &buffer_defaults); |
| 5058 XSETPVECTYPE (&buffer_local_symbols, PVEC_BUFFER); | |
| 5026 XSETBUFFER (Vbuffer_local_symbols, &buffer_local_symbols); | 5059 XSETBUFFER (Vbuffer_local_symbols, &buffer_local_symbols); |
| 5027 | 5060 |
| 5028 /* Set up the default values of various buffer slots. */ | 5061 /* Set up the default values of various buffer slots. */ |
| 5029 /* Must do these before making the first buffer! */ | 5062 /* Must do these before making the first buffer! */ |
| 5030 | 5063 |
| 5258 temp = get_minibuffer (0); | 5291 temp = get_minibuffer (0); |
| 5259 XBUFFER (temp)->directory = current_buffer->directory; | 5292 XBUFFER (temp)->directory = current_buffer->directory; |
| 5260 | 5293 |
| 5261 free (pwd); | 5294 free (pwd); |
| 5262 } | 5295 } |
| 5296 | |
| 5297 /* Similar to defvar_lisp but define a variable whose value is the Lisp | |
| 5298 Object stored in the current buffer. address is the address of the slot | |
| 5299 in the buffer that is current now. */ | |
| 5300 | |
| 5301 /* TYPE is nil for a general Lisp variable. | |
| 5302 An integer specifies a type; then only LIsp values | |
| 5303 with that type code are allowed (except that nil is allowed too). | |
| 5304 LNAME is the LIsp-level variable name. | |
| 5305 VNAME is the name of the buffer slot. | |
| 5306 DOC is a dummy where you write the doc string as a comment. */ | |
| 5307 #define DEFVAR_PER_BUFFER(lname, vname, type, doc) \ | |
| 5308 defvar_per_buffer (lname, vname, type, 0) | |
| 5309 | |
| 5310 static void | |
| 5311 defvar_per_buffer (namestring, address, type, doc) | |
| 5312 char *namestring; | |
| 5313 Lisp_Object *address; | |
| 5314 Lisp_Object type; | |
| 5315 char *doc; | |
| 5316 { | |
| 5317 Lisp_Object sym, val; | |
| 5318 int offset; | |
| 5319 | |
| 5320 sym = intern (namestring); | |
| 5321 val = allocate_misc (); | |
| 5322 offset = (char *)address - (char *)current_buffer; | |
| 5323 | |
| 5324 XMISCTYPE (val) = Lisp_Misc_Buffer_Objfwd; | |
| 5325 XBUFFER_OBJFWD (val)->offset = offset; | |
| 5326 SET_SYMBOL_VALUE (sym, val); | |
| 5327 PER_BUFFER_SYMBOL (offset) = sym; | |
| 5328 PER_BUFFER_TYPE (offset) = type; | |
| 5329 | |
| 5330 if (PER_BUFFER_IDX (offset) == 0) | |
| 5331 /* Did a DEFVAR_PER_BUFFER without initializing the corresponding | |
| 5332 slot of buffer_local_flags */ | |
| 5333 abort (); | |
| 5334 } | |
| 5335 | |
| 5263 | 5336 |
| 5264 /* initialize the buffer routines */ | 5337 /* initialize the buffer routines */ |
| 5265 void | 5338 void |
| 5266 syms_of_buffer () | 5339 syms_of_buffer () |
| 5267 { | 5340 { |
| 5544 | 5617 |
| 5545 DEFVAR_PER_BUFFER ("mode-name", ¤t_buffer->mode_name, | 5618 DEFVAR_PER_BUFFER ("mode-name", ¤t_buffer->mode_name, |
| 5546 Qnil, | 5619 Qnil, |
| 5547 doc: /* Pretty name of current buffer's major mode (a string). */); | 5620 doc: /* Pretty name of current buffer's major mode (a string). */); |
| 5548 | 5621 |
| 5622 DEFVAR_PER_BUFFER ("local-abbrev-table", ¤t_buffer->abbrev_table, Qnil, | |
| 5623 doc: /* Local (mode-specific) abbrev table of current buffer. */); | |
| 5624 | |
| 5549 DEFVAR_PER_BUFFER ("abbrev-mode", ¤t_buffer->abbrev_mode, Qnil, | 5625 DEFVAR_PER_BUFFER ("abbrev-mode", ¤t_buffer->abbrev_mode, Qnil, |
| 5550 doc: /* Non-nil turns on automatic expansion of abbrevs as they are inserted. */); | 5626 doc: /* Non-nil turns on automatic expansion of abbrevs as they are inserted. */); |
| 5551 | 5627 |
| 5552 DEFVAR_PER_BUFFER ("case-fold-search", ¤t_buffer->case_fold_search, | 5628 DEFVAR_PER_BUFFER ("case-fold-search", ¤t_buffer->case_fold_search, |
| 5553 Qnil, | 5629 Qnil, |
