From: Howard Melman <hmelman@gmail.com>
To: 46878@debbugs.gnu.org
Subject: bug#46878: 27.1; lisp-outline-level returns imprecise level number
Date: Tue, 2 Mar 2021 11:35:01 -0500 [thread overview]
Message-ID: <F6E4F24E-80D4-4921-8706-A93563DADB68@gmail.com> (raw)
lisp-outline-level returns a functional but incorrect level
number. Comments beginning with ";;; " should be at level 1
but it returns 5 because they match ";;; [^ \t\n]" and the
current code just returns that length.
The following version returns the right level following the
convention that ;;; are top level comments and each lower
level adds a ;. As in the existing code, lines that match
an autoload tag or begin with ( return level 1000.
This fix would be helpful for code that wants to deal with
headings by level number generically (e.g., display the top
3 heading levels). Other modes like outline, org, texinfo,
and html-mode return a level rooted at 1. Programming modes
are more mixed, but this seems like an easy improvement for
lisp modes.
(defun lisp-outline-level ()
"Lisp mode `outline-level' function."
;; expects outline-regexp is ";;;\\(;* [^ \t\n]\\|###autoload\\)\\|("
;; and point is at the beginning of a matching line
(let ((len (- (match-end 0) (match-beginning 0))))
(cond ((looking-at "(\\|;;;###autoload")
1000)
((looking-at ";;\\(;+\\) ")
(- (match-end 1) (match-beginning 1)))
;; above should match everything but just in case
(t
len))))
In GNU Emacs 27.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95))
of 2020-08-12 built on builder10-14.porkrind.org
Windowing system distributor 'Apple', version 10.3.1894
System Description: Mac OS X 10.15.7
Configured using:
'configure --with-ns '--enable-locallisppath=/Library/Application
Support/Emacs/${version}/site-lisp:/Library/Application
Support/Emacs/site-lisp' --with-modules'
--
Howard
next reply other threads:[~2021-03-02 16:35 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-02 16:35 Howard Melman [this message]
2021-03-02 17:05 ` bug#46878: 27.1; lisp-outline-level returns imprecise level number 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
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=F6E4F24E-80D4-4921-8706-A93563DADB68@gmail.com \
--to=hmelman@gmail.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).