diff options
| author | Gerd Moellmann | 2000-03-26 14:08:52 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-03-26 14:08:52 +0000 |
| commit | 979332f67f567886ee041c95b707e84f71f4f5bd (patch) | |
| tree | 696a9143760f3d0665f08f1fbb174997992aa2d0 /src/buffer.h | |
| parent | c3279ad4abd78eb1641c6a1ee3fe37502b21596d (diff) | |
| download | emacs-979332f67f567886ee041c95b707e84f71f4f5bd.tar.gz emacs-979332f67f567886ee041c95b707e84f71f4f5bd.zip | |
(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.
Diffstat (limited to 'src/buffer.h')
| -rw-r--r-- | src/buffer.h | 85 |
1 files changed, 80 insertions, 5 deletions
diff --git a/src/buffer.h b/src/buffer.h index e37cd91c87e..fc11d91ed11 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -477,9 +477,14 @@ struct 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 |
| @@ -749,8 +754,8 @@ extern struct buffer buffer_defaults; | |||
| 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, |
| @@ -850,3 +855,73 @@ extern char *r_re_alloc P_ ((char **, unsigned long)); | |||
| 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)) | ||