After finding myself spending a while trying to re-create one of the features [0] of the el sphinx domain used in flycheck, I decided to try just converting the docs to use that sphinx extension. As I remarked in 2018 [1], there doesn't seem to be a distributed version of this sphinx extension. It also seems like the use-case in notmuch is a bit different in terms of what we want to put in the index, but perhaps someone better at sphinx than I could do those customizations without modifying the extension (as this series does). Overall I think the quality of the resulting HTML documentation is quite nice. The change in the info documentation is less clear. This may also be tweakable, but in the first version the info docs seem more verbose than necessary (e.g. writing "Key Binding" everywhere) On the other hand, if it encourages people (e.g. me) to document things, then it's probably a win overall. [0]: documenting both a keybinding and a function name with the same directive, with nice index entries. [1]: id:20180521200856.17103-1-david@tethera.net
This corresponds to flycheck commit 1702d2db3d8ba9bcb9b2bf810e791e907fcc3adc, which is apparently the last time this file was modified (2018). Embedding seems defensible since the file is evidently not changing that much, and we need to change some labels to make it fit with the not-just-emacs nature of notmuch docs. --- doc/conf.py | 4 +- doc/elisp.py | 433 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 436 insertions(+), 1 deletion(-) create mode 100644 doc/elisp.py diff --git a/doc/conf.py b/doc/conf.py index 11896b50..503255b5 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -3,8 +3,10 @@ import sys import os +from pathlib import Path +sys.path.append(str(Path(__file__).parent)) -extensions = [ 'sphinx.ext.autodoc' ] +extensions = [ 'sphinx.ext.autodoc', 'elisp' ] # The suffix of source filenames. source_suffix = '.rst' diff --git a/doc/elisp.py b/doc/elisp.py new file mode 100644 index 00000000..1a96b12a --- /dev/null +++ b/doc/elisp.py @@ -0,0 +1,433 @@ +# Copyright (C) 2016 Sebastian Wiesner and Flycheck contributors + +# This file is not part of GNU Emacs. + +# This program is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation, either version 3 of the License, or (at your option) any later +# version. + +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. + +# You should have received a copy of the GNU General Public License along with +# this program. If not, see <http://www.gnu.org/licenses/>. + + +from collections import namedtuple +from sphinx import addnodes +from sphinx.util import ws_re +from sphinx.roles import XRefRole +from sphinx.domains import Domain, ObjType +from sphinx.util.nodes import make_refnode +from sphinx.directives import ObjectDescription + + +def make_target(cell, name): + """Create a target name from ``cell`` and ``name``. + + ``cell`` is the name of a symbol cell, and ``name`` is a symbol name, both + as strings. + + The target names are used as cross-reference targets for Sphinx. + + """ + return '{cell}-{name}'.format(cell=cell, name=name) + + +def to_mode_name(symbol_name): + """Convert ``symbol_name`` to a mode name. + + Split at ``-`` and titlecase each part. + + """ + return ' '.join(p.title() for p in symbol_name.split('-')) + + +class Cell(namedtuple('Cell', 'objtype docname')): + """A cell in a symbol. + + A cell holds the object type and the document name of the description for + the cell. + + Cell objects are used within symbol entries in the domain data. + + """ + + pass + + +class KeySequence(namedtuple('KeySequence', 'keys')): + """A key sequence.""" + + PREFIX_KEYS = {'C-u'} + PREFIX_KEYS.update('M-{}'.format(n) for n in range(10)) + + @classmethod + def fromstring(cls, s): + return cls(s.split()) + + @property + def command_name(self): + """The command name in this key sequence. + + Return ``None`` for key sequences that are no command invocations with + ``M-x``. + + """ + try: + return self.keys[self.keys.index('M-x') + 1] + except ValueError: + return None + + @property + def has_prefix(self): + """Whether this key sequence has a prefix.""" + return self.keys[0] in self.PREFIX_KEYS + + def __str__(self): + return ' '.join(self.keys) + + +class EmacsLispSymbol(ObjectDescription): + """An abstract base class for directives documenting symbols. + + Provide target and index generation and registration of documented symbols + within the domain data. + + Deriving classes must have a ``cell`` attribute which refers to the cell + the documentation goes in, and a ``label`` attribute which provides a + human-readable name for what is documented, used in the index entry. + + """ + + cell_for_objtype = { + 'defcustom': 'variable', + 'defconst': 'variable', + 'defvar': 'variable', + 'defface': 'face' + } + + @property + def cell(self): + """The cell in which to store symbol metadata.""" + return self.cell_for_objtype[self.objtype] + + @property + def label(self): + """The label for the documented object type.""" + return self.objtype + + def handle_signature(self, signature, signode): + """Create nodes in ``signode`` for the ``signature``. + + ``signode`` is a docutils node to which to add the nodes, and + ``signature`` is the symbol name. + + Add the object type label before the symbol name and return + ``signature``. + + """ + label = self.label + ' ' + signode += addnodes.desc_annotation(label, label) + signode += addnodes.desc_name(signature, signature) + return signature + + def _add_index(self, name, target): + index_text = '{name}; {label}'.format( + name=name, label=self.label) + self.indexnode['entries'].append( + ('pair', index_text, target, '', None)) + + def _add_target(self, name, sig, signode): + target = make_target(self.cell, name) + if target not in self.state.document.ids: + signode['names'].append(name) + signode['ids'].append(target) + signode['first'] = (not self.names) + self.state.document.note_explicit_target(signode) + + obarray = self.env.domaindata['el']['obarray'] + symbol = obarray.setdefault(name, {}) + if self.cell in symbol: + self.state_machine.reporter.warning( + 'duplicate description of %s %s, ' % (self.objtype, name) + + 'other instance in ' + + self.env.doc2path(symbol[self.cell].docname), + line=self.lineno) + symbol[self.cell] = Cell(self.objtype, self.env.docname) + + return target + + def add_target_and_index(self, name, sig, signode): + target = self._add_target(name, sig, signode) + self._add_index(name, target) + + +class EmacsLispMinorMode(EmacsLispSymbol): + cell = 'function' + label = 'Minor Mode' + + def handle_signature(self, signature, signode): + """Create nodes in ``signode`` for the ``signature``. + + ``signode`` is a docutils node to which to add the nodes, and + ``signature`` is the symbol name. + + Add the object type label before the symbol name and return + ``signature``. + + """ + label = self.label + ' ' + signode += addnodes.desc_annotation(label, label) + signode += addnodes.desc_name(signature, to_mode_name(signature)) + return signature + + def _add_index(self, name, target): + return super()._add_index(to_mode_name(name), target) + + +class EmacsLispFunction(EmacsLispSymbol): + """A directive to document Emacs Lisp functions.""" + + cell_for_objtype = { + 'defun': 'function', + 'defmacro': 'function' + } + + def handle_signature(self, signature, signode): + function_name, *args = ws_re.split(signature) + label = self.label + ' ' + signode += addnodes.desc_annotation(label, label) + signode += addnodes.desc_name(function_name, function_name) + for arg in args: + is_keyword = arg.startswith('&') + node = (addnodes.desc_annotation + if is_keyword + else addnodes.desc_addname) + signode += node(' ' + arg, ' ' + arg) + + return function_name + + +class EmacsLispKey(ObjectDescription): + """A directive to document interactive commands via their bindings.""" + + label = 'Interactive command' + + def handle_signature(self, signature, signode): + """Create nodes to ``signode`` for ``signature``. + + ``signode`` is a docutils node to which to add the nodes, and + ``signature`` is the symbol name. + """ + key_sequence = KeySequence.fromstring(signature) + signode += addnodes.desc_name(signature, str(key_sequence)) + return str(key_sequence) + + def _add_command_target_and_index(self, name, sig, signode): + target_name = make_target('function', name) + if target_name not in self.state.document.ids: + signode['names'].append(name) + signode['ids'].append(target_name) + self.state.document.note_explicit_target(signode) + + obarray = self.env.domaindata['el']['obarray'] + symbol = obarray.setdefault(name, {}) + if 'function' in symbol: + self.state_machine.reporter.warning( + 'duplicate description of %s %s, ' % (self.objtype, name) + + 'other instance in ' + + self.env.doc2path(symbol['function'].docname), + line=self.lineno) + symbol['function'] = Cell(self.objtype, self.env.docname) + + index_text = '{name}; {label}'.format(name=name, label=self.label) + self.indexnode['entries'].append( + ('pair', index_text, target_name, '', None)) + + def _add_binding_target_and_index(self, binding, sig, signode): + reftarget = make_target('key', binding) + + if reftarget not in self.state.document.ids: + signode['names'].append(reftarget) + signode['ids'].append(reftarget) + signode['first'] = (not self.names) + self.state.document.note_explicit_target(signode) + + keymap = self.env.domaindata['el']['keymap'] + if binding in keymap: + self.state_machine.reporter.warning( + 'duplicate description of binding %s, ' % binding + + 'other instance in ' + + self.env.doc2path(keymap[binding]), + line=self.lineno) + keymap[binding] = self.env.docname + + index_text = '{name}; key binding'.format(name=binding) + self.indexnode['entries'].append( + ('pair', index_text, reftarget, '', None)) + + def add_target_and_index(self, name, sig, signode): + # If unprefixed M-x command index as function and not as key binding + sequence = KeySequence.fromstring(name) + if sequence.command_name and not sequence.has_prefix: + self._add_command_target_and_index(sequence.command_name, + sig, signode) + else: + self._add_binding_target_and_index(name, sig, signode) + + +class XRefModeRole(XRefRole): + """A role to cross-reference a minor mode. + + Like a normal cross-reference role but appends ``-mode`` to the reference + target and title-cases the symbol name like Emacs does when referring to + modes. + + """ + + fix_parens = False + lowercase = False + + def process_link(self, env, refnode, has_explicit_title, title, target): + refnode['reftype'] = 'minor-mode' + target = target + '-mode' + return (title if has_explicit_title else to_mode_name(target), target) + + +class EmacsLispDomain(Domain): + """A domain to document Emacs Lisp code.""" + + name = 'el' + label = 'Emacs Lisp' + + object_types = { + # TODO: Set search prio for object types + # Types for user-facing options and commands + 'minor-mode': ObjType('minor-mode', 'function', 'mode', + cell='function'), + 'define-key': ObjType('key binding', cell='interactive'), + 'defcustom': ObjType('defcustom', 'defcustom', cell='variable'), + 'defface': ObjType('defface', 'defface', cell='face'), + # Object types for code + 'defun': ObjType('defun', 'defun', cell='function'), + 'defmacro': ObjType('defmacro', 'defmacro', cell='function'), + 'defvar': ObjType('defvar', 'defvar', cell='variable'), + 'defconst': ObjType('defconst', 'defconst', cell='variable') + } + directives = { + 'minor-mode': EmacsLispMinorMode, + 'define-key': EmacsLispKey, + 'defcustom': EmacsLispSymbol, + 'defvar': EmacsLispSymbol, + 'defconst': EmacsLispSymbol, + 'defface': EmacsLispSymbol, + 'defun': EmacsLispFunction, + 'defmacro': EmacsLispFunction + } + roles = { + 'mode': XRefModeRole(), + 'defvar': XRefRole(), + 'defconst': XRefRole(), + 'defcustom': XRefRole(), + 'defface': XRefRole(), + 'defun': XRefRole(), + 'defmacro': XRefRole() + } + + data_version = 1 + initial_data = { + # Our domain data attempts to somewhat mirror the semantics of Emacs + # Lisp, so we have an obarray which holds symbols which in turn have + # function, variable, face, etc. cells, and a keymap which holds the + # documentation for key bindings. + 'obarray': {}, + 'keymap': {} + } + + def clear_doc(self, docname): + """Clear all cells documented ``docname``.""" + for symbol in self.data['obarray'].values(): + for cell in list(symbol.keys()): + if docname == symbol[cell].docname: + del symbol[cell] + for binding in list(self.data['keymap']): + if self.data['keymap'][binding] == docname: + del self.data['keymap'][binding] + + def resolve_xref(self, env, fromdocname, builder, + objtype, target, node, contnode): + """Resolve a cross reference to ``target``.""" + if objtype == 'key': + todocname = self.data['keymap'].get(target) + if not todocname: + return None + reftarget = make_target('key', target) + else: + cell = self.object_types[objtype].attrs['cell'] + symbol = self.data['obarray'].get(target, {}) + if cell not in symbol: + return None + reftarget = make_target(cell, target) + todocname = symbol[cell].docname + + return make_refnode(builder, fromdocname, todocname, + reftarget, contnode, target) + + def resolve_any_xref(self, env, fromdocname, builder, + target, node, contnode): + """Return all possible cross references for ``target``.""" + nodes = ((objtype, self.resolve_xref(env, fromdocname, builder, + objtype, target, node, contnode)) + for objtype in ['key', 'defun', 'defvar', 'defface']) + return [('el:{}'.format(objtype), node) for (objtype, node) in nodes + if node is not None] + + def merge_warn_duplicate(self, objname, our_docname, their_docname): + self.env.warn( + their_docname, + "Duplicate declaration: '{}' also defined in '{}'.\n".format( + objname, their_docname)) + + def merge_keymapdata(self, docnames, our_keymap, their_keymap): + for key, docname in their_keymap.items(): + if docname in docnames: + if key in our_keymap: + our_docname = our_keymap[key] + self.merge_warn_duplicate(key, our_docname, docname) + else: + our_keymap[key] = docname + + def merge_obarraydata(self, docnames, our_obarray, their_obarray): + for objname, their_cells in their_obarray.items(): + our_cells = our_obarray.setdefault(objname, dict()) + for cellname, their_cell in their_cells.items(): + if their_cell.docname in docnames: + our_cell = our_cells.get(cellname) + if our_cell: + self.merge_warn_duplicate(objname, our_cell.docname, + their_cell.docname) + else: + our_cells[cellname] = their_cell + + def merge_domaindata(self, docnames, otherdata): + self.merge_keymapdata(docnames, self.data['keymap'], + otherdata['keymap']) + self.merge_obarraydata(docnames, self.data['obarray'], + otherdata['obarray']) + + def get_objects(self): + """Get all documented symbols for use in the search index.""" + for name, symbol in self.data['obarray'].items(): + for cellname, cell in symbol.items(): + yield (name, name, cell.objtype, cell.docname, + make_target(cellname, name), + self.object_types[cell.objtype].attrs['searchprio']) + + +def setup(app): + app.add_domain(EmacsLispDomain) + return {'version': '0.1', 'parallel_read_safe': True} -- 2.35.2
In the notmuch doc index it is important to be clear which parts are Emacs related. --- doc/elisp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/elisp.py b/doc/elisp.py index 1a96b12a..642ea9ae 100644 --- a/doc/elisp.py +++ b/doc/elisp.py @@ -215,7 +215,7 @@ class EmacsLispFunction(EmacsLispSymbol): class EmacsLispKey(ObjectDescription): """A directive to document interactive commands via their bindings.""" - label = 'Interactive command' + label = 'Emacs command' def handle_signature(self, signature, signode): """Create nodes to ``signode`` for ``signature``. @@ -266,7 +266,7 @@ class EmacsLispKey(ObjectDescription): line=self.lineno) keymap[binding] = self.env.docname - index_text = '{name}; key binding'.format(name=binding) + index_text = '{name}; Emacs key binding'.format(name=binding) self.indexnode['entries'].append( ('pair', index_text, reftarget, '', None)) -- 2.35.2
This makes the generate info files somewhat less verbose, so that they say e.g. "Key Binding" instead of "Emacs Key Binding" --- doc/elisp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/elisp.py b/doc/elisp.py index 642ea9ae..b8b4931b 100644 --- a/doc/elisp.py +++ b/doc/elisp.py @@ -302,7 +302,7 @@ class EmacsLispDomain(Domain): """A domain to document Emacs Lisp code.""" name = 'el' - label = 'Emacs Lisp' + label = '' object_types = { # TODO: Set search prio for object types -- 2.35.2
A more verbose category is needed for the index, but not the description in the manual. --- doc/elisp.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/doc/elisp.py b/doc/elisp.py index b8b4931b..1b0392e6 100644 --- a/doc/elisp.py +++ b/doc/elisp.py @@ -110,6 +110,13 @@ class EmacsLispSymbol(ObjectDescription): 'defface': 'face' } + category_for_objtype = { + 'defcustom': 'Emacs variable (customizable)', + 'defconst': 'Emacs constant', + 'defvar': 'Emacs variable', + 'defface': 'Emacs face' + } + @property def cell(self): """The cell in which to store symbol metadata.""" @@ -120,6 +127,11 @@ class EmacsLispSymbol(ObjectDescription): """The label for the documented object type.""" return self.objtype + @property + def category(self): + """Index category""" + return self.category_for_objtype[self.objtype] + def handle_signature(self, signature, signode): """Create nodes in ``signode`` for the ``signature``. @@ -137,7 +149,7 @@ class EmacsLispSymbol(ObjectDescription): def _add_index(self, name, target): index_text = '{name}; {label}'.format( - name=name, label=self.label) + name=name, label=self.category) self.indexnode['entries'].append( ('pair', index_text, target, '', None)) -- 2.35.2
This allows us to eliminate the ad-hoc emacscmd directive / role, and improve indexing. doc/emacs: convert remaining uses of emacscmd to define-key This allows us to remove the no-longer used object type. --- doc/conf.py | 5 ----- doc/notmuch-emacs.rst | 14 ++++++++------ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 503255b5..0b7b8af5 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -228,8 +228,3 @@ def setup(app): indextemplate='pair: Emacs variable; %s', ref_nodeclass=docutils.nodes.generated, objname='Emacs variable') - app.add_object_type('emacscmd','emacscmd', - indextemplate='pair: Emacs command; %s', - ref_nodeclass=docutils.nodes.generated, - objname='Emacs command') - diff --git a/doc/notmuch-emacs.rst b/doc/notmuch-emacs.rst index e69bd23d..b7656fe1 100644 --- a/doc/notmuch-emacs.rst +++ b/doc/notmuch-emacs.rst @@ -543,7 +543,7 @@ following key bindings: ``k`` Tagging operations using :ref:`notmuch-tag-jump` -``C-_`` ``C-/`` ``C-x u``: Undo previous tagging operation using :ref:`notmuch-tag-undo` +``C-_`` ``C-/`` ``C-x u``: Undo previous tagging operation using :any:`notmuch-tag-undo` .. _notmuch-jump: @@ -574,7 +574,6 @@ operations specified in ``notmuch-tagging-keys``; i.e. each |docstring::notmuch-tagging-keys| -.. _notmuch-tag-undo: notmuch-tag-undo ---------------- @@ -582,17 +581,20 @@ notmuch-tag-undo Each notmuch buffer supporting tagging operations (i.e buffers in :any:`notmuch-show`, :any:`notmuch-search`, :any:`notmuch-tree`, and :any:`notmuch-unthreaded` mode) keeps a local stack of tagging -operations. These can be undone via :emacscmd:`notmuch-tag-undo`. By default +operations. These can be undone via :any:`notmuch-tag-undo`. By default this is bound to the usual Emacs keys for undo. -.. emacscmd:: notmuch-tag-undo +.. el:define-key:: C-_ + C-/ + C-x u + M-x notmuch-tag-undo |docstring::notmuch-tag-undo| Buffer navigation ================= -.. emacscmd:: notmuch-cycle-notmuch-buffers +.. el:define-key:: M-x notmuch-cycle-notmuch-buffers |docstring::notmuch-cycle-notmuch-buffers| @@ -604,7 +606,7 @@ Configuration Importing Mail -------------- -.. emacscmd:: notmuch-poll +.. el:define-key:: M-x notmuch-poll |docstring::notmuch-poll| -- 2.35.2
Mainly this allows dropping the ad-hoc directive emacsvar --- doc/conf.py | 4 --- doc/notmuch-emacs.rst | 74 +++++++++++++++++++++---------------------- 2 files changed, 37 insertions(+), 41 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 0b7b8af5..e23cb7d7 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -224,7 +224,3 @@ def setup(app): indextemplate='pair: configuration item; %s', ref_nodeclass=docutils.nodes.generated, objname='config item' ) - app.add_object_type('emacsvar','emacsvar', - indextemplate='pair: Emacs variable; %s', - ref_nodeclass=docutils.nodes.generated, - objname='Emacs variable') diff --git a/doc/notmuch-emacs.rst b/doc/notmuch-emacs.rst index b7656fe1..a3ca5331 100644 --- a/doc/notmuch-emacs.rst +++ b/doc/notmuch-emacs.rst @@ -50,19 +50,19 @@ a mouse or by positioning the cursor and pressing ``<return>`` You can change the overall appearance of the notmuch-hello screen by customizing the variables -.. emacsvar:: notmuch-hello-sections +.. el:defcustom:: notmuch-hello-sections |docstring::notmuch-hello-sections| -.. emacsvar:: notmuch-hello-thousands-separator +.. el:defcustom:: notmuch-hello-thousands-separator |docstring::notmuch-hello-thousands-separator| -.. emacsvar:: notmuch-show-logo +.. el:defcustom:: notmuch-show-logo |docstring::notmuch-show-logo| -.. emacsvar:: notmuch-column-control +.. el:defcustom:: notmuch-column-control Controls the number of columns for saved searches/tags in notmuch view. @@ -94,7 +94,7 @@ customizing the variables - if you don't want to worry about all of this nonsense, leave this set to `t`. -.. emacsvar:: notmuch-show-empty-saved-searches +.. el:defcustom:: notmuch-show-empty-saved-searches |docstring::notmuch-show-empty-saved-searches| @@ -144,12 +144,12 @@ The saved searches default to various common searches such as ``tag:inbox`` to access the inbox and ``tag:unread`` to access all unread mail, but there are several options for customization: -.. emacsvar:: notmuch-saved-searches +.. el:defcustom:: notmuch-saved-searches The list of saved searches, including names, queries, and additional per-query options. -.. emacsvar:: notmuch-saved-search-sort-function +.. el:defcustom:: notmuch-saved-search-sort-function This variable controls how saved searches should be sorted. A value of ``nil`` displays the saved searches in the order they are stored @@ -163,7 +163,7 @@ The search box lets the user enter a Notmuch query. See section syntax. A history of recent searches is also displayed by default. The latter is controlled by the variable `notmuch-hello-recent-searches-max`. -.. emacsvar:: notmuch-hello-recent-searches-max +.. el:defcustom:: notmuch-hello-recent-searches-max |docstring::notmuch-hello-recent-searches-max| @@ -174,12 +174,12 @@ One special kind of saved search provided by default is for each individual tag defined in the database. This can be controlled via the following variables. -.. emacsvar:: notmuch-hello-tag-list-make-query +.. el:defcustom:: notmuch-hello-tag-list-make-query Control how to construct a search (“virtual folder”) from a given tag. -.. emacsvar:: notmuch-hello-hide-tags +.. el:defcustom:: notmuch-hello-hide-tags Which tags not to display at all. @@ -218,7 +218,7 @@ menu of results that the user can explore further by pressing The presentation of results can be controlled by the following variables. -.. emacsvar:: notmuch-search-result-format +.. el:defcustom:: notmuch-search-result-format |docstring::notmuch-search-result-format| @@ -253,21 +253,21 @@ variables. ("subject" . "%s ") ("tags" . "(%s)"))) - See also :emacsvar:`notmuch-tree-result-format` and - :emacsvar:`notmuch-unthreaded-result-format`. + See also :el:defcustom:`notmuch-tree-result-format` and + :el:defcustom:`notmuch-unthreaded-result-format`. -.. emacsvar:: notmuch-search-oldest-first +.. el:defcustom:: notmuch-search-oldest-first Display the oldest threads at the top of the buffer It is also possible to customize how the name of buffers containing search results is formatted using the following variables: -.. emacsvar:: notmuch-search-buffer-name-format +.. el:defcustom:: notmuch-search-buffer-name-format |docstring::notmuch-search-buffer-name-format| -.. emacsvar:: notmuch-saved-search-buffer-name-format +.. el:defcustom:: notmuch-saved-search-buffer-name-format |docstring::notmuch-saved-search-buffer-name-format| @@ -316,19 +316,19 @@ pressing RET after positioning the cursor on a hidden part. Display of messages can be controlled by the following variables; see also :ref:`show-large`. -.. emacsvar:: notmuch-message-headers +.. el:defcustom:: notmuch-message-headers |docstring::notmuch-message-headers| -.. emacsvar:: notmuch-message-headers-visible +.. el:defcustom:: notmuch-message-headers-visible |docstring::notmuch-message-headers-visible| -.. emacsvar:: notmuch-show-header-line +.. el:defcustom:: notmuch-show-header-line |docstring::notmuch-show-header-line| -.. emacsvar:: notmuch-multipart/alternative-discouraged +.. el:defcustom:: notmuch-multipart/alternative-discouraged Which mime types to hide by default for multipart messages. @@ -356,7 +356,7 @@ Dealing with large messages and threads If you are finding :ref:`notmuch-show` is annoyingly slow displaying large messages, you can customize -:emacsvar:`notmuch-show-max-text-part-size`. If you want to speed up the +:el:defcustom:`notmuch-show-max-text-part-size`. If you want to speed up the display of large threads (with or without large messages), there are several options. First, you can display the same query in one of the other modes. :ref:`notmuch-unthreaded` is the most robust for @@ -364,21 +364,21 @@ extremely large queries, but :ref:`notmuch-tree` is also be faster than :ref:`notmuch-show` in general, since it only renders a single message a time. If you prefer to stay with the rendered thread ("conversation") view of :ref:`notmuch-show`, you can customize the -variables :emacsvar:`notmuch-show-depth-limit`, -:emacsvar:`notmuch-show-height-limit` and -:emacsvar:`notmuch-show-max-text-part-size` to limit the amount of +variables :el:defcustom:`notmuch-show-depth-limit`, +:el:defcustom:`notmuch-show-height-limit` and +:el:defcustom:`notmuch-show-max-text-part-size` to limit the amount of rendering done initially. Note that these limits are implicitly *OR*-ed together, and combinations might have surprising effects. -.. emacsvar:: notmuch-show-depth-limit +.. el:defcustom:: notmuch-show-depth-limit |docstring::notmuch-show-depth-limit| -.. emacsvar:: notmuch-show-height-limit +.. el:defcustom:: notmuch-show-height-limit |docstring::notmuch-show-height-limit| -.. emacsvar:: notmuch-show-max-text-part-size +.. el:defcustom:: notmuch-show-max-text-part-size |docstring::notmuch-show-max-text-part-size| @@ -478,7 +478,7 @@ tags. As is the case with :ref:`notmuch-search`, the presentation of results can be controlled by the variable ``notmuch-search-oldest-first``. -.. emacsvar:: notmuch-tree-result-format +.. el:defcustom:: notmuch-tree-result-format |docstring::notmuch-tree-result-format| @@ -509,8 +509,8 @@ can be controlled by the variable ``notmuch-search-oldest-first``. . " %-54s ") ("tags" . "(%s)"))) - See also :emacsvar:`notmuch-search-result-format` and - :emacsvar:`notmuch-unthreaded-result-format`. + See also :el:defcustom:`notmuch-search-result-format` and + :el:defcustom:`notmuch-unthreaded-result-format`. .. _notmuch-unthreaded: @@ -524,12 +524,12 @@ is presented. Keybindings are the same as :any:`notmuch-tree`. -.. emacsvar:: notmuch-unthreaded-result-format +.. el:defcustom:: notmuch-unthreaded-result-format |docstring::notmuch-unthreaded-result-format| - See also :emacsvar:`notmuch-search-result-format` and - :emacsvar:`notmuch-tree-result-format`. + See also :el:defcustom:`notmuch-search-result-format` and + :el:defcustom:`notmuch-tree-result-format`. Global key bindings =================== @@ -570,7 +570,7 @@ prefix (:kbd:`C-u k`), notmuch displays a menu of the reverses of the operations specified in ``notmuch-tagging-keys``; i.e. each ``+tag`` is replaced by ``-tag`` and vice versa. -.. emacsvar:: notmuch-tagging-keys +.. el:defcustom:: notmuch-tagging-keys |docstring::notmuch-tagging-keys| @@ -610,21 +610,21 @@ Importing Mail |docstring::notmuch-poll| -.. emacsvar:: notmuch-poll-script +.. el:defcustom:: notmuch-poll-script |docstring::notmuch-poll-script| Sending Mail ------------ -.. emacsvar:: mail-user-agent +.. el:defcustom:: mail-user-agent Emacs consults the variable :code:`mail-user-agent` to choose a mail sending package for commands like :code:`report-emacs-bug` and :code:`compose-mail`. To use ``notmuch`` for this, customize this variable to the symbol :code:`notmuch-user-agent`. -.. emacsvar:: message-dont-reply-to-names +.. el:defcustom:: message-dont-reply-to-names When composing mail replies, Emacs's message mode uses the variable :code:`message-dont-reply-to-names` to exclude -- 2.35.2 \r
Add keys to index. Allow indexing of both keys and commands. Use standard typesetting for multiple keybindings. --- doc/notmuch-emacs.rst | 180 ++++++++++++++++++++++++++++++------------ 1 file changed, 129 insertions(+), 51 deletions(-) diff --git a/doc/notmuch-emacs.rst b/doc/notmuch-emacs.rst index a3ca5331..c59d567b 100644 --- a/doc/notmuch-emacs.rst +++ b/doc/notmuch-emacs.rst @@ -101,32 +101,42 @@ customizing the variables notmuch-hello key bindings -------------------------- -``<tab>`` +.. el:define-key:: <tab> + Move to the next widget (button or text entry field) -``<backtab>`` +.. el:define-key:: <backtab> + Move to the previous widget. -``<return>`` +.. el:define-key:: <return> + Activate the current widget. -``g`` ``=`` +.. el:define-key:: g + = + Refresh the buffer; mainly update the counts of messages for various saved searches. -``G`` +.. el:define-key:: G + Import mail, See :ref:`importing` -``m`` +.. el:define-key:: m + Compose a message -``s`` +.. el:define-key:: s + Search the notmuch database using :ref:`notmuch-search` -``v`` +.. el:define-key:: v + Print notmuch version -``q`` +.. el:define-key:: q + Quit .. _saved-searches: @@ -200,19 +210,30 @@ The main purpose of the ``notmuch-search-mode`` buffer is to act as a menu of results that the user can explore further by pressing ``<return>`` on the appropriate line. -``n,C-n,<down>`` +.. el:define-key:: n + C-n + <down> + Move to next line -``p,C-p,<up>`` +.. el:define-key:: + p + C-p + <up> + Move to previous line -``<return>`` +.. el:define-key:: <return> + Open thread on current line in :ref:`notmuch-show` mode -``g`` ``=`` +.. el:define-key:: g + = + Refresh the buffer -``?`` +.. el:define-key:: ? + Display full set of key bindings The presentation of results can be controlled by the following @@ -285,33 +306,43 @@ signatures, already-read messages), are hidden. You can make these parts visible by clicking with the mouse button or by pressing RET after positioning the cursor on a hidden part. -``<space>`` +.. el:define-key:: <space> + Scroll the current message (if necessary), advance to the next message, or advance to the next thread (if already on the last message of a thread). -``c`` +.. el:define-key:: c + :ref:`show-copy` -``N`` +.. el:define-key:: N + Move to next message -``P`` +.. el:define-key:: P + Move to previous message (or start of current message) -``n`` +.. el:define-key:: n + Move to next matching message -``p`` +.. el:define-key:: p + Move to previous matching message -``+,-`` +.. el:define-key:: + + - + Add or remove arbitrary tags from the current message. -``!`` +.. el:define-key:: ! + |docstring::notmuch-show-toggle-elide-non-matching| -``?`` +.. el:define-key:: ? + Display full set of key bindings Display of messages can be controlled by the following variables; see also :ref:`show-large`. @@ -392,44 +423,70 @@ but notmuch also provides some shortcuts. These keys are available in :ref:`notmuch-show`, and :ref:`notmuch-tree`. A subset are available in :ref:`notmuch-search`. -``c F`` ``notmuch-show-stash-filename`` +.. el:define-key:: c F + M-x notmuch-show-stash-filename + |docstring::notmuch-show-stash-filename| -``c G`` ``notmuch-show-stash-git-send-email`` +.. el:define-key:: c G + M-x notmuch-show-stash-git-send-email + |docstring::notmuch-show-stash-git-send-email| -``c I`` ``notmuch-show-stash-message-id-stripped`` +.. el:define-key:: c I + M-x notmuch-show-stash-message-id-stripped + |docstring::notmuch-show-stash-message-id-stripped| -``c L`` ``notmuch-show-stash-mlarchive-link-and-go`` +.. el:define-key:: c L + M-x notmuch-show-stash-mlarchive-link-and-go + |docstring::notmuch-show-stash-mlarchive-link-and-go| -``c T`` ``notmuch-show-stash-tags`` +.. el:define-key:: c T + M-x notmuch-show-stash-tags + |docstring::notmuch-show-stash-tags| -``c c`` ``notmuch-show-stash-cc`` +.. el:define-key:: c c + M-x notmuch-show-stash-cc + |docstring::notmuch-show-stash-cc| -``c d`` ``notmuch-show-stash-date`` +.. el:define-key:: c d + M-x notmuch-show-stash-date + |docstring::notmuch-show-stash-date| -``c f`` ``notmuch-show-stash-from`` +.. el:define-key:: c f + M-x notmuch-show-stash-from + |docstring::notmuch-show-stash-from| -``c i`` ``notmuch-show-stash-message-id`` +.. el:define-key:: c i + M-x notmuch-show-stash-message-id + |docstring::notmuch-show-stash-message-id| -``c l`` ``notmuch-show-stash-mlarchive-link`` +.. el:define-key:: c l + M-x notmuch-show-stash-mlarchive-link + |docstring::notmuch-show-stash-mlarchive-link| -``c s`` ``notmuch-show-stash-subject`` +.. el:define-key:: c s + M-x notmuch-show-stash-subject + |docstring::notmuch-show-stash-subject| -``c t`` ``notmuch-show-stash-to`` +.. el:define-key:: c t + M-x notmuch-show-stash-to + |docstring::notmuch-show-stash-to| -``c ?`` - Show all available copying commands +.. el:define-key:: c ? + M-x notmuch-subkeymap-help + + Show all available copying commands .. _notmuch-tree: @@ -441,38 +498,53 @@ email archives. Each line in the buffer represents a single message giving the relative date, the author, subject, and any tags. -``c`` +.. el:define-key:: c + :ref:`show-copy` -``<return>`` +.. el:define-key:: <return> + Displays that message. -``N`` +.. el:define-key:: N + Move to next message -``P`` +.. el:define-key:: P + Move to previous message -``n`` +.. el:define-key:: n + Move to next matching message -``p`` +.. el:define-key:: p + Move to previous matching message -``o`` ``notmuch-tree-toggle-order`` +.. el:define-key:: o + M-x notmuch-tree-toggle-order + |docstring::notmuch-tree-toggle-order| -``l`` ``notmuch-tree-filter`` +.. el:define-key:: l + M-x notmuch-tree-filter + Filter or LIMIT the current search results based on an additional query string -``t`` ``notmuch-tree-filter-by-tag`` +.. el:define-key:: t + M-x notmuch-tree-filter-by-tag + Filter the current search results based on an additional tag -``g`` ``=`` +.. el:define-key:: g + = + Refresh the buffer -``?`` +.. el:define-key:: ? + Display full set of key bindings As is the case with :ref:`notmuch-search`, the presentation of results @@ -537,13 +609,19 @@ Global key bindings Several features are accessible from most places in notmuch through the following key bindings: -``j`` +.. el:define-key:: j + Jump to saved searches using :ref:`notmuch-jump`. -``k`` +.. el:define-key:: k + Tagging operations using :ref:`notmuch-tag-jump` -``C-_`` ``C-/`` ``C-x u``: Undo previous tagging operation using :any:`notmuch-tag-undo` +.. el:define-key:: C-_ + C-/ + C-x u + + Undo previous tagging operation using :any:`notmuch-tag-undo` .. _notmuch-jump: -- 2.35.2
On Sun, Jul 31 2022, David Bremner wrote: > After finding myself spending a while trying to re-create one of the > features [0] of the el sphinx domain used in flycheck, I decided to try > just converting the docs to use that sphinx extension. > > As I remarked in 2018 [1], there doesn't seem to be a distributed > version of this sphinx extension. It also seems like the use-case in > notmuch is a bit different in terms of what we want to put in the > index, but perhaps someone better at sphinx than I could do those > customizations without modifying the extension (as this series does). > > Overall I think the quality of the resulting HTML documentation is > quite nice. The change in the info documentation is less clear. This > may also be tweakable, but in the first version the info docs seem > more verbose than necessary (e.g. writing "Key Binding" everywhere) On > the other hand, if it encourages people (e.g. me) to document things, > then it's probably a win overall. > > [0]: documenting both a keybinding and a function name with the same > directive, with nice index entries. This series is probably good; at least it does not break software (and if doc quality (or making of it) gets better then good :D) Tomi > > [1]: id:20180521200856.17103-1-david@tethera.net > > > _______________________________________________ > notmuch mailing list -- notmuch@notmuchmail.org > To unsubscribe send an email to notmuch-leave@notmuchmail.org
Tomi Ollila <tomi.ollila@iki.fi> writes:
>
> This series is probably good; at least it does not break software
> (and if doc quality (or making of it) gets better then good :D)
>
> Tomi
Applied to master.
d