]> git.eshelyaron.com Git - emacs.git/commitdiff
Add the function `fill-polish-nobreak-p'
authorMarcin Borkowski <mbork@mbork.pl>
Wed, 27 Apr 2016 06:59:15 +0000 (08:59 +0200)
committerMarcin Borkowski <mbork@mbork.pl>
Mon, 15 Jan 2018 05:25:16 +0000 (06:25 +0100)
* lisp/textmodes/fill.el (fill-polish-nobreak-p): Prevent
line-breaking after a single-letter word even if this word is not
preceded by a space.  Fixes bug #20871.

doc/emacs/text.texi
etc/NEWS
lisp/textmodes/fill.el

index 846d9fe8c627aaf1f75a336fe2a20866907530ff..2f180f82ca2a6fa3667a2c4a38d32823f329fc9c 100644 (file)
@@ -636,8 +636,11 @@ line.  If a function returns a non-@code{nil} value, Emacs will not
 break the line there.  Functions you can use there include:
 @code{fill-single-word-nobreak-p} (don't break after the first word of
 a sentence or before the last); @code{fill-single-char-nobreak-p}
-(don't break after a one-letter word); and @code{fill-french-nobreak-p}
-(don't break after @samp{(} or before @samp{)}, @samp{:} or @samp{?}).
+(don't break after a one-letter word preceded by a whitespace
+character); @code{fill-french-nobreak-p} (don't break after @samp{(}
+or before @samp{)}, @samp{:} or @samp{?}); and
+@code{fill-polish-nobreak-p} (don't break after a one letter word,
+even if preceded by a non-whitespace character).
 
 @node Fill Prefix
 @subsection The Fill Prefix
index 1d546c4ec17f94b87eb97ac75701a3f4bbe5eae3..ed1f9315478621bba83aabd43a437501a25bae50 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -69,6 +69,11 @@ detect built-in libxml support, instead of testing for that
 indirectly, e.g., by checking that functions like
 'libxml-parse-html-region' return nil.
 
++++
+** New function 'fill-polish-nobreak-p', to be used in 'fill-nobreak-predicate'.
+It blocks line breaking after a one-letter word, also in the case when
+this word is preceded by a non-space, but non-alphanumeric character.
+
 \f
 * Editing Changes in Emacs 27.1
 
index a46f0b2a4cd6a93d1d36715415c3d4c939da084d..6d37be870b23d9e53dca9df659fda1e096991f41 100644 (file)
@@ -339,6 +339,18 @@ places."
              (and (memq (preceding-char) '(?\t ?\s))
                   (eq (char-syntax (following-char)) ?w)))))))
 
+(defun fill-polish-nobreak-p ()
+  "Return nil if Polish style allows breaking the line at point.
+This function may be used in the `fill-nobreak-predicate' hook.
+It is almost the same as `fill-single-char-nobreak-p', with the
+exception that it does not require the one-letter word to be
+preceded by a space.  This blocks line-breaking in cases like
+\"(a jednak)\"."
+  (save-excursion
+    (skip-chars-backward " \t")
+    (backward-char 2)
+    (looking-at "[^[:alpha:]]\\cl")))
+
 (defun fill-single-char-nobreak-p ()
   "Return non-nil if a one-letter word is before point.
 This function is suitable for adding to the hook `fill-nobreak-predicate',