From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dan Nicolaescu Newsgroups: gmane.emacs.devel Subject: Re: TAB when the region is active Date: Tue, 18 Sep 2007 20:42:51 -0700 Message-ID: <200709190342.l8J3gpHQ020774@oogie-boogie.ics.uci.edu> 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> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1190173402 3723 80.91.229.12 (19 Sep 2007 03:43:22 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 19 Sep 2007 03:43:22 +0000 (UTC) Cc: rms@gnu.org, Drew Adams , emacs-devel@gnu.org To: "Lennart Borgman \(gmail\)" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 19 05:43:21 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 1IXqTA-0003p1-QU for ged-emacs-devel@m.gmane.org; Wed, 19 Sep 2007 05:43:21 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IXqT9-0008IU-7A for ged-emacs-devel@m.gmane.org; Tue, 18 Sep 2007 23:43:19 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IXqT4-0008FN-Pv for emacs-devel@gnu.org; Tue, 18 Sep 2007 23:43:14 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IXqT4-0008E2-6J for emacs-devel@gnu.org; Tue, 18 Sep 2007 23:43:14 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IXqT3-0008Dm-SP for emacs-devel@gnu.org; Tue, 18 Sep 2007 23:43:13 -0400 Original-Received: from oogie-boogie.ics.uci.edu ([128.195.1.41]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IXqSz-0007pa-DR; Tue, 18 Sep 2007 23:43:09 -0400 Original-Received: from mothra.ics.uci.edu (mothra.ics.uci.edu [128.195.6.93]) by oogie-boogie.ics.uci.edu (8.13.6/8.13.6) with ESMTP id l8J3gpHQ020774; Tue, 18 Sep 2007 20:42:51 -0700 (PDT) In-Reply-To: <200709172328.l8HNSCK9001067@oogie-boogie.ics.uci.edu> (Dan Nicolaescu's message of "Mon\, 17 Sep 2007 16\:28\:12 -0700") Original-Lines: 85 X-ICS-MailScanner: Found to be clean X-ICS-MailScanner-SpamCheck: not spam, SpamAssassin (score=-0.84, required 5, autolearn=disabled, ALL_TRUSTED -1.44, J_CHICKENPOX_62 0.60) X-ICS-MailScanner-From: dann@mothra.ics.uci.edu X-Detected-Kernel: Solaris 9 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:79265 Archived-At: Dan Nicolaescu writes: > "Lennart Borgman (gmail)" writes: > > > 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: Here's my first try at doing this. lisp-mode needed changes because it binds TAB differently... Can you please give it a spin? Does anything need to be done for the case where TAB is used to insert a tab character? (I don't know when that is supposed to happen and what is the expected behavior...) *** indent.el 26 Jul 2007 10:17:33 -0700 1.68 --- indent.el 18 Sep 2007 08:38:25 -0700 *************** *** 75,81 **** (indent-line-to column) (save-excursion (indent-line-to column)))) ;; The normal case. ! (funcall indent-line-function))) (defun indent-for-tab-command (&optional arg) "Indent line in proper way for current major mode or insert a tab. --- 75,84 ---- (indent-line-to column) (save-excursion (indent-line-to column)))) ;; The normal case. ! (if (and transient-mark-mode mark-active ! (not (eq (region-beginning) (region-end)))) ! (indent-region (region-beginning) (region-end)) ! (funcall indent-line-function)))) (defun indent-for-tab-command (&optional arg) "Indent line in proper way for current major mode or insert a tab. *** emacs-lisp/lisp-mode.el 20 Aug 2007 15:47:53 -0700 1.207 --- emacs-lisp/lisp-mode.el 18 Sep 2007 08:46:08 -0700 *************** *** 261,267 **** (defvar lisp-mode-shared-map (let ((map (make-sparse-keymap))) ! (define-key map "\t" 'lisp-indent-line) (define-key map "\e\C-q" 'indent-sexp) (define-key map "\177" 'backward-delete-char-untabify) ;; This gets in the way when viewing a Lisp file in view-mode. As --- 261,267 ---- (defvar lisp-mode-shared-map (let ((map (make-sparse-keymap))) ! (define-key map "\t" 'lisp-indent-line-or-region) (define-key map "\e\C-q" 'indent-sexp) (define-key map "\177" 'backward-delete-char-untabify) ;; This gets in the way when viewing a Lisp file in view-mode. As *************** *** 828,833 **** --- 828,841 ---- (> end beg)) (indent-code-rigidly beg end shift-amt))))) + (defun lisp-indent-line-or-region (&optional whole-exp) + "Indent the current line or the region if it is active." + (interactive "P") + (if (and transient-mark-mode mark-active + (not (eq (region-beginning) (region-end)))) + (lisp-indent-region (region-beginning) (region-end)) + (lisp-indent-line whole-exp))) + (defvar calculate-lisp-indent-last-sexp) (defun calculate-lisp-indent (&optional parse-start)