[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fixup-whitespace for scripts with no inter-word space
From: |
Eric Abrahamsen |
Subject: |
fixup-whitespace for scripts with no inter-word space |
Date: |
Tue, 05 Nov 2013 13:55:14 +0800 |
User-agent: |
Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3 (gnu/linux) |
A while ago I posted on emacs.help about improving inter-word boundary
behavior for Chinese prose editing. I was directed to post here, but
also given some good tips. I realized I'm looking at two separate
issues, and I'm posting about the simpler of the two first.
That problem is interword spaces -- Chinese doesn't put spaces between
words. I was pointed at fill-nospace-between-words-table, which sure
enough knows all about this:
(aref fill-nospace-between-words-table ?δΈ) -> t
This is used in fill-paragraph (actually fill-delete-newlines) to good
effect. I realized what was actually annoying me was delete-indentation,
which calls fixup-whitespace, which (mostly) unconditionally adds a
space between joined lines.
I did a quick grep of emacs' lisp directory and in the basic libraries,
at least, it seems fixup-whitespace is only called by
delete-indentation.
Would it be acceptable to patch fixup-whitespace so that it does what
fill-delete-newlines does? Ie, rewrite as such:
(defun fixup-whitespace ()
"Fixup white space between objects around point.
Leave one space or none, according to the context."
(interactive "*")
(save-excursion
(delete-horizontal-space)
(if (or (looking-at "^\\|\\s)")
(save-excursion (forward-char -1)
(looking-at "$\\|\\s(\\|\\s'"))
(and enable-multibyte-characters
(let ((prev (preceding-char))
(next (following-char)))
(and (or (aref (char-category-set next) ?|)
(aref (char-category-set prev) ?|))
(or (aref fill-nospace-between-words-table next)
(aref fill-nospace-between-words-table prev))))))
nil
(insert ?\s))))
If this seems acceptable in principle I'll report a bug and provide a
patch.
Thanks,
Eric
- fixup-whitespace for scripts with no inter-word space,
Eric Abrahamsen <=