From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: Insert character pairs Date: Sat, 01 May 2004 02:22:22 +0300 Organization: JURTA Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <87ad0tyrsu.fsf@mail.jurta.org> References: <87brlb1840.fsf@mail.jurta.org> <87vfjiakte.fsf@mail.jurta.org> <87ad0ukxxm.fsf@mail.jurta.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1083368038 20135 80.91.224.253 (30 Apr 2004 23:33:58 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 30 Apr 2004 23:33:58 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sat May 01 01:33:50 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BJhVu-0002pJ-00 for ; Sat, 01 May 2004 01:33:50 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BJhVt-000766-00 for ; Sat, 01 May 2004 01:33:50 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BJhUU-0005HQ-NH for emacs-devel@quimby.gnus.org; Fri, 30 Apr 2004 19:32:22 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1BJhQr-0004O0-3Y for emacs-devel@gnu.org; Fri, 30 Apr 2004 19:28:37 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1BJhPv-0003Ra-La for emacs-devel@gnu.org; Fri, 30 Apr 2004 19:28:12 -0400 Original-Received: from [66.33.219.19] (helo=spoon.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BJhPv-0003R8-1o for emacs-devel@gnu.org; Fri, 30 Apr 2004 19:27:39 -0400 Original-Received: from mail.jurta.org (80-235-32-234-dsl.mus.estpak.ee [80.235.32.234]) by spoon.dreamhost.com (Postfix) with ESMTP id 2639213D8B3; Fri, 30 Apr 2004 16:27:43 -0700 (PDT) Original-To: Stefan Monnier In-Reply-To: (Stefan Monnier's message of "30 Apr 2004 09:43:23 -0400") User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:22472 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:22472 Stefan Monnier writes: >>>>>> The following patch generalizes the function `insert-parentheses' >>>>> Why not start from skeleton-insert-paren-maybe ? >>>> It doesn't work with key modifiers. >>> That why I said "start" rather than "use". I know it requires changes. >> I am not sure that the meaning of arguments of `skeleton-insert-paren-maybe' >> should be redefined. > That's why I said "start with" rather than "change". > Anyway, it's not like it makes any real difference. Creating a function similar to `insert-parentheses' is very easy. The following diff shows the needed changes (note that I don't propose to change the existing function, this diff only demonstrates the differences between the existing function and the new `skeleton-pair-insert' function): -(defun skeleton-pair-insert-maybe (arg) +(defun skeleton-pair-insert (arg) (interactive "*P") - (if (or arg (not skeleton-pair)) + (if (not skeleton-pair) (self-insert-command (prefix-numeric-value arg)) (let* ((mark (and skeleton-autowrap (or (eq last-command 'mouse-drag-region) (and transient-mark-mode mark-active)))) (skeleton-end-hook) - (char last-command-char) + (char (event-basic-type last-command-event)) (skeleton (or (assq char skeleton-pair-alist) (assq char skeleton-pair-default-alist) `(,char _ ,char)))) (if (or (memq (char-syntax (preceding-char)) '(?\\ ?/)) (and (not mark) (or overwrite-mode (if (not skeleton-pair-on-word) (looking-at "\\w")) (funcall skeleton-pair-filter)))) (self-insert-command (prefix-numeric-value arg)) - (skeleton-insert (cons nil skeleton) (if mark -1)))))) + (skeleton-insert (cons nil skeleton) (if mark -1 (prefix-numeric-value arg))))))) But I think my changes in `insert-parentheses' are useful too, because these function are still different: `skeleton-insert' counts words, but `insert-parentheses' counts s-expressions. And there are other less important differences. -- Juri Linkov http://www.jurta.org/emacs/