all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Stefan Monnier" <monnier+gnu.emacs.help/news/@rum.cs.yale.edu>
Cc: emacs-devel@gnu.org
Subject: Re: Tabs (yikes)
Date: 18 Mar 2003 14:28:56 -0500	[thread overview]
Message-ID: <5lof48wk1z.fsf@rum.cs.yale.edu> (raw)
In-Reply-To: <5lu1e0wl2u.fsf@rum.cs.yale.edu>

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.

      parent reply	other threads:[~2003-03-18 19:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-18 16:24 Tabs (yikes) Tony Vitonis
2003-03-18 18:40 ` Karl Pflästerer
2003-03-18 18:44 ` Benjamin Rutt
     [not found] ` <5lu1e0wl2u.fsf@rum.cs.yale.edu>
2003-03-18 19:28   ` Stefan Monnier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5lof48wk1z.fsf@rum.cs.yale.edu \
    --to=monnier+gnu.emacs.help/news/@rum.cs.yale.edu \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.