summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStefan Kangas <stefankangas@gmail.com>2020-08-19 12:49:39 +0200
committerStefan Kangas <stefan@marxist.se>2020-10-18 17:25:19 +0200
commit647b1c5142d7a029a3124e0177112f16f84d3794 (patch)
treef1a558a2628c8d4b34e59bf22eede0fb21c0675c /src
parentafd31f9e62e551a3f286d1d581a56ef1de33ee94 (diff)
downloademacs-647b1c5142d7a029a3124e0177112f16f84d3794.tar.gz
Translate describe_map to Lisp
Third step in converting substitute-command-keys to Lisp. * lisp/help.el (describe-map): New Lisp version of describe_map. (help--describe-map-compare, help--describe-translation) (help--describe-command, help--shadow-lookup): New helper functions for describe-map. (help--keymaps-seen, help--previous-description-column): New variables. * src/keymap.c (Fkeymap__get_keyelt): New defun to expose get_keyelt to Lisp. (Fdescribe_map_tree_old, Fdescribe_map): Remove defuns. (Fdescribe_vector_internal): New defun to expose describe_vector to Lisp in a way usable by describe-map. (syms_of_keymap): New defsubrs for Fkeymap__get_keyelt and Fdescribe_vector_internal. Remove defsubrs for Fdescribe_map_tree_old and Fdescribe_map. Remove 'help--keymaps-seen'. * test/lisp/help-tests.el (help-tests-substitute-command-keys/shadow): Extend test. (help-tests-substitute-command-keys/test-mode) (help-tests-substitute-command-keys/compare-all) (help-tests-describe-map-tree/no-menu-t) (help-tests-describe-map-tree/no-menu-nil) (help-tests-describe-map-tree/mention-shadow-t) (help-tests-describe-map-tree/mention-shadow-nil) (help-tests-describe-map-tree/partial-t) (help-tests-describe-map-tree/partial-nil): New tests.
Diffstat (limited to 'src')
-rw-r--r--src/keymap.c99
1 files changed, 41 insertions, 58 deletions
diff --git a/src/keymap.c b/src/keymap.c
index 704b89eeecc..2076e29b6fb 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -679,6 +679,23 @@ usage: (map-keymap FUNCTION KEYMAP) */)
return Qnil;
}
+DEFUN ("keymap--get-keyelt", Fkeymap__get_keyelt, Skeymap__get_keyelt, 2, 2, 0,
+ doc: /* Given OBJECT which was found in a slot in a keymap,
+trace indirect definitions to get the actual definition of that slot.
+An indirect definition is a list of the form
+(KEYMAP . INDEX), where KEYMAP is a keymap or a symbol defined as one
+and INDEX is the object to look up in KEYMAP to yield the definition.
+
+Also if OBJECT has a menu string as the first element,
+remove that. Also remove a menu help string as second element.
+
+If AUTOLOAD, load autoloadable keymaps
+that are referred to with indirection. */)
+ (Lisp_Object object, Lisp_Object autoload)
+{
+ return get_keyelt (object, NILP (autoload) ? false : true);
+}
+
/* Given OBJECT which was found in a slot in a keymap,
trace indirect definitions to get the actual definition of that slot.
An indirect definition is a list of the form
@@ -2915,37 +2932,6 @@ You type Translation\n\
Any inserted text ends in two newlines (used by `help-make-xrefs'). */
-DEFUN ("describe-map-tree-old", Fdescribe_map_tree_old, Sdescribe_map_tree_old, 1, 8, 0,
- doc: /* This is just temporary. */)
- (Lisp_Object startmap, Lisp_Object partial, Lisp_Object shadow,
- Lisp_Object prefix, Lisp_Object title, Lisp_Object nomenu,
- Lisp_Object transl, Lisp_Object always_title)
-{
- ptrdiff_t count = SPECPDL_INDEX ();
- char *title_string;
-
- if ( !NILP (title) )
- {
- CHECK_STRING (title);
- title_string = SSDATA(title);
- }
- else
- {
- title_string = NULL;
- }
-
- bool b_partial = NILP (partial) ? false : true;
- bool b_nomenu = NILP (nomenu) ? false : true;
- bool b_transl = NILP (transl) ? false : true;
- bool b_always_title = NILP (always_title) ? false : true;
-
- /* specbind (Qstandard_output, Fcurrent_buffer ()); */
- describe_map_tree (startmap, b_partial, shadow, prefix, title_string,
- b_nomenu, b_transl, b_always_title, true);
-
- return unbind_to (count, Qnil);
-}
-
void
describe_map_tree (Lisp_Object startmap, bool partial, Lisp_Object shadow,
Lisp_Object prefix, const char *title, bool nomenu,
@@ -3131,27 +3117,6 @@ describe_map_compare (const void *aa, const void *bb)
return 0;
}
-DEFUN ("describe-map", Fdescribe_map, Sdescribe_map, 1, 7, 0,
- doc: /* This is a temporary definition preparing the transition
-of this function to Lisp. */)
- (Lisp_Object map, Lisp_Object prefix,
- Lisp_Object transl, Lisp_Object partial, Lisp_Object shadow,
- Lisp_Object nomenu, Lisp_Object mention_shadow)
-{
- ptrdiff_t count = SPECPDL_INDEX ();
-
- bool b_transl = NILP(transl) ? false : true;
- bool b_partial = NILP (partial) ? false : true;
- bool b_nomenu = NILP (nomenu) ? false : true;
- bool b_mention_shadow = NILP (mention_shadow) ? false : true;
- describe_map (map, prefix,
- b_transl ? describe_translation : describe_command,
- b_partial, shadow, &Vhelp__keymaps_seen,
- b_nomenu, b_mention_shadow);
-
- return unbind_to (count, Qnil);
-}
-
/* Describe the contents of map MAP, assuming that this map itself is
reached by the sequence of prefix keys PREFIX (a string or vector).
PARTIAL, SHADOW, NOMENU are as in `describe_map_tree' above. */
@@ -3363,6 +3328,28 @@ DESCRIBER is the output function used; nil means use `princ'. */)
return unbind_to (count, Qnil);
}
+DEFUN ("describe-vector-internal", Fdescribe_vector_internal, Sdescribe_vector_internal, 8, 8, 0,
+ doc: /* Insert a description of contents of VECTOR. */)
+ (Lisp_Object vector, Lisp_Object prefix, Lisp_Object transl,
+ Lisp_Object partial, Lisp_Object shadow, Lisp_Object entire_map,
+ Lisp_Object keymap_p, Lisp_Object mention_shadow)
+{
+ ptrdiff_t count = SPECPDL_INDEX ();
+ specbind (Qstandard_output, Fcurrent_buffer ());
+ CHECK_VECTOR_OR_CHAR_TABLE (vector);
+
+ bool b_transl = NILP (transl) ? false : true;
+ bool b_partial = NILP (partial) ? false : true;
+ bool b_keymap_p = NILP (keymap_p) ? false : true;
+ bool b_mention_shadow = NILP (mention_shadow) ? false : true;
+
+ describe_vector (vector, prefix, Qnil,
+ b_transl ? describe_translation : describe_command,
+ b_partial, shadow, entire_map,
+ b_keymap_p, b_mention_shadow);
+ return unbind_to (count, Qnil);
+}
+
/* Insert in the current buffer a description of the contents of VECTOR.
We call ELT_DESCRIBER to insert the description of one value found
in VECTOR.
@@ -3706,10 +3693,6 @@ exists, bindings using keys without modifiers (or only with meta) will
be preferred. */);
Vwhere_is_preferred_modifier = Qnil;
where_is_preferred_modifier = 0;
- DEFVAR_LISP ("help--keymaps-seen", Vhelp__keymaps_seen,
- doc: /* List of seen keymaps.
-This is used for internal purposes only. */);
- Vhelp__keymaps_seen = Qnil;
DEFSYM (Qmenu_bar, "menu-bar");
DEFSYM (Qmode_line, "mode-line");
@@ -3764,9 +3747,9 @@ This is used for internal purposes only. */);
defsubr (&Scurrent_active_maps);
defsubr (&Saccessible_keymaps);
defsubr (&Skey_description);
- defsubr (&Sdescribe_map_tree_old);
- defsubr (&Sdescribe_map);
+ defsubr (&Skeymap__get_keyelt);
defsubr (&Sdescribe_vector);
+ defsubr (&Sdescribe_vector_internal);
defsubr (&Ssingle_key_description);
defsubr (&Stext_char_description);
defsubr (&Swhere_is_internal);