From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Lennart Borgman (gmail)" Newsgroups: gmane.emacs.devel Subject: Re: TAB when the region is active Date: Tue, 18 Sep 2007 00:40:02 +0200 Message-ID: <46EF0242.1080806@gmail.com> References: <200709142159.l8ELxFpE029330@oogie-boogie.ics.uci.edu> <200709170409.l8H49nmZ022542@oogie-boogie.ics.uci.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1190068852 16419 80.91.229.12 (17 Sep 2007 22:40:52 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 17 Sep 2007 22:40:52 +0000 (UTC) Cc: Dan Nicolaescu , Drew Adams , emacs-devel@gnu.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 18 00:40:51 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 1IXPGn-0005K6-0L for ged-emacs-devel@m.gmane.org; Tue, 18 Sep 2007 00:40:45 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IXPGl-0003DR-On for ged-emacs-devel@m.gmane.org; Mon, 17 Sep 2007 18:40:43 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IXPGi-0003DC-HW for emacs-devel@gnu.org; Mon, 17 Sep 2007 18:40:40 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IXPGg-0003D0-Jn for emacs-devel@gnu.org; Mon, 17 Sep 2007 18:40:39 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IXPGg-0003Cx-Di for emacs-devel@gnu.org; Mon, 17 Sep 2007 18:40:38 -0400 Original-Received: from ch-smtp01.sth.basefarm.net ([80.76.149.212]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IXPGb-0003nK-O2; Mon, 17 Sep 2007 18:40:34 -0400 Original-Received: from c83-254-133-189.bredband.comhem.se ([83.254.133.189]:61209 helo=[127.0.0.1]) by ch-smtp01.sth.basefarm.net with esmtp (Exim 4.66) (envelope-from ) id 1IXPGZ-0001Nm-5r; Tue, 18 Sep 2007 00:40:32 +0200 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070728 Thunderbird/2.0.0.6 Mnenhy/0.7.5.666 In-Reply-To: X-Antivirus: avast! (VPS 000775-1, 2007-09-17), Outbound message X-Antivirus-Status: Clean X-Originating-IP: 83.254.133.189 X-Scan-Result: No virus found in message 1IXPGZ-0001Nm-5r. X-Scan-Signature: ch-smtp01.sth.basefarm.net 1IXPGZ-0001Nm-5r 7c03150d72d9cb66163498de7c061fe0 X-Detected-Kernel: Linux 2.6? (barebone, rare!) 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:79147 Archived-At: Richard Stallman wrote: > > The idea is logical, but we need to ask users if they find the change > > annoying. > > Given that we are not close to a release, this would be a good time to > experiment. Can you please OK such a change? > > I will ok trying it, if you agree to follow up in a few weeks > by reminding people to try it and say if they don't like it. The code below is what I currently use. There are some problems I know about: - I do not remember what Drew wanted to add (in another message). - indent-according-to-mode is not supported everywhere. BTW, there is another problem with the indentation functions. I believe it would be useful (at least in mumamo.el) if the function that indents a line where split into one that gives the indentation amount and one that does the indentation (for every major mode). (defun indent-line-or-region () "Indent line or region. Only do this if indentation seems bound to \\t. Call `indent-region' if region is active, otherwise `indent-according-to-mode'." (interactive) ;; Do a wild guess if we should indent or not ... (let* ((indent-region-mode) (t-bound (key-binding [?\t]))) (if (not (save-match-data (string-match "indent" (symbol-name t-bound)))) (call-interactively t-bound t) (if (and mark-active ;; there is a visible region selected transient-mark-mode) (indent-region (region-beginning) (region-end)) (indent-according-to-mode))))) ;; indent line