* Re: On the behavior of `c-beginning-of-defun'
[not found] <200612301209.55371.xugp@alibaba-inc.com>
@ 2006-12-30 20:15 ` Alan Mackenzie
2006-12-31 9:40 ` Herbert Euler
2007-01-20 19:37 ` Alan Mackenzie
1 sibling, 1 reply; 10+ messages in thread
From: Alan Mackenzie @ 2006-12-30 20:15 UTC (permalink / raw)
Cc: bug-cc-mode, herberteuler, rms, emacs-devel
Hi, Guanpeng!
On Sat, Dec 30, 2006 at 12:09:55PM +0800, Herbert Euler wrote:
> Hello Alan,
[ .... ]
> I planned to use `c-beginning-of-defun' and `c-end-of-defun'. But I
> found a strange behavior of `c-beginning-of-defun'. In the attatched
> `x.c' file, `c-beginning-of-defun' moves point differently for the
> function `main' and others. For the `main' function, it moves point
> to the open of the function body, i.e. before the { at line 6; for
> other functions, it moves point to the beginning of the definition of
> the function, i.e. before the type specification of the return value
> of the function.
[ .... ]
> Is this a bug or a desired behavior of `c-beginning-of-defun'?
The behaviour of c-beginning-of-defun in your `main' function is a bug.
c-b-o-d should go to before "int \nmain". As you wrote, the square
brackets in "*argv[]" is confusing the function. Thanks for reporting
this bug!
I'll try and fix it soon.
> Please reply to both this mail address (xugp@alibaba-inc.com) and my
> orignal mail address (herberteuler@hotmail.com) if possible.
> Thanks in advance.
> Regards,
> Guanpeng Xu
> int
> main (argc, argv)
> int argc;
> char *argv[];
> {
> if ()
> ;
> }
[ .... ]
--
Alan Mackenzie (Ittersbach, Germany)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: On the behavior of `c-beginning-of-defun'
2006-12-30 20:15 ` On the behavior of `c-beginning-of-defun' Alan Mackenzie
@ 2006-12-31 9:40 ` Herbert Euler
2006-12-31 22:13 ` Richard Stallman
2007-01-01 22:30 ` Alan Mackenzie
0 siblings, 2 replies; 10+ messages in thread
From: Herbert Euler @ 2006-12-31 9:40 UTC (permalink / raw)
Cc: bug-cc-mode, rms, emacs-devel
And is this a bug too?
For the following class definition:
class a_b::c_d1 : public e_f, public g_h
{
-!-};
Suppose -!- represents the location of point. `c-beginning-of-defun'
moves point to
class a_b::c_d1 : -!-public e_f, public g_h
{
};
Rather than
-!-class a_b::c_d1 : public e_f, public g_h
{
};
Thanks in advance.
Regards,
Guanpeng Xu
>From: Alan Mackenzie <acm@muc.de>
>To: Herbert Euler <xugp@alibaba-inc.com>
>CC: bug-cc-mode@gnu.org, herberteuler@hotmail.com, rms@gnu.org,
>emacs-devel@gnu.org
>Subject: Re: On the behavior of `c-beginning-of-defun'
>Date: Sat, 30 Dec 2006 21:27:15 +0000
>
>Hi, Guanpeng!
>
>On Sat, Dec 30, 2006 at 12:09:55PM +0800, Herbert Euler wrote:
> > Hello Alan,
>
>[ .... ]
>
> > I planned to use `c-beginning-of-defun' and `c-end-of-defun'. But I
> > found a strange behavior of `c-beginning-of-defun'. In the attatched
> > `x.c' file, `c-beginning-of-defun' moves point differently for the
> > function `main' and others. For the `main' function, it moves point
> > to the open of the function body, i.e. before the { at line 6; for
> > other functions, it moves point to the beginning of the definition of
> > the function, i.e. before the type specification of the return value
> > of the function.
>
>[ .... ]
>
> > Is this a bug or a desired behavior of `c-beginning-of-defun'?
>
>The behaviour of c-beginning-of-defun in your `main' function is a bug.
>c-b-o-d should go to before "int \nmain". As you wrote, the square
>brackets in "*argv[]" is confusing the function. Thanks for reporting
>this bug!
>
>I'll try and fix it soon.
>
> > Please reply to both this mail address (xugp@alibaba-inc.com) and my
> > orignal mail address (herberteuler@hotmail.com) if possible.
>
> > Thanks in advance.
>
> > Regards,
> > Guanpeng Xu
>
>
> > int
> > main (argc, argv)
> > int argc;
> > char *argv[];
> > {
> > if ()
> > ;
> > }
>
>[ .... ]
>
>--
>Alan Mackenzie (Ittersbach, Germany)
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: On the behavior of `c-beginning-of-defun'
2006-12-31 9:40 ` Herbert Euler
@ 2006-12-31 22:13 ` Richard Stallman
2007-01-01 22:30 ` Alan Mackenzie
1 sibling, 0 replies; 10+ messages in thread
From: Richard Stallman @ 2006-12-31 22:13 UTC (permalink / raw)
Cc: bug-cc-mode, acm, xugp, emacs-devel
Suppose -!- represents the location of point. `c-beginning-of-defun'
moves point to
class a_b::c_d1 : -!-public e_f, public g_h
{
};
I think that is a bug. But whether it is worth fixing now
depends on how simple and safe the fix is.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: On the behavior of `c-beginning-of-defun'
2006-12-31 9:40 ` Herbert Euler
2006-12-31 22:13 ` Richard Stallman
@ 2007-01-01 22:30 ` Alan Mackenzie
2007-01-02 1:19 ` Herbert Euler
1 sibling, 1 reply; 10+ messages in thread
From: Alan Mackenzie @ 2007-01-01 22:30 UTC (permalink / raw)
Cc: bug-cc-mode, xugp, rms, emacs-devel
Hi, Guanpeng!
On Sun, Dec 31, 2006 at 05:40:52PM +0800, Herbert Euler wrote:
> And is this a bug too?
Hey, have you got any more? ;-)
> For the following class definition:
>
> class a_b::c_d1 : public e_f, public g_h
> {
> -!-};
>
> Suppose -!- represents the location of point. `c-beginning-of-defun'
> moves point to
>
> class a_b::c_d1 : -!-public e_f, public g_h
> {
> };
>
> Rather than
>
> -!-class a_b::c_d1 : public e_f, public g_h
> {
> };
That is indeed was a bug. I've just committed a batch of CC Mode bug fixes
(updating its version to 5.31.4). This bug seems to have been fixed.
Would you try it out again with these updated files, please.
> Thanks in advance.
>
> Regards,
> Guanpeng Xu
--
Alan Mackenzie (Ittersbach, Germany)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: On the behavior of `c-beginning-of-defun'
2007-01-01 22:30 ` Alan Mackenzie
@ 2007-01-02 1:19 ` Herbert Euler
0 siblings, 0 replies; 10+ messages in thread
From: Herbert Euler @ 2007-01-02 1:19 UTC (permalink / raw)
Cc: bug-cc-mode, xugp, rms, emacs-devel
Hello Alan,
> > For the following class definition:
> >
> > class a_b::c_d1 : public e_f, public g_h
> > {
> > -!-};
> >
> > Suppose -!- represents the location of point. `c-beginning-of-defun'
> > moves point to
> >
> > class a_b::c_d1 : -!-public e_f, public g_h
> > {
> > };
> >
> > Rather than
> >
> > -!-class a_b::c_d1 : public e_f, public g_h
> > {
> > };
>
>That is indeed was a bug. I've just committed a batch of CC Mode bug fixes
>(updating its version to 5.31.4). This bug seems to have been fixed.
>Would you try it out again with these updated files, please.
I have tested the above case with your updated CC Mode 5.31.4.
This bug is indeed fixed.
Thank you very much and Happy New Year! :-D
Best wishes,
Guanpeng Xu
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: On the behavior of `c-beginning-of-defun'
[not found] <200612301209.55371.xugp@alibaba-inc.com>
2006-12-30 20:15 ` On the behavior of `c-beginning-of-defun' Alan Mackenzie
@ 2007-01-20 19:37 ` Alan Mackenzie
1 sibling, 0 replies; 10+ messages in thread
From: Alan Mackenzie @ 2007-01-20 19:37 UTC (permalink / raw)
Cc: bug-cc-mode, herberteuler, rms, emacs-devel
Hi, Guanpeng!
On Sat, Dec 30, 2006 at 12:09:55PM +0800, Herbert Euler wrote:
[ .... ]
> I planned to use `c-beginning-of-defun' and `c-end-of-defun'. But I
> found a strange behavior of `c-beginning-of-defun'. In the attatched
> `x.c' file, `c-beginning-of-defun' moves point differently for the
> function `main' and others. For the `main' function, it moves point to
> the open of the function body, i.e. before the { at line 6; for other
> functions, it moves point to the beginning of the definition of the
> function, i.e. before the type specification of the return value of the
> function.
[ .... ]
I've fixed this bug, basically by analysing K&R regions much more
rigorously. I've just committed cc-defs.el and cc-engine.el to
savannah.gnu.org.
Please try out the amended version and let me know if anything's not
right.
> Thanks in advance.
Thank you for the bug report!
> int
> main (argc, argv)
> int argc;
> char *argv[];
> {
> if ()
> ;
> }
--
Alan Mackenzie (Ittersbach, Germany).
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: On the behavior of `c-beginning-of-defun'
@ 2007-01-21 1:19 Herbert Euler
2007-01-21 1:22 ` Herbert Euler
2007-01-21 19:33 ` Alan Mackenzie
0 siblings, 2 replies; 10+ messages in thread
From: Herbert Euler @ 2007-01-21 1:19 UTC (permalink / raw)
Cc: bug-cc-mode, rms, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1745 bytes --]
>Please try out the amended version and let me know if anything's not
>right.
I did not test all cases but only the case that function
`c-beginning-of-defun' fails. I think it is almost Ok. However,
please try the following case, it might be a bug.
Suppose `-!-' indicates the position of point. If point is, for
example, in the body of function `main1':
/* 1. K&R C. */
/* This will not get correct result until the bug in CC mode is fixed.
See
http://lists.gnu.org/archive/html/emacs-devel/2006-12/msg01341.html
*/
int
main1 (argc, argv)
int argc;
char *argv[];
{
-!-/* ... */
}
Then `c-beginning-of-defun' moves point to before ``int'':
/* 1. K&R C. */
/* This will not get correct result until the bug in CC mode is fixed.
See
http://lists.gnu.org/archive/html/emacs-devel/2006-12/msg01341.html
*/
-!-int
main1 (argc, argv)
int argc;
char *argv[];
{
/* ... */
}
Which is a desired behavior. But if point is just after ``[]'':
/* 1. K&R C. */
/* This will not get correct result until the bug in CC mode is fixed.
See
http://lists.gnu.org/archive/html/emacs-devel/2006-12/msg01341.html
*/
int
main1 (argc, argv)
int argc;
char *argv[]-!-;
{
/* ... */
}
`c-beginning-of-defun' moves point to the start of the file, rather
than the desired position.
This is the only problem I can see until now. Thank you very much.
Regards,
Guanpeng Xu
_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now!
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
[-- Attachment #2: x.c --]
[-- Type: application/octet-stream, Size: 4754 bytes --]
/* 1. K&R C. */
/* This will not get correct result until the bug in CC mode is fixed.
See
http://lists.gnu.org/archive/html/emacs-devel/2006-12/msg01341.html */
int
main1 (argc, argv)
int argc;
char *argv[];
{
/* ... */
}
int
f1 (arg)
Lisp_Object arg;
{
}
int
f2 (arg)
Lisp_Object arg;
/* The `arg' is a Lisp_Object. */
{
}
DEFUN ("catch", Fcatch1, Scatch, 1, UNEVALLED, 0,
doc: /* Eval BODY allowing nonlocal exits using `throw'.
TAG is evalled to get the tag to use; it must not be nil.
Then the BODY is executed.
Within BODY, a call to `throw' with the same TAG exits BODY and this `catch'.
If no throw happens, `catch' returns the value of the last BODY form.
If a throw happens, it specifies the value to return from `catch'.
usage: (catch TAG BODY...) */)
(args)
Lisp_Object args;
{
register Lisp_Object tag;
struct gcpro gcpro1;
GCPRO1 (args);
tag = Feval (Fcar (args));
UNGCPRO;
return internal_catch (tag, Fprogn, Fcdr (args));
}
/* Now, some badly formatted code. */
int
main2 (argc, argv)
int argc;
char *argv[];
{
/* ... */
}
int
f3
(arg)
Lisp_Object
arg
;
{
}
int f4
(arg)
Lisp_Object arg;
/* The `arg' is a Lisp_Object. */
{
}
DEFUN ("catch", Fcatch2, Scatch, 1, UNEVALLED, 0,
doc: /* Eval BODY allowing nonlocal exits using `throw'.
TAG is evalled to get the tag to use; it must not be nil.
Then the BODY is executed.
Within BODY, a call to `throw' with the same TAG exits BODY and this `catch'.
If no throw happens, `catch' returns the value of the last BODY form.
If a throw happens, it specifies the value to return from `catch'.
usage: (catch TAG BODY...) */)
(args)
Lisp_Object args;
{
register Lisp_Object tag;
struct gcpro gcpro1;
GCPRO1 (args);
tag = Feval (Fcar (args));
UNGCPRO;
return internal_catch (tag, Fprogn, Fcdr (args));
}
/* 2. ANSI/ISO C. */
int
main3 (int argc, char *argv[])
{
}
int
f5 (Lisp_Object arg)
{
}
int
f6 (Lisp_Object arg)
/* The `arg' is a Lisp_Object. */
{
}
DEFUN ("catch", Fcatch3, Scatch, 1, UNEVALLED, 0,
doc: /* Eval BODY allowing nonlocal exits using `throw'.
TAG is evalled to get the tag to use; it must not be nil.
Then the BODY is executed.
Within BODY, a call to `throw' with the same TAG exits BODY and this `catch'.
If no throw happens, `catch' returns the value of the last BODY form.
If a throw happens, it specifies the value to return from `catch'.
usage: (catch TAG BODY...) */)
(Lisp_Object args)
{
register Lisp_Object tag;
struct gcpro gcpro1;
GCPRO1 (args);
tag = Feval (Fcar (args));
UNGCPRO;
return internal_catch (tag, Fprogn, Fcdr (args));
}
/* Now, some badly formatted code. */
int
main4
(int
argc,
char *
argv[])
{
}
int
f7
(
Lisp_Object
arg)
{
}
int
f8
(Lisp_Object
arg)
/* The `arg' is a Lisp_Object. */
{
}
DEFUN ("catch", Fcatch4, Scatch, 1, UNEVALLED, 0,
doc: /* Eval BODY allowing nonlocal exits using `throw'.
TAG is evalled to get the tag to use; it must not be nil.
Then the BODY is executed.
Within BODY, a call to `throw' with the same TAG exits BODY and this `catch'.
If no throw happens, `catch' returns the value of the last BODY form.
If a throw happens, it specifies the value to return from `catch'.
usage: (catch TAG BODY...) */)
(Lisp_Object args)
{
register Lisp_Object tag;
struct gcpro gcpro1;
GCPRO1 (args);
tag = Feval (Fcar (args));
UNGCPRO;
return internal_catch (tag, Fprogn, Fcdr (args));
}
/* 3. C++ functions. */
int
a_b::c_d::e_f1 ()
{
}
int
a_b
::
c_d::e_f2 ()
{
}
int
a_b
::
c_d
::
e_f3
()
{
}
/* 4. struct, enum, class, union; private, protected, public. */
/* The cases of `struct' can represent all `struct', `enum', `class',
and `union'. */
struct struct1
{
};
struct
struct2
{
};
struct struct3
{
};
struct
struct4
{
};
class a_b1 : public c_d
{
};
class a_b2
: public c_d
{
};
class a_b3:
public c_d
{
};
class a_b4
:
public c_d
{
};
class
a_b5 : public c_d
{
};
class a_b6
: public
c_d
{
};
class
a_b7 :
public c_d
{
};
class
a_b8
:
public
c_d
{
};
class a_b::c_d1 : public e_f, public g_h
{
};
class a_b
::
c_d2
: public
e_f
,
public
g_h
{
};
[-- Attachment #3: Type: text/plain, Size: 347 bytes --]
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: On the behavior of `c-beginning-of-defun'
2007-01-21 1:19 Herbert Euler
@ 2007-01-21 1:22 ` Herbert Euler
2007-01-21 19:33 ` Alan Mackenzie
1 sibling, 0 replies; 10+ messages in thread
From: Herbert Euler @ 2007-01-21 1:22 UTC (permalink / raw)
Cc: bug-cc-mode, rms, emacs-devel
All functions are in the attached file. I'm sorry I forgot to
declare this.
Best regards,
Guanpeng Xu
>From: "Herbert Euler" <herberteuler@hotmail.com>
>To: acm@muc.de, xugp@alibaba-inc.com
>CC: bug-cc-mode@gnu.org, rms@gnu.org, emacs-devel@gnu.org
>Subject: Re: On the behavior of `c-beginning-of-defun'
>Date: Sun, 21 Jan 2007 09:19:44 +0800
>
>>Please try out the amended version and let me know if anything's not
>>right.
>
>I did not test all cases but only the case that function
>`c-beginning-of-defun' fails. I think it is almost Ok. However,
>please try the following case, it might be a bug.
>
>Suppose `-!-' indicates the position of point. If point is, for
>example, in the body of function `main1':
>
> /* 1. K&R C. */
>
> /* This will not get correct result until the bug in CC mode is fixed.
> See
> http://lists.gnu.org/archive/html/emacs-devel/2006-12/msg01341.html
>*/
> int
> main1 (argc, argv)
> int argc;
> char *argv[];
> {
> -!-/* ... */
> }
>
>Then `c-beginning-of-defun' moves point to before ``int'':
>
> /* 1. K&R C. */
>
> /* This will not get correct result until the bug in CC mode is fixed.
> See
> http://lists.gnu.org/archive/html/emacs-devel/2006-12/msg01341.html
>*/
> -!-int
> main1 (argc, argv)
> int argc;
> char *argv[];
> {
> /* ... */
> }
>
>Which is a desired behavior. But if point is just after ``[]'':
>
> /* 1. K&R C. */
>
> /* This will not get correct result until the bug in CC mode is fixed.
> See
> http://lists.gnu.org/archive/html/emacs-devel/2006-12/msg01341.html
>*/
> int
> main1 (argc, argv)
> int argc;
> char *argv[]-!-;
> {
> /* ... */
> }
>
>`c-beginning-of-defun' moves point to the start of the file, rather
>than the desired position.
>
>This is the only problem I can see until now. Thank you very much.
>
>Regards,
>Guanpeng Xu
>
>_________________________________________________________________
>FREE pop-up blocking with the new MSN Toolbar - get it now!
>http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
><< x.c >>
>_______________________________________________
>Emacs-devel mailing list
>Emacs-devel@gnu.org
>http://lists.gnu.org/mailman/listinfo/emacs-devel
_________________________________________________________________
Don't just search. Find. Check out the new MSN Search!
http://search.msn.com/
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: On the behavior of `c-beginning-of-defun'
2007-01-21 1:19 Herbert Euler
2007-01-21 1:22 ` Herbert Euler
@ 2007-01-21 19:33 ` Alan Mackenzie
2007-01-22 2:06 ` Herbert Euler
1 sibling, 1 reply; 10+ messages in thread
From: Alan Mackenzie @ 2007-01-21 19:33 UTC (permalink / raw)
Cc: bug-cc-mode, xugp, rms, emacs-devel
Hi, Guanpeng!
On Sun, Jan 21, 2007 at 09:19:44AM +0800, Herbert Euler wrote:
> >Please try out the amended version and let me know if anything's not
> >right.
> I did not test all cases but only the case that function
> `c-beginning-of-defun' fails. I think it is almost Ok. However,
> please try the following case, it might be a bug.
Yes. It's a bug.
> Suppose `-!-' indicates the position of point.
[ .... ]
> But if point is just after ``[]'':
>
> /* 1. K&R C. */
>
> /* This will not get correct result until the bug in CC mode is fixed.
> See
> http://lists.gnu.org/archive/html/emacs-devel/2006-12/msg01341.html
> */
> int
> main1 (argc, argv)
> int argc;
> char *argv[]-!-;
> {
> /* ... */
> }
>
> `c-beginning-of-defun' moves point to the start of the file, rather
> than the desired position.
I've patched cc-cmds.el, which should fix the bug, and committed this to
savannah. Please try it out again!
> This is the only problem I can see until now. Thank you very much.
> Regards,
> Guanpeng Xu
--
Alan Mackenzie (Ittersbach, Germany).
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2007-01-22 2:06 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <200612301209.55371.xugp@alibaba-inc.com>
2006-12-30 20:15 ` On the behavior of `c-beginning-of-defun' Alan Mackenzie
2006-12-31 9:40 ` Herbert Euler
2006-12-31 22:13 ` Richard Stallman
2007-01-01 22:30 ` Alan Mackenzie
2007-01-02 1:19 ` Herbert Euler
2007-01-20 19:37 ` Alan Mackenzie
2007-01-21 1:19 Herbert Euler
2007-01-21 1:22 ` Herbert Euler
2007-01-21 19:33 ` Alan Mackenzie
2007-01-22 2:06 ` Herbert Euler
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.