From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Zoltan Kemenczy" Newsgroups: gmane.emacs.devel Subject: Re: [kemenczy@rogers.com: cc-engine:c-guess-basic-syntax related problem in latest CVS] Date: Wed, 9 Jul 2003 22:08:16 -0400 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <000501c34688$20902500$0701a8c0@rim.net> References: <5b1xx0tx2l.fsf@lister.roxen.com> Reply-To: Zoltan Kemenczy NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1057802881 16718 80.91.224.249 (10 Jul 2003 02:08:01 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 10 Jul 2003 02:08:01 +0000 (UTC) Cc: rms@gnu.org, monnier@cs.yale.edu, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Thu Jul 10 04:07:58 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19aQqk-0004LG-00 for ; Thu, 10 Jul 2003 04:07:58 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 19aR1q-000810-00 for ; Thu, 10 Jul 2003 04:19:26 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19aQrD-0006BM-Vd for emacs-devel@quimby.gnus.org; Wed, 09 Jul 2003 22:08:27 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19aQr8-00067a-5u for emacs-devel@gnu.org; Wed, 09 Jul 2003 22:08:22 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19aQr6-00066v-EH for emacs-devel@gnu.org; Wed, 09 Jul 2003 22:08:21 -0400 Original-Received: from fep01-mail.bloor.is.net.cable.rogers.com ([66.185.86.71]) by monty-python.gnu.org with esmtp (Exim 4.20) id 19aQr4-00060Z-KU; Wed, 09 Jul 2003 22:08:18 -0400 Original-Received: from zkemenczylt ([24.112.238.47]) by fep01-mail.bloor.is.net.cable.rogers.com (InterMail vM.5.01.05.12 201-253-122-126-112-20020820) with ESMTP id <20030710020810.IDKN427382.fep01-mail.bloor.is.net.cable.rogers.com@zkemenczylt>; Wed, 9 Jul 2003 22:08:10 -0400 Original-To: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4920.2300 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4920.2300 X-Authentication-Info: Submitted using SMTP AUTH LOGIN at fep01-mail.bloor.is.net.cable.rogers.com from [24.112.238.47] using ID at Wed, 9 Jul 2003 22:08:10 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:15528 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:15528 Getting syntax information on write-protected C++ buffers does work now... (however, visiting a .java file now doesn't load java-mode?? :-( . (don't have time to look into the cc-mode autoloads) But after loading java-mode, the syntactic information is returned correctly). Regarding syntactic info 'predicates': In gud-find-class certain lookups are performed a couple of times per syntactic context as the information is parsed backward in the file looking for any nested classes ('inclass syntactic elements). Two "predicates" (there must be a better term for "getAttribute" type methods?) I found useful to define (inside gud-find-class as local symbols) are: (fset 'syntax-symbol (lambda (x) (car (car x)))) ; symbol of first syntactic element (fset 'syntax-point (lambda (x) (car (cdr (car x))))) ; point (integer) of first syntactic element If feeling pedantic, one could also define an iterator: (fset 'syntax-remaining (lambda (x) (cdr x))) to make reading code easier (a bit). I did look through cc-engine to see if anything like the above existed... It's just common sense to have such predicates with the "objects", so if you agree, redesign/name them for cc-engine, and I'll patch gud-jdb accordingly... Regards, Zoltan ----- Original Message ----- From: "Martin Stjernholm" To: "Zoltan Kemenczy" Cc: ; ; ; Sent: Tuesday, July 08, 2003 7:31 PM Subject: Re: [kemenczy@rogers.com: cc-engine:c-guess-basic-syntax related problem in latest CVS] > > From: "Zoltan Kemenczy" > > Subject: cc-engine:c-guess-basic-syntax related problem in latest CVS > > To: > > Date: Tue Jul 8 04:11:46 2003 +0200 > > > > Try S-M-; (c-guess-basic-syntax) at different points within a buffer > > visiting a C source file that is *write-protected*... - I get a "Buffer is > > read-only: #" message in many places. If the buffer is made > > writeable, the syntactic information is returned... > > This has to do with functions that make "hidden buffer changes", i.e. > change text properties for internal purposes. See the blurb on that > near the top of cc-engine.el. c-guess-basic-syntax is a function that > could do such hidden buffer changes, but I've now wrapped it so that > it can be called in read only mode again. > > > A related question (that started all this) is that the point value of the > > syntactic information is now returned as '(syntax-symbol point-integer) list > > (it used to be a cons cell: '(symbol . point-integer)). This breaks my > > gud-find-class function inside gud.el. I fixed that function (to use more > > maintainable predicate functions on the syntactic info as opposed to the > > (car (cdr...)), but before I submit the patch, I'd like to ask if this > > change to the '(syntax-symbol point-integer) is there to stay... > > It is. I had to do that change to be able to extend syntactic > information. There's a note about it in NEWS (which I've extended a > bit now). > > I think such predicate functions belong in CC Mode. How did you design > them?