summaryrefslogtreecommitdiff
path: root/lisp/textmodes/fill.el
diff options
context:
space:
mode:
authorMarcin Borkowski <mbork@mbork.pl>2016-04-27 08:59:15 +0200
committerMarcin Borkowski <mbork@mbork.pl>2018-01-15 06:25:16 +0100
commita1f257d81c58eb3069928ed584b06c4bcb2c7111 (patch)
tree4dde4cbab4970421245c7dbabf9bce0970bf9d7f /lisp/textmodes/fill.el
parent5af5df1f7c20858dab762830e1a94994ceda425b (diff)
downloademacs-a1f257d81c58eb3069928ed584b06c4bcb2c7111.tar.gz
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.
Diffstat (limited to 'lisp/textmodes/fill.el')
-rw-r--r--lisp/textmodes/fill.el12
1 files changed, 12 insertions, 0 deletions
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el
index a46f0b2a4cd..6d37be870b2 100644
--- a/lisp/textmodes/fill.el
+++ b/lisp/textmodes/fill.el
@@ -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',