* Semantic parser uses c-forward-conditional @ 2009-09-21 19:19 Chong Yidong 2009-09-21 19:21 ` Chong Yidong ` (2 more replies) 0 siblings, 3 replies; 10+ messages in thread From: Chong Yidong @ 2009-09-21 19:19 UTC (permalink / raw) To: Alan Mackenzie; +Cc: Eric M. Ludlam, emacs-devel Hi Alan, Semantic's C parser calls c-forward-conditional while it's parsing C files. This happens frequently, often at idle time, if you visit a large C file. The trouble is that c-forward-conditional sets the mark. The call to it is wrapped in a save-excursion, so it doesn't clobber the user's mark, but it does lead to a stream of ugly "Mark set" messages. Would it be possible to change c-forward-conditional so that it pushes the mark only if called interactively? ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Semantic parser uses c-forward-conditional 2009-09-21 19:19 Semantic parser uses c-forward-conditional Chong Yidong @ 2009-09-21 19:21 ` Chong Yidong 2009-09-22 10:57 ` Alan Mackenzie 2009-09-22 16:24 ` Richard Stallman 2 siblings, 0 replies; 10+ messages in thread From: Chong Yidong @ 2009-09-21 19:21 UTC (permalink / raw) To: Alan Mackenzie; +Cc: Eric M. Ludlam, emacs-devel > Would it be possible to change c-forward-conditional so that it pushes > the mark only if called interactively? Or to call `push-mark' with a non-nil NOMSG argument if called non-interactively. That may be safer, I don't know. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Semantic parser uses c-forward-conditional 2009-09-21 19:19 Semantic parser uses c-forward-conditional Chong Yidong 2009-09-21 19:21 ` Chong Yidong @ 2009-09-22 10:57 ` Alan Mackenzie 2009-09-22 11:43 ` Eric M. Ludlam 2009-09-23 6:30 ` Richard Stallman 2009-09-22 16:24 ` Richard Stallman 2 siblings, 2 replies; 10+ messages in thread From: Alan Mackenzie @ 2009-09-22 10:57 UTC (permalink / raw) To: Chong Yidong; +Cc: Eric M. Ludlam, emacs-devel Hi, Yidong! On Mon, Sep 21, 2009 at 03:19:10PM -0400, Chong Yidong wrote: > Hi Alan, > Semantic's C parser calls c-forward-conditional while it's parsing C > files. This happens frequently, often at idle time, if you visit a > large C file. Ah. c-forward-conditional is really intended as an interactive command rather than for use in a lisp function - a bit like beginning-of-buffer. > The trouble is that c-forward-conditional sets the mark. The call to it > is wrapped in a save-excursion, so it doesn't clobber the user's mark, > but it does lead to a stream of ugly "Mark set" messages. > Would it be possible to change c-forward-conditional so that it pushes > the mark only if called interactively? I'm not very keen on that, but how about this instead: a new defun c-forward-conditional-1 which does the same, except it doesn't push a mark, doesn't throw errors like "No following conditional at this level", and returns the final point, or nil? Then all occurances inside CEDET can be changed to (cedet-forward-c-conditional), where the following macro goes into CEDET: (require 'cc-cmds) (defmacro forward-cedet-c-conditional (count &optional target-depth with-else) .... (if (fboundp 'c-forward-conditional-1) ...) .... ) This will avoid complexifying cc-cmds.el, whilst still allowing CEDET and friends to work with older CC MODE versions. It would also be good for CC MODE to separate out the "engine" part of the command from the "wrapper". As a matter of interest, have you grepped CEDET to find other similar problems? -- Alan Mackenzie (Nuremberg, Germany). ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Semantic parser uses c-forward-conditional 2009-09-22 10:57 ` Alan Mackenzie @ 2009-09-22 11:43 ` Eric M. Ludlam 2009-09-22 22:08 ` Alan Mackenzie 2009-09-23 6:30 ` Richard Stallman 1 sibling, 1 reply; 10+ messages in thread From: Eric M. Ludlam @ 2009-09-22 11:43 UTC (permalink / raw) To: Alan Mackenzie; +Cc: Chong Yidong, Eric M. Ludlam, emacs-devel On Tue, 2009-09-22 at 10:57 +0000, Alan Mackenzie wrote: > Hi, Yidong! > > On Mon, Sep 21, 2009 at 03:19:10PM -0400, Chong Yidong wrote: > > Hi Alan, > > > Semantic's C parser calls c-forward-conditional while it's parsing C > > files. This happens frequently, often at idle time, if you visit a > > large C file. > > Ah. c-forward-conditional is really intended as an interactive command > rather than for use in a lisp function - a bit like beginning-of-buffer. > > > The trouble is that c-forward-conditional sets the mark. The call to it > > is wrapped in a save-excursion, so it doesn't clobber the user's mark, > > but it does lead to a stream of ugly "Mark set" messages. > > > Would it be possible to change c-forward-conditional so that it pushes > > the mark only if called interactively? > > I'm not very keen on that, but how about this instead: a new defun > c-forward-conditional-1 which does the same, except it doesn't push a > mark, doesn't throw errors like "No following conditional at this > level", and returns the final point, or nil? > > Then all occurances inside CEDET can be changed to > (cedet-forward-c-conditional), where the following macro goes into > CEDET: > > (require 'cc-cmds) > (defmacro forward-cedet-c-conditional (count &optional target-depth with-else) > .... > (if (fboundp 'c-forward-conditional-1) ...) > .... > ) > > This will avoid complexifying cc-cmds.el, whilst still allowing CEDET > and friends to work with older CC MODE versions. It would also be good > for CC MODE to separate out the "engine" part of the command from the > "wrapper". The above seems like a fine solution to me. > As a matter of interest, have you grepped CEDET to find other similar > problems? All the C support for the parser is in one. It also uses c-end-of-macro which stands out for me. Eric ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Semantic parser uses c-forward-conditional 2009-09-22 11:43 ` Eric M. Ludlam @ 2009-09-22 22:08 ` Alan Mackenzie 0 siblings, 0 replies; 10+ messages in thread From: Alan Mackenzie @ 2009-09-22 22:08 UTC (permalink / raw) To: Eric M. Ludlam; +Cc: Chong Yidong, Eric M. Ludlam, emacs-devel Hi, Eric, On Tue, Sep 22, 2009 at 07:43:47AM -0400, Eric M. Ludlam wrote: > On Tue, 2009-09-22 at 10:57 +0000, Alan Mackenzie wrote: > > I'm not very keen on that, but how about this instead: a new defun > > c-forward-conditional-1 which does the same, except it doesn't push a > > mark, doesn't throw errors like "No following conditional at this > > level", and returns the final point, or nil? > > Then all occurances inside CEDET can be changed to > > (cedet-forward-c-conditional), where the following macro goes into > > CEDET: > > (require 'cc-cmds) > > (defmacro forward-cedet-c-conditional (count &optional target-depth with-else) > > .... > > (if (fboundp 'c-forward-conditional-1) ...) > > .... > > ) > > This will avoid complexifying cc-cmds.el, whilst still allowing CEDET > > and friends to work with older CC MODE versions. It would also be good > > for CC MODE to separate out the "engine" part of the command from the > > "wrapper". > The above seems like a fine solution to me. I've had a closer look at it, and it seems it would be better to let c-forward-conditional just signal errors (which it does when there aren't enough conditional to go over/out of/into). c-f-c (which is patterned on scan-lists) also does all the work for c-backward-conditional etc., so returning some sort of error status would mean having to throw identically in the other five defuns. Callers can catch the error if they need to, just as they do at the moment. I'll just take out the setting of the mark. > > As a matter of interest, have you grepped CEDET to find other similar > > problems? > All the C support for the parser is in one. It also uses c-end-of-macro > which stands out for me. Thanks! c-end-of-macro isn't a problem, it just goes forward past escaped EOLs. > Eric -- Alan Mackenzie (Nuremberg, Germany). ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Semantic parser uses c-forward-conditional 2009-09-22 10:57 ` Alan Mackenzie 2009-09-22 11:43 ` Eric M. Ludlam @ 2009-09-23 6:30 ` Richard Stallman 2009-09-23 9:24 ` Alan Mackenzie 1 sibling, 1 reply; 10+ messages in thread From: Richard Stallman @ 2009-09-23 6:30 UTC (permalink / raw) To: Alan Mackenzie; +Cc: cyd, zappo, emacs-devel I'm not very keen on that, but how about this instead: a new defun c-forward-conditional-1 which does the same, except it doesn't push a mark, doesn't throw errors like "No following conditional at this level", and returns the final point, or nil? Since that would be meant as a command for other programs to use, and not merely a subroutine, it would be better to give it a name that fits. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Semantic parser uses c-forward-conditional 2009-09-23 6:30 ` Richard Stallman @ 2009-09-23 9:24 ` Alan Mackenzie 2009-09-23 11:22 ` Eric M. Ludlam 0 siblings, 1 reply; 10+ messages in thread From: Alan Mackenzie @ 2009-09-23 9:24 UTC (permalink / raw) To: Richard Stallman, Eric M. Ludlam; +Cc: cyd, emacs-devel Hi, Richard and Eric! On Wed, Sep 23, 2009 at 02:30:18AM -0400, Richard Stallman wrote: > I'm not very keen on that, but how about this instead: a new defun > c-forward-conditional-1 which does the same, except it doesn't push a > mark, doesn't throw errors like "No following conditional at this > level", and returns the final point, or nil? > Since that would be meant as a command for other programs to use, > and not merely a subroutine, it would be better to give it a name > that fits. Um, well, thanks for the suggestion. ;-) How about `c-scan-conditionals', since the function does the same as scan-lists, more or less? Actually, more, since it moves point to the end position, unlike scan-lists. Maybe the new c-scan-conditionals shouldn't move point? Eric, what do you think? -- Alan Mackenzie (Nuremberg, Germany). ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Semantic parser uses c-forward-conditional 2009-09-23 9:24 ` Alan Mackenzie @ 2009-09-23 11:22 ` Eric M. Ludlam 2009-09-24 20:44 ` Alan Mackenzie 0 siblings, 1 reply; 10+ messages in thread From: Eric M. Ludlam @ 2009-09-23 11:22 UTC (permalink / raw) To: Alan Mackenzie; +Cc: cyd, Eric M. Ludlam, Richard Stallman, emacs-devel On Wed, 2009-09-23 at 09:24 +0000, Alan Mackenzie wrote: > Hi, Richard and Eric! > > On Wed, Sep 23, 2009 at 02:30:18AM -0400, Richard Stallman wrote: > > I'm not very keen on that, but how about this instead: a new defun > > c-forward-conditional-1 which does the same, except it doesn't push a > > mark, doesn't throw errors like "No following conditional at this > > level", and returns the final point, or nil? > > > Since that would be meant as a command for other programs to use, > > and not merely a subroutine, it would be better to give it a name > > that fits. > > Um, well, thanks for the suggestion. ;-) > > How about `c-scan-conditionals', since the function does the same as > scan-lists, more or less? Actually, more, since it moves point to the > end position, unlike scan-lists. Maybe the new c-scan-conditionals > shouldn't move point? > > Eric, what do you think? > For your reference, here is the file in which I use c-forward-conditional, and any other c specific functions: http://cedet.cvs.sourceforge.net/viewvc/*checkout*/cedet/cedet/semantic/bovine/semantic-c.el It would not greatly affect my code if some new function moved the point, or just returned where the end is. In semantic-c-skip-conditional-section it is trying to do more than just skip a conditional. It is trying to skip only parts of a conditional, and allow other parts to be analyzed regularly. (ie - execute the effects of the preprocessor.) The c-forward-conditional call is used on nested ifs so I don't have to deal with the balancing of the conditional commands. For all I know, there may be some additional cc-mode features I could take advantage of to help solve this problem. Eric ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Semantic parser uses c-forward-conditional 2009-09-23 11:22 ` Eric M. Ludlam @ 2009-09-24 20:44 ` Alan Mackenzie 0 siblings, 0 replies; 10+ messages in thread From: Alan Mackenzie @ 2009-09-24 20:44 UTC (permalink / raw) To: Eric M. Ludlam; +Cc: cyd, Eric M. Ludlam, Richard Stallman, emacs-devel Hi, Eric! On Wed, Sep 23, 2009 at 07:22:56AM -0400, Eric M. Ludlam wrote: > On Wed, 2009-09-23 at 09:24 +0000, Alan Mackenzie wrote: > > Hi, Richard and Eric! > > How about `c-scan-conditionals', since the function does the same as > > scan-lists, more or less? Actually, more, since it moves point to the > > end position, unlike scan-lists. Maybe the new c-scan-conditionals > > shouldn't move point? > > Eric, what do you think? > For your reference, here is the file in which I use > c-forward-conditional, and any other c specific functions: > http://cedet.cvs.sourceforge.net/viewvc/*checkout*/cedet/cedet/semantic/bovine/semantic-c.el Thanks, I had a look at that. > It would not greatly affect my code if some new function moved the > point, or just returned where the end is. OK. I just committed a change to .../lisp/progmodes/cc-cmds.el with the new function c-scan-conditionals which doesn't set the mark, and doesn't move point, instead returning the final position, much like scan-lists. > In semantic-c-skip-conditional-section it is trying to do more than > just skip a conditional. It is trying to skip only parts of a > conditional, and allow other parts to be analyzed regularly. (ie - > execute the effects of the preprocessor.) The c-forward-conditional > call is used on nested ifs so I don't have to deal with the balancing > of the conditional commands. > For all I know, there may be some additional cc-mode features I could > take advantage of to help solve this problem. Possibly the WITH-ELSE parameter to c-scan-conditionals might be useful. > Eric -- Alan Mackenzie (Nuremberg, Germany). ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Semantic parser uses c-forward-conditional 2009-09-21 19:19 Semantic parser uses c-forward-conditional Chong Yidong 2009-09-21 19:21 ` Chong Yidong 2009-09-22 10:57 ` Alan Mackenzie @ 2009-09-22 16:24 ` Richard Stallman 2 siblings, 0 replies; 10+ messages in thread From: Richard Stallman @ 2009-09-22 16:24 UTC (permalink / raw) To: Chong Yidong; +Cc: acm, zappo, emacs-devel The trouble is that c-forward-conditional sets the mark. The call to it is wrapped in a save-excursion, so it doesn't clobber the user's mark, but it does lead to a stream of ugly "Mark set" messages. Perhaps the clean solution is to break out most of the code into a lower-level function that doesn't set the mark. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2009-09-24 20:44 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-09-21 19:19 Semantic parser uses c-forward-conditional Chong Yidong 2009-09-21 19:21 ` Chong Yidong 2009-09-22 10:57 ` Alan Mackenzie 2009-09-22 11:43 ` Eric M. Ludlam 2009-09-22 22:08 ` Alan Mackenzie 2009-09-23 6:30 ` Richard Stallman 2009-09-23 9:24 ` Alan Mackenzie 2009-09-23 11:22 ` Eric M. Ludlam 2009-09-24 20:44 ` Alan Mackenzie 2009-09-22 16:24 ` Richard Stallman
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).