From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.bugs Subject: bug#20871: 25.0.50; fill-single-char-nobreak-p does not recognize a single-letter word when it is preceded by an open paren Date: Mon, 15 Jan 2018 06:30:20 +0100 Message-ID: <871siradub.fsf@mbork.pl> References: <87y4jchwog.fsf@mbork.pl> <87vb33h6ux.fsf@mbork.pl> <83a8kfzff7.fsf@gnu.org> <87shy4vc9x.fsf@mbork.pl> <838tzvpcjb.fsf@gnu.org> <87vb2zth8r.fsf@mbork.pl> <837fffp8zt.fsf@gnu.org> <877fff3v7n.fsf@mbork.pl> <83mvobni94.fsf@gnu.org> <874maj3plo.fsf@mbork.pl> <83bn4qor96.fsf@gnu.org> <87zi6u7jm3.fsf@mbork.pl> <831sk4unix.fsf@gnu.org> <87vahf7vnx.fsf@mbork.pl> <87r2rr7xii.fsf@mbork.pl> <83a7yepuby.fsf@gnu.org> <87o9mchc6k.fsf@mbork.pl> <83o9ly16zg.fsf@gnu.org> <87shb9d9yt.fsf@mbork.pl> <83h8rp1yzj.fsf@gnu.org> <874lnnaen0.fsf@mbork.pl> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1515994156 26572 195.159.176.226 (15 Jan 2018 05:29:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 15 Jan 2018 05:29:16 +0000 (UTC) User-Agent: mu4e 0.9.19; emacs 27.0.50 Cc: 20871@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jan 15 06:29:12 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eaxKY-0006dJ-UO for geb-bug-gnu-emacs@m.gmane.org; Mon, 15 Jan 2018 06:29:11 +0100 Original-Received: from localhost ([::1]:38009 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eaxMY-0001P2-Jk for geb-bug-gnu-emacs@m.gmane.org; Mon, 15 Jan 2018 00:31:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48775) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eaxMP-0001OC-Ag for bug-gnu-emacs@gnu.org; Mon, 15 Jan 2018 00:31:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eaxMM-00016t-4o for bug-gnu-emacs@gnu.org; Mon, 15 Jan 2018 00:31:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48713) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eaxML-00016c-Vy for bug-gnu-emacs@gnu.org; Mon, 15 Jan 2018 00:31:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eaxML-0008EP-K2 for bug-gnu-emacs@gnu.org; Mon, 15 Jan 2018 00:31:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Marcin Borkowski Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 15 Jan 2018 05:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20871 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 20871-submit@debbugs.gnu.org id=B20871.151599423731611 (code B ref 20871); Mon, 15 Jan 2018 05:31:01 +0000 Original-Received: (at 20871) by debbugs.gnu.org; 15 Jan 2018 05:30:37 +0000 Original-Received: from localhost ([127.0.0.1]:56610 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eaxLv-0008Dj-K0 for submit@debbugs.gnu.org; Mon, 15 Jan 2018 00:30:37 -0500 Original-Received: from mail.mojserwer.eu ([195.110.48.8]:50410) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eaxLt-0008Db-9g for 20871@debbugs.gnu.org; Mon, 15 Jan 2018 00:30:33 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by mail.mojserwer.eu (Postfix) with ESMTP id 2D78CE673B; Mon, 15 Jan 2018 06:30:31 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mail.mojserwer.eu Original-Received: from mail.mojserwer.eu ([127.0.0.1]) by localhost (mail.mojserwer.eu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id N9NKNoKkrai1; Mon, 15 Jan 2018 06:30:24 +0100 (CET) Original-Received: from localhost (static-dwadziewiec-jedenpiec7.echostar.pl [109.232.29.157]) by mail.mojserwer.eu (Postfix) with ESMTPSA id CD322E6034; Mon, 15 Jan 2018 06:30:23 +0100 (CET) In-reply-to: <874lnnaen0.fsf@mbork.pl> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:142169 Archived-At: --=-=-= Content-Type: text/plain On 2018-01-15, at 06:13, Marcin Borkowski wrote: > On 2018-01-13, at 17:53, Eli Zaretskii wrote: > >>> > So please post the full patch for this issue, and let's take it from >>> > there. > > I see, I'll do it in a minute. I attach the patch (which is made by squashing both the commits I made). Best, -- Marcin Borkowski --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-the-function-fill-polish-nobreak-p-with-tests.patch >From 96b4bd4cef5008561f336d8d1de47548d738c1ff Mon Sep 17 00:00:00 2001 From: Marcin Borkowski Date: Wed, 27 Apr 2016 08:59:15 +0200 Subject: [PATCH] Add the function `fill-polish-nobreak-p' with tests * 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 ++++++++++ test/lisp/textmodes/fill-tests.el | 50 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 test/lisp/textmodes/fill-tests.el diff --git a/doc/emacs/text.texi b/doc/emacs/text.texi index 846d9fe8c6..2f180f82ca 100644 --- a/doc/emacs/text.texi +++ b/doc/emacs/text.texi @@ -636,8 +636,11 @@ Fill Commands 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 diff --git a/etc/NEWS b/etc/NEWS index 1d546c4ec1..ed1f931547 100644 --- 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. + * Editing Changes in Emacs 27.1 diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el index a46f0b2a4c..6d37be870b 100644 --- a/lisp/textmodes/fill.el +++ b/lisp/textmodes/fill.el @@ -339,6 +339,18 @@ fill-french-nobreak-p (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 0000000000..03323090f9 --- /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 +;; 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 . + +;;; 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 -- 2.15.1 --=-=-=--