From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: Filling and one-letter words at end of line Date: Mon, 08 Nov 2004 23:32:35 GMT Message-ID: References: <1099939138.418fbd42b66cf@www.bluebottle.com> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1099956708 17629 80.91.229.6 (8 Nov 2004 23:31:48 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 8 Nov 2004 23:31:48 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Nov 09 00:31:44 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CRIzA-0001oi-00 for ; Tue, 09 Nov 2004 00:31:44 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CRJ7W-0001GC-DG for geh-help-gnu-emacs@m.gmane.org; Mon, 08 Nov 2004 18:40:22 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!nntp.cs.ubc.ca!torn!snoopy.risq.qc.ca!charlie.risq.qc.ca!53ab2750!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux) Cancel-Lock: sha1:ib8ljVNr9avUKrp89oLS1qof4Ds= Original-Lines: 42 Original-NNTP-Posting-Host: 132.204.24.84 Original-X-Complaints-To: abuse@umontreal.ca Original-X-Trace: charlie.risq.qc.ca 1099956755 132.204.24.84 (Mon, 08 Nov 2004 18:32:35 EST) Original-NNTP-Posting-Date: Mon, 08 Nov 2004 18:32:35 EST Original-Xref: shelby.stanford.edu gnu.emacs.help:126447 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:21838 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:21838 > 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)