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: Thu, 06 May 2004 15:02:15 +0300 Organization: JURTA Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <87r7txpxug.fsf@mail.jurta.org> References: <87brlb1840.fsf@mail.jurta.org> <87smeka7aj.fsf@mail.jurta.org> <4096A229.4050301@yahoo.com> <87ekq0yc2z.fsf@mail.jurta.org> <4097E14B.3080908@yahoo.com> <87d65k0z3d.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 1083848403 32451 80.91.224.253 (6 May 2004 13:00:03 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 6 May 2004 13:00:03 +0000 (UTC) Cc: ihs_4664@yahoo.com, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Thu May 06 14:59: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 1BLiTe-0004sa-00 for ; Thu, 06 May 2004 14:59: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 1BLiTe-0007By-00 for ; Thu, 06 May 2004 14:59: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 1BLiPW-0007Bd-QL for emacs-devel@quimby.gnus.org; Thu, 06 May 2004 08:55:34 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1BLiFk-0005Dr-BP for emacs-devel@gnu.org; Thu, 06 May 2004 08:45:28 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1BLhmx-000153-Gw for emacs-devel@gnu.org; Thu, 06 May 2004 08:16:15 -0400 Original-Received: from [66.33.219.6] (helo=knife.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BLheC-0007Rn-0V; Thu, 06 May 2004 08:06:40 -0400 Original-Received: from mail.jurta.org (80-235-39-194-dsl.mus.estpak.ee [80.235.39.194]) by knife.dreamhost.com (Postfix) with ESMTP id 5CF02E404A; Thu, 6 May 2004 05:06:37 -0700 (PDT) Original-To: rms@gnu.org In-Reply-To: (Richard Stallman's message of "Wed, 05 May 2004 16:20:45 -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:22848 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:22848 Richard Stallman writes: > Good names, but not completely true. Actually, this function deletes > all the text inside the sexp out of one level of parentheses, except > sexps selected by the argument or active region in transient-mark-mode. > > The name delete-surrounding-sexp would fit that command, but > that doesn't seem like a very useful command. > > I had misunderstood the previous description; I though the idea was > to delete just the parentheses, more or less the opposite of what > insert-parentheses does. The name delete-surrounding-sexp would > not fit that at all, but raise-sexp or promote-sexp would fit it. This suggests that actually two separate commands would be useful: `delete-parentheses' and `raise-sexp'. Both would operate on the sexp that follows point, with the difference that the latter simply deletes enclosing parentheses, and the former deletes the whole surrounding sexp excluding some selected inner sexps. Both are useful: `delete-parentheses' is useful to delete not only parentheses, but any enclosing characters, including all kinds of quotes. And `raise-sexp' is very handy for editing Emacs Lisp programs to replace the surrounding sexp by selected inner sexps: e.g. to move sexps from `if' condition, from `save-excursion' and in many other similar situations. For example, suppose that there is the need to change `(save-excursion (insert s))' into `(insert s)'. Currently, this requires too many keystrokes. `raise-sexp' will allow to do this with only one command. Index: emacs/lisp/emacs-lisp/lisp.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/lisp.el,v retrieving revision 1.53 diff -u -r1.53 lisp.el --- emacs/lisp/emacs-lisp/lisp.el 1 May 2004 03:58:43 -0000 1.53 +++ emacs/lisp/emacs-lisp/lisp.el 6 May 2004 11:56:44 -0000 @@ -348,6 +371,27 @@ +(defun delete-pair () + "Delete a pair of characters enclosing the sexp that follows point." + (interactive) + (save-excursion (forward-sexp 1) (delete-char -1)) + (delete-char 1)) + +(defalias 'delete-parentheses 'delete-pair) + +(defun raise-sexp (&optional arg) + "Raise ARG sexps higher up the tree." + (interactive "p") + (let ((s (if (and transient-mark-mode mark-active) + (buffer-substring (region-beginning) (region-end)) + (buffer-substring + (point) + (save-excursion (forward-sexp arg) (point)))))) + (backward-up-list 1) + (delete-region (point) (save-excursion (forward-sexp 1) (point))) + (save-excursion (insert s)))) -- Juri Linkov http://www.jurta.org/emacs/