diff options
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/buffer.c b/src/buffer.c index 75cb470af8d..f8c57a74b4e 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* Buffer manipulation primitives for GNU Emacs. | 1 | /* Buffer manipulation primitives for GNU Emacs. |
| 2 | 2 | ||
| 3 | Copyright (C) 1985-1989, 1993-1995, 1997-2017 Free Software Foundation, | 3 | Copyright (C) 1985-1989, 1993-1995, 1997-2018 Free Software Foundation, |
| 4 | Inc. | 4 | Inc. |
| 5 | 5 | ||
| 6 | This file is part of GNU Emacs. | 6 | This file is part of GNU Emacs. |
| @@ -1320,7 +1320,12 @@ menu bar menus and the frame title. */) | |||
| 1320 | DEFUN ("set-buffer-modified-p", Fset_buffer_modified_p, Sset_buffer_modified_p, | 1320 | DEFUN ("set-buffer-modified-p", Fset_buffer_modified_p, Sset_buffer_modified_p, |
| 1321 | 1, 1, 0, | 1321 | 1, 1, 0, |
| 1322 | doc: /* Mark current buffer as modified or unmodified according to FLAG. | 1322 | doc: /* Mark current buffer as modified or unmodified according to FLAG. |
| 1323 | A non-nil FLAG means mark the buffer modified. */) | 1323 | A non-nil FLAG means mark the buffer modified. |
| 1324 | In addition, this function unconditionally forces redisplay of the | ||
| 1325 | mode lines of the windows that display the current buffer, and also | ||
| 1326 | locks or unlocks the file visited by the buffer, depending on whether | ||
| 1327 | the function's argument is non-nil, but only if both `buffer-file-name' | ||
| 1328 | and `buffer-file-truename' are non-nil. */) | ||
| 1324 | (Lisp_Object flag) | 1329 | (Lisp_Object flag) |
| 1325 | { | 1330 | { |
| 1326 | Frestore_buffer_modified_p (flag); | 1331 | Frestore_buffer_modified_p (flag); |
| @@ -1341,12 +1346,14 @@ A non-nil FLAG means mark the buffer modified. */) | |||
| 1341 | 1346 | ||
| 1342 | DEFUN ("restore-buffer-modified-p", Frestore_buffer_modified_p, | 1347 | DEFUN ("restore-buffer-modified-p", Frestore_buffer_modified_p, |
| 1343 | Srestore_buffer_modified_p, 1, 1, 0, | 1348 | Srestore_buffer_modified_p, 1, 1, 0, |
| 1344 | doc: /* Like `set-buffer-modified-p', with a difference concerning redisplay. | 1349 | doc: /* Like `set-buffer-modified-p', but doesn't redisplay buffer's mode line. |
| 1350 | This function also locks and unlocks the file visited by the buffer, | ||
| 1351 | if both `buffer-file-truename' and `buffer-file-name' are non-nil. | ||
| 1352 | |||
| 1345 | It is not ensured that mode lines will be updated to show the modified | 1353 | It is not ensured that mode lines will be updated to show the modified |
| 1346 | state of the current buffer. Use with care. */) | 1354 | state of the current buffer. Use with care. */) |
| 1347 | (Lisp_Object flag) | 1355 | (Lisp_Object flag) |
| 1348 | { | 1356 | { |
| 1349 | Lisp_Object fn; | ||
| 1350 | 1357 | ||
| 1351 | /* If buffer becoming modified, lock the file. | 1358 | /* If buffer becoming modified, lock the file. |
| 1352 | If buffer becoming unmodified, unlock the file. */ | 1359 | If buffer becoming unmodified, unlock the file. */ |
| @@ -1355,15 +1362,18 @@ state of the current buffer. Use with care. */) | |||
| 1355 | ? current_buffer->base_buffer | 1362 | ? current_buffer->base_buffer |
| 1356 | : current_buffer; | 1363 | : current_buffer; |
| 1357 | 1364 | ||
| 1358 | fn = BVAR (b, file_truename); | 1365 | if (!inhibit_modification_hooks) |
| 1359 | /* Test buffer-file-name so that binding it to nil is effective. */ | ||
| 1360 | if (!NILP (fn) && ! NILP (BVAR (b, filename))) | ||
| 1361 | { | 1366 | { |
| 1362 | bool already = SAVE_MODIFF < MODIFF; | 1367 | Lisp_Object fn = BVAR (b, file_truename); |
| 1363 | if (!already && !NILP (flag)) | 1368 | /* Test buffer-file-name so that binding it to nil is effective. */ |
| 1364 | lock_file (fn); | 1369 | if (!NILP (fn) && ! NILP (BVAR (b, filename))) |
| 1365 | else if (already && NILP (flag)) | 1370 | { |
| 1366 | unlock_file (fn); | 1371 | bool already = SAVE_MODIFF < MODIFF; |
| 1372 | if (!already && !NILP (flag)) | ||
| 1373 | lock_file (fn); | ||
| 1374 | else if (already && NILP (flag)) | ||
| 1375 | unlock_file (fn); | ||
| 1376 | } | ||
| 1367 | } | 1377 | } |
| 1368 | 1378 | ||
| 1369 | /* Here we have a problem. SAVE_MODIFF is used here to encode | 1379 | /* Here we have a problem. SAVE_MODIFF is used here to encode |