From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: TAB when the region is active Date: Mon, 24 Sep 2007 03:07:57 +0300 Organization: JURTA Message-ID: <871wcokiuq.fsf@jurta.org> References: <200709142159.l8ELxFpE029330@oogie-boogie.ics.uci.edu> <200709170409.l8H49nmZ022542@oogie-boogie.ics.uci.edu> <46EF0242.1080806@gmail.com> <200709172328.l8HNSCK9001067@oogie-boogie.ics.uci.edu> <200709190342.l8J3gpHQ020774@oogie-boogie.ics.uci.edu> <200709200154.l8K1sX2u011202@oogie-boogie.ics.uci.edu> <200709220100.l8M10Ub3008452@oogie-boogie.ics.uci.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1190594715 18221 80.91.229.12 (24 Sep 2007 00:45:15 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 24 Sep 2007 00:45:15 +0000 (UTC) Cc: emacs-devel@gnu.org To: Dan Nicolaescu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 24 02:45:09 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IZc4S-0007Rt-WD for ged-emacs-devel@m.gmane.org; Mon, 24 Sep 2007 02:45:09 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IZc4Q-0003nn-Hq for ged-emacs-devel@m.gmane.org; Sun, 23 Sep 2007 20:45:06 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IZc3R-0003Iu-Dk for emacs-devel@gnu.org; Sun, 23 Sep 2007 20:44:05 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IZc3Q-0003I1-Fg for emacs-devel@gnu.org; Sun, 23 Sep 2007 20:44:04 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IZc3Q-0003Ht-6f for emacs-devel@gnu.org; Sun, 23 Sep 2007 20:44:04 -0400 Original-Received: from relay01.kiev.sovam.com ([62.64.120.200]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IZc3P-00053b-IF for emacs-devel@gnu.org; Sun, 23 Sep 2007 20:44:03 -0400 Original-Received: from [83.170.232.243] (helo=smtp.svitonline.com) by relay01.kiev.sovam.com with esmtp (Exim 4.67) (envelope-from ) id 1IZc3J-000INB-Bk; Mon, 24 Sep 2007 03:44:01 +0300 In-Reply-To: <200709220100.l8M10Ub3008452@oogie-boogie.ics.uci.edu> (Dan Nicolaescu's message of "Fri\, 21 Sep 2007 18\:00\:30 -0700") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux) X-Scanner-Signature: 021e97fb5facab6d3ae496d7b6c27559 X-DrWeb-checked: yes X-SpamTest-Envelope-From: juri@jurta.org X-SpamTest-Group-ID: 00000000 X-SpamTest-Header: Not Detected X-SpamTest-Info: Profiles 1513 [September 21 2007] X-SpamTest-Info: helo_type=3 X-SpamTest-Info: {HEADERS: header Content-Type found without required header Content-Transfer-Encoding} X-SpamTest-Method: none X-SpamTest-Rate: 25 X-SpamTest-Status: Not detected X-SpamTest-Status-Extended: not_detected X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0255], KAS30/Release X-Detected-Kernel: FreeBSD 4.8-5.1 (or MacOS X 10.2-10.3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:79645 Archived-At: > I have committed the patch. > > cc-mode would need to be updated to do the same thing. I emailed the > maintainer. > > Other major modes might need updates too. We can do them as soon as we > find out they need changes. Thanks! It's a pity this very good feature doesn't work yet in c-mode. I also tried it in some other modes (fundamental-mode, text-mode) and it doesn't do something useful here. It inserts a single TAB whereas C-M-\ (`indent-region') tries to indent the region. However, what C-M-\ does in text modes is not useful too because it shifts each consequent line relative to the previous line in a staircase-like style. So perhaps there is nothing useful it can do in text modes. What would be useful to do in text modes is to make a similar change for M-q (`fill-paragraph'). When the region is active in transient-mark-mode, then M-q would call `fill-region' instead of `fill-paragraph'. Please note that there was a keybinding for `fill-region' in bindings.el but currently it is commented out because there are no free keybindings for it. Using M-q to fill the active region would be convenient for users of transient-mark-mode. Below is a patch that implement the new command `fill-paragraph-or-region': Index: lisp/bindings.el =================================================================== RCS file: /sources/emacs/emacs/lisp/bindings.el,v retrieving revision 1.184 diff -c -r1.184 bindings.el *** lisp/bindings.el 20 Sep 2007 21:49:18 -0000 1.184 --- lisp/bindings.el 24 Sep 2007 00:04:22 -0000 *************** *** 1041,1048 **** (define-key ctl-x-map "rw" 'window-configuration-to-register) (define-key ctl-x-map "rf" 'frame-configuration-to-register) ! (define-key esc-map "q" 'fill-paragraph) ! ;; (define-key esc-map "g" 'fill-region) (define-key ctl-x-map "." 'set-fill-prefix) (define-key esc-map "{" 'backward-paragraph) --- 1041,1047 ---- (define-key ctl-x-map "rw" 'window-configuration-to-register) (define-key ctl-x-map "rf" 'frame-configuration-to-register) ! (define-key esc-map "q" 'fill-paragraph-or-region) (define-key ctl-x-map "." 'set-fill-prefix) (define-key esc-map "{" 'backward-paragraph) Index: lisp/textmodes/fill.el =================================================================== RCS file: /sources/emacs/emacs/lisp/textmodes/fill.el,v retrieving revision 1.205 diff -c -r1.205 fill.el *** lisp/textmodes/fill.el 26 Jul 2007 05:27:32 -0000 1.205 --- lisp/textmodes/fill.el 24 Sep 2007 00:04:56 -0000 *************** *** 1007,1012 **** --- 1007,1022 ---- (goto-char end)))) fill-pfx)) + (defun fill-paragraph-or-region (arg) + "Fill the active region or paragraph." + (interactive (progn + (barf-if-buffer-read-only) + (list (if current-prefix-arg 'full)))) + (if (and transient-mark-mode mark-active + (not (eq (region-beginning) (region-end)))) + (fill-region (region-beginning) (region-end) arg) + (fill-paragraph arg))) + (defcustom default-justification 'left "*Method of justifying text not otherwise specified. -- Juri Linkov http://www.jurta.org/emacs/