emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fwd: Re: beginning-of-defun]


From: Andreas Roehler
Subject: Re: [Fwd: Re: beginning-of-defun]
Date: Mon, 10 Jul 2006 15:46:02 +0200
User-agent: Thunderbird 1.5.0.4 (X11/20060516)

Thien-Thi Nguyen schrieb:
Andreas Roehler <address@hidden> writes:

`defun' is a special form with a special meaning in emacs-lisp

yes, but "defun" is also in common parlance a "top-level
form".  these two meanings are congruent but not identical.
you have to sort of alternatively squint and relax your ears
to hear the similarity...

If you don't discriminate between termini
top-level-form, function (which is a known name in many
programing languages but not in all) and the special
Emacs Lisp form defun, you will run into confusion when
the difference matters.


Think it's disturbing to introduce a different meaning
employing the same name.

you get used to being disturbed w/ a little practice.

What about to take it as a chance, not being used to?
Certainly a function `beginning-of-top-level-form' is
useful. However, it should be callable separate from
`beginning-of-defun' and vice versa.

here is a (self-testable in the right context ;-) toy:

(global-set-key "\C-\M-a"
 (defun beginning-of-defun-just-defun-really-i-mean-it! ()
   (interactive)
   (let ((beginning-of-defun-function
          (lambda ()
            (search-backward "(defun" (point-min) t))))
     (beginning-of-defun))))

This form will fail, should there be a string "(defun"
somewhere in a docu or other included text before the
real beginning of function.

Also its focus is on the less general form in this context.

Propose a top-down proceeding while re-designing
venerable `beginning-of-defun' function.


beginning-of-top-level-form

beginning-of-form ;; before and under point

beginning-of-function

The latter would - if in Emacs Lisp-mode - be provided with
a spec to indentify the defun-form

 `beginning-of-defun' should work right out of the
box at least in Emacs Lisp. That's easily to be done -
if the need is recognised so far.

it works for my understanding of "defun".  more importantly,
my understanding of "defun" is shared by many people, most
of whom are probably uninclined to add something like the
above function to emacs.

thi


The author of edebug.el at least seems conscious of the
problem. Doesn't seem an accident he named it

edebug-eval-top-level-form

providing just an alias

(defalias 'edebug-defun 'edebug-eval-top-level-form)

Also I read there

(defun edebug-read-top-level-form ()
 (let ((starting-point (point)))
   (end-of-defun)
   (beginning-of-defun)
...

It's not just for fun I entered this
matter. `beginning-of-defun' is buggy - and a lot of
forms which rely on it.


(unless t
 (defun foo ()
   "Explore the right \"(defun-funktion\" "
   (interactive)
   (message "%s" "baz")))
                  ^
M-x beginning-of-defun ==>

(unless t
^  (defun foo ()
   "Explore the right \"(defun-funktion\" "
   (interactive)
   (message "%s" "baz")))


When the [ \t]* as regexp-prefix is set

M-x beginning-of-defun ==>

(unless t
 (defun foo ()
   "Explore the right \"(defun-funktion\" "
   (interactive)
   (message "%s" "baz")))
^

__
Andreas Roehler






reply via email to

[Prev in Thread] Current Thread [Next in Thread]