diff options
| author | Marcin Borkowski | 2016-04-27 08:59:15 +0200 |
|---|---|---|
| committer | Marcin Borkowski | 2018-01-15 06:25:16 +0100 |
| commit | a1f257d81c58eb3069928ed584b06c4bcb2c7111 (patch) | |
| tree | 4dde4cbab4970421245c7dbabf9bce0970bf9d7f | |
| parent | 5af5df1f7c20858dab762830e1a94994ceda425b (diff) | |
| download | emacs-a1f257d81c58eb3069928ed584b06c4bcb2c7111.tar.gz emacs-a1f257d81c58eb3069928ed584b06c4bcb2c7111.zip | |
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.
| -rw-r--r-- | doc/emacs/text.texi | 7 | ||||
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/textmodes/fill.el | 12 |
3 files changed, 22 insertions, 2 deletions
diff --git a/doc/emacs/text.texi b/doc/emacs/text.texi index 846d9fe8c62..2f180f82ca2 100644 --- a/doc/emacs/text.texi +++ b/doc/emacs/text.texi | |||
| @@ -636,8 +636,11 @@ line. If a function returns a non-@code{nil} value, Emacs will not | |||
| 636 | break the line there. Functions you can use there include: | 636 | break the line there. Functions you can use there include: |
| 637 | @code{fill-single-word-nobreak-p} (don't break after the first word of | 637 | @code{fill-single-word-nobreak-p} (don't break after the first word of |
| 638 | a sentence or before the last); @code{fill-single-char-nobreak-p} | 638 | a sentence or before the last); @code{fill-single-char-nobreak-p} |
| 639 | (don't break after a one-letter word); and @code{fill-french-nobreak-p} | 639 | (don't break after a one-letter word preceded by a whitespace |
| 640 | (don't break after @samp{(} or before @samp{)}, @samp{:} or @samp{?}). | 640 | character); @code{fill-french-nobreak-p} (don't break after @samp{(} |
| 641 | or before @samp{)}, @samp{:} or @samp{?}); and | ||
| 642 | @code{fill-polish-nobreak-p} (don't break after a one letter word, | ||
| 643 | even if preceded by a non-whitespace character). | ||
| 641 | 644 | ||
| 642 | @node Fill Prefix | 645 | @node Fill Prefix |
| 643 | @subsection The Fill Prefix | 646 | @subsection The Fill Prefix |
| @@ -69,6 +69,11 @@ detect built-in libxml support, instead of testing for that | |||
| 69 | indirectly, e.g., by checking that functions like | 69 | indirectly, e.g., by checking that functions like |
| 70 | 'libxml-parse-html-region' return nil. | 70 | 'libxml-parse-html-region' return nil. |
| 71 | 71 | ||
| 72 | +++ | ||
| 73 | ** New function 'fill-polish-nobreak-p', to be used in 'fill-nobreak-predicate'. | ||
| 74 | It blocks line breaking after a one-letter word, also in the case when | ||
| 75 | this word is preceded by a non-space, but non-alphanumeric character. | ||
| 76 | |||
| 72 | 77 | ||
| 73 | * Editing Changes in Emacs 27.1 | 78 | * Editing Changes in Emacs 27.1 |
| 74 | 79 | ||
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." | |||
| 339 | (and (memq (preceding-char) '(?\t ?\s)) | 339 | (and (memq (preceding-char) '(?\t ?\s)) |
| 340 | (eq (char-syntax (following-char)) ?w))))))) | 340 | (eq (char-syntax (following-char)) ?w))))))) |
| 341 | 341 | ||
| 342 | (defun fill-polish-nobreak-p () | ||
| 343 | "Return nil if Polish style allows breaking the line at point. | ||
| 344 | This function may be used in the `fill-nobreak-predicate' hook. | ||
| 345 | It is almost the same as `fill-single-char-nobreak-p', with the | ||
| 346 | exception that it does not require the one-letter word to be | ||
| 347 | preceded by a space. This blocks line-breaking in cases like | ||
| 348 | \"(a jednak)\"." | ||
| 349 | (save-excursion | ||
| 350 | (skip-chars-backward " \t") | ||
| 351 | (backward-char 2) | ||
| 352 | (looking-at "[^[:alpha:]]\\cl"))) | ||
| 353 | |||
| 342 | (defun fill-single-char-nobreak-p () | 354 | (defun fill-single-char-nobreak-p () |
| 343 | "Return non-nil if a one-letter word is before point. | 355 | "Return non-nil if a one-letter word is before point. |
| 344 | This function is suitable for adding to the hook `fill-nobreak-predicate', | 356 | This function is suitable for adding to the hook `fill-nobreak-predicate', |