unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: Tabs (yikes)
       [not found] ` <5lu1e0wl2u.fsf@rum.cs.yale.edu>
@ 2003-03-18 19:28   ` Stefan Monnier
  0 siblings, 0 replies; only message in thread
From: Stefan Monnier @ 2003-03-18 19:28 UTC (permalink / raw)
  Cc: emacs-devel

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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-03-18 19:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <sJGdnbGJpLOm1eqjXTWcpQ@comcast.com>
     [not found] ` <5lu1e0wl2u.fsf@rum.cs.yale.edu>
2003-03-18 19:28   ` Tabs (yikes) Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).