all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Function `lisp-outline-level' in `emacs-lisp/lisp-mode.el'.
@ 2002-07-10 18:12 Lute Kamstra
       [not found] ` <200207111201.g6BC1UV16952@aztec.santafe.edu>
  0 siblings, 1 reply; 2+ messages in thread
From: Lute Kamstra @ 2002-07-10 18:12 UTC (permalink / raw)


Dear People,

I've been working on a substitute of the outline minor mode, so I
studied the implementation of this minor mode and its interaction with
some major modes.  In `emacs-lisp/lisp-mode.el' (Emacs 21.2),
`outline-regexp' and `outline-level' are set as follows:

  (setq outline-regexp ";;;;* \\|(")
  (setq outline-level 'lisp-outline-level)

The function `lisp-outline-level' is defined as:

  (defun lisp-outline-level ()
    "Lisp mode `outline-level' function."
    (if (looking-at "(")
        1000
      (looking-at outline-regexp)
      (- (match-end 0) (match-beginning 0))))

I'm a bit surprised by this.  It means that comments starting with
four semi-colons are less important then comments starting with three.
This is counter-intuitive to me.  I don't know if there are people
that have a coding style that involves comments that start with more
than three semi-colons, but I doubt that they would deem such comments
subordinate to comments starting with three.  The following definition
of `lisp-outline-level' would fix this problem:

  (defun lisp-outline-level ()
    "Lisp mode `outline-level' function."
    (if (looking-at "(")
        1000
      (looking-at outline-regexp)
      (- 100 (- (match-end 0) (match-beginning 0)))))

However, I do not like the fact that the number returned by the
function does not accurately reflect the level of the header in the
sense that the most important headers in a buffer are not assigned 1
and that there is a large gap in the range of the function.  I would
prefer to give all comments starting with three or more semi-colons
the same level number an define `lisp-outline-level' like:

  (defun lisp-outline-level ()
    "Lisp mode `outline-level' function."
    (if (looking-at "(")
        2
      1))

Regards,

  Lute Kamstra.

-- 
Lute Kamstra  <Lute.Kamstra@cwi.nl>
CWI  department PNA4
Room M233  phone (+31) 20 592 4214

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

* Re: Function `lisp-outline-level' in `emacs-lisp/lisp-mode.el'.
       [not found] ` <200207111201.g6BC1UV16952@aztec.santafe.edu>
@ 2002-07-11 15:17   ` Lute Kamstra
  0 siblings, 0 replies; 2+ messages in thread
From: Lute Kamstra @ 2002-07-11 15:17 UTC (permalink / raw)
  Cc: bug-gnu-emacs

Richard Stallman <rms@gnu.org> writes:

> I don't remember, actually, what people used four semicolons for.

Hmm, the Emacs lisp manual has a section on commenting styles.  This
section suggests that comments starting with three semicolons are
subordinate to comments starting with four semicolons.

However, some browsing through the source code of Emacs learns that
commenting style is not very consistent, even within files.  Some
people do seem to treat four semicolons comments as less important
than three semicolon comments.

Considering this, I suppose it's best to leave `lisp-outline-level'
alone, since this problem can't be solved for everyone and some people
may have come to rely on the current situation.

Sorry to have bothered you with this.

Regards,

  Lute Kamstra.

-- 
Lute Kamstra
CWI  department PNA4

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

end of thread, other threads:[~2002-07-11 15:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-07-10 18:12 Function `lisp-outline-level' in `emacs-lisp/lisp-mode.el' Lute Kamstra
     [not found] ` <200207111201.g6BC1UV16952@aztec.santafe.edu>
2002-07-11 15:17   ` Lute Kamstra

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.