From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: emacs: are multi-char parentheses possible? Date: Mon, 09 Jun 2014 11:38:44 -0400 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1402328377 2661 80.91.229.3 (9 Jun 2014 15:39:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 9 Jun 2014 15:39:37 +0000 (UTC) Cc: emacs-devel@gnu.org To: Leo Liu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jun 09 17:39:30 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Wu1fW-0007cu-92 for ged-emacs-devel@m.gmane.org; Mon, 09 Jun 2014 17:39:30 +0200 Original-Received: from localhost ([::1]:33988 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wu1fV-0000Rj-TU for ged-emacs-devel@m.gmane.org; Mon, 09 Jun 2014 11:39:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40023) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wu1fK-0000Qb-0q for emacs-devel@gnu.org; Mon, 09 Jun 2014 11:39:26 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wu1fB-0004Bv-QP for emacs-devel@gnu.org; Mon, 09 Jun 2014 11:39:17 -0400 Original-Received: from mercure.iro.umontreal.ca ([132.204.24.67]:42558) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wu1fB-0004Bq-MY for emacs-devel@gnu.org; Mon, 09 Jun 2014 11:39:09 -0400 Original-Received: from hidalgo.iro.umontreal.ca (hidalgo.iro.umontreal.ca [132.204.27.50]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id AAB1724133; Mon, 9 Jun 2014 11:39:08 -0400 (EDT) Original-Received: from lechon.iro.umontreal.ca (lechon.iro.umontreal.ca [132.204.27.242]) by hidalgo.iro.umontreal.ca (Postfix) with ESMTP id 12F231E5B74; Mon, 9 Jun 2014 11:38:45 -0400 (EDT) Original-Received: by lechon.iro.umontreal.ca (Postfix, from userid 20848) id E831AB4167; Mon, 9 Jun 2014 11:38:44 -0400 (EDT) In-Reply-To: (Leo Liu's message of "Mon, 09 Jun 2014 14:30:01 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=-2.82, requis 5, autolearn=not spam, ALL_TRUSTED -2.82, MC_TSTLAST 0.00) X-DIRO-MailScanner-From: monnier@iro.umontreal.ca X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 132.204.24.67 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:172420 Archived-At: > Do you know if it is possible for Emacs to handle a pair of multi-char > parentheses? Yes, I do. I also know the answer is not just a plain boolean. > Take << and >> for example, > > (setq-local syntax-propertize-function (syntax-propertize-rules > ("\\(<\\)<" (1 "(>")) > (">\\(>\\)" (1 ")<")))) > > show-paren-mode can highlight "<<" and ">>" but up-list aren't aware of > them. up-list should handle this just as well as show-paren and for/backward-sexp (and does, in my tests). Maybe you tried a "forward up-list" where the closing ">>" hadn't yet been syntax-propertized? This technique has some downsides, but in the case of << ... >> it might work well enough. For things like "begin...end" it's more annoying (e.g. backward word will stop right between the "b" and the "egin" and forward-word will stop right between "en" and "d"). For those, SMIE might be a better option (which uses hooks in show-paren and forward-sexp to try and make them do The Right Thing, tho the up-list case is only 90% working). Stefan