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: Sun, 02 May 2004 19:19:44 +0300 Organization: JURTA Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <871xm2ol7j.fsf@mail.jurta.org> References: <87brlb1840.fsf@mail.jurta.org> <87smeka7aj.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 1083516188 14021 80.91.224.253 (2 May 2004 16:43:08 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 2 May 2004 16:43:08 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sun May 02 18:43:02 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 1BKK3S-00038J-00 for ; Sun, 02 May 2004 18:43:02 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BKK3R-0004QJ-00 for ; Sun, 02 May 2004 18:43:01 +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 1BKK31-0002Wd-Jl for emacs-devel@quimby.gnus.org; Sun, 02 May 2004 12:42:35 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1BKK1K-0001vN-To for emacs-devel@gnu.org; Sun, 02 May 2004 12:40:50 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1BKK0k-0001c7-82 for emacs-devel@gnu.org; Sun, 02 May 2004 12:40:45 -0400 Original-Received: from [199.232.41.8] (helo=mx20.gnu.org) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.30) id 1BKK0k-0001YV-00 for emacs-devel@gnu.org; Sun, 02 May 2004 12:40:14 -0400 Original-Received: from [66.33.219.4] (helo=spork.dreamhost.com) by mx20.gnu.org with esmtp (Exim 4.30) id 1BKJnp-0003HC-W2 for emacs-devel@gnu.org; Sun, 02 May 2004 12:26:54 -0400 Original-Received: from mail.jurta.org (80-235-32-164-dsl.mus.estpak.ee [80.235.32.164]) by spork.dreamhost.com (Postfix) with ESMTP id C9C9711DC27 for ; Sun, 2 May 2004 09:26:50 -0700 (PDT) Original-To: emacs-devel@gnu.org 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:22539 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:22539 > Maybe, a better name is `move-up-list' (however, not good since > the word `move' often means `move the point') or `lift-up-list'? > > The command `promote-list' is basically opposite to `insert-parentheses', > so another possible name is `remove-parentheses', but it is misleading, > because it removes more than only enclosing parentheses. I propose to bind `rise-up-list' to currently unused `C-x C-M-u'. The reason is that it is similar to `backward-up-list' (`C-M-u'), but with the prefix C-x will move the list backward out of one level of parentheses instead of moving the point as `backward-up-list' does. And while on this topic, another suggestion is to add a prefix argument to the command C-M-q (`indent-sexp') which currently has no prefix argument. This can be similar to M-q (`fill-paragraph') whose prefix argument adds a special meaning to justify paragraphs. C-M-q without prefix will work exactly as it currently works, but with a prefix will pretty-print the list after point. This is relevant only for emacs-lisp-mode and buffers in lisp-interaction-mode like the *scratch* buffer. Index: lisp/emacs-lisp/lisp-mode.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/lisp-mode.el,v retrieving revision 1.155 diff -U4 -r1.155 lisp-mode.el --- lisp/emacs-lisp/lisp-mode.el 22 Mar 2004 15:31:46 -0000 1.155 +++ lisp/emacs-lisp/lisp-mode.el 2 May 2004 15:13:58 -0000 @@ -238,8 +238,9 @@ (setq emacs-lisp-mode-map (make-sparse-keymap)) (set-keymap-parent emacs-lisp-mode-map lisp-mode-shared-map) (define-key emacs-lisp-mode-map "\e\t" 'lisp-complete-symbol) (define-key emacs-lisp-mode-map "\e\C-x" 'eval-defun) + (define-key emacs-lisp-mode-map "\e\C-q" 'indent-or-pp-sexp) (define-key emacs-lisp-mode-map [menu-bar] (make-sparse-keymap)) (define-key emacs-lisp-mode-map [menu-bar emacs-lisp] (cons "Emacs-Lisp" map)) (define-key map [edebug-defun] @@ -368,8 +369,9 @@ (defvar lisp-interaction-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map lisp-mode-shared-map) (define-key map "\e\C-x" 'eval-defun) + (define-key map "\e\C-q" 'indent-or-pp-sexp) (define-key map "\e\t" 'lisp-complete-symbol) (define-key map "\n" 'eval-print-last-sexp) map) "Keymap for Lisp Interaction mode. @@ -1082,8 +1084,19 @@ (and (bolp) (not (eolp)) (lisp-indent-line)) (indent-sexp endmark) (set-marker endmark nil)))) + +(defun indent-or-pp-sexp (&optional arg) + "Indent each line of the list or, with argument, pretty-printify the list." + (interactive "P") + (if arg + (let* (p (str (pp-to-string (save-excursion + (prog1 (read (current-buffer)) + (setq p (point))))))) + (delete-region (point) p) + (save-excursion (insert str))) + (indent-sexp))) ;;;; Lisp paragraph filling commands. (defcustom emacs-lisp-docstring-fill-column 65 -- Juri Linkov http://www.jurta.org/emacs/