diff options
| author | Stefan Monnier | 2010-08-19 17:43:45 +0200 |
|---|---|---|
| committer | Stefan Monnier | 2010-08-19 17:43:45 +0200 |
| commit | a2e5caf79e75361fb4d7e096e782398299ad1083 (patch) | |
| tree | d5a10d0781d2f7b368f9acd1c31328b16199e31b /src | |
| parent | 20d60baf356016231980a55673950dcdbc512b37 (diff) | |
| download | emacs-a2e5caf79e75361fb4d7e096e782398299ad1083.tar.gz emacs-a2e5caf79e75361fb4d7e096e782398299ad1083.zip | |
New post-self-insert-hook.
* src/cmds.c (Vself_insert_face, Vself_insert_face_command): Remove.
(Qpost_self_insert_hook, Vpost_self_insert_hook): New vars.
(internal_self_insert): Run post-self-insert-hook rather than handle
self-insert-face.
(syms_of_cmds): Initialize the new vars.
* lisp/facemenu.el (facemenu-self-insert-data): New var.
(facemenu-post-self-insert-function, facemenu-set-self-insert-face): New funs.
(facemenu-add-face): Use them.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/cmds.c | 41 |
2 files changed, 22 insertions, 27 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 649964178d5..96d5c774339 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2010-08-19 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * cmds.c (Vself_insert_face, Vself_insert_face_command): Remove. | ||
| 4 | (Qpost_self_insert_hook, Vpost_self_insert_hook): New vars. | ||
| 5 | (internal_self_insert): Run Qpost_self_insert_hook rather than handle | ||
| 6 | self-insert-face. | ||
| 7 | (syms_of_cmds): Initialize the new vars. | ||
| 8 | |||
| 1 | 2010-08-19 Jason Rumney <jasonr@gnu.org> | 9 | 2010-08-19 Jason Rumney <jasonr@gnu.org> |
| 2 | 10 | ||
| 3 | * w32fns.c (w32_wnd_proc): Don't check context before initializing. | 11 | * w32fns.c (w32_wnd_proc): Don't check context before initializing. |
diff --git a/src/cmds.c b/src/cmds.c index 4cb6ca199e7..f306ede7ca5 100644 --- a/src/cmds.c +++ b/src/cmds.c | |||
| @@ -37,12 +37,6 @@ Lisp_Object Qkill_forward_chars, Qkill_backward_chars, Vblink_paren_function; | |||
| 37 | /* A possible value for a buffer's overwrite-mode variable. */ | 37 | /* A possible value for a buffer's overwrite-mode variable. */ |
| 38 | Lisp_Object Qoverwrite_mode_binary; | 38 | Lisp_Object Qoverwrite_mode_binary; |
| 39 | 39 | ||
| 40 | /* Non-nil means put this face on the next self-inserting character. */ | ||
| 41 | Lisp_Object Vself_insert_face; | ||
| 42 | |||
| 43 | /* This is the command that set up Vself_insert_face. */ | ||
| 44 | Lisp_Object Vself_insert_face_command; | ||
| 45 | |||
| 46 | static int internal_self_insert (int, int); | 40 | static int internal_self_insert (int, int); |
| 47 | 41 | ||
| 48 | DEFUN ("forward-point", Fforward_point, Sforward_point, 1, 1, 0, | 42 | DEFUN ("forward-point", Fforward_point, Sforward_point, 1, 1, 0, |
| @@ -346,6 +340,7 @@ After insertion, the value of `auto-fill-function' is called if the | |||
| 346 | A value of 2 means this did things that call for an undo boundary. */ | 340 | A value of 2 means this did things that call for an undo boundary. */ |
| 347 | 341 | ||
| 348 | static Lisp_Object Qexpand_abbrev; | 342 | static Lisp_Object Qexpand_abbrev; |
| 343 | static Lisp_Object Qpost_self_insert_hook, Vpost_self_insert_hook; | ||
| 349 | 344 | ||
| 350 | static int | 345 | static int |
| 351 | internal_self_insert (int c, int noautofill) | 346 | internal_self_insert (int c, int noautofill) |
| @@ -451,10 +446,10 @@ internal_self_insert (int c, int noautofill) | |||
| 451 | && synt != Sword | 446 | && synt != Sword |
| 452 | && NILP (current_buffer->read_only) | 447 | && NILP (current_buffer->read_only) |
| 453 | && PT > BEGV | 448 | && PT > BEGV |
| 454 | && (!NILP (current_buffer->enable_multibyte_characters) | 449 | && (SYNTAX (!NILP (current_buffer->enable_multibyte_characters) |
| 455 | ? SYNTAX (XFASTINT (Fprevious_char ())) == Sword | 450 | ? XFASTINT (Fprevious_char ()) |
| 456 | : (SYNTAX (UNIBYTE_TO_CHAR (XFASTINT (Fprevious_char ()))) | 451 | : UNIBYTE_TO_CHAR (XFASTINT (Fprevious_char ()))) |
| 457 | == Sword))) | 452 | == Sword)) |
| 458 | { | 453 | { |
| 459 | int modiff = MODIFF; | 454 | int modiff = MODIFF; |
| 460 | Lisp_Object sym; | 455 | Lisp_Object sym; |
| @@ -514,15 +509,6 @@ internal_self_insert (int c, int noautofill) | |||
| 514 | hairy = 2; | 509 | hairy = 2; |
| 515 | } | 510 | } |
| 516 | 511 | ||
| 517 | /* If previous command specified a face to use, use it. */ | ||
| 518 | if (!NILP (Vself_insert_face) | ||
| 519 | && EQ (current_kboard->Vlast_command, Vself_insert_face_command)) | ||
| 520 | { | ||
| 521 | Fput_text_property (make_number (PT - 1), make_number (PT), | ||
| 522 | Qface, Vself_insert_face, Qnil); | ||
| 523 | Vself_insert_face = Qnil; | ||
| 524 | } | ||
| 525 | |||
| 526 | if ((synt == Sclose || synt == Smath) | 512 | if ((synt == Sclose || synt == Smath) |
| 527 | && !NILP (Vblink_paren_function) && INTERACTIVE | 513 | && !NILP (Vblink_paren_function) && INTERACTIVE |
| 528 | && !noautofill) | 514 | && !noautofill) |
| @@ -530,6 +516,9 @@ internal_self_insert (int c, int noautofill) | |||
| 530 | call0 (Vblink_paren_function); | 516 | call0 (Vblink_paren_function); |
| 531 | hairy = 2; | 517 | hairy = 2; |
| 532 | } | 518 | } |
| 519 | /* Run hooks for electric keys. */ | ||
| 520 | call1 (Vrun_hooks, Qpost_self_insert_hook); | ||
| 521 | |||
| 533 | return hairy; | 522 | return hairy; |
| 534 | } | 523 | } |
| 535 | 524 | ||
| @@ -550,15 +539,13 @@ syms_of_cmds (void) | |||
| 550 | Qexpand_abbrev = intern_c_string ("expand-abbrev"); | 539 | Qexpand_abbrev = intern_c_string ("expand-abbrev"); |
| 551 | staticpro (&Qexpand_abbrev); | 540 | staticpro (&Qexpand_abbrev); |
| 552 | 541 | ||
| 553 | DEFVAR_LISP ("self-insert-face", &Vself_insert_face, | 542 | Qpost_self_insert_hook = intern_c_string ("post-self-insert-hook"); |
| 554 | doc: /* If non-nil, set the face of the next self-inserting character to this. | 543 | staticpro (&Qpost_self_insert_hook); |
| 555 | See also `self-insert-face-command'. */); | ||
| 556 | Vself_insert_face = Qnil; | ||
| 557 | 544 | ||
| 558 | DEFVAR_LISP ("self-insert-face-command", &Vself_insert_face_command, | 545 | DEFVAR_LISP ("post-self-insert-hook", &Vpost_self_insert_hook, |
| 559 | doc: /* This is the command that set up `self-insert-face'. | 546 | doc: /* Hook run at the end of `self-insert-command'. |
| 560 | If `last-command' does not equal this value, we ignore `self-insert-face'. */); | 547 | This run is run after inserting the charater. */); |
| 561 | Vself_insert_face_command = Qnil; | 548 | Vpost_self_insert_hook = Qnil; |
| 562 | 549 | ||
| 563 | DEFVAR_LISP ("blink-paren-function", &Vblink_paren_function, | 550 | DEFVAR_LISP ("blink-paren-function", &Vblink_paren_function, |
| 564 | doc: /* Function called, if non-nil, whenever a close parenthesis is inserted. | 551 | doc: /* Function called, if non-nil, whenever a close parenthesis is inserted. |