* [PATCH] Add a fill nobreak predicate preventing line breaks after 1-character word.
@ 2013-10-25 8:48 Michal Nazarewicz
2013-11-04 4:30 ` Stefan Monnier
0 siblings, 1 reply; 2+ messages in thread
From: Michal Nazarewicz @ 2013-10-25 8:48 UTC (permalink / raw)
To: emacs-devel; +Cc: Stefan Monnier
From: Michal Nazarewicz <mina86@mina86.com>
* 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)
+
\f
* 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 <mina86@mina86.com>
+
+ * 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 <dgutov@yandex.ru>
* 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
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-11-04 4:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-25 8:48 [PATCH] Add a fill nobreak predicate preventing line breaks after 1-character word Michal Nazarewicz
2013-11-04 4:30 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.