Mercurial > emacs
comparison src/buffer.h @ 28317:a7da319e3765
(struct buffer): Remove member local_var_flags,
add local_flags.
(MAX_BUFFER_LOCAL_VARS): New macro.
(BUFFER_LOCAL_VAR_OFFSET, BUFFER_LOCAL_VAR_IDX)
(BUFFER_HAS_LOCAL_VALUE_P, SET_BUFFER_HAS_LOCAL_VALUE_P)
(BUFFER_LOCAL_IDX, BUFFER_LOCAL_DEFAULT_VALUE, BUFFER_LOCAL_VALUE)
(BUFFER_LOCAL_SYMBOL, BUFFER_LOCAL_TYPE): New macros.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Sun, 26 Mar 2000 14:08:52 +0000 |
parents | b16a6381a87b |
children | 7d1e7bfa5ae1 |
comparison
equal
deleted
inserted
replaced
28316:869387703a36 | 28317:a7da319e3765 |
---|---|
475 | 475 |
476 /* In an indirect buffer, this points to the base buffer. | 476 /* In an indirect buffer, this points to the base buffer. |
477 In an ordinary buffer, it is 0. */ | 477 In an ordinary buffer, it is 0. */ |
478 struct buffer *base_buffer; | 478 struct buffer *base_buffer; |
479 | 479 |
480 /* Flags saying which DEFVAR_PER_BUFFER variables | 480 /* A non-zero value in slot IDX means that per-buffer variable |
481 are local to this buffer. */ | 481 with index IDX has a local value in this buffer. The index IDX |
482 int local_var_flags; | 482 for a buffer-local variable is stored in that variable's slot |
483 in buffer_local_flags as a Lisp integer. If the index is -1, | |
484 this means the variable is always local in all buffers. */ | |
485 #define MAX_BUFFER_LOCAL_VARS 30 | |
486 char local_flags[MAX_BUFFER_LOCAL_VARS]; | |
487 | |
483 /* Set to the modtime of the visited file when read or written. | 488 /* Set to the modtime of the visited file when read or written. |
484 -1 means visited file was nonexistent. | 489 -1 means visited file was nonexistent. |
485 0 means visited file modtime unknown; in no case complain | 490 0 means visited file modtime unknown; in no case complain |
486 about any mismatch on next save attempt. */ | 491 about any mismatch on next save attempt. */ |
487 int modtime; | 492 int modtime; |
747 default values in buffer_defaults. | 752 default values in buffer_defaults. |
748 Each such slot has a nonzero value in this structure. | 753 Each such slot has a nonzero value in this structure. |
749 The value has only one nonzero bit. | 754 The value has only one nonzero bit. |
750 | 755 |
751 When a buffer has its own local value for a slot, | 756 When a buffer has its own local value for a slot, |
752 the bit for that slot (found in the same slot in this structure) | 757 the entry for that slot (found in the same slot in this structure) |
753 is turned on in the buffer's local_var_flags slot. | 758 is turned on in the buffer's local_flags array. |
754 | 759 |
755 If a slot in this structure is zero, then even though there may | 760 If a slot in this structure is zero, then even though there may |
756 be a Lisp-level local variable for the slot, it has no default value, | 761 be a Lisp-level local variable for the slot, it has no default value, |
757 and the corresponding slot in buffer_defaults is not used. */ | 762 and the corresponding slot in buffer_defaults is not used. */ |
758 | 763 |
848 #define BUFFER_REALLOC(data,size) ((unsigned char *) realloc ((data), (size))) | 853 #define BUFFER_REALLOC(data,size) ((unsigned char *) realloc ((data), (size))) |
849 #define BUFFER_FREE(data) (free ((data))) | 854 #define BUFFER_FREE(data) (free ((data))) |
850 #define R_ALLOC_DECLARE(var,data) | 855 #define R_ALLOC_DECLARE(var,data) |
851 #endif | 856 #endif |
852 | 857 |
858 /*********************************************************************** | |
859 Buffer-local Variables | |
860 ***********************************************************************/ | |
861 | |
862 /* Number of per-buffer variables used. */ | |
863 | |
864 extern int max_buffer_local_idx; | |
865 | |
866 /* Return the offset in bytes of member VAR of struct buffer | |
867 from the start of a buffer structure. */ | |
868 | |
869 #define BUFFER_LOCAL_VAR_OFFSET(VAR) \ | |
870 ((char *) &buffer_local_flags.VAR - (char *) &buffer_local_flags) | |
871 | |
872 /* Return the index of buffer-local variable VAR. Each per-buffer | |
873 variable has an index > 0 associated with it, except when it always | |
874 has buffer-local values, in which case the index is -1. If this is | |
875 0, this is a bug and means that the slot of VAR in | |
876 buffer_local_flags wasn't intiialized. */ | |
877 | |
878 #define BUFFER_LOCAL_VAR_IDX(VAR) \ | |
879 BUFFER_LOCAL_IDX (BUFFER_LOCAL_VAR_OFFSET (VAR)) | |
880 | |
881 /* Value is non-zero if the variable with index IDX has a local value | |
882 in buffer B. */ | |
883 | |
884 #define BUFFER_HAS_LOCAL_VALUE_P(B, IDX) \ | |
885 (((IDX) < 0 || IDX >= max_buffer_local_idx) \ | |
886 ? (abort (), 0) \ | |
887 : ((B)->local_flags[IDX] != 0)) | |
888 | |
889 /* Set whether per-buffer variable with index IDX has a buffer-local | |
890 value in buffer B. VAL zero means it hasn't. */ | |
891 | |
892 #define SET_BUFFER_HAS_LOCAL_VALUE_P(B, IDX, VAL) \ | |
893 do { \ | |
894 if ((IDX) < 0 || (IDX) >= max_buffer_local_idx) \ | |
895 abort (); \ | |
896 (B)->local_flags[IDX] = (VAL); \ | |
897 } while (0) | |
898 | |
899 /* Return the index of the per-buffer variable at offset OFFSET in the | |
900 buffer structure. */ | |
901 | |
902 #define BUFFER_LOCAL_IDX(OFFSET) \ | |
903 XINT (*(Lisp_Object *)((OFFSET) + (char *) &buffer_local_flags)) | |
904 | |
905 /* Return the default value of the per-buffer variable at offset | |
906 OFFSET in the buffer structure. */ | |
907 | |
908 #define BUFFER_LOCAL_DEFAULT_VALUE(OFFSET) \ | |
909 (*(Lisp_Object *)((OFFSET) + (char *) &buffer_defaults)) | |
910 | |
911 /* Return the buffer-local value of the per-buffer variable at offset | |
912 OFFSET in the buffer structure. */ | |
913 | |
914 #define BUFFER_LOCAL_VALUE(BUFFER, OFFSET) \ | |
915 (*(Lisp_Object *)((OFFSET) + (char *) (BUFFER))) | |
916 | |
917 /* Return the symbol of the per-buffer variable at offset OFFSET in | |
918 the buffer structure. */ | |
919 | |
920 #define BUFFER_LOCAL_SYMBOL(OFFSET) \ | |
921 (*(Lisp_Object *)((OFFSET) + (char *) &buffer_local_symbols)) | |
922 | |
923 /* Return the type of the per-buffer variable at offset OFFSET in the | |
924 buffer structure. */ | |
925 | |
926 #define BUFFER_LOCAL_TYPE(OFFSET) \ | |
927 (*(Lisp_Object *)((OFFSET) + (char *) &buffer_local_types)) |