all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Filling and one-letter words at end of line
@ 2004-11-06  3:55 Maciek Pasternacki
  0 siblings, 0 replies; 4+ messages in thread
From: Maciek Pasternacki @ 2004-11-06  3:55 UTC (permalink / raw)


I use Emacs to type texts in polish, which is my native language.  It
has a few frequently used one-letter words.  I also use both
auto-fill-mode (on by default) and, when reformatting text,
fill-paragraph and other manual filling commands.  The problem is that
these one-letter characters shouldn't occur at end of line, and fill
commands frequently places them there.  I usually place them manually
now but it's bothersome.  What is funny is that english one-letter
words (`I' and `a') are never filled at end of line.  Is there some
way to tell Emacs not to fill *any* one-letter words at end of line?

Thanks in advance,

		--japhy

-- 
__    Maciek Pasternacki <maciekp@japhy.fnord.org> [ http://japhy.fnord.org/ ]
`| _   |_\  / {  Any sufficiently complicated C or Fortran program contains an
,|{-}|}| }\/ad hoc informally-specified bug-ridden slow implementation of half
\/   |____/  of Common Lisp. }  ( Greenspun's 10th Rule of Programming )  -><-

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: Filling and one-letter words at end of line
@ 2004-11-08 18:38 JayBingham
  2004-11-08 22:05 ` Maciek Pasternacki
       [not found] ` <mailman.1514.1099952102.8225.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 4+ messages in thread
From: JayBingham @ 2004-11-08 18:38 UTC (permalink / raw)


<Send replies only to the list not to this address>

OnFriday, November 05, 2004 9:55 PM Maciek Pasternacki wrote:

> What is funny is that english one-letter words (`I' and `a') are
never 
> filled at end of line.

I am curious as to why you think this is true.  I just did a quick
test in emacs 21.3 running on my Win2000 PC and I do not see the
above behavior.   I entered a paragraph where both `a' and `I' are
the final words on subsequent lines in the paragraph.  I can find
nothing in the emacs info file or the emacs lisp reference that
describes any options to do what you are describing.

-_
J_)
C_)ingham
.    Hewlett-Packard
.    Austin, TX
. “Language is the apparel in which your thoughts parade in public.
.  Never clothe them in vulgar and shoddy attire.”     -Dr. George W.
Crane-

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Filling and one-letter words at end of line
  2004-11-08 18:38 JayBingham
@ 2004-11-08 22:05 ` Maciek Pasternacki
       [not found] ` <mailman.1514.1099952102.8225.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 4+ messages in thread
From: Maciek Pasternacki @ 2004-11-08 22:05 UTC (permalink / raw)


On Pungenday, The Aftermath 21, 3170 YOLD, binghamjc@bluebottle.com wrote:

>> What is funny is that english one-letter words (`I' and `a') are never 
>> filled at end of line.
>
> I am curious as to why you think this is true.  I just did a quick
> test in emacs 21.3 running on my Win2000 PC and I do not see the
> above behavior.   I entered a paragraph where both `a' and `I' are
> the final words on subsequent lines in the paragraph.  I can find
> nothing in the emacs info file or the emacs lisp reference that
> describes any options to do what you are describing.

Well, I thought it was true; maybe it was some time ago, on another
distribution with changed defaults or some add-ons; now I'm not even
sure if it wasn't in vim long, long ago... after testing I found emacs
isn't as smart as I thought (at least by default).

Anyway, it'd be nice to have these one-letter words filled correctly.
Any ideas on how to do it, or at least where to start poking elisp?
Some kind of refill command would be easy to write (starting with
sierotki.el which is used for inserting tilde instead of space before
one-letter words when typing TeX files (tilde means non-breakable
space)) but I'd prefer all fill commands to behave well.  Is there
some way to insert a non-breakable space or to mark space as such?
I could modify sierotki.el then to insert these spaces (or mark them)
instead of inserting tilde instead.

-- 
__    Maciek Pasternacki <maciekp@japhy.fnord.org> [ http://japhy.fnord.org/ ]
`| _   |_\  / { (2a) No matter how hard you try, you can't make a baby in much
,|{-}|}| }\/less then 9 months;trying to speed this up *might* make it slower,
\/   |____/ but it won't make it happen any quicker. }      ( RFC 1925 )  -><-

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Filling and one-letter words at end of line
       [not found] ` <mailman.1514.1099952102.8225.help-gnu-emacs@gnu.org>
@ 2004-11-08 23:32   ` Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2004-11-08 23:32 UTC (permalink / raw)


> Well, I thought it was true; maybe it was some time ago, on another
> distribution with changed defaults or some add-ons; now I'm not even
> sure if it wasn't in vim long, long ago... after testing I found emacs
> isn't as smart as I thought (at least by default).

I use the code below:

(defun fill-french-nobreak-p ()
  "Return nil if French style allows breaking the line at point.
This is used in `fill-nobreak-predicate' to prevent breaking lines just
after an opening paren or just before a closing paren or a punctuation
mark such as `?' or `:'.  It is common in French writing to put a space
at such places, which would normally allow breaking the line at those
places."
  (or (looking-at "[ \t]*[])}»?!;:-]")
      (save-excursion
	(skip-chars-backward " \t")
	(unless (bolp)
	  (backward-char 1)
	  (or (looking-at "[([{«]")
	      ;; Don't cut right after a single-letter word.
	      (and (memq (preceding-char) '(?\t ?\ ))
		   (eq (char-syntax (following-char)) ?w)))))))

(add-hook 'fill-nobreak-predicate 'fill-french-nobreak-p)


        Stefan


PS: Another one I use is:

(defun fill-single-word-nobreak-p ()
  "Don't break a line after the first or before the last word of a sentence."
  (or (looking-at "[ \t]*\\sw+[ \t]*[.?!:][ \t]*$")
      (save-excursion
	(skip-chars-backward " \t")
	(and (/= (skip-syntax-backward "w") 0)
	     (/= (skip-chars-backward " \t") 0)
	     (/= (skip-chars-backward ".?!:") 0)))))

(add-hook 'fill-nobreak-predicate 'fill-single-word-nobreak-p)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-11-08 23:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-06  3:55 Filling and one-letter words at end of line Maciek Pasternacki
  -- strict thread matches above, loose matches on Subject: below --
2004-11-08 18:38 JayBingham
2004-11-08 22:05 ` Maciek Pasternacki
     [not found] ` <mailman.1514.1099952102.8225.help-gnu-emacs@gnu.org>
2004-11-08 23:32   ` Stefan Monnier

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.