From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.help Subject: Re: Setting up user defined texinfo headlines using outline-heading-alist Date: Thu, 13 May 2021 23:05:18 +0700 Message-ID: References: <878s4m5mbj.fsf@posteo.net> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4979"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Help Gnu Emacs To: Christopher Dimech Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu May 13 18:12:35 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lhDwx-0001CY-0R for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 13 May 2021 18:12:35 +0200 Original-Received: from localhost ([::1]:53574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lhDww-0002CU-2Z for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 13 May 2021 12:12:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34910) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhDqB-0000LF-CA for help-gnu-emacs@gnu.org; Thu, 13 May 2021 12:05:37 -0400 Original-Received: from mail-ua1-x935.google.com ([2607:f8b0:4864:20::935]:38613) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lhDq7-0005hv-Pv for help-gnu-emacs@gnu.org; Thu, 13 May 2021 12:05:35 -0400 Original-Received: by mail-ua1-x935.google.com with SMTP id k45so1933953uag.5 for ; Thu, 13 May 2021 09:05:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=nRi3eggGtPW8JdcSzacwqIjCstuuIxny1RdUe/9Nle8=; b=c74X7rnKDgHp3LfzplZtRvFjY05KheKqaw8L+aYfL/oOi950KDI/iKPDdPLo1jU90j FSScKgXw5HO+oYIMgUjpr2d+WuC1ozBd4dr7dvzWyHo+/Ef99d18a+HsXZzwATwrqtbi lkJxHpVPQ2iMteX7K5x2fXo7EwFn4WchnZLmi7U3PppEvgsHqS7u006FWo01cpwv3MKX M7y4a8fVAv296aMscD2h1KrwoZfHabGWSq8cdFAQ5fWQB9K3WwYsVjGg3zNJWeU7YUME O6cPHYp/0QBXH3wsnJH/1Wj9FmIgDYkc/Jdi8fM+SNkyozjUIn7DZUyQqrRZuVjYItR8 lnAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=nRi3eggGtPW8JdcSzacwqIjCstuuIxny1RdUe/9Nle8=; b=hYDBfFoaNw7SIS0+K20LSnGhiSu1AZzJh2GHXNUMBceEgtJx+97BAix77p8N1/tfXG Y6qAqR6Q5/R9nQmJPqhujfsQjwVwsn/v/DeUWHPserAoZGFCJkOcb1x9jog8l7Np6YpI BBIzE/9vRSZz0l2TVmaIQWSzxA1aH9iP1UOFhzpW2MQYs9+VF9+Mf4Uw3+UEMzO6+ymq y7IUzm1sX/4O3Y0vFAeBT4oFrumZ/gIBzF8RQgXcX4thK73oHRdioo4YDDlWRInWUyeQ RUAdoU1YdQoOkiVbvfeTJ1CSh2uIYyVO90AAcMYKzyV7vegrGdZiMcJ2xomtO5eK4Sbg LlxA== X-Gm-Message-State: AOAM533MyRHc54jwxHdhjoQGjKbmOZmV8azjZcpnVW0yD1SX9qVC5KLG l8t/R+tkjWZfB1uGgg3BM4FmuazLXy1kr57yILk= X-Google-Smtp-Source: ABdhPJx3Y61+gj9XC5pw86c7SEyfg84j0T6Zxiz9IrM7X2P+ZE4ksrohiexd/NeigvlaKn78jt3HLiRRWEqDAHJYvjQ= X-Received: by 2002:ab0:6497:: with SMTP id p23mr38205336uam.86.1620921929745; Thu, 13 May 2021 09:05:29 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::935; envelope-from=yurivkhan@gmail.com; helo=mail-ua1-x935.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:129752 Archived-At: On Thu, 13 May 2021 at 22:10, Christopher Dimech wrote: > I have followed your suggestion of using a function that sets outline-hea= ding-alist > using texinfo-mode-hook. > > Have included the following setup (see code section), yet I am still gett= ing > > @node uchapter-amcoh > @unnumbered 6 @ Ameliorating Waveform Coherency... > > whenever I hit "C-C @ C-t" (Hide Body). Should I not get @usec and @usu= bsec > showing up as well? Now that you gave a recipe, I was able to reproduce it. I saved your test.texi and put your code into /tmp/20210513/.emacs and started Emacs as =E2=80=9CHOME=3D. emacs test.texi=E2=80=9D. This way, my own confi= g does not affect the reproduction. I pressed C-c @ C-t, and, yes, everything after the first heading got collapsed. So next I pressed C-c @ C-h to see what other commands are available. I spotted C-c @ C-a (outline-show-all) as the way to expand it all back, and C-c @ C-n (outline-next-visible-heading) as a reasonable way to check what Emacs thinks are your headings. And, predictably, starting at the top, it stopped on @unnumbered, and then at the bottom of the buffer. Which means it does not detect @usec as a heading. Next, I went to read the docstring on outline-next-visible-heading. And it = says: A heading line is one that starts with a =E2=80=98*=E2=80=99 (or that =E2=80=98outline-regexp=E2=80=99 matches). So next let=E2=80=99s see what outline-regexp is: outline-regexp is a variable defined in =E2=80=98outline.el=E2=80=99. Its value is "[*^L]+" [=E2=80=A6] Regular expression to match the beginning of a heading. Any line whose beginning matches this regexp is considered to start a heading. Note that Outline mode only checks this regexp at the start of a line, so the regexp need not (and usually does not) start with =E2=80=98^=E2= =80=99. So let=E2=80=99s change your hook function to set that: (defun instate-texinfo-hdlevels () (setq-local outline-heading-alist texinfo-hdlevels) (setq-local outline-regexp (concat (regexp-opt (mapcar 'car texinfo-hdlevels)) "\\>"= ))) Now I press C-M-x within the above source to update the function definition, switch to test.texi, and press M-x normal-mode RET to reapply the major mode, which reruns all its hooks, which sets the variables as needed. Now, C-c @ C-n from the top goes through @unnumbered, @usec, @usec, @usubsec, @usec, @usubsec, bottom; and C-c @ C-t leaves all custom headings visible: @node uchapter-amcoh @unnumbered 6 @ Ameliorating Waveform Coherency... @usec{@value{seclb}, Abductive Reasoning}... @usec{@value{seclb}, Parsimony over Complexity}... @usubsec{@value{seclb}, The Claerbout Conjecture}... @usec{@value{seclb}, Correlograms in Helioseismology}... @usubsec{@value{seclb}, Solar Magnetic Cycle and the Interface Dynamo}.= .. Now I save the modified .emacs and restart this Emacs instance to see if my solution works when applied from the init file. It does, so I am confident enough to post it. Next you might want to read the full docstring for outline-regexp, as it tells you the recommended way to set it so that it travels with your file rather than lives in your personal configuration. You might also see if setting outline-heading alist the same way works.