comparison src/keymap.c @ 4023:5e4f918d5d44

(describe_map_tree): When inserting TITLE, mention PREFIX. Insert newline at end, if inserted anything else. (describe_buffer_bindings): Corresponding changes. For minor mode maps, build up a title string, then let describe_map_tree insert it.
author Richard M. Stallman <rms@gnu.org>
date Wed, 07 Jul 1993 18:40:35 +0000
parents 38041a5069a8
children 42faad1466fa
comparison
equal deleted inserted replaced
4022:a3d3d7eef5ce 4023:5e4f918d5d44
1733 shadow = Qnil; 1733 shadow = Qnil;
1734 1734
1735 /* Print the minor mode maps. */ 1735 /* Print the minor mode maps. */
1736 for (i = 0; i < nmaps; i++) 1736 for (i = 0; i < nmaps; i++)
1737 { 1737 {
1738 /* Tht title for a minor mode keymap
1739 is constructed at run time.
1740 We let describe_map_tree do the actual insertion
1741 because it takes care of other features when doing so. */
1742 char *title = (char *) alloca (40 + XSYMBOL (modes[i])->name->size);
1743 char *p = title;
1744
1738 if (XTYPE (modes[i]) == Lisp_Symbol) 1745 if (XTYPE (modes[i]) == Lisp_Symbol)
1739 { 1746 {
1740 insert_char ('`'); 1747 *p++ = '`';
1741 insert_string (XSYMBOL (modes[i])->name->data); 1748 bcopy (XSYMBOL (modes[i])->name->data, p,
1742 insert_char ('\''); 1749 XSYMBOL (modes[i])->name->size);
1750 p += XSYMBOL (modes[i])->name->size;
1751 *p++ = '\'';
1743 } 1752 }
1744 else 1753 else
1745 insert_string ("Strangely Named"); 1754 {
1746 insert_string (" Minor Mode Bindings:\n"); 1755 bcopy ("Strangely Named", p, sizeof ("Strangely Named"));
1747 describe_map_tree (maps[i], 0, shadow, prefix, 0); 1756 p += sizeof ("Strangely Named");
1757 }
1758 bcopy (" Minor Mode Bindings", p, sizeof (" Minor Mode Bindings"));
1759 p += sizeof (" Minor Mode Bindings");
1760 *p = 0;
1761
1762 describe_map_tree (maps[i], 0, shadow, prefix, title);
1748 shadow = Fcons (maps[i], shadow); 1763 shadow = Fcons (maps[i], shadow);
1749 insert_char ('\n');
1750 } 1764 }
1751 } 1765 }
1752 1766
1753 /* Print the (major mode) local map. */ 1767 /* Print the (major mode) local map. */
1754 start1 = XBUFFER (descbuf)->keymap; 1768 start1 = XBUFFER (descbuf)->keymap;
1755 if (!NILP (start1)) 1769 if (!NILP (start1))
1756 { 1770 {
1757 describe_map_tree (start1, 0, shadow, prefix, 1771 describe_map_tree (start1, 0, shadow, prefix,
1758 "Major Mode Bindings:\n"); 1772 "Major Mode Bindings");
1759 shadow = Fcons (start1, shadow); 1773 shadow = Fcons (start1, shadow);
1760 insert_string ("\n");
1761 } 1774 }
1762 1775
1763 describe_map_tree (current_global_map, 0, shadow, prefix, 1776 describe_map_tree (current_global_map, 0, shadow, prefix,
1764 "Global Bindings:\n"); 1777 "Global Bindings");
1765 1778
1766 Fset_buffer (descbuf); 1779 Fset_buffer (descbuf);
1767 return Qnil; 1780 return Qnil;
1768 } 1781 }
1769 1782
1772 If PARTIAL is nonzero, omit certain "uninteresting" commands 1785 If PARTIAL is nonzero, omit certain "uninteresting" commands
1773 (such as `undefined'). 1786 (such as `undefined').
1774 If SHADOW is non-nil, it is a list of maps; 1787 If SHADOW is non-nil, it is a list of maps;
1775 don't mention keys which would be shadowed by any of them. 1788 don't mention keys which would be shadowed by any of them.
1776 PREFIX, if non-nil, says mention only keys that start with PREFIX. 1789 PREFIX, if non-nil, says mention only keys that start with PREFIX.
1777 TITLE, if not 0, is a string to insert at the beginning. */ 1790 TITLE, if not 0, is a string to insert at the beginning.
1791 TITLE should not end with a colon or a newline; we supply that. */
1778 1792
1779 void 1793 void
1780 describe_map_tree (startmap, partial, shadow, prefix, title) 1794 describe_map_tree (startmap, partial, shadow, prefix, title)
1781 Lisp_Object startmap, shadow, prefix; 1795 Lisp_Object startmap, shadow, prefix;
1782 int partial; 1796 int partial;
1783 char *title; 1797 char *title;
1784 { 1798 {
1785 Lisp_Object maps; 1799 Lisp_Object maps;
1786 struct gcpro gcpro1; 1800 struct gcpro gcpro1;
1801 int something = 0;
1787 char *key_heading 1802 char *key_heading
1788 = "\ 1803 = "\
1789 key binding\n\ 1804 key binding\n\
1790 --- -------\n"; 1805 --- -------\n";
1791 1806
1793 GCPRO1 (maps); 1808 GCPRO1 (maps);
1794 1809
1795 if (!NILP (maps)) 1810 if (!NILP (maps))
1796 { 1811 {
1797 if (title) 1812 if (title)
1798 insert_string (title); 1813 {
1814 insert_string (title);
1815 if (!NILP (prefix))
1816 {
1817 insert_string (" Starting With ");
1818 insert1 (Fkey_description (prefix));
1819 }
1820 insert_string (":\n");
1821 }
1799 insert_string (key_heading); 1822 insert_string (key_heading);
1823 something = 1;
1800 } 1824 }
1801 1825
1802 for (; !NILP (maps); maps = Fcdr (maps)) 1826 for (; !NILP (maps); maps = Fcdr (maps))
1803 { 1827 {
1804 register Lisp_Object elt, prefix, sub_shadows, tail; 1828 register Lisp_Object elt, prefix, sub_shadows, tail;
1843 1867
1844 describe_map (Fcdr (elt), Fcar (elt), partial, sub_shadows); 1868 describe_map (Fcdr (elt), Fcar (elt), partial, sub_shadows);
1845 1869
1846 skip: ; 1870 skip: ;
1847 } 1871 }
1872
1873 if (something)
1874 insert_string ("\n");
1848 1875
1849 UNGCPRO; 1876 UNGCPRO;
1850 } 1877 }
1851 1878
1852 static void 1879 static void