From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Davis Herring Newsgroups: gmane.emacs.devel Subject: Re: paren-close-dwim: elisp function of a newbie; feedback welcome Date: Thu, 26 Sep 2013 14:38:14 -0600 Organization: XCP-1 Message-ID: <52449B36.4080009@lanl.gov> References: <20130925114643.GA7187@csr-pc9.zib.de> <52431E25.3030603@lanl.gov> <87txh7gxyt.fsf@newsguy.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1380227919 5002 80.91.229.3 (26 Sep 2013 20:38:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 26 Sep 2013 20:38:39 +0000 (UTC) Cc: emacs-devel@gnu.org To: Harry Putnam Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 26 22:38:41 2013 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 1VPIKd-0005Sk-EM for ged-emacs-devel@m.gmane.org; Thu, 26 Sep 2013 22:38:39 +0200 Original-Received: from localhost ([::1]:59835 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPIKc-00058B-Jd for ged-emacs-devel@m.gmane.org; Thu, 26 Sep 2013 16:38:38 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50370) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPIKR-000582-Sm for emacs-devel@gnu.org; Thu, 26 Sep 2013 16:38:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VPIKJ-0001HS-ML for emacs-devel@gnu.org; Thu, 26 Sep 2013 16:38:27 -0400 Original-Received: from proofpoint5.lanl.gov ([204.121.3.53]:40091) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPIKJ-0001Gt-Dc for emacs-devel@gnu.org; Thu, 26 Sep 2013 16:38:19 -0400 Original-Received: from mailrelay2.lanl.gov (mailrelay2.lanl.gov [128.165.4.103]) by mailgate5.lanl.gov (8.14.5/8.14.5) with ESMTP id r8QKcEA8017952; Thu, 26 Sep 2013 14:38:15 -0600 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by mailrelay2.lanl.gov (Postfix) with ESMTP id F01B91921E35; Thu, 26 Sep 2013 14:38:14 -0600 (MDT) X-NIE-2-Virus-Scanner: amavisd-new at mailrelay2.lanl.gov Original-Received: from [128.165.123.183] (xray-r06.lanl.gov [128.165.123.183]) by mailrelay2.lanl.gov (Postfix) with ESMTP id 9FA0A1921E2B; Thu, 26 Sep 2013 14:38:14 -0600 (MDT) User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110717 Lanikai/3.1.11 In-Reply-To: <87txh7gxyt.fsf@newsguy.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.10.8794, 1.0.431, 0.0.0000 definitions=2013-09-26_08:2013-09-26, 2013-09-26, 1970-01-01 signatures=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 204.121.3.53 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:163665 Archived-At: >> (defun paren-close-dwim () >> "Insert closing parenthesis from syntax table. >> Use a normal parenthesis if not inside any." >> (interactive "*") >> (insert (or (ignore-errors >> (save-excursion (backward-up-list) >> (cdr (syntax-after (point))))) >> ?\)))) > > I'm a total illiterate in elisp but the narrative so far sounds like a > this code might do something really useful. > > Can someone describe briefly how this would work, maybe with a small > example, when repairing my own perl code? I'm not sure what you mean about "repairing ... code". This command simply inserts ')', ']', or '}' (and perhaps '>' or so) to match the most recent unclosed ([{<. (If it is "really useful", know that it's not my idea; you just quoted my reimplementation of Florian's code.) Davis -- This product is sold by volume, not by mass. If it appears too dense or too sparse, it is because mass-energy conversion has occurred during shipping.