[slime-devel] slime-region-for-defun-function

* 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. `beginning-of-sexp' is the right thing to use here. What motivated you to change this to `beginning-of-defun'? -- Madhu

* 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?
`beginning-of-sexp' is the right thing to use here. What motivated you to change this to `beginning-of-defun'?
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. Helmut.

* 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

Madhu <enometh@meer.net> writes:
* 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
Yeah we all know how Emacs' primitive heuristic for beginning-of-defun is annoying. However, notice that C-M-x is bound to slime-eval-defun, so its failure on the above case is traditionally correct. :-) You're probably looking for C-x C-e which is bound to slime-eval-last-expression. (It however, doesn't do the DEFVAR reevaluation magic.) -T.

* "Tobias C. Rittweiler" <87ej384ndw.fsf@freebits.de> : Wrote on Thu, 25 Sep 2008 10:53:47 +0200: |> Heres One case. |> |> #+nil |> (progn |> (print 1) |> (print 2)) |> |> Note the progn and each enclosed sexp all begin at column 0 | | Yeah we all know how Emacs' primitive heuristic for beginning-of-defun | is annoying. This is irrelevant to my example. | However, notice that C-M-x is bound to slime-eval-defun, | so its failure on the above case is traditionally correct. :-) Assume I am sending C-c C-c if it helps you to understand the issue. | You're probably looking for C-x C-e which is bound to | slime-eval-last-expression. (It however, doesn't do the DEFVAR | reevaluation magic.) No I am looking for M-C-x. -- Madhu

* Madhu [2008-09-25 09:24+0200] writes:
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.
slime-eval-defun selects the same region as eval-defun. If that's not what you expect, then report it as an Emacs bug. Helmut.

* Helmut Eller <m2abdwsd9k.fsf@common-lisp.net> : Wrote on Thu, 25 Sep 2008 12:58:31 +0200: | slime-eval-defun selects the same region as eval-defun. If that's not | what you expect, then report it as an Emacs bug. No , I consider this a slime bug introduced by your commit. -- Madhu
participants (3)
-
Helmut Eller
-
Madhu
-
Tobias C. Rittweiler