diff options
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/src/buffer.c b/src/buffer.c index 53b3bd960c4..f1cb4d50414 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -119,6 +119,7 @@ static void free_buffer_text (struct buffer *b); | |||
| 119 | static struct Lisp_Overlay * copy_overlays (struct buffer *, struct Lisp_Overlay *); | 119 | static struct Lisp_Overlay * copy_overlays (struct buffer *, struct Lisp_Overlay *); |
| 120 | static void modify_overlay (struct buffer *, ptrdiff_t, ptrdiff_t); | 120 | static void modify_overlay (struct buffer *, ptrdiff_t, ptrdiff_t); |
| 121 | static Lisp_Object buffer_lisp_local_variables (struct buffer *, bool); | 121 | static Lisp_Object buffer_lisp_local_variables (struct buffer *, bool); |
| 122 | static Lisp_Object buffer_local_variables_1 (struct buffer *buf, int offset, Lisp_Object sym); | ||
| 122 | 123 | ||
| 123 | static void | 124 | static void |
| 124 | CHECK_OVERLAY (Lisp_Object x) | 125 | CHECK_OVERLAY (Lisp_Object x) |
| @@ -1300,6 +1301,25 @@ buffer_lisp_local_variables (struct buffer *buf, bool clone) | |||
| 1300 | return result; | 1301 | return result; |
| 1301 | } | 1302 | } |
| 1302 | 1303 | ||
| 1304 | |||
| 1305 | /* If the variable at position index OFFSET in buffer BUF has a | ||
| 1306 | buffer-local value, return (name . value). If SYM is non-nil, | ||
| 1307 | it replaces name. */ | ||
| 1308 | |||
| 1309 | static Lisp_Object | ||
| 1310 | buffer_local_variables_1 (struct buffer *buf, int offset, Lisp_Object sym) | ||
| 1311 | { | ||
| 1312 | int idx = PER_BUFFER_IDX (offset); | ||
| 1313 | if ((idx == -1 || PER_BUFFER_VALUE_P (buf, idx)) | ||
| 1314 | && SYMBOLP (PER_BUFFER_SYMBOL (offset))) | ||
| 1315 | { | ||
| 1316 | sym = NILP (sym) ? PER_BUFFER_SYMBOL (offset) : sym; | ||
| 1317 | Lisp_Object val = per_buffer_value (buf, offset); | ||
| 1318 | return EQ (val, Qunbound) ? sym : Fcons (sym, val); | ||
| 1319 | } | ||
| 1320 | return Qnil; | ||
| 1321 | } | ||
| 1322 | |||
| 1303 | DEFUN ("buffer-local-variables", Fbuffer_local_variables, | 1323 | DEFUN ("buffer-local-variables", Fbuffer_local_variables, |
| 1304 | Sbuffer_local_variables, 0, 1, 0, | 1324 | Sbuffer_local_variables, 0, 1, 0, |
| 1305 | doc: /* Return an alist of variables that are buffer-local in BUFFER. | 1325 | doc: /* Return an alist of variables that are buffer-local in BUFFER. |
| @@ -1311,25 +1331,25 @@ No argument or nil as argument means use current buffer as BUFFER. */) | |||
| 1311 | { | 1331 | { |
| 1312 | struct buffer *buf = decode_buffer (buffer); | 1332 | struct buffer *buf = decode_buffer (buffer); |
| 1313 | Lisp_Object result = buffer_lisp_local_variables (buf, 0); | 1333 | Lisp_Object result = buffer_lisp_local_variables (buf, 0); |
| 1334 | Lisp_Object tem; | ||
| 1314 | 1335 | ||
| 1315 | /* Add on all the variables stored in special slots. */ | 1336 | /* Add on all the variables stored in special slots. */ |
| 1316 | { | 1337 | { |
| 1317 | int offset, idx; | 1338 | int offset; |
| 1318 | 1339 | ||
| 1319 | FOR_EACH_PER_BUFFER_OBJECT_AT (offset) | 1340 | FOR_EACH_PER_BUFFER_OBJECT_AT (offset) |
| 1320 | { | 1341 | { |
| 1321 | idx = PER_BUFFER_IDX (offset); | 1342 | tem = buffer_local_variables_1 (buf, offset, Qnil); |
| 1322 | if ((idx == -1 || PER_BUFFER_VALUE_P (buf, idx)) | 1343 | if (!NILP (tem)) |
| 1323 | && SYMBOLP (PER_BUFFER_SYMBOL (offset))) | 1344 | result = Fcons (tem, result); |
| 1324 | { | ||
| 1325 | Lisp_Object sym = PER_BUFFER_SYMBOL (offset); | ||
| 1326 | Lisp_Object val = per_buffer_value (buf, offset); | ||
| 1327 | result = Fcons (EQ (val, Qunbound) ? sym : Fcons (sym, val), | ||
| 1328 | result); | ||
| 1329 | } | ||
| 1330 | } | 1345 | } |
| 1331 | } | 1346 | } |
| 1332 | 1347 | ||
| 1348 | tem = buffer_local_variables_1 (buf, PER_BUFFER_VAR_OFFSET (undo_list), | ||
| 1349 | intern ("buffer-undo-list")); | ||
| 1350 | if (!NILP (tem)) | ||
| 1351 | result = Fcons (tem, result); | ||
| 1352 | |||
| 1333 | return result; | 1353 | return result; |
| 1334 | } | 1354 | } |
| 1335 | 1355 | ||