From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Miles Bader Newsgroups: gmane.emacs.devel Subject: Re: C-u prefix behavior of TAB broken Date: Sun, 23 Dec 2007 04:52:46 +0900 Message-ID: <87bq8ia4mp.fsf@catnip.gol.com> References: <874peijnu4.fsf@catnip.gol.com> <47667010.40209@gmx.at> <87tzmhs8g8.fsf@catnip.gol.com> <4766C7F7.5060504@gmx.at> <87fxxvbnbv.fsf@catnip.gol.com> <476CD8CF.4060108@gmx.at> <874peac02g.fsf@catnip.gol.com> <476D4C5D.7020202@gmx.at> Reply-To: Miles Bader NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1198353199 19712 80.91.229.12 (22 Dec 2007 19:53:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 22 Dec 2007 19:53:19 +0000 (UTC) Cc: emacs-devel@gnu.org, Stefan Monnier , rms@gnu.org To: martin rudalics Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Dec 22 20:53:31 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 1J6APV-0000cx-3k for ged-emacs-devel@m.gmane.org; Sat, 22 Dec 2007 20:53:25 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J6APB-0005JY-19 for ged-emacs-devel@m.gmane.org; Sat, 22 Dec 2007 14:53:05 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1J6AP6-0005J8-LZ for emacs-devel@gnu.org; Sat, 22 Dec 2007 14:53:00 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1J6AP5-0005Iw-1M for emacs-devel@gnu.org; Sat, 22 Dec 2007 14:53:00 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J6AP4-0005It-Uh for emacs-devel@gnu.org; Sat, 22 Dec 2007 14:52:58 -0500 Original-Received: from smtp02.dentaku.gol.com ([203.216.5.72]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1J6AOx-0005H0-CK; Sat, 22 Dec 2007 14:52:51 -0500 Original-Received: from 203-216-96-195.dsl.gol.ne.jp ([203.216.96.195] helo=catnip.gol.com) by smtp02.dentaku.gol.com with esmtpa (Dentaku) id 1J6AOt-0004W1-PW; Sun, 23 Dec 2007 04:52:47 +0900 Original-Received: by catnip.gol.com (Postfix, from userid 1000) id 70D7B2FF7; Sun, 23 Dec 2007 04:52:46 +0900 (JST) System-Type: i686-pc-linux-gnu In-Reply-To: <476D4C5D.7020202@gmx.at> (martin rudalics's message of "Sat, 22 Dec 2007 18:41:49 +0100") Original-Lines: 78 X-Abuse-Complaints: abuse@gol.com X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) 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:85381 Archived-At: martin rudalics writes: > For `tab-always-indent' t it might make sense to do `beginning-of-line' > before the `forward-sexp'. True. It doesn't reach that code at all if tab-always-indent is nil and the point is not in the indentation, so I think it can just always move to the start of the line before calling forward-sexp. > BTW, isn't > > ((memq indent-line-function '(indent-relative indent-relative-maybe)) > (funcall indent-line-function)) > ;; Indent the line. > (t > (indent-according-to-mode)) > > semantically equivalent to > > (t > (funcall indent-line-function)) Indeed yes! That's a nice simplification... I fixed some other little problems (e.g. it should have been using "P" [raw-prefix] in the interactive spec), so here's the current patch: --- orig/lisp/indent.el +++ mod/lisp/indent.el @@ -86,10 +86,10 @@ indent the region. The function actually called to indent the line is determined by the value of `indent-line-function'." - (interactive "p") + (interactive "P") (cond ;; The region is active, indent it. - ((and arg transient-mark-mode mark-active + ((and transient-mark-mode mark-active (not (eq (region-beginning) (region-end)))) (indent-region (region-beginning) (region-end))) ((or ;; indent-to-left-margin is only meant for indenting, @@ -99,13 +99,26 @@ (or (> (current-column) (current-indentation)) (eq this-command last-command)))) (insert-tab arg)) - ;; Those functions are meant specifically for tabbing and not for - ;; indenting, so we can't pass them to indent-according-to-mode. - ((memq indent-line-function '(indent-relative indent-relative-maybe)) - (funcall indent-line-function)) - ;; Indent the line. (t - (indent-according-to-mode)))) + (let ((end-marker + (and arg + (save-excursion + (forward-line 0) (forward-sexp) (point-marker)))) + (old-indent + (current-indentation))) + + ;; Indent the line. + (funcall indent-line-function) + + ;; If a prefix argument was given, rigidly indent the following + ;; sexp to match the change in the current line's indentation. + ;; + (when arg + (let ((indentation-change (- (current-indentation) old-indent))) + (save-excursion + (forward-line 1) + (when (< (point) end-marker) + (indent-rigidly (point) end-marker indentation-change))))))))) (defun insert-tab (&optional arg) (let ((count (prefix-numeric-value arg))) -- Ich bin ein Virus. Mach' mit und kopiere mich in Deine .signature.