]> code.delx.au - gnu-emacs/blobdiff - src/keymap.c
(message): Use message2, not message1.
[gnu-emacs] / src / keymap.c
index f3567a8d13b334c961b8cbe04dfd9c93a91b60c2..909645f7e0cf41f8487af882233c2106be5ad3bc 100644 (file)
@@ -18,7 +18,7 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 
-#include "config.h"
+#include <config.h>
 #include <stdio.h>
 #undef NULL
 #include "lisp.h"
@@ -507,6 +507,8 @@ DEFUN ("define-key", Fdefine_key, Sdefine_key, 3, 3, 0,
   "Args KEYMAP, KEY, DEF.  Define key sequence KEY, in KEYMAP, as DEF.\n\
 KEYMAP is a keymap.  KEY is a string or a vector of symbols and characters\n\
 meaning a sequence of keystrokes and events.\n\
+Non-ASCII characters with codes above 127 (such as ISO Latin-1)\n\
+can be included if you use a vector.\n\
 DEF is anything that can be a key's definition:\n\
  nil (means key is undefined in this keymap),\n\
  a command (a Lisp function suitable for interactive calling)\n\
@@ -808,8 +810,8 @@ The binding is probably a symbol with a function definition.\n\
 \n\
 Normally, `key-binding' ignores bindings for t, which act as default\n\
 bindings, used when nothing else in the keymap applies; this makes it\n\
-useable as a general function for probing keymaps.  However, if the\n\
-third optional argument ACCEPT-DEFAULT is non-nil, `key-binding' will\n\
+usable as a general function for probing keymaps.  However, if the\n\
+optional second argument ACCEPT-DEFAULT is non-nil, `key-binding' does\n\
 recognize the default bindings, just as `read-key-sequence' does.")
   (key, accept_default)
      Lisp_Object key;
@@ -913,6 +915,8 @@ DEFUN ("global-set-key", Fglobal_set_key, Sglobal_set_key, 2, 2,
   "Give KEY a global binding as COMMAND.\n\
 COMMAND is a symbol naming an interactively-callable function.\n\
 KEY is a key sequence (a string or vector of characters or event types).\n\
+Non-ASCII characters with codes above 127 (such as ISO Latin-1)\n\
+can be included if you use a vector.\n\
 Note that if KEY has a local binding in the current buffer\n\
 that local binding will continue to shadow any global binding.")
   (keys, function)
@@ -931,6 +935,8 @@ DEFUN ("local-set-key", Flocal_set_key, Slocal_set_key, 2, 2,
   "Give KEY a local binding as COMMAND.\n\
 COMMAND is a symbol naming an interactively-callable function.\n\
 KEY is a key sequence (a string or vector of characters or event types).\n\
+Non-ASCII characters with codes above 127 (such as ISO Latin-1)\n\
+can be included if you use a vector.\n\
 The binding goes in the current buffer's local map,\n\
 which is shared with other buffers in the same major mode.")
   (keys, function)
@@ -1048,7 +1054,9 @@ DEFUN ("accessible-keymaps", Faccessible_keymaps, Saccessible_keymaps,
   "Find all keymaps accessible via prefix characters from KEYMAP.\n\
 Returns a list of elements of the form (KEYS . MAP), where the sequence\n\
 KEYS starting from KEYMAP gets you to MAP.  These elements are ordered\n\
-so that the KEYS increase in length.  The first element is (\"\" . KEYMAP).")
+so that the KEYS increase in length.  The first element is (\"\" . KEYMAP).\n\
+An optional argument PREFIX, if non-nil, should be a key sequence;\n\
+then the value includes only maps for prefixes that start with PREFIX.")
   (startmap, prefix)
      Lisp_Object startmap, prefix;
 {
@@ -1681,6 +1689,7 @@ nominal         alternate\n\
 
   descbuf = XCONS (arg)->car;
   prefix = XCONS (arg)->cdr;
+  shadow = Qnil;
 
   Fset_buffer (Vstandard_output);
 
@@ -1718,9 +1727,6 @@ nominal         alternate\n\
   {
     int i, nmaps;
     Lisp_Object *modes, *maps;
-    Lisp_Object shadow;
-
-    shadow = Qnil;
 
     /* Temporarily switch to descbuf, so that we can get that buffer's
        minor modes correctly.  */
@@ -1728,23 +1734,35 @@ nominal         alternate\n\
     nmaps = current_minor_maps (&modes, &maps);
     Fset_buffer (Vstandard_output);
 
-    shadow = Qnil;
-
     /* Print the minor mode maps.  */
     for (i = 0; i < nmaps; i++)
       {
+       /* Tht title for a minor mode keymap
+          is constructed at run time.
+          We let describe_map_tree do the actual insertion
+          because it takes care of other features when doing so.  */
+       char *title = (char *) alloca (40 + XSYMBOL (modes[i])->name->size);
+       char *p = title;
+
        if (XTYPE (modes[i]) == Lisp_Symbol)
          {
-           insert_char ('`');
-           insert_string (XSYMBOL (modes[i])->name->data);
-           insert_char ('\'');
+           *p++ = '`';
+           bcopy (XSYMBOL (modes[i])->name->data, p,
+                  XSYMBOL (modes[i])->name->size);
+           p += XSYMBOL (modes[i])->name->size;
+           *p++ = '\'';
          }
        else
-         insert_string ("Strangely Named");
-       insert_string (" Minor Mode Bindings:\n");
-       describe_map_tree (maps[i], 0, shadow, prefix, 0);
+         {
+           bcopy ("Strangely Named", p, sizeof ("Strangely Named"));
+           p += sizeof ("Strangely Named");
+         }
+       bcopy (" Minor Mode Bindings", p, sizeof (" Minor Mode Bindings"));
+       p += sizeof (" Minor Mode Bindings");
+       *p = 0;
+
+       describe_map_tree (maps[i], 0, shadow, prefix, title);
        shadow = Fcons (maps[i], shadow);
-       insert_char ('\n');
       }
   }
 
@@ -1753,13 +1771,12 @@ nominal         alternate\n\
   if (!NILP (start1))
     {
       describe_map_tree (start1, 0, shadow, prefix,
-                        "Major Mode Bindings:\n");
+                        "Major Mode Bindings");
       shadow = Fcons (start1, shadow);
-      insert_string ("\n");
     }
 
   describe_map_tree (current_global_map, 0, shadow, prefix,
-                    "Global Bindings:\n");
+                    "Global Bindings");
 
   Fset_buffer (descbuf);
   return Qnil;
@@ -1772,7 +1789,8 @@ nominal         alternate\n\
    If SHADOW is non-nil, it is a list of maps;
     don't mention keys which would be shadowed by any of them.
    PREFIX, if non-nil, says mention only keys that start with PREFIX.
-   TITLE, if not 0, is a string to insert at the beginning.  */
+   TITLE, if not 0, is a string to insert at the beginning.
+   TITLE should not end with a colon or a newline; we supply that.  */
 
 void
 describe_map_tree (startmap, partial, shadow, prefix, title)
@@ -1782,6 +1800,7 @@ describe_map_tree (startmap, partial, shadow, prefix, title)
 {
   Lisp_Object maps;
   struct gcpro gcpro1;
+  int something = 0;
   char *key_heading
     = "\
 key             binding\n\
@@ -1793,8 +1812,17 @@ key             binding\n\
   if (!NILP (maps))
     {
       if (title)
-       insert_string (title);
+       {
+         insert_string (title);
+         if (!NILP (prefix))
+           {
+             insert_string (" Starting With ");
+             insert1 (Fkey_description (prefix));
+           }
+         insert_string (":\n");
+       }
       insert_string (key_heading);
+      something = 1;
     }
 
   for (; !NILP (maps); maps = Fcdr (maps))
@@ -1844,6 +1872,9 @@ key             binding\n\
     skip: ;
     }
 
+  if (something)
+    insert_string ("\n");
+
   UNGCPRO;
 }
 
@@ -2214,14 +2245,14 @@ terminals at any point in a key sequence.\n\
 The read-key-sequence function replaces subsequences bound by\n\
 function-key-map with their bindings.  When the current local and global\n\
 keymaps have no binding for the current key sequence but\n\
-function-key-map binds a suffix of the sequence to a vector,\n\
+function-key-map binds a suffix of the sequence to a vector or string,\n\
 read-key-sequence replaces the matching suffix with its binding, and\n\
 continues with the new sequence.\n\
 \n\
-For example, suppose function-key-map binds `ESC O P' to [pf1].\n\
-Typing `ESC O P' to read-key-sequence would return [pf1].  Typing\n\
-`C-x ESC O P' would return [?\C-x pf1].  If [pf1] were a prefix\n\
-key, typing `ESC O P x' would return [pf1 x].");
+For example, suppose function-key-map binds `ESC O P' to [f1].\n\
+Typing `ESC O P' to read-key-sequence would return [f1].  Typing\n\
+`C-x ESC O P' would return [?\\C-x f1].  If [f1] were a prefix\n\
+key, typing `ESC O P x' would return [f1 x].");
   Vfunction_key_map = Fmake_sparse_keymap (Qnil);
 
   Qsingle_key_description = intern ("single-key-description");