From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#46878: 27.1; lisp-outline-level returns imprecise level number Date: Sun, 21 Mar 2021 22:17:39 +0200 Organization: LINKOV.NET Message-ID: <87wnu05k1w.fsf@mail.linkov.net> References: <871rcxuz4h.fsf@mail.linkov.net> <54FD8677-43E1-4806-9F8D-86850CBC3B29@gmail.com> <87mtvkcfr1.fsf@mail.linkov.net> <44DA0D54-D744-41A3-A7A1-D6A45B9536A4@gmail.com> <874khmkgcl.fsf@mail.linkov.net> <6A310565-0A96-416B-B476-EE5D26D72615@gmail.com> <87zgzdd7td.fsf@mail.linkov.net> <87tuplv8he.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10138"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: 46878@debbugs.gnu.org To: Gabriel Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 21 21:46:08 2021 Return-path: Envelope-to: geb-bug-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 1lO4xc-0002TU-AE for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 21 Mar 2021 21:46:08 +0100 Original-Received: from localhost ([::1]:49938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lO4xb-0002eF-C6 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 21 Mar 2021 16:46:07 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39042) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lO4wZ-0002Fp-4U for bug-gnu-emacs@gnu.org; Sun, 21 Mar 2021 16:45:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43997) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lO4wY-00029e-TD for bug-gnu-emacs@gnu.org; Sun, 21 Mar 2021 16:45:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lO4wY-00018T-RM for bug-gnu-emacs@gnu.org; Sun, 21 Mar 2021 16:45:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 21 Mar 2021 20:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46878 X-GNU-PR-Package: emacs Original-Received: via spool by 46878-submit@debbugs.gnu.org id=B46878.16163594424254 (code B ref 46878); Sun, 21 Mar 2021 20:45:02 +0000 Original-Received: (at 46878) by debbugs.gnu.org; 21 Mar 2021 20:44:02 +0000 Original-Received: from localhost ([127.0.0.1]:55539 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lO4vZ-00016Q-TY for submit@debbugs.gnu.org; Sun, 21 Mar 2021 16:44:02 -0400 Original-Received: from relay4-d.mail.gandi.net ([217.70.183.196]:45691) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lO4vX-00015y-Fv for 46878@debbugs.gnu.org; Sun, 21 Mar 2021 16:44:01 -0400 X-Originating-IP: 91.129.107.223 Original-Received: from mail.gandi.net (m91-129-107-223.cust.tele2.ee [91.129.107.223]) (Authenticated sender: juri@linkov.net) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id CDA07E0003; Sun, 21 Mar 2021 20:43:51 +0000 (UTC) In-Reply-To: (Gabriel's message of "Sat, 20 Mar 2021 23:23:21 -0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:202806 Archived-At: > 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). Thanks for the analysis. After replacing the hard-coded 1 with 5 it works as expected in emacs-lisp-mode. > 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. Maybe a better name for a new buffer-local variable would be 'outline-top-level', to make it similar to the internal variable 'has-top-level'. Or maybe better just to apply the patch that Howard sent in the top message of this bug report to change 'outline-level' in emacs-lisp-mode to count from 1.