aboutsummaryrefslogtreecommitdiffstats
path: root/src/keymap.c
diff options
context:
space:
mode:
authorBill Wohler2014-02-23 18:04:35 -0800
committerBill Wohler2014-02-23 18:04:35 -0800
commit3e93bafb95608467e438ba7f725fd1f020669f8c (patch)
treef2f90109f283e06a18caea3cb2a2623abcfb3a92 /src/keymap.c
parent791c0d7634e44bb92ca85af605be84ff2ae08963 (diff)
parente918e27fdf331e89268fc2c9d7cf838d3ecf7aa7 (diff)
downloademacs-3e93bafb95608467e438ba7f725fd1f020669f8c.tar.gz
emacs-3e93bafb95608467e438ba7f725fd1f020669f8c.zip
Merge from trunk; up to 2014-02-23T23:41:17Z!lekktu@gmail.com.
Diffstat (limited to 'src/keymap.c')
-rw-r--r--src/keymap.c109
1 files changed, 63 insertions, 46 deletions
diff --git a/src/keymap.c b/src/keymap.c
index 922c1703edf..c1416f8a780 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1,5 +1,5 @@
1/* Manipulation of keymaps 1/* Manipulation of keymaps
2 Copyright (C) 1985-1988, 1993-1995, 1998-2013 Free Software 2 Copyright (C) 1985-1988, 1993-1995, 1998-2014 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -56,28 +56,28 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
56#include "keymap.h" 56#include "keymap.h"
57#include "window.h" 57#include "window.h"
58 58
59/* Actually allocate storage for these variables */ 59/* Actually allocate storage for these variables. */
60 60
61Lisp_Object current_global_map; /* Current global keymap */ 61Lisp_Object current_global_map; /* Current global keymap. */
62 62
63Lisp_Object global_map; /* default global key bindings */ 63Lisp_Object global_map; /* Default global key bindings. */
64 64
65Lisp_Object meta_map; /* The keymap used for globally bound 65Lisp_Object meta_map; /* The keymap used for globally bound
66 ESC-prefixed default commands */ 66 ESC-prefixed default commands. */
67 67
68Lisp_Object control_x_map; /* The keymap used for globally bound 68Lisp_Object control_x_map; /* The keymap used for globally bound
69 C-x-prefixed default commands */ 69 C-x-prefixed default commands. */
70 70
71 /* The keymap used by the minibuf for local 71 /* The keymap used by the minibuf for local
72 bindings when spaces are allowed in the 72 bindings when spaces are allowed in the
73 minibuf */ 73 minibuf. */
74 74
75 /* The keymap used by the minibuf for local 75 /* The keymap used by the minibuf for local
76 bindings when spaces are not encouraged 76 bindings when spaces are not encouraged
77 in the minibuf */ 77 in the minibuf. */
78 78
79/* keymap used for minibuffers when doing completion */ 79/* Keymap used for minibuffers when doing completion. */
80/* keymap used for minibuffers when doing completion and require a match */ 80/* Keymap used for minibuffers when doing completion and require a match. */
81static Lisp_Object Qkeymapp, Qnon_ascii; 81static Lisp_Object Qkeymapp, Qnon_ascii;
82Lisp_Object Qkeymap, Qmenu_item, Qremap; 82Lisp_Object Qkeymap, Qmenu_item, Qremap;
83static Lisp_Object QCadvertised_binding; 83static Lisp_Object QCadvertised_binding;
@@ -106,6 +106,12 @@ static void describe_vector (Lisp_Object, Lisp_Object, Lisp_Object,
106 Lisp_Object, Lisp_Object, bool, bool); 106 Lisp_Object, Lisp_Object, bool, bool);
107static void silly_event_symbol_error (Lisp_Object); 107static void silly_event_symbol_error (Lisp_Object);
108static Lisp_Object get_keyelt (Lisp_Object, bool); 108static Lisp_Object get_keyelt (Lisp_Object, bool);
109
110static void
111CHECK_VECTOR_OR_CHAR_TABLE (Lisp_Object x)
112{
113 CHECK_TYPE (VECTORP (x) || CHAR_TABLE_P (x), Qvector_or_char_table_p, x);
114}
109 115
110/* Keymap object support - constructors and predicates. */ 116/* Keymap object support - constructors and predicates. */
111 117
@@ -123,7 +129,7 @@ in case you use it as a menu with `x-popup-menu'. */)
123{ 129{
124 Lisp_Object tail; 130 Lisp_Object tail;
125 if (!NILP (string)) 131 if (!NILP (string))
126 tail = Fcons (string, Qnil); 132 tail = list1 (string);
127 else 133 else
128 tail = Qnil; 134 tail = Qnil;
129 return Fcons (Qkeymap, 135 return Fcons (Qkeymap,
@@ -145,9 +151,9 @@ in case you use it as a menu with `x-popup-menu'. */)
145 { 151 {
146 if (!NILP (Vpurify_flag)) 152 if (!NILP (Vpurify_flag))
147 string = Fpurecopy (string); 153 string = Fpurecopy (string);
148 return Fcons (Qkeymap, Fcons (string, Qnil)); 154 return list2 (Qkeymap, string);
149 } 155 }
150 return Fcons (Qkeymap, Qnil); 156 return list1 (Qkeymap);
151} 157}
152 158
153/* This function is used for installing the standard key bindings 159/* This function is used for installing the standard key bindings
@@ -528,12 +534,12 @@ access_keymap_1 (Lisp_Object map, Lisp_Object idx,
528 retval = val; 534 retval = val;
529 else if (CONSP (retval_tail)) 535 else if (CONSP (retval_tail))
530 { 536 {
531 XSETCDR (retval_tail, Fcons (val, Qnil)); 537 XSETCDR (retval_tail, list1 (val));
532 retval_tail = XCDR (retval_tail); 538 retval_tail = XCDR (retval_tail);
533 } 539 }
534 else 540 else
535 { 541 {
536 retval_tail = Fcons (val, Qnil); 542 retval_tail = list1 (val);
537 retval = Fcons (Qkeymap, Fcons (retval, retval_tail)); 543 retval = Fcons (Qkeymap, Fcons (retval, retval_tail));
538 } 544 }
539 } 545 }
@@ -565,7 +571,8 @@ map_keymap_char_table_item (Lisp_Object args, Lisp_Object key, Lisp_Object val)
565{ 571{
566 if (!NILP (val)) 572 if (!NILP (val))
567 { 573 {
568 map_keymap_function_t fun = XSAVE_POINTER (args, 0); 574 map_keymap_function_t fun
575 = (map_keymap_function_t) XSAVE_FUNCPOINTER (args, 0);
569 /* If the key is a range, make a copy since map_char_table modifies 576 /* If the key is a range, make a copy since map_char_table modifies
570 it in place. */ 577 it in place. */
571 if (CONSP (key)) 578 if (CONSP (key))
@@ -610,7 +617,8 @@ map_keymap_internal (Lisp_Object map,
610 } 617 }
611 else if (CHAR_TABLE_P (binding)) 618 else if (CHAR_TABLE_P (binding))
612 map_char_table (map_keymap_char_table_item, Qnil, binding, 619 map_char_table (map_keymap_char_table_item, Qnil, binding,
613 make_save_value ("ppo", fun, data, args)); 620 make_save_funcptr_ptr_obj ((voidfuncptr) fun, data,
621 args));
614 } 622 }
615 UNGCPRO; 623 UNGCPRO;
616 return tail; 624 return tail;
@@ -1037,9 +1045,9 @@ However, a key definition which is a symbol whose definition is a keymap
1037is not copied. */) 1045is not copied. */)
1038 (Lisp_Object keymap) 1046 (Lisp_Object keymap)
1039{ 1047{
1040 register Lisp_Object copy, tail; 1048 Lisp_Object copy, tail;
1041 keymap = get_keymap (keymap, 1, 0); 1049 keymap = get_keymap (keymap, 1, 0);
1042 copy = tail = Fcons (Qkeymap, Qnil); 1050 copy = tail = list1 (Qkeymap);
1043 keymap = XCDR (keymap); /* Skip the `keymap' symbol. */ 1051 keymap = XCDR (keymap); /* Skip the `keymap' symbol. */
1044 1052
1045 while (CONSP (keymap) && !EQ (XCAR (keymap), Qkeymap)) 1053 while (CONSP (keymap) && !EQ (XCAR (keymap), Qkeymap))
@@ -1065,7 +1073,7 @@ is not copied. */)
1065 else 1073 else
1066 elt = Fcons (XCAR (elt), copy_keymap_item (XCDR (elt))); 1074 elt = Fcons (XCAR (elt), copy_keymap_item (XCDR (elt)));
1067 } 1075 }
1068 XSETCDR (tail, Fcons (elt, Qnil)); 1076 XSETCDR (tail, list1 (elt));
1069 tail = XCDR (tail); 1077 tail = XCDR (tail);
1070 keymap = XCDR (keymap); 1078 keymap = XCDR (keymap);
1071 } 1079 }
@@ -1333,8 +1341,7 @@ append_key (Lisp_Object key_sequence, Lisp_Object key)
1333 Lisp_Object args[2]; 1341 Lisp_Object args[2];
1334 1342
1335 args[0] = key_sequence; 1343 args[0] = key_sequence;
1336 1344 args[1] = list1 (key);
1337 args[1] = Fcons (key, Qnil);
1338 return Fvconcat (2, args); 1345 return Fvconcat (2, args);
1339} 1346}
1340 1347
@@ -1541,7 +1548,7 @@ like in the respective argument of `key-binding'. */)
1541{ 1548{
1542 ptrdiff_t count = SPECPDL_INDEX (); 1549 ptrdiff_t count = SPECPDL_INDEX ();
1543 1550
1544 Lisp_Object keymaps = Fcons (current_global_map, Qnil); 1551 Lisp_Object keymaps = list1 (current_global_map);
1545 1552
1546 /* If a mouse click position is given, our variables are based on 1553 /* If a mouse click position is given, our variables are based on
1547 the buffer clicked on, not the current buffer. So we may have to 1554 the buffer clicked on, not the current buffer. So we may have to
@@ -1554,8 +1561,8 @@ like in the respective argument of `key-binding'. */)
1554 window = POSN_WINDOW (position); 1561 window = POSN_WINDOW (position);
1555 1562
1556 if (WINDOWP (window) 1563 if (WINDOWP (window)
1557 && BUFFERP (XWINDOW (window)->buffer) 1564 && BUFFERP (XWINDOW (window)->contents)
1558 && XBUFFER (XWINDOW (window)->buffer) != current_buffer) 1565 && XBUFFER (XWINDOW (window)->contents) != current_buffer)
1559 { 1566 {
1560 /* Arrange to go back to the original buffer once we're done 1567 /* Arrange to go back to the original buffer once we're done
1561 processing the key sequence. We don't use 1568 processing the key sequence. We don't use
@@ -1565,21 +1572,18 @@ like in the respective argument of `key-binding'. */)
1565 things the same. 1572 things the same.
1566 */ 1573 */
1567 record_unwind_current_buffer (); 1574 record_unwind_current_buffer ();
1568 set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); 1575 set_buffer_internal (XBUFFER (XWINDOW (window)->contents));
1569 } 1576 }
1570 } 1577 }
1571 1578
1572 if (!NILP (olp)) 1579 if (!NILP (olp)
1573 {
1574 if (!NILP (KVAR (current_kboard, Voverriding_terminal_local_map)))
1575 keymaps = Fcons (KVAR (current_kboard, Voverriding_terminal_local_map),
1576 keymaps);
1577 /* The doc said that overriding-terminal-local-map should 1580 /* The doc said that overriding-terminal-local-map should
1578 override overriding-local-map. The code used them both, 1581 override overriding-local-map. The code used them both,
1579 but it seems clearer to use just one. rms, jan 2005. */ 1582 but it seems clearer to use just one. rms, jan 2005. */
1580 else if (!NILP (Voverriding_local_map)) 1583 && NILP (KVAR (current_kboard, Voverriding_terminal_local_map))
1581 keymaps = Fcons (Voverriding_local_map, keymaps); 1584 && !NILP (Voverriding_local_map))
1582 } 1585 keymaps = Fcons (Voverriding_local_map, keymaps);
1586
1583 if (NILP (XCDR (keymaps))) 1587 if (NILP (XCDR (keymaps)))
1584 { 1588 {
1585 Lisp_Object *maps; 1589 Lisp_Object *maps;
@@ -1590,6 +1594,7 @@ like in the respective argument of `key-binding'. */)
1590 Lisp_Object local_map = get_local_map (pt, current_buffer, Qlocal_map); 1594 Lisp_Object local_map = get_local_map (pt, current_buffer, Qlocal_map);
1591 /* This returns nil unless there is a `keymap' property. */ 1595 /* This returns nil unless there is a `keymap' property. */
1592 Lisp_Object keymap = get_local_map (pt, current_buffer, Qkeymap); 1596 Lisp_Object keymap = get_local_map (pt, current_buffer, Qkeymap);
1597 Lisp_Object otlp = KVAR (current_kboard, Voverriding_terminal_local_map);
1593 1598
1594 if (CONSP (position)) 1599 if (CONSP (position))
1595 { 1600 {
@@ -1654,6 +1659,9 @@ like in the respective argument of `key-binding'. */)
1654 1659
1655 if (!NILP (keymap)) 1660 if (!NILP (keymap))
1656 keymaps = Fcons (keymap, keymaps); 1661 keymaps = Fcons (keymap, keymaps);
1662
1663 if (!NILP (olp) && !NILP (otlp))
1664 keymaps = Fcons (otlp, keymaps);
1657 } 1665 }
1658 1666
1659 unbind_to (count, Qnil); 1667 unbind_to (count, Qnil);
@@ -1800,7 +1808,7 @@ bindings; see the description of `lookup-key' for more details about this. */)
1800 if (KEYMAPP (binding)) 1808 if (KEYMAPP (binding))
1801 maps[j++] = Fcons (modes[i], binding); 1809 maps[j++] = Fcons (modes[i], binding);
1802 else if (j == 0) 1810 else if (j == 0)
1803 RETURN_UNGCPRO (Fcons (Fcons (modes[i], binding), Qnil)); 1811 RETURN_UNGCPRO (list1 (Fcons (modes[i], binding)));
1804 } 1812 }
1805 1813
1806 UNGCPRO; 1814 UNGCPRO;
@@ -1942,7 +1950,7 @@ accessible_keymaps_1 (Lisp_Object key, Lisp_Object cmd, Lisp_Object args, void *
1942 else 1950 else
1943 { 1951 {
1944 tem = append_key (thisseq, key); 1952 tem = append_key (thisseq, key);
1945 nconc2 (tail, Fcons (Fcons (tem, cmd), Qnil)); 1953 nconc2 (tail, list1 (Fcons (tem, cmd)));
1946 } 1954 }
1947} 1955}
1948 1956
@@ -1996,13 +2004,13 @@ then the value includes only maps for prefixes that start with PREFIX. */)
1996 } 2004 }
1997 prefix = copy; 2005 prefix = copy;
1998 } 2006 }
1999 maps = Fcons (Fcons (prefix, tem), Qnil); 2007 maps = list1 (Fcons (prefix, tem));
2000 } 2008 }
2001 else 2009 else
2002 return Qnil; 2010 return Qnil;
2003 } 2011 }
2004 else 2012 else
2005 maps = Fcons (Fcons (zero_vector, get_keymap (keymap, 1, 0)), Qnil); 2013 maps = list1 (Fcons (zero_vector, get_keymap (keymap, 1, 0)));
2006 2014
2007 /* For each map in the list maps, 2015 /* For each map in the list maps,
2008 look at any other maps it points to, 2016 look at any other maps it points to,
@@ -2310,7 +2318,6 @@ around function keys and event symbols. */)
2310 return Fcopy_sequence (key); 2318 return Fcopy_sequence (key);
2311 else 2319 else
2312 error ("KEY must be an integer, cons, symbol, or string"); 2320 error ("KEY must be an integer, cons, symbol, or string");
2313 return Qnil;
2314} 2321}
2315 2322
2316static char * 2323static char *
@@ -2611,7 +2618,7 @@ The optional 5th arg NO-REMAP alters how command remapping is handled:
2611 if (CONSP (keymap) && KEYMAPP (XCAR (keymap))) 2618 if (CONSP (keymap) && KEYMAPP (XCAR (keymap)))
2612 keymaps = keymap; 2619 keymaps = keymap;
2613 else if (!NILP (keymap)) 2620 else if (!NILP (keymap))
2614 keymaps = Fcons (keymap, Fcons (current_global_map, Qnil)); 2621 keymaps = list2 (keymap, current_global_map);
2615 else 2622 else
2616 keymaps = Fcurrent_active_maps (Qnil, Qnil); 2623 keymaps = Fcurrent_active_maps (Qnil, Qnil);
2617 2624
@@ -2850,7 +2857,7 @@ You type Translation\n\
2850 2857
2851 insert ("\n", 1); 2858 insert ("\n", 1);
2852 2859
2853 /* Insert calls signal_after_change which may GC. */ 2860 /* Insert calls signal_after_change which may GC. */
2854 translate = SDATA (KVAR (current_kboard, Vkeyboard_translate_table)); 2861 translate = SDATA (KVAR (current_kboard, Vkeyboard_translate_table));
2855 } 2862 }
2856 2863
@@ -2866,6 +2873,14 @@ You type Translation\n\
2866 start1 = Qnil; 2873 start1 = Qnil;
2867 if (!NILP (KVAR (current_kboard, Voverriding_terminal_local_map))) 2874 if (!NILP (KVAR (current_kboard, Voverriding_terminal_local_map)))
2868 start1 = KVAR (current_kboard, Voverriding_terminal_local_map); 2875 start1 = KVAR (current_kboard, Voverriding_terminal_local_map);
2876
2877 if (!NILP (start1))
2878 {
2879 describe_map_tree (start1, 1, shadow, prefix,
2880 "\f\nOverriding Bindings", nomenu, 0, 0, 0);
2881 shadow = Fcons (start1, shadow);
2882 start1 = Qnil;
2883 }
2869 else if (!NILP (Voverriding_local_map)) 2884 else if (!NILP (Voverriding_local_map))
2870 start1 = Voverriding_local_map; 2885 start1 = Voverriding_local_map;
2871 2886
@@ -3234,8 +3249,7 @@ describe_map (Lisp_Object map, Lisp_Object prefix,
3234 for (tail = map; CONSP (tail); tail = XCDR (tail)) 3249 for (tail = map; CONSP (tail); tail = XCDR (tail))
3235 length_needed++; 3250 length_needed++;
3236 3251
3237 vect = ((struct describe_map_elt *) 3252 vect = alloca (length_needed * sizeof *vect);
3238 alloca (sizeof (struct describe_map_elt) * length_needed));
3239 3253
3240 for (tail = map; CONSP (tail); tail = XCDR (tail)) 3254 for (tail = map; CONSP (tail); tail = XCDR (tail))
3241 { 3255 {
@@ -3369,9 +3383,12 @@ describe_map (Lisp_Object map, Lisp_Object prefix,
3369 3383
3370 if (vect[i].shadowed) 3384 if (vect[i].shadowed)
3371 { 3385 {
3372 SET_PT (PT - 1); 3386 ptrdiff_t pt = max (PT - 1, BEG);
3387
3388 SET_PT (pt);
3373 insert_string ("\n (that binding is currently shadowed by another mode)"); 3389 insert_string ("\n (that binding is currently shadowed by another mode)");
3374 SET_PT (PT + 1); 3390 pt = min (PT + 1, Z);
3391 SET_PT (pt);
3375 } 3392 }
3376 } 3393 }
3377 3394
@@ -3736,7 +3753,7 @@ it is provided for major modes to bind locally. */);
3736 Vminor_mode_overriding_map_alist = Qnil; 3753 Vminor_mode_overriding_map_alist = Qnil;
3737 3754
3738 DEFVAR_LISP ("emulation-mode-map-alists", Vemulation_mode_map_alists, 3755 DEFVAR_LISP ("emulation-mode-map-alists", Vemulation_mode_map_alists,
3739 doc: /* List of keymap alists to use for emulations modes. 3756 doc: /* List of keymap alists to use for emulation modes.
3740It is intended for modes or packages using multiple minor-mode keymaps. 3757It is intended for modes or packages using multiple minor-mode keymaps.
3741Each element is a keymap alist just like `minor-mode-map-alist', or a 3758Each element is a keymap alist just like `minor-mode-map-alist', or a
3742symbol with a variable binding which is a keymap alist, and it is used 3759symbol with a variable binding which is a keymap alist, and it is used