emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tabs (yikes)


From: Stefan Monnier
Subject: Re: Tabs (yikes)
Date: 18 Mar 2003 14:28:56 -0500
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]