[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] fix/bug-20871 ab5fc7c: Add the function `fill-polish-nobre
From: |
Marcin Borkowski |
Subject: |
[Emacs-diffs] fix/bug-20871 ab5fc7c: Add the function `fill-polish-nobreak-p' |
Date: |
Tue, 20 Jun 2017 05:26:15 -0400 (EDT) |
branch: fix/bug-20871
commit ab5fc7c8215e1066449da4eb0e027f8250cc9f49
Author: Marcin Borkowski <address@hidden>
Commit: Marcin Borkowski <address@hidden>
Add the function `fill-polish-nobreak-p'
* 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 | 7 +++++--
etc/NEWS | 5 +++++
lisp/textmodes/fill.el | 12 ++++++++++++
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/doc/emacs/text.texi b/doc/emacs/text.texi
index d1e4511..4dcbaec 100644
--- a/doc/emacs/text.texi
+++ b/doc/emacs/text.texi
@@ -616,8 +616,11 @@ line. If a function returns a address@hidden 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
address@hidden (don't break after a one letter word,
+even if preceded by a non-whitespace character).
@node Fill Prefix
@subsection The Fill Prefix
diff --git a/etc/NEWS b/etc/NEWS
index 85d1273..6bf124c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -468,6 +468,11 @@ current buffer with the contents of the accessible portion
of a
different buffer while keeping point, mark, markers, and text
properties as intact as possible.
++++
+** 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.
+
* Changes in Specialized Modes and Packages in Emacs 26.1
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el
index ee523ed..b640adb 100644
--- a/lisp/textmodes/fill.el
+++ b/lisp/textmodes/fill.el
@@ -338,6 +338,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',