* Helmut Eller m2k5d0spr6.fsf@common-lisp.net : Wrote on Thu, 25 Sep 2008 08:28:45 +0200:
| * Madhu [2008-09-25 08:00+0200] writes: | |> * 2008-03-13 Helmut Eller heller@common-lisp.net |> | * slime.el (slime-region-for-defun-function): Deleted. |> | (slime-region-for-defun-at-point): Use beginning-of-defun |> | and not beginning-of-sexp. |> |> This breaks multiple use cases when evaluating s-expressions from lisp |> file buffers. | | Which cases?
Heres One case.
#+nil (progn (print 1) (print 2))
Note the progn and each enclosed sexp all begin at column 0
When I place the cursor at some point inside the sexp and do C-M-x (say), I want the correct enclosing sexp to be sent to lisp for evaluation
If I place it within `(print 2)' and do C-M-x I want the expression `(print 2)' to be sent .
If I place it within `(print 1)' and do C-M-x I want the expression `(print 1)' to be sent.
If I place it between the `progn' and (print 1) and do C-M-x I want the whole progn to be evaluated. Instead what gets evaluated is only the last sexp in the progn which is (print 2)
I can come up with a few other cases, but this is the basic problem.
| |> `beginning-of-sexp' is the right thing to use here. What motivated you to |> change this to `beginning-of-defun'?
slime-region-for-defun-at-point does an end-of-defun . The implementation of end-of-defun internally calls beginning-of-defun to figure out the beginning and then goes to the end.
Since we are dealing with sexps, Note that once you go to the end of the sexp via `end-of-defun', beginning-of-sexp will find the beginning of the particular sexpression - whose end was determined by `end-of-defun'.
[This is why beginning-of-sexp is the correct function to call after an end-of-defun]
Calling `beginning-of-defun' again does not find this sexpression that you want to get a hold of but finds something else.
| beginning-of-defun can be customized with beginning-of-defun-function; | beginning-of-sexp can't. I'm using that to find CMUCL's | (declaim (start-block)) forms.
How would I go about customizing it to get the behaviour desired without breaking other uses ?
(Haven't looked yet, Thanks)
-- Madhu