From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.help Subject: Re: How to complete \] when I input \[ . Date: Mon, 15 Sep 2008 07:57:34 +0200 Message-ID: <873ak2uf1t.fsf@tux.homenetwork> References: <878wuxksn4.fsf@localhorst.mine.nu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1221458496 11888 80.91.229.12 (15 Sep 2008 06:01:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 15 Sep 2008 06:01:36 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: dkcombs@panix.com (David Combs) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Sep 15 08:02:33 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Kf7AN-00056C-JJ for geh-help-gnu-emacs@m.gmane.org; Mon, 15 Sep 2008 08:02:31 +0200 Original-Received: from localhost ([127.0.0.1]:50391 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kf79M-0004nv-Mr for geh-help-gnu-emacs@m.gmane.org; Mon, 15 Sep 2008 02:01:28 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kf78u-0004mY-6f for help-gnu-emacs@gnu.org; Mon, 15 Sep 2008 02:01:00 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kf78r-0004jy-W0 for help-gnu-emacs@gnu.org; Mon, 15 Sep 2008 02:00:59 -0400 Original-Received: from [199.232.76.173] (port=35488 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kf78r-0004ja-Nj for help-gnu-emacs@gnu.org; Mon, 15 Sep 2008 02:00:57 -0400 Original-Received: from ug-out-1314.google.com ([66.249.92.170]:61880) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Kf78r-0003Vz-IL for help-gnu-emacs@gnu.org; Mon, 15 Sep 2008 02:00:57 -0400 Original-Received: by ug-out-1314.google.com with SMTP id z36so911968uge.17 for ; Sun, 14 Sep 2008 23:00:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:references :date:in-reply-to:message-id:user-agent:mime-version:content-type; bh=SsfWlJGHbKFfTPFGKTs2ArVEDaQgb3jACZSovl0B//I=; b=dqGCcNEpz7laf0+VKh23lA3+SBlpyBSoiN+swRIS2OJnGieF08apQ5X72hqyAo+wdE VhzVsL8thkwa9TkSJzqz0TrPiZ/Ix1EZNIqUkQXyRxU6xgzXeGIOjzcoefeSZE5sGSDt 7Ome3by4yidgJ9cMuulpqSmDgRIVuMm5+5eO8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=LtLQWCUp0TsjvUeefnFpNygKF5jvZNwxi6flrVmQgWwdtgBuwUvHvSPZp/wQd7MfOZ pKumCJcEkkHR2kQ02XRyc3zjjQrDViM2Vp9lVny9nT3uiew591mjd2VPYWWmo6bYfYwc difyNDFwZhd6s3/QFK0taBpdrLBeApP3QkNJM= Original-Received: by 10.210.25.19 with SMTP id 19mr4816369eby.134.1221458456152; Sun, 14 Sep 2008 23:00:56 -0700 (PDT) Original-Received: from tux.homenetwork ( [79.85.211.147]) by mx.google.com with ESMTPS id z34sm23216652ikz.3.2008.09.14.23.00.54 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 14 Sep 2008 23:00:55 -0700 (PDT) In-Reply-To: (David Combs's message of "Mon, 15 Sep 2008 02:38:34 +0000 (UTC)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:57600 Archived-At: dkcombs@panix.com (David Combs) writes: > In article , > Thierry Volpiatto wrote: >>"xiaopeng hu" writes: >> >>> I mean \[ \]. thanks >>> >>> 2008/8/16 David Hansen >>> >>>> On Sat, 16 Aug 2008 21:09:46 +0800 xiaopeng hu wrote: >>>> >>>> > When I input \[ , how to complete \] and put point at middle? >>>> > >>>> >>>> Should work: >>>> >>>> (global-set-key (kbd "[") #'insert-pair) >>>> >>>> David >> >>,---- >>| (defun insert-second-hook () >>| (interactive) >>| (insert "\[\\]") >>| (goto-char (- (point) 2))) >>| (global-set-key (kbd "\[") 'insert-second-hook) >>`---- >> >>-- >>A + Thierry Volpiatto >>Location: Saint-Cyr-Sur-Mer - France > > If you're got time, please briefly explain how it works, what it does, etc. If i remember OP wanted completion on \[ with \] with the "\" included thats why there is \ in insert. This version complete the "[" with "]" and put point between the []. ,----[ insert pair of [] ] | (defun insert-second-hook () | (interactive) | (insert "[]") | (goto-char (- (point) 1))) | (global-set-key (kbd "\[") 'insert-second-hook) `---- when you press key [ it insert the two [] and then go back one char. Note that is a very simple code and can be much better, look at pair-mode.el. Note also you can set key [ locally for a special mode with `define-key' instead of setting it globally with `global-set-key'. Personnaly i don't like completion on pairs so i don't use that :) -- A + Thierry Volpiatto Location: Saint-Cyr-Sur-Mer - France