mailing-list for TeXmacs Users

Text archives Help


Re: Double space after period?


Chronological Thread 
  • From: address@hidden
  • To: "Karl M. Hegbloom" <address@hidden>
  • Cc: address@hidden
  • Subject: Re: Double space after period?
  • Date: Mon, 24 Feb 2003 11:31:05 +0100

On Wed, Feb 19, 2003 at 02:19:00PM -0800, Karl M. Hegbloom wrote:
> In ordinary TeX, the number of spaces after a period in the source
> does not matter. It always uses the right amount of space after a
> period. But in TeXmacs, it inserts extra space. When a period falls
> at the end of a line, the next line is then indented by one space.
> This is not quite right!
>
> OpenOffice.org Writer has a setting to have it ignore extra spacebar
> presses -- when that's on, if you push space twice, only the first one
> is input. Perhaps this is a good solution for TeXmacs as well, then
> make shift-space (or whatever) insert the explicit extra space?

You may use the following script in your my-init-texmacs.scm:

------------------------------------------------------------
(define (string-space-at? s i) (== #\space (string-ref s i)))
(define (tree-leaf? t) (== "" (tree-get-label t)))
(define (tree-func? t s) (== s (tree-get-label t)))
(define (near-space?/leaf t1 i)
(let ((s (tree->object t1)))
(or (and (< 0 i)
(string-space-at? s (1- i)))
(and (< i (string-length s))
(string-space-at? s i)))))

(define (near-space?/after p1)
(and-let* ((t2 (tm-subtree (cDr p1)))
((tree-func? t2 "concat"))
(i (cAr p1))
((< (1+ i) (tree-arity t2)))
(next-t (tree-ref t2 (1+ i)))
((tree-leaf? next-t))
((string-space-at? (tree->string next-t) 0)))))

(define (near-space?)
(let* ((p (the-path))
(p1 (cDr p))
(i (cAr p))
(t1 (tm-subtree p1)))
(cond ((tree-leaf? t1) (near-space?/leaf t1 i))
((== i 1) (near-space?/after p1))
(else #f))))

(define (smart-space)
(if (not (near-space?)) (insert-string " ")))
(kbd-map in-text? ("space" (smart-space)))
------------------------------------------------------------

Note: These scripts use the new syntax for keymap definition
introduced in TeXmacs-1.0.1.4.

--
David Allouche | GNU TeXmacs -- Writing is a pleasure
Free software engineer | http://www.texmacs.org
http://ddaa.net | http://alqua.com/tmresources
address@hidden | address@hidden
TeXmacs is NOT a LaTeX front-end and is unrelated to emacs.



Archive powered by MHonArc 2.6.19.

Top of page