emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 96de050 3/3: Merge branch 'fix/bug-20871-cur'


From: Marcin Borkowski
Subject: [Emacs-diffs] master 96de050 3/3: Merge branch 'fix/bug-20871-cur'
Date: Wed, 24 Jan 2018 04:32:52 -0500 (EST)

branch: master
commit 96de0503cd04f3cba7c4db94789b958e9775e2c6
Merge: 109da68 5214709
Author: Marcin Borkowski <address@hidden>
Commit: Marcin Borkowski <address@hidden>

    Merge branch 'fix/bug-20871-cur'
---
 doc/emacs/text.texi               |  7 ++++--
 etc/NEWS                          |  5 ++++
 lisp/textmodes/fill.el            | 12 ++++++++++
 test/lisp/textmodes/fill-tests.el | 50 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 72 insertions(+), 2 deletions(-)

diff --git a/doc/emacs/text.texi b/doc/emacs/text.texi
index b765997..7e49a46 100644
--- a/doc/emacs/text.texi
+++ b/doc/emacs/text.texi
@@ -637,8 +637,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 bb84396..ad31553 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -75,6 +75,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.
+
 
 * Editing Changes in Emacs 27.1
 
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el
index 7f9538f..08e975f 100644
--- a/lisp/textmodes/fill.el
+++ b/lisp/textmodes/fill.el
@@ -340,6 +340,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',
diff --git a/test/lisp/textmodes/fill-tests.el 
b/test/lisp/textmodes/fill-tests.el
new file mode 100644
index 0000000..0332309
--- /dev/null
+++ b/test/lisp/textmodes/fill-tests.el
@@ -0,0 +1,50 @@
+;;; fill-test.el --- ERT tests for fill.el -*- lexical-binding: t -*-
+
+;; Copyright (C) 2017 Free Software Foundation, Inc.
+
+;; Author:     Marcin Borkowski <address@hidden>
+;; Keywords:   text, wp
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This package defines tests for the filling feature, specifically
+;; the `fill-polish-nobreak-p' function.
+
+;;; Code:
+
+(require 'ert)
+
+(ert-deftest fill-test-no-fill-polish-nobreak-p nil
+  "Tests of the `fill-polish-nobreak-p' function."
+  (with-temp-buffer
+    (insert "Abc d efg (h ijk).")
+    (setq fill-column 8)
+    (setq-local fill-nobreak-predicate '())
+    (fill-paragraph)
+    (should (string= (buffer-string) "Abc d\nefg (h\nijk).")))
+  (with-temp-buffer
+    (insert "Abc d efg (h ijk).")
+    (setq fill-column 8)
+    (setq-local fill-nobreak-predicate '(fill-polish-nobreak-p))
+    (fill-paragraph)
+    (should (string= (buffer-string) "Abc\nd efg\n(h ijk)."))))
+
+
+(provide 'fill-tests)
+
+;;; fill-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]