From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michal Nazarewicz Newsgroups: gmane.emacs.devel Subject: [PATCH] Add a fill nobreak predicate preventing line breaks after 1-character word. Date: Fri, 25 Oct 2013 09:48:00 +0100 Message-ID: <594aa180e99f34b8635102b80646785d01dc4541.1382690656.git.mina86@mina86.com> NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1382690912 4819 80.91.229.3 (25 Oct 2013 08:48:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 25 Oct 2013 08:48:32 +0000 (UTC) Cc: Stefan Monnier To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Oct 25 10:48:34 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VZd4M-0001Fi-4L for ged-emacs-devel@m.gmane.org; Fri, 25 Oct 2013 10:48:34 +0200 Original-Received: from localhost ([::1]:58180 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZd4L-0002Dd-Qe for ged-emacs-devel@m.gmane.org; Fri, 25 Oct 2013 04:48:33 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33400) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZd4E-0002CT-Ub for emacs-devel@gnu.org; Fri, 25 Oct 2013 04:48:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VZd46-00018X-Qt for emacs-devel@gnu.org; Fri, 25 Oct 2013 04:48:26 -0400 Original-Received: from mail-wg0-x233.google.com ([2a00:1450:400c:c00::233]:38777) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZd46-00017K-Jw for emacs-devel@gnu.org; Fri, 25 Oct 2013 04:48:18 -0400 Original-Received: by mail-wg0-f51.google.com with SMTP id l18so3403799wgh.18 for ; Fri, 25 Oct 2013 01:48:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=55SvzJ1CuHHHT6TBk+L9uHQfqAxsXYTAYQ/qlxUOIlg=; b=Mjn/yYAUcoIkEvTkeZi+rPYq9psbXkrDW/6FRzKqoSdybgYPu2L4aX9+umzZ63c2lZ x2VClwhRzUPr8DN8jdZULpr7Ad26yuVbpXcZZbsTX47eO2vZAwgDCLMX6eUPU8IQ7Lkn DqFFWR+bLIzmxj2TGSFHuErVHRBr1/24q5tWqFe6NfWY/xX3o8F/P9Qdnor35fJWZmRH 7LB6rHx34AjAC4bBq8vkOLL/xsPYPehQWL3b5AIE+K3BvKQb23pcvohBsthO8Gu7eQ5n qKdrjPFJFTXQyOGE6h4vgG3+RgYqxdCrv1JBWdB+jHSG/ybSAcGWMYwOKwpXvjkbgj8e 6j7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=55SvzJ1CuHHHT6TBk+L9uHQfqAxsXYTAYQ/qlxUOIlg=; b=YQ55TrmKIwMHFfGZNce7LdSKANUIAzr/sGy+oxupqXUvlaZuaEAVmKZHMbtgaLJdEq H7gFkqhQGlUSHBVyUf6fq3f4YQhZxwjs0hsi4GMTwUL6lcUmw59QpO9Y0HHWczvQcKmk Vlo4bXjQWvtdZsdRLcPpKiCEbpLAeIFAFifZtqw+m0gt2F/KbVny54oRjfuCvIAiPzii 1nI835T4tY5qLRbi/NQBxZImGqfOybPTeUH/T8wNqtk8k0jscFT+tGWp9aAABE92gNZ/ wsgf6v4nHUWflhpWJnQK1ELTUpELIL6sv5fkHVfQ4FlIMOqAXQfLH+RF6H79w2svL0Wm A5ZA== X-Gm-Message-State: ALoCoQn0aEBb5Y8VazCpZ8zjsol6UEUE18EI2NXqSZ5e4CvfXr9OsLGA68ay33zRMdmoda4opUXSlZH1/5zm0z6NJOWBHLhvXCQR6Ng/F1R56QO+kks3ED9coU98SKrXkmi8NXNff7yhi+rDJ8fuOzH2NyhBFWKDYHP/+iNJIjTWMIto5BhH+6Mv8uDPUuhZlIeeqZz1W29vZqzI+QAIYj6/kGkaWyXM1Q== X-Received: by 10.194.158.67 with SMTP id ws3mr6257990wjb.5.1382690897238; Fri, 25 Oct 2013 01:48:17 -0700 (PDT) Original-Received: from mpn-glaptop.roam.corp.google.com (ed03490-ge-0-0-0.mgdfwr.lumison.net. [212.20.242.100]) by mx.google.com with ESMTPSA id dq11sm3710939wid.3.2013.10.25.01.48.15 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 25 Oct 2013 01:48:16 -0700 (PDT) X-Mailer: git-send-email 1.8.4 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c00::233 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:164529 Archived-At: From: Michal Nazarewicz * textmodes/fill.el (fill-single-char-nobreak-p): New function checking whether point is after a 1-letter word. As per its name, it should be used with fill-nobreak-predicate to prevent fill from breaking the line after a 1-letter word, which is considered an error in Polish and Czech typography... --- etc/NEWS | 6 ++++++ lisp/ChangeLog | 8 ++++++++ lisp/textmodes/fill.el | 13 ++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/etc/NEWS b/etc/NEWS index 232a1bc..f52b522 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -176,6 +176,12 @@ some enhancements, like the ability to restore deleted frames. Command ** The default value of `comment-use-global-state' is changed to t, and this variable has been marked obsolete. +** `fill-single-char-nobreak-p' prevents fill from breaking a line after +a 1-letter word, which is an error according to Polish and +Czech typography rules. To globally enable this feature, evaluate: + + (add-hook 'fill-nobreak-predicate 'fill-single-char-nobreak-p) + * Editing Changes in Emacs 24.4 diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6d852d9..25036a2 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2013-10-25 Michal Nazarewicz + + * textmodes/fill.el (fill-single-char-nobreak-p): New function + checking whether point is after a 1-letter word. As per its name, + it should be used with fill-nobreak-predicate to prevent fill from + breaking the line after a 1-letter word, which is considered an + error in Polish and Czech typography.. + 2013-10-25 Dmitry Gutov * progmodes/ruby-mode.el (ruby-mode-menu): Use proper diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el index 119b4b0..49003b4 100644 --- a/lisp/textmodes/fill.el +++ b/lisp/textmodes/fill.el @@ -329,13 +329,24 @@ places." (and (memq (preceding-char) '(?\t ?\s)) (eq (char-syntax (following-char)) ?w))))))) +(defun fill-single-char-nobreak-p () + "Return t if point is placed just after a 1-letter word. +This is used in `fill-nobreak-predicate' to prevent breaking line just +after a 1-letter word (usually conjunction or preposition) which is +considered composition error in Polish and Czech typography." + (save-excursion + (skip-chars-backward " \t") + (backward-char 2) + (looking-at "[[:space:]][a-zA-Z]"))) + (defcustom fill-nobreak-predicate nil "List of predicates for recognizing places not to break a line. The predicates are called with no arguments, with point at the place to be tested. If it returns t, fill commands do not break the line there." :group 'fill :type 'hook - :options '(fill-french-nobreak-p fill-single-word-nobreak-p)) + :options '(fill-french-nobreak-p fill-single-word-nobreak-p + fill-single-char-nobreak-p)) (defcustom fill-nobreak-invisible nil "Non-nil means that fill commands do not break lines in invisible text." -- 1.8.4