From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: TAB when the region is active Date: Thu, 20 Sep 2007 09:52:21 -0400 Message-ID: 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> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1190296430 26923 80.91.229.12 (20 Sep 2007 13:53:50 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 20 Sep 2007 13:53:50 +0000 (UTC) Cc: "Lennart Borgman \(gmail\)" , rms@gnu.org, Drew Adams , emacs-devel@gnu.org To: Dan Nicolaescu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 20 15:53:39 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 1IYMTJ-0001FF-2Z for ged-emacs-devel@m.gmane.org; Thu, 20 Sep 2007 15:53:37 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IYMTH-0001Iq-6t for ged-emacs-devel@m.gmane.org; Thu, 20 Sep 2007 09:53:35 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IYMTD-0001IR-Pe for emacs-devel@gnu.org; Thu, 20 Sep 2007 09:53:31 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IYMTC-0001I6-Gf for emacs-devel@gnu.org; Thu, 20 Sep 2007 09:53:30 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IYMTC-0001I3-8w for emacs-devel@gnu.org; Thu, 20 Sep 2007 09:53:30 -0400 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IYMT8-0007Sa-73; Thu, 20 Sep 2007 09:53:26 -0400 Original-Received: from ceviche.home (vpn-132-204-232-71.acd.umontreal.ca [132.204.232.71]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id l8KDrMwE019309; Thu, 20 Sep 2007 09:53:22 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id B9B4A70028; Thu, 20 Sep 2007 09:52:21 -0400 (EDT) In-Reply-To: <200709200154.l8K1sX2u011202@oogie-boogie.ics.uci.edu> (Dan Nicolaescu's message of "Wed\, 19 Sep 2007 18\:54\:29 -0700") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux) X-NAI-Spam-Score: -2.5 X-NAI-Spam-Rules: 2 Rules triggered BAYES_00=-2.5, HAS_X_HELO=0 X-Detected-Kernel: Linux 2.6 (newer, 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:79367 Archived-At: >> > Here's my first try at doing this. >> The change should not be in indent-according-to-mode, but in >> indent-for-tab-command. > If I do it like this: > *** indent.el 26 Jul 2007 10:17:33 -0700 1.68 > --- indent.el 19 Sep 2007 18:29:56 -0700 > *************** > *** 98,104 **** > ((memq indent-line-function '(indent-relative indent-relative-maybe)) > (funcall indent-line-function)) > (t ;; The normal case. > ! (indent-according-to-mode)))) > (defun insert-tab (&optional arg) > (let ((count (prefix-numeric-value arg))) > --- 101,110 ---- > ((memq indent-line-function '(indent-relative indent-relative-maybe)) > (funcall indent-line-function)) > (t ;; The normal case. > ! (if (and transient-mark-mode mark-active > ! (not (eq (region-beginning) (region-end)))) > ! (indent-region (region-beginning) (region-end)) > ! (indent-according-to-mode))))) Please don't use an `if' in the tail of a `cond': just place the condition directly in the `cond'. > (defun insert-tab (&optional arg) > (let ((count (prefix-numeric-value arg))) > then indenting the region by pressing TAB does not work in c-mode > anymore (it did work in my first try). Sure. Some modes use the default behavior of TAB (e.g. it obeys tab-always-indent), others override it. Those who override it have their reason to do it, so we may want to tell them about it, but we shouldn't impose it. Putting the code in indent-according-to-mode will introduce bugs in code that calls it specifically to indent a single line. It is just the wrong place. > Should c-mode also not bind TAB? That's up to the maintainer of c-mode. Stefan