From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Peter Milliken Newsgroups: gmane.emacs.bugs Subject: bug#25903: Question re syntax tables and unexpected behaviour in C/C++ major mode Date: Wed, 1 Mar 2017 09:04:05 +1100 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=94eb2c1cc94ce9d10405499e5f35 X-Trace: blaine.gmane.org 1488319519 20369 195.159.176.226 (28 Feb 2017 22:05:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 28 Feb 2017 22:05:19 +0000 (UTC) To: 25903@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Feb 28 23:05:15 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ciptR-0004Ql-JF for geb-bug-gnu-emacs@m.gmane.org; Tue, 28 Feb 2017 23:05:13 +0100 Original-Received: from localhost ([::1]:37256 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciptT-0001AX-Fx for geb-bug-gnu-emacs@m.gmane.org; Tue, 28 Feb 2017 17:05:15 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52887) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciptH-00019E-HR for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2017 17:05:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciptG-0007t4-Dj for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2017 17:05:03 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:34217) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ciptG-0007t0-Ak for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2017 17:05:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ciptG-0001Rk-0q for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2017 17:05:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Peter Milliken Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 28 Feb 2017 22:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 25903 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.14883194605503 (code B ref -1); Tue, 28 Feb 2017 22:05:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 28 Feb 2017 22:04:20 +0000 Original-Received: from localhost ([127.0.0.1]:60649 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cipsa-0001Qg-EU for submit@debbugs.gnu.org; Tue, 28 Feb 2017 17:04:20 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:33405) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cipsY-0001QT-Ac for submit@debbugs.gnu.org; Tue, 28 Feb 2017 17:04:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cipsS-0007kB-4M for submit@debbugs.gnu.org; Tue, 28 Feb 2017 17:04:13 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:35311) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cipsS-0007k7-29 for submit@debbugs.gnu.org; Tue, 28 Feb 2017 17:04:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cipsQ-0000ef-Mz for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2017 17:04:11 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cipsP-0007ik-Gw for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2017 17:04:10 -0500 Original-Received: from mail-wr0-x22f.google.com ([2a00:1450:400c:c0c::22f]:33696) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cipsP-0007i8-8I for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2017 17:04:09 -0500 Original-Received: by mail-wr0-x22f.google.com with SMTP id u48so17995749wrc.0 for ; Tue, 28 Feb 2017 14:04:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=G3LPR0NHupQnuZrpY0pJHEDJO0leVc8IxezwPwbDUcY=; b=uV3KXX1s/NXwoCnp6I+m4on+4I0Bcv+hiD/gv1Xp+MEWhg8TgMHSjeuiTclS+pUQnz NvBu6+Hi3vZ5QKJk80WJLIJ08Dm/RepJIjXXPQPHvYbJOKUUkIAEJRf+YJBlQFIEdVFx qJzS+ogi/D3KWb0FKxIi0OgFRTAU4Bo7GZRtzlrMm5BL4Q2/DRXQxWhXCO9dTS2cNGeH HhpBm4vOyBYj1vz3+F/qOcDN5LTLg4ZfPIf24Hq9g17ph3WfmmuXxpfiFAQvcom8J0S6 YTpoD7tPpuu+yWt14X+0eoxooRgBRD4dlLIlTlMG5lubfJu7jm13AqwJxy0Nn4RSRRA4 Sfiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=G3LPR0NHupQnuZrpY0pJHEDJO0leVc8IxezwPwbDUcY=; b=gR34Dh8ekvfzZGqz34rBoxNvOkqpSc8zy0PM2Ho5JmF0Bw8YifyUn69wutV/T7Oc4T ga7RLsimrn8kw+WqU1d7WqHdF82XWuljQ3FO11+R15X5CdzqokBliTn4vzBWLI5r4XYO uILi1sHweWTp+z903wSKWvEEMZKUzkcwLXY8KgMcfll/6/2RYTt4b1rHV/Hucy0V+xT8 KLFmQl/FqHpaExm6CTd8CWyUQx0WdLPe3hOELDQZ0a/DtikULsWoKI1gewT5ojjx28zb gNgIdpcnbcBTlTOEkC2qbXjH6zvbQE2EkwW7O+b0KafOnDafLeUUaE7wO1qHdwbZ2Qh/ rXSQ== X-Gm-Message-State: AMke39kGsa9xCVfTpH7VdgX3ji/tlu/pZjZSlMAvBQKe4lWLwang/84rQv5rXDdfzfKPw0gh2ENsaCpYwtPuSQ== X-Received: by 10.223.170.70 with SMTP id q6mr4079953wrd.103.1488319446370; Tue, 28 Feb 2017 14:04:06 -0800 (PST) Original-Received: by 10.28.47.6 with HTTP; Tue, 28 Feb 2017 14:04:05 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:129963 Archived-At: --94eb2c1cc94ce9d10405499e5f35 Content-Type: text/plain; charset=UTF-8 I tried asking this question in gnu.emacs.help but obviously didn't attract the attention of the correct person/people. Hopefully somebody on this list can help. My code is intended to work as a minor mode with any (programming) major mode (I am actually re-writing a minor mode that I wrote back when Emacs was still at version 19 - a lot has changed since then :-)). I want to be able to search through a buffer to detect text within {}/[] pairings - and nothing else. I could use regexp searches of course, but I thought it would be a good learning opportunity to use syntax tables (and the forward/backward-sexp functions). My code works fine in buffers that have Python, Ada and Lisp major modes but it experiences difficulties in buffers with C/C++ major mode. Basically, when in a C/C++ buffer, the code locates text within "<>" pairs as well as "{}"/"[]" pairs. I really don't want my code to have an (ugly) exception case where it tests "if in C/C++ mode then check if <> has been detected and skip over them and continue looking for {}/[] pairs" My code copies the default syntax table, changing every entry to be a word-constituent and then adding the appropriate open parenthesis characters i.e. (defvar my-syntax-table (copy-syntax-table (standard-syntax-table))) (modify-syntax-entry (cons 0 (max-char)) "w" my-syntax-table) (modify-syntax-entry ?\{ "(}" my-syntax-table) (modify-syntax-entry ?\} "){" my-syntax-table) (modify-syntax-entry ?[ "(]" my-syntax-table) (modify-syntax-entry ?] ")[" my-syntax-table) my code then starts with: (with-syntax-table my-syntax-table . . . I have checked the "<", ">" entries in the syntax table when running in a buffer with C/C++ and the aref returns (2) which I believe is the code for a word-constituent, so something in the C/C++ mode must be affecting the sexp functions, but I have no idea what it could be or how to isolate it. Any help/clarification would be appreciated - thanks Peter --94eb2c1cc94ce9d10405499e5f35 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I tried asking this question in gnu.emacs.help but obvious= ly didn't attract the attention of the correct person/people. Hopefully= somebody on this list can help.

My code is in= tended to work as a minor mode with any (programming) major mode (I am actu= ally re-writing a minor mode that I wrote back when Emacs was still at vers= ion 19 - a lot has changed since then :-)).

I want = to be able to search through a buffer to detect text within {}/[] pairings = - and nothing else. I could use regexp searches of course, but I thought it= would be a good learning opportunity to use syntax tables (and the forward= /backward-sexp functions).=C2=A0


My code works fine in buffers that have= Python, Ada and Lisp major modes but it experiences difficulties in buffer= s with C/C++ major mode. Basically, when in a C/C++ buffer, the code locate= s text within "<>" pairs as well as "{}"/"[]= " pairs.=C2=A0=C2=A0I really don't want my code to have an (ugly) excep= tion case where it tests "if in C/C++ mode then check if <> has = been detected and skip over them and continue looking for {}/[] pairs"=

M= y code copies the default syntax table, changing every entry to be a word-c= onstituent and then adding the appropriate open parenthesis characters i.e.= =C2=A0

<= span style=3D"font-family:arial,helvetica,sans-serif;font-size:13px">(defva= r my-syntax-table (copy-syntax-table (standard-syntax-table)))=C2=A0=

(modify-syntax-entry (cons 0 (max-char)) &quo= t;w" my-syntax-table)

(modify-syntax-entry ?\{ "(}" my-syntax-table)=C2= =A0
(m= odify-syntax-entry ?\} "){" my-syntax-table)=C2=A0
(modify-syntax-entry= ?[ "(]" my-syntax-table)=C2=A0
(modify-syntax-entry ?] ")[" = my-syntax-table)=C2=A0

my code then starts with:=C2=A0

(with-syntax-table my-syntax-table=C2=A0
=C2=A0 .=C2= =A0
= =C2=A0 .=C2=A0
=C2=A0 .=C2=A0



I have checked the "<", ">" entries in the synt= ax table when running in a buffer with C/C++ and the aref=C2=A0returns (2) = =C2=A0which I believe is the code for a word-constituent, so something in t= he C/C++ mode must be affecting the sexp=C2=A0functions, but I have no idea= what it could be or how to isolate it.=C2=A0

Any help/clarification would be apprec= iated - thanks=C2=A0

Peter=C2=A0
--94eb2c1cc94ce9d10405499e5f35--