unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Gabriel <gabriel376@hotmail.com>
To: 46878@debbugs.gnu.org
Subject: bug#46878: 27.1; lisp-outline-level returns imprecise level number
Date: Sat, 20 Mar 2021 23:23:21 -0300	[thread overview]
Message-ID: <CH2PR01MB587903499B1E1133BB95588B8B669@CH2PR01MB5879.prod.exchangelabs.com> (raw)
In-Reply-To: <87tuplv8he.fsf@mail.linkov.net> (Juri Linkov's message of "Mon,  08 Mar 2021 19:52:13 +0200")

Juri Linkov <juri@linkov.net> writes:

>>> M-x outline-cycle-buffer RET
>>>
>>> It consistently alternates between only two states:
>>>
>>> Show all
>>> All headings
>>>
>>> But after evaluating your version of lisp-outline-level,
>>> it alternates between three states:
>>>
>>> Show all
>>> Top level headings
>>> All headings
>>
>> That is strange.  Is outline-regexp changing?  (I'm not on Emacs 28 so I can't check.)
>
> I don't think that outline-regexp is changing.  But I can't check
> in Emacs 27 because outline-cycle-buffer is only in Emacs 28.

So I checked this "apparent strange behavior" on master branch and it
seems to be working as expected. The commit
5a823a2a0c3eca60dd3939fba67df1bbe5a1b715 (Lars on 24 Nov 2020) added a
new condition ('has-top-level') to 'outline-cycle-buffer' to check,
well, if there is a top level heading, which is used to decide to hide
or not sublevels, in case they exist. For emacs-lisp-mode, it fails to
identify a top-level because 'outline-level' for a line starting with
";;; " returns a number greater than 1, which the code thinks its a
child level:

(when (= (funcall outline-level) 1)
  (setq has-top-level t))

Even though the outline level is used to compare relatively the headings
to decide which ones are parents and which ones are children (level 5 is
parent of level 6 and subsequent levels), there are cases (like the one
above) where it's expected to have an ordered levelling starting from
1. It's more intuitive, and otherwise it's impossible to know what is a
top-level or to set faces according to is level (level 1 with face
outline-1 and so on).

A simpler approach to avoid rewriting the existing functions and regexps
would be to create a new variable called 'outline-level-offset', which
could be used inside 'outline-level' to subtract from the original
value. For example, if today the outline level for ";;; " in emacs-lisp
returns 3, the elisp-mode.el (or lisp.mode.el) could set
'outline-level-offset' to 2, so 3 - 2 = 1, the expected value.

Regards,
Gabriel






  reply	other threads:[~2021-03-21  2:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-02 16:35 bug#46878: 27.1; lisp-outline-level returns imprecise level number Howard Melman
2021-03-02 17:05 ` Eli Zaretskii
2021-03-02 17:48   ` Howard Melman
2021-03-02 19:36 ` Juri Linkov
2021-03-03  0:25   ` Howard Melman
2021-03-03 19:04     ` Juri Linkov
2021-03-03 20:04       ` Howard Melman
2021-03-07 18:45         ` Juri Linkov
2021-03-07 18:57           ` Howard Melman
2021-03-08 17:23             ` Juri Linkov
2021-03-08 17:38               ` Howard Melman
2021-03-08 17:52                 ` Juri Linkov
2021-03-21  2:23                   ` Gabriel [this message]
2021-03-21 20:17                     ` Juri Linkov
2021-03-24  1:34                       ` Howard Melman
2021-05-18  1:12                         ` Howard Melman
2021-05-18 20:36                           ` Juri Linkov
2021-05-18 23:38                             ` Howard Melman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CH2PR01MB587903499B1E1133BB95588B8B669@CH2PR01MB5879.prod.exchangelabs.com \
    --to=gabriel376@hotmail.com \
    --cc=46878@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).