From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Stefan Monnier" Newsgroups: gmane.emacs.devel Subject: Re: Tabs (yikes) Date: 18 Mar 2003 14:28:56 -0500 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <5lof48wk1z.fsf@rum.cs.yale.edu> References: <5lu1e0wl2u.fsf@rum.cs.yale.edu> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1048015843 18814 80.91.224.249 (18 Mar 2003 19:30:43 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 18 Mar 2003 19:30:43 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Tue Mar 18 20:30:42 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18vMn1-0004sl-00 for ; Tue, 18 Mar 2003 20:30:23 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18vMnQ-00066x-00 for ; Tue, 18 Mar 2003 20:30:49 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18vMmO-0007Ej-07 for emacs-devel@quimby.gnus.org; Tue, 18 Mar 2003 14:29:44 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18vMly-00077y-00 for emacs-devel@gnu.org; Tue, 18 Mar 2003 14:29:18 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18vMli-00069M-00 for emacs-devel@gnu.org; Tue, 18 Mar 2003 14:29:12 -0500 Original-Received: from rum.cs.yale.edu ([128.36.229.169]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18vMld-0005qh-00 for emacs-devel@gnu.org; Tue, 18 Mar 2003 14:28:57 -0500 Original-Received: from rum.cs.yale.edu (localhost [127.0.0.1]) by rum.cs.yale.edu (8.12.8/8.12.8) with ESMTP id h2IJSvPe019384 for ; Tue, 18 Mar 2003 14:28:57 -0500 Original-Received: (from monnier@localhost) by rum.cs.yale.edu (8.12.8/8.12.8/Submit) id h2IJSve9019380; Tue, 18 Mar 2003 14:28:57 -0500 X-Authentication-Warning: rum.cs.yale.edu: monnier set sender to monnier@cs.yale.edu using -f Original-Newsgroups: gnu.emacs.help Original-Lines: 38 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 In-Reply-To: <5lu1e0wl2u.fsf@rum.cs.yale.edu> Posted-To: gnu.emacs.help X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:12447 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:12447 The following message is a courtesy copy of an article that has been posted to gnu.emacs.help as well. > Actually, once you pass the last tab-stop in `tab-stop-list', > `tab-to-tab-stop' just inserts a TAB character, which does have I need sleep: it doesn't insert a TAB but a space. It sounds wrong. How about the patch below ? Stefan --- indent.el 14 Mar 2003 23:11:20 -0000 1.54 +++ indent.el 18 Mar 2003 19:26:49 -0000 @@ -498,14 +586,19 @@ (interactive) (and abbrev-mode (= (char-syntax (preceding-char)) ?w) (expand-abbrev)) - (let ((tabs tab-stop-list)) - (while (and tabs (>= (current-column) (car tabs))) + (let ((tabs tab-stop-list) + (col (current-column))) + (while (and tabs (>= col (car tabs))) (setq tabs (cdr tabs))) - (if tabs - (let ((opoint (point))) (delete-horizontal-space t) - (indent-to (car tabs))) - (insert ?\ )))) + (indent-to + (if tabs (car tabs) + ;; We passed the end of tab-stop-list: guess a continuation. + (let* ((last (last tab-stop-list 2)) + (step (if (cdr last) (- (cadr last) (car last)) tab-width))) + (setq last (or (cadr last) (car last) 0)) + ;; Repeat the last tab's length. + (+ last (* step (1+ (/ (- col last) step))))))))) (defun move-to-tab-stop () "Move point to next defined tab-stop column.