all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: David Kastrup <dak@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: lisp-outline-level.
Date: Sun, 13 Feb 2005 17:37:04 +0100	[thread overview]
Message-ID: <x5r7jkto0f.fsf@lola.goethe.zz> (raw)
In-Reply-To: <87ekfke9hk.fsf@xs4all.nl> (Lute Kamstra's message of "Sun, 13 Feb 2005 16:59:51 +0100")

Lute Kamstra <Lute.Kamstra.lists@xs4all.nl> writes:

> In (Emacs) Lisp mode, outline-regexp is ";;;;* [^ \t\n]\\|(" and
> outline-level is lisp-outline-level:
>
> (defun lisp-outline-level ()
>   "Lisp mode `outline-level' function."
>   (if (looking-at "(\\|;;;###autoload")
>       1000
>     (looking-at outline-regexp)
>     (- (match-end 0) (match-beginning 0))))
>
> This is a bit strange as outline-regexp doesn't match
> ";;;###autoload".

Why is that strange?  outline-regexp is not even consulted when
;###autoload is found, so I don't see how it would come into play
here.

> Shall I commit the patch below?

> *** lisp/emacs-lisp/lisp-mode.el	1 Feb 2005 15:48:50 -0000	1.171
> --- lisp/emacs-lisp/lisp-mode.el	13 Feb 2005 11:03:02 -0000
> ***************
> *** 212,223 ****
>   
>   (defun lisp-outline-level ()
>     "Lisp mode `outline-level' function."
> !   (if (looking-at "(\\|;;;###autoload")
>         1000
> -     (looking-at outline-regexp)
>       (- (match-end 0) (match-beginning 0))))
>   
> - 
> --- 212,221 ----
>   
>   (defun lisp-outline-level ()
>     "Lisp mode `outline-level' function."
> !   (if (eq (following-char) ?\()
>         1000
>       (- (match-end 0) (match-beginning 0))))

The patch is completely nonsensical.  It returns rubbish in almost all
cases since it is the "looking-at" that established match-end and
match-beginning in the first place.

However, the original code also is buggy since it returns nonsense in
case outline-regexp does not match at point.  So one should probably
rather write

        (and (looking-at outline-regexp)
             (- (match-end 0) (match-beginning 0)))

as the last lines.  This will return "nil" instead of a nonsensical
value in case there is no match at point.  I don't know how and where
lisp-outline-level is used, so maybe some other value (1000?) would be
more appropriate than nil.  But returning some random value (which
includes a segmentation violation, by the way) in case that none of
the two looking-at expressions succeeded does not seem like a good
idea in any case.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

  reply	other threads:[~2005-02-13 16:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-13 15:59 lisp-outline-level Lute Kamstra
2005-02-13 16:37 ` David Kastrup [this message]
2005-02-13 17:06   ` lisp-outline-level Lute Kamstra
2005-02-13 17:37     ` lisp-outline-level David Kastrup
2005-02-13 18:13       ` lisp-outline-level Lute Kamstra
2005-02-13 16:56 ` lisp-outline-level Stefan Monnier
2005-02-13 17:35   ` lisp-outline-level Lute Kamstra
2005-02-13 17:48   ` lisp-outline-level David Kastrup
2005-02-13 18:23     ` lisp-outline-level Lute Kamstra
2005-02-13 19:01     ` lisp-outline-level Stefan Monnier
2005-02-15  6:19 ` lisp-outline-level Richard Stallman
2005-02-15  9:30   ` lisp-outline-level Lute Kamstra
2005-02-16  9:32     ` lisp-outline-level Richard Stallman
2005-02-16 10:47       ` lisp-outline-level Lute Kamstra
2005-02-17 23:07         ` lisp-outline-level Richard Stallman

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

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

  git send-email \
    --in-reply-to=x5r7jkto0f.fsf@lola.goethe.zz \
    --to=dak@gnu.org \
    --cc=emacs-devel@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 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.