diff options
| author | Stefan Monnier | 2013-11-11 13:05:47 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2013-11-11 13:05:47 -0500 |
| commit | ecda65d4f7ea34faca40cd188fb5bb095e874092 (patch) | |
| tree | dfff4cf951a1bb5ba227677295ccd160a598152c /src/buffer.c | |
| parent | 5389db9e7160a85080078a1cf26dbc46ace55c21 (diff) | |
| download | emacs-ecda65d4f7ea34faca40cd188fb5bb095e874092.tar.gz emacs-ecda65d4f7ea34faca40cd188fb5bb095e874092.zip | |
* lisp/subr.el (force-mode-line-update): Delete, move to buffer.c.
* src/buffer.c (Frestore_buffer_modified_p): Sync it with
Fset_buffer_modified_p.
(Fforce_mode_line_update): New function, moved from subr.el.
(Fset_buffer_modified_p): Use them.
(syms_of_buffer): Defsubr Fforce_mode_line_update.
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 98 |
1 files changed, 47 insertions, 51 deletions
diff --git a/src/buffer.c b/src/buffer.c index 7a424ffd901..a528397a9d2 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -1328,15 +1328,55 @@ No argument or nil as argument means use current buffer as BUFFER. */) | |||
| 1328 | return BUF_SAVE_MODIFF (buf) < BUF_MODIFF (buf) ? Qt : Qnil; | 1328 | return BUF_SAVE_MODIFF (buf) < BUF_MODIFF (buf) ? Qt : Qnil; |
| 1329 | } | 1329 | } |
| 1330 | 1330 | ||
| 1331 | DEFUN ("force-mode-line-update", Fforce_mode_line_update, | ||
| 1332 | Sforce_mode_line_update, 0, 1, 0, | ||
| 1333 | doc: /* Force redisplay of the current buffer's mode line and header line. | ||
| 1334 | With optional non-nil ALL, force redisplay of all mode lines and | ||
| 1335 | header lines. This function also forces recomputation of the | ||
| 1336 | menu bar menus and the frame title. */) | ||
| 1337 | (Lisp_Object all) | ||
| 1338 | { | ||
| 1339 | if (!NILP (all) || buffer_window_count (current_buffer)) | ||
| 1340 | { | ||
| 1341 | update_mode_lines = 10; | ||
| 1342 | current_buffer->prevent_redisplay_optimizations_p = 1; | ||
| 1343 | } | ||
| 1344 | } | ||
| 1345 | |||
| 1331 | DEFUN ("set-buffer-modified-p", Fset_buffer_modified_p, Sset_buffer_modified_p, | 1346 | DEFUN ("set-buffer-modified-p", Fset_buffer_modified_p, Sset_buffer_modified_p, |
| 1332 | 1, 1, 0, | 1347 | 1, 1, 0, |
| 1333 | doc: /* Mark current buffer as modified or unmodified according to FLAG. | 1348 | doc: /* Mark current buffer as modified or unmodified according to FLAG. |
| 1334 | A non-nil FLAG means mark the buffer modified. */) | 1349 | A non-nil FLAG means mark the buffer modified. */) |
| 1335 | (Lisp_Object flag) | 1350 | (Lisp_Object flag) |
| 1336 | { | 1351 | { |
| 1337 | Lisp_Object fn; | 1352 | Frestore_buffer_modified_p (flag); |
| 1353 | |||
| 1354 | /* Set update_mode_lines only if buffer is displayed in some window. | ||
| 1355 | Packages like jit-lock or lazy-lock preserve a buffer's modified | ||
| 1356 | state by recording/restoring the state around blocks of code. | ||
| 1357 | Setting update_mode_lines makes redisplay consider all windows | ||
| 1358 | (on all frames). Stealth fontification of buffers not displayed | ||
| 1359 | would incur additional redisplay costs if we'd set | ||
| 1360 | update_modes_lines unconditionally. | ||
| 1361 | |||
| 1362 | Ideally, I think there should be another mechanism for fontifying | ||
| 1363 | buffers without "modifying" buffers, or redisplay should be | ||
| 1364 | smarter about updating the `*' in mode lines. --gerd */ | ||
| 1365 | Fforce_mode_line_update (Qnil); | ||
| 1338 | 1366 | ||
| 1367 | return flag; | ||
| 1368 | } | ||
| 1369 | |||
| 1370 | DEFUN ("restore-buffer-modified-p", Frestore_buffer_modified_p, | ||
| 1371 | Srestore_buffer_modified_p, 1, 1, 0, | ||
| 1372 | doc: /* Like `set-buffer-modified-p', with a difference concerning redisplay. | ||
| 1373 | It is not ensured that mode lines will be updated to show the modified | ||
| 1374 | state of the current buffer. Use with care. */) | ||
| 1375 | (Lisp_Object flag) | ||
| 1376 | { | ||
| 1339 | #ifdef CLASH_DETECTION | 1377 | #ifdef CLASH_DETECTION |
| 1378 | Lisp_Object fn; | ||
| 1379 | |||
| 1340 | /* If buffer becoming modified, lock the file. | 1380 | /* If buffer becoming modified, lock the file. |
| 1341 | If buffer becoming unmodified, unlock the file. */ | 1381 | If buffer becoming unmodified, unlock the file. */ |
| 1342 | 1382 | ||
| @@ -1376,52 +1416,6 @@ A non-nil FLAG means mark the buffer modified. */) | |||
| 1376 | or increase MODIFF. */ | 1416 | or increase MODIFF. */ |
| 1377 | : MODIFF++); | 1417 | : MODIFF++); |
| 1378 | 1418 | ||
| 1379 | /* Set update_mode_lines only if buffer is displayed in some window. | ||
| 1380 | Packages like jit-lock or lazy-lock preserve a buffer's modified | ||
| 1381 | state by recording/restoring the state around blocks of code. | ||
| 1382 | Setting update_mode_lines makes redisplay consider all windows | ||
| 1383 | (on all frames). Stealth fontification of buffers not displayed | ||
| 1384 | would incur additional redisplay costs if we'd set | ||
| 1385 | update_modes_lines unconditionally. | ||
| 1386 | |||
| 1387 | Ideally, I think there should be another mechanism for fontifying | ||
| 1388 | buffers without "modifying" buffers, or redisplay should be | ||
| 1389 | smarter about updating the `*' in mode lines. --gerd */ | ||
| 1390 | if (buffer_window_count (current_buffer)) | ||
| 1391 | { | ||
| 1392 | update_mode_lines = 10; | ||
| 1393 | current_buffer->prevent_redisplay_optimizations_p = 1; | ||
| 1394 | } | ||
| 1395 | |||
| 1396 | return flag; | ||
| 1397 | } | ||
| 1398 | |||
| 1399 | DEFUN ("restore-buffer-modified-p", Frestore_buffer_modified_p, | ||
| 1400 | Srestore_buffer_modified_p, 1, 1, 0, | ||
| 1401 | doc: /* Like `set-buffer-modified-p', with a difference concerning redisplay. | ||
| 1402 | It is not ensured that mode lines will be updated to show the modified | ||
| 1403 | state of the current buffer. Use with care. */) | ||
| 1404 | (Lisp_Object flag) | ||
| 1405 | { | ||
| 1406 | #ifdef CLASH_DETECTION | ||
| 1407 | Lisp_Object fn; | ||
| 1408 | |||
| 1409 | /* If buffer becoming modified, lock the file. | ||
| 1410 | If buffer becoming unmodified, unlock the file. */ | ||
| 1411 | |||
| 1412 | fn = BVAR (current_buffer, file_truename); | ||
| 1413 | /* Test buffer-file-name so that binding it to nil is effective. */ | ||
| 1414 | if (!NILP (fn) && ! NILP (BVAR (current_buffer, filename))) | ||
| 1415 | { | ||
| 1416 | bool already = SAVE_MODIFF < MODIFF; | ||
| 1417 | if (!already && !NILP (flag)) | ||
| 1418 | lock_file (fn); | ||
| 1419 | else if (already && NILP (flag)) | ||
| 1420 | unlock_file (fn); | ||
| 1421 | } | ||
| 1422 | #endif /* CLASH_DETECTION */ | ||
| 1423 | |||
| 1424 | SAVE_MODIFF = NILP (flag) ? MODIFF : 0; | ||
| 1425 | return flag; | 1419 | return flag; |
| 1426 | } | 1420 | } |
| 1427 | 1421 | ||
| @@ -1794,7 +1788,7 @@ cleaning up all windows currently displaying the buffer to be killed. */) | |||
| 1794 | /* Run replace_buffer_in_windows before making another buffer current | 1788 | /* Run replace_buffer_in_windows before making another buffer current |
| 1795 | since set-window-buffer-start-and-point will refuse to make another | 1789 | since set-window-buffer-start-and-point will refuse to make another |
| 1796 | buffer current if the selected window does not show the current | 1790 | buffer current if the selected window does not show the current |
| 1797 | buffer. (Bug#10114) */ | 1791 | buffer (bug#10114). */ |
| 1798 | replace_buffer_in_windows (buffer); | 1792 | replace_buffer_in_windows (buffer); |
| 1799 | 1793 | ||
| 1800 | /* Exit if replacing the buffer in windows has killed our buffer. */ | 1794 | /* Exit if replacing the buffer in windows has killed our buffer. */ |
| @@ -5403,12 +5397,12 @@ defvar_per_buffer (struct Lisp_Buffer_Objfwd *bo_fwd, const char *namestring, | |||
| 5403 | 5397 | ||
| 5404 | if (PER_BUFFER_IDX (offset) == 0) | 5398 | if (PER_BUFFER_IDX (offset) == 0) |
| 5405 | /* Did a DEFVAR_PER_BUFFER without initializing the corresponding | 5399 | /* Did a DEFVAR_PER_BUFFER without initializing the corresponding |
| 5406 | slot of buffer_local_flags */ | 5400 | slot of buffer_local_flags. */ |
| 5407 | emacs_abort (); | 5401 | emacs_abort (); |
| 5408 | } | 5402 | } |
| 5409 | 5403 | ||
| 5410 | 5404 | ||
| 5411 | /* initialize the buffer routines */ | 5405 | /* Initialize the buffer routines. */ |
| 5412 | void | 5406 | void |
| 5413 | syms_of_buffer (void) | 5407 | syms_of_buffer (void) |
| 5414 | { | 5408 | { |
| @@ -5798,7 +5792,8 @@ its value may not be a list of functions. */); | |||
| 5798 | 5792 | ||
| 5799 | DEFVAR_PER_BUFFER ("buffer-file-name", &BVAR (current_buffer, filename), | 5793 | DEFVAR_PER_BUFFER ("buffer-file-name", &BVAR (current_buffer, filename), |
| 5800 | Qstringp, | 5794 | Qstringp, |
| 5801 | doc: /* Name of file visited in current buffer, or nil if not visiting a file. */); | 5795 | doc: /* Name of file visited in current buffer, or nil if not visiting a file. |
| 5796 | This should be an absolute file name. */); | ||
| 5802 | 5797 | ||
| 5803 | DEFVAR_PER_BUFFER ("buffer-file-truename", &BVAR (current_buffer, file_truename), | 5798 | DEFVAR_PER_BUFFER ("buffer-file-truename", &BVAR (current_buffer, file_truename), |
| 5804 | Qstringp, | 5799 | Qstringp, |
| @@ -6298,6 +6293,7 @@ and `bury-buffer-internal'. */); | |||
| 6298 | defsubr (&Sbuffer_local_value); | 6293 | defsubr (&Sbuffer_local_value); |
| 6299 | defsubr (&Sbuffer_local_variables); | 6294 | defsubr (&Sbuffer_local_variables); |
| 6300 | defsubr (&Sbuffer_modified_p); | 6295 | defsubr (&Sbuffer_modified_p); |
| 6296 | defsubr (&Sforce_mode_line_update); | ||
| 6301 | defsubr (&Sset_buffer_modified_p); | 6297 | defsubr (&Sset_buffer_modified_p); |
| 6302 | defsubr (&Sbuffer_modified_tick); | 6298 | defsubr (&Sbuffer_modified_tick); |
| 6303 | defsubr (&Sbuffer_chars_modified_tick); | 6299 | defsubr (&Sbuffer_chars_modified_tick); |