From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Peter Newsgroups: gmane.emacs.help Subject: help using/understanding syntax tables Date: Sat, 4 Feb 2017 21:24:29 -0800 (PST) Message-ID: <43e46d85-5b39-47b6-b42b-5e8c748b33f0@googlegroups.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1486272330 25218 195.159.176.226 (5 Feb 2017 05:25:30 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 5 Feb 2017 05:25:30 +0000 (UTC) Injection-Date: Sun, 05 Feb 2017 05:24:29 +0000 User-Agent: G2/1.0 To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Feb 05 06:25:23 2017 Return-path: Envelope-to: geh-help-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 1caFKE-0006Fb-KA for geh-help-gnu-emacs@m.gmane.org; Sun, 05 Feb 2017 06:25:22 +0100 Original-Received: from localhost ([::1]:41837 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1caFKK-0003Dz-5f for geh-help-gnu-emacs@m.gmane.org; Sun, 05 Feb 2017 00:25:28 -0500 X-Received: by 10.129.41.206 with SMTP id p197mr1157049ywp.28.1486272269502; Sat, 04 Feb 2017 21:24:29 -0800 (PST) X-Received: by 10.157.46.212 with SMTP id w78mr273675ota.0.1486272269465; Sat, 04 Feb 2017 21:24:29 -0800 (PST) Original-Path: usenet.stanford.edu!q58no847447qte.0!news-out.google.com!15ni8915itm.0!nntp.google.com!r185no1365367ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Complaints-To: groups-abuse@google.com Original-Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=49.2.114.246; posting-account=xn0CbQoAAAASWsnV689K01BfDuqsREZp Original-NNTP-Posting-Host: 49.2.114.246 Original-Xref: usenet.stanford.edu gnu.emacs.help:219061 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:112245 Archived-At: I want to be able to search a buffer to detect the 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 scan-lists function). What I have tried is copying 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))) (map-char-table #'(lambda (key value) (modify-syntax-entry key "w" my-syntax-table)) (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 . . . This seems to work OK finding {}/[] pairings, but for some reason, it also detects <> pairings - which I do not want at all. I was not sure of the use of "(syntax-table)" in the 'map-char-table statement - I tried changing it to be "my-syntax-table" but it made no difference to the results. Any help/clarification would be appreciated - thanks Peter