unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#46878: 27.1; lisp-outline-level returns imprecise level number
@ 2021-03-02 16:35 Howard Melman
  2021-03-02 17:05 ` Eli Zaretskii
  2021-03-02 19:36 ` Juri Linkov
  0 siblings, 2 replies; 18+ messages in thread
From: Howard Melman @ 2021-03-02 16:35 UTC (permalink / raw)
  To: 46878

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





^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2021-05-18 23:38 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).