GNU bug report logs - #12785
[octave-mod] Changed behaviour of octave-mark-block?

Previous Next

Package: emacs;

Reported by: Mark Hepburn <mark.hepburn <at> gmail.com>

Date: Fri, 2 Nov 2012 07:50:02 UTC

Severity: important

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 12785 in the body.
You can then email your comments to 12785 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#12785; Package emacs. (Fri, 02 Nov 2012 07:50:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Mark Hepburn <mark.hepburn <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 02 Nov 2012 07:50:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Mark Hepburn <mark.hepburn <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [octave-mod] Changed behaviour of octave-mark-block?
Date: Fri, 2 Nov 2012 18:42:28 +1100
[Message part 1 (text/plain, inline)]
Hi all,

I'm wondering if the recent modernisation of octave-mod with emacs24 has
introduced an error; at least, it appears that the behaviour of
octave-mark-block is different.

For example, in the following trivial octave code:

for i=1:n, something; end;

If octave-mark-block is invoked with the cursor anywhere inside the
'for' token, it will fail ("unbalanced parentheses").  The following
situations all fail in the recent version, but succeed in the older
version: |for, f|or, fo|r.

Assuming this is in error I'm not sure how to fix it, I'm sorry.  The form
(and level (null (cadr level)))
seems a bit suspicious as there are no null entries in smie-grammar for
me, so that would be equivalent to just level.

It also looks like backward-up-list (-> up-list) might be incorrect for
similar cursor locations?  (Which may be the root cause I suppose)

Thank you for your time,
Mark.

Emacs  : GNU Emacs 24.1.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.12)
 of 2012-09-23 on batsu, modified by Debian
Package: Emacs version 24.1.1

current state:
==============
(setq
 octave-blink-matching-block t
 octave-block-offset 2
 octave-comment-char 35
 octave-continuation-offset 4
 octave-continuation-string "\\"
 octave-send-echo-input t
 octave-send-line-auto-forward t
 octave-send-show-buffer t
 )
[Message part 2 (text/html, inline)]

Severity set to 'important' from 'normal' Request was from Chong Yidong <cyd <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 17 Nov 2012 07:04:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#12785; Package emacs. (Tue, 04 Dec 2012 22:03:02 GMT) Full text and rfc822 format available.

Message #10 received at 12785 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Mark Hepburn <mark.hepburn <at> gmail.com>
Cc: 12785 <at> debbugs.gnu.org
Subject: Re: bug#12785: [octave-mod] Changed behaviour of octave-mark-block?
Date: Tue, 04 Dec 2012 17:02:22 -0500
> for i=1:n, something; end;

> If octave-mark-block is invoked with the cursor anywhere inside the
> 'for' token, it will fail ("unbalanced parentheses").  The following
> situations all fail in the recent version, but succeed in the older
> version: |for, f|or, fo|r.

For the "|for" case I think the behavior makes sense (it will try to
mark the enclosing block).  But maybe indeed it's an accidental change.

For the "f|or" and "fo|r" cases, indeed the smie primitives assume the
cursor is not within a token, so they get all confused.  Shouldn't be
too hard to fix.

What should be the behavior when point is at "end|"?  Should it mark
this block or the enclosing one?


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#12785; Package emacs. (Tue, 04 Dec 2012 23:24:01 GMT) Full text and rfc822 format available.

Message #13 received at 12785 <at> debbugs.gnu.org (full text, mbox):

From: Mark Hepburn <mark.hepburn <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 12785 <at> debbugs.gnu.org
Subject: Re: bug#12785: [octave-mod] Changed behaviour of octave-mark-block?
Date: Wed, 5 Dec 2012 10:23:22 +1100
[Message part 1 (text/plain, inline)]
Hi,

Thanks for your reply.

Regarding the "end|" case, the old mode wouldn't mark the block, and I feel
that's correct behaviour.  In the "|for" case as I mentioned, the old mode
_did_ mark the block (not the enclosing one), but I agree that marking the
enclosing block is probably preferable and more consistent.

In my case I was trying to get the same behaviour in some related code --
expand-region.el -- across both versions, but that has been resolved via
other means anyway.

Cheers, Mark.



On 5 December 2012 09:02, Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:

> > for i=1:n, something; end;
>
> > If octave-mark-block is invoked with the cursor anywhere inside the
> > 'for' token, it will fail ("unbalanced parentheses").  The following
> > situations all fail in the recent version, but succeed in the older
> > version: |for, f|or, fo|r.
>
> For the "|for" case I think the behavior makes sense (it will try to
> mark the enclosing block).  But maybe indeed it's an accidental change.
>
> For the "f|or" and "fo|r" cases, indeed the smie primitives assume the
> cursor is not within a token, so they get all confused.  Shouldn't be
> too hard to fix.
>
> What should be the behavior when point is at "end|"?  Should it mark
> this block or the enclosing one?
>
>
>         Stefan
>



-- 
Where the hell is Mark:
http://blog.everythingtastesbetterwithchilli.com/
[Message part 2 (text/html, inline)]

Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Wed, 05 Dec 2012 05:31:01 GMT) Full text and rfc822 format available.

Notification sent to Mark Hepburn <mark.hepburn <at> gmail.com>:
bug acknowledged by developer. (Wed, 05 Dec 2012 05:31:02 GMT) Full text and rfc822 format available.

Message #18 received at 12785-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Mark Hepburn <mark.hepburn <at> gmail.com>
Cc: 12785-done <at> debbugs.gnu.org
Subject: Re: bug#12785: [octave-mod] Changed behaviour of octave-mark-block?
Date: Wed, 05 Dec 2012 00:30:47 -0500
> Regarding the "end|" case, the old mode wouldn't mark the block, and I feel
> that's correct behaviour.  In the "|for" case as I mentioned, the old mode
> _did_ mark the block (not the enclosing one), but I agree that marking the
> enclosing block is probably preferable and more consistent.

Indeed, the code tried to reproduce this "mark the block after point
instead of the enclosing one" but had a bug in it.
I've fixed the "starting within a token" problem as well as the above
check (so the inner `for' will be marked if you're right in front of it).


        Stefan


=== modified file 'lisp/progmodes/octave-mod.el'
--- lisp/progmodes/octave-mod.el	2012-09-17 05:41:04 +0000
+++ lisp/progmodes/octave-mod.el	2012-12-05 05:21:07 +0000
@@ -794,11 +794,14 @@
   "Put point at the beginning of this Octave block, mark at the end.
 The block marked is the one that contains point or follows point."
   (interactive)
+  (if (and (looking-at "\\sw\\|\\s_")
+           (looking-back "\\sw\\|\\s_" (1- (point))))
+      (skip-syntax-forward "w_"))
   (unless (or (looking-at "\\s(")
               (save-excursion
                 (let* ((token (funcall smie-forward-token-function))
                        (level (assoc token smie-grammar)))
-                  (and level (null (cadr level))))))
+                  (and level (not (numberp (cadr level)))))))
     (backward-up-list 1))
   (mark-sexp))
 





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#12785; Package emacs. (Wed, 05 Dec 2012 12:06:01 GMT) Full text and rfc822 format available.

Message #21 received at 12785-done <at> debbugs.gnu.org (full text, mbox):

From: Mark Hepburn <mark.hepburn <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 12785-done <at> debbugs.gnu.org
Subject: Re: bug#12785: [octave-mod] Changed behaviour of octave-mark-block?
Date: Wed, 5 Dec 2012 23:04:56 +1100
Thanks.

On 5 December 2012 16:30, Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:
>> Regarding the "end|" case, the old mode wouldn't mark the block, and I feel
>> that's correct behaviour.  In the "|for" case as I mentioned, the old mode
>> _did_ mark the block (not the enclosing one), but I agree that marking the
>> enclosing block is probably preferable and more consistent.
>
> Indeed, the code tried to reproduce this "mark the block after point
> instead of the enclosing one" but had a bug in it.
> I've fixed the "starting within a token" problem as well as the above
> check (so the inner `for' will be marked if you're right in front of it).
>
>
>         Stefan
>
>
> === modified file 'lisp/progmodes/octave-mod.el'
> --- lisp/progmodes/octave-mod.el        2012-09-17 05:41:04 +0000
> +++ lisp/progmodes/octave-mod.el        2012-12-05 05:21:07 +0000
> @@ -794,11 +794,14 @@
>    "Put point at the beginning of this Octave block, mark at the end.
>  The block marked is the one that contains point or follows point."
>    (interactive)
> +  (if (and (looking-at "\\sw\\|\\s_")
> +           (looking-back "\\sw\\|\\s_" (1- (point))))
> +      (skip-syntax-forward "w_"))
>    (unless (or (looking-at "\\s(")
>                (save-excursion
>                  (let* ((token (funcall smie-forward-token-function))
>                         (level (assoc token smie-grammar)))
> -                  (and level (null (cadr level))))))
> +                  (and level (not (numberp (cadr level)))))))
>      (backward-up-list 1))
>    (mark-sexp))
>
>



-- 
Where the hell is Mark:
http://blog.everythingtastesbetterwithchilli.com/




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 02 Jan 2013 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 221 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.