diff options
| author | Kenichi Handa | 1999-12-15 00:15:16 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1999-12-15 00:15:16 +0000 |
| commit | adf5cb9c38bbe5605720a139a5d1a2cfcdb1831f (patch) | |
| tree | 1baa8e242d12557f67334c18c8d27a61eb014365 /src | |
| parent | f56b42ac9e43c1f77ecd782ceab46a65c10604fe (diff) | |
| download | emacs-adf5cb9c38bbe5605720a139a5d1a2cfcdb1831f.tar.gz emacs-adf5cb9c38bbe5605720a139a5d1a2cfcdb1831f.zip | |
(Vdisable_point_adjustment): New variable.
(Vglobal_disable_point_adjustment): New variable.
(syms_of_keyboard): Declare them as Lisp variables.
(command_loop_1): Check them and call adjust_point_for_property if
necessary.
(adjust_point_for_property): New function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index be6acd31b54..7066a56360c 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -603,6 +603,17 @@ int flow_control; | |||
| 603 | #ifdef HAVE_WINDOW_SYSTEM | 603 | #ifdef HAVE_WINDOW_SYSTEM |
| 604 | #define POLL_FOR_INPUT | 604 | #define POLL_FOR_INPUT |
| 605 | #endif | 605 | #endif |
| 606 | |||
| 607 | /* After a command is executed, if point is moved into a region that | ||
| 608 | has specific properties (e.g. composition, display), we adjust | ||
| 609 | point to the boundary of the region. But, if a command sets this | ||
| 610 | valiable to non-nil, we suppress this point adjustment. This | ||
| 611 | variable is set to nil before reading a command. */ | ||
| 612 | Lisp_Object Vdisable_point_adjustment; | ||
| 613 | |||
| 614 | /* If non-nil, always disable point adjustment. */ | ||
| 615 | Lisp_Object Vglobal_disable_point_adjustment; | ||
| 616 | |||
| 606 | 617 | ||
| 607 | /* Global variable declarations. */ | 618 | /* Global variable declarations. */ |
| 608 | 619 | ||
| @@ -1182,6 +1193,7 @@ DEFUN ("abort-recursive-edit", Fabort_recursive_edit, Sabort_recursive_edit, 0, | |||
| 1182 | Lisp_Object Fcommand_execute (); | 1193 | Lisp_Object Fcommand_execute (); |
| 1183 | static int read_key_sequence (); | 1194 | static int read_key_sequence (); |
| 1184 | void safe_run_hooks (); | 1195 | void safe_run_hooks (); |
| 1196 | static void adjust_point_for_property (); | ||
| 1185 | 1197 | ||
| 1186 | Lisp_Object | 1198 | Lisp_Object |
| 1187 | command_loop_1 () | 1199 | command_loop_1 () |
| @@ -1369,6 +1381,12 @@ command_loop_1 () | |||
| 1369 | last_point_position = PT; | 1381 | last_point_position = PT; |
| 1370 | XSETBUFFER (last_point_position_buffer, prev_buffer); | 1382 | XSETBUFFER (last_point_position_buffer, prev_buffer); |
| 1371 | 1383 | ||
| 1384 | /* By default, we adjust point to a boundary of a region that | ||
| 1385 | has such a property that should be treated intangible | ||
| 1386 | (e.g. composition, display). But, some commands will set | ||
| 1387 | this variable differently. */ | ||
| 1388 | Vdisable_point_adjustment = Qnil; | ||
| 1389 | |||
| 1372 | /* Execute the command. */ | 1390 | /* Execute the command. */ |
| 1373 | 1391 | ||
| 1374 | Vthis_command = cmd; | 1392 | Vthis_command = cmd; |
| @@ -1571,6 +1589,13 @@ command_loop_1 () | |||
| 1571 | } | 1589 | } |
| 1572 | 1590 | ||
| 1573 | finalize: | 1591 | finalize: |
| 1592 | |||
| 1593 | if (current_buffer == prev_buffer | ||
| 1594 | && last_point_position != PT | ||
| 1595 | && NILP (Vdisable_point_adjustment) | ||
| 1596 | && NILP (Vglobal_disable_point_adjustment)) | ||
| 1597 | adjust_point_for_property (last_point_position); | ||
| 1598 | |||
| 1574 | /* Install chars successfully executed in kbd macro. */ | 1599 | /* Install chars successfully executed in kbd macro. */ |
| 1575 | 1600 | ||
| 1576 | if (!NILP (current_kboard->defining_kbd_macro) | 1601 | if (!NILP (current_kboard->defining_kbd_macro) |
| @@ -1584,6 +1609,53 @@ command_loop_1 () | |||
| 1584 | } | 1609 | } |
| 1585 | } | 1610 | } |
| 1586 | 1611 | ||
| 1612 | extern Lisp_Object Qcomposition, Qdisplay; | ||
| 1613 | |||
| 1614 | /* Adjust point to a boundary of a region that has such a property | ||
| 1615 | that should be treated intangible. For the moment, we check | ||
| 1616 | `composition' and `display' property. LAST_PT is the last position | ||
| 1617 | of point. */ | ||
| 1618 | |||
| 1619 | static void | ||
| 1620 | adjust_point_for_property (last_pt) | ||
| 1621 | int last_pt; | ||
| 1622 | { | ||
| 1623 | int start, end; | ||
| 1624 | Lisp_Object val; | ||
| 1625 | int check_composition = 1, check_display = 1; | ||
| 1626 | |||
| 1627 | while (check_composition || check_display) | ||
| 1628 | { | ||
| 1629 | if (check_composition | ||
| 1630 | && PT > BEGV && PT < ZV | ||
| 1631 | && get_property_and_range (PT, Qcomposition, &val, &start, &end, Qnil) | ||
| 1632 | && COMPOSITION_VALID_P (start, end, val) | ||
| 1633 | && start < PT && end > PT | ||
| 1634 | && (last_pt <= start || last_pt >= end)) | ||
| 1635 | { | ||
| 1636 | if (PT < last_pt) | ||
| 1637 | SET_PT (start); | ||
| 1638 | else | ||
| 1639 | SET_PT (end); | ||
| 1640 | check_display = 1; | ||
| 1641 | } | ||
| 1642 | check_composition = 0; | ||
| 1643 | if (check_display | ||
| 1644 | && PT > BEGV && PT < ZV | ||
| 1645 | && get_property_and_range (PT, Qdisplay, &val, &start, &end, Qnil) | ||
| 1646 | && start < PT && end > PT | ||
| 1647 | && (last_pt <= start || last_pt >= end)) | ||
| 1648 | { | ||
| 1649 | if (PT < last_pt) | ||
| 1650 | SET_PT (start); | ||
| 1651 | else | ||
| 1652 | SET_PT (end); | ||
| 1653 | check_composition = 1; | ||
| 1654 | } | ||
| 1655 | check_display = 0; | ||
| 1656 | } | ||
| 1657 | } | ||
| 1658 | |||
| 1587 | /* Subroutine for safe_run_hooks: run the hook HOOK. */ | 1659 | /* Subroutine for safe_run_hooks: run the hook HOOK. */ |
| 1588 | 1660 | ||
| 1589 | static Lisp_Object | 1661 | static Lisp_Object |
| @@ -10085,6 +10157,27 @@ before running the input method. It is nil if there was no message."); | |||
| 10085 | "If non-nil, the function that implements the display of help.\n\ | 10157 | "If non-nil, the function that implements the display of help.\n\ |
| 10086 | It's called with one argument, the help string to display."); | 10158 | It's called with one argument, the help string to display."); |
| 10087 | Vshow_help_function = Qnil; | 10159 | Vshow_help_function = Qnil; |
| 10160 | |||
| 10161 | DEFVAR_LISP ("disable-point-adjustment", &Vdisable_point_adjustment, | ||
| 10162 | "If non-nil, suppress point adjustment after executing a command.\n\ | ||
| 10163 | \n\ | ||
| 10164 | After a command is executed, if point is moved into a region that has\n\ | ||
| 10165 | special properties (e.g. composition, display), we adjust point to\n\ | ||
| 10166 | the boundary of the region. But, several special commands sets this\n\ | ||
| 10167 | variable to non-nil, then we suppress the point adjustment.\n\ | ||
| 10168 | \n\ | ||
| 10169 | This variable is set to nil before reading a command, and is checked\n\ | ||
| 10170 | just after executing the command"); | ||
| 10171 | Vdisable_point_adjustment = Qnil; | ||
| 10172 | |||
| 10173 | DEFVAR_LISP ("global-disable-point-adjustment", | ||
| 10174 | &Vglobal_disable_point_adjustment, | ||
| 10175 | "*If non-nil, always suppress point adjustment.\n\ | ||
| 10176 | \n\ | ||
| 10177 | The default value is nil, in which case, point adjustment are\n\ | ||
| 10178 | suppressed only after special commands that set\n\ | ||
| 10179 | `disable-point-adjustment' (which see) to non-nil."); | ||
| 10180 | Vglobal_disable_point_adjustment = Qnil; | ||
| 10088 | } | 10181 | } |
| 10089 | 10182 | ||
| 10090 | void | 10183 | void |