Mercurial > emacs
changeset 50757:89533dc3e837
(text-property-default-nonsticky): Add fill-space.
(fill-delete-newlines): Respect the new property.
(fill-newline): Use the property instead of leaving "spurious" spaces.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Wed, 30 Apr 2003 21:01:05 +0000 |
parents | 454941789575 |
children | ee55f23e4fbc |
files | lisp/textmodes/fill.el |
diffstat | 1 files changed, 24 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/textmodes/fill.el Wed Apr 30 20:53:04 2003 +0000 +++ b/lisp/textmodes/fill.el Wed Apr 30 21:01:05 2003 +0000 @@ -406,6 +406,12 @@ (goto-char (match-end 0))) (setq from (point)))) +;; The `fill-space' property carries the string with which a newline +;; should be replaced when unbreaking a line (in fill-delete-newlines). +;; It is added to newline characters by fill-newline when the default +;; behavior of fill-delete-newlines is not what we want. +(add-to-list 'text-property-default-nonsticky '(fill-space . t)) + (defun fill-delete-newlines (from to justify nosqueeze squeeze-after) (goto-char from) ;; Make sure sentences ending at end of line get an extra space. @@ -434,15 +440,17 @@ ;; character preceding a newline has text property ;; `nospace-between-words'. (while (search-forward "\n" to t) - (let ((prev (char-before (match-beginning 0))) - (next (following-char))) - (if (and (or (aref (char-category-set next) ?|) - (aref (char-category-set prev) ?|)) - (or (get-charset-property (char-charset prev) - 'nospace-between-words) - (get-text-property (1- (match-beginning 0)) - 'nospace-between-words))) - (delete-char -1))))) + (if (get-text-property (match-beginning 0) 'fill-space) + (replace-match (get-text-property (match-beginning 0) 'fill-space)) + (let ((prev (char-before (match-beginning 0))) + (next (following-char))) + (if (and (or (aref (char-category-set next) ?|) + (aref (char-category-set prev) ?|)) + (or (get-charset-property (char-charset prev) + 'nospace-between-words) + (get-text-property (1- (match-beginning 0)) + 'nospace-between-words))) + (delete-char -1)))))) (goto-char from) (skip-chars-forward " \t") @@ -520,19 +528,17 @@ ;; Replace whitespace here with one newline, then ;; indent to left margin. (skip-chars-backward " \t") - (if (and (= (following-char) ?\ ) - (or (aref (char-category-set (preceding-char)) ?|) - (looking-at "[ \t]+\\c|"))) - ;; We need one space at end of line so that - ;; further filling won't delete it. NOTE: We - ;; intentionally leave this one space to - ;; distinguish the case that user wants to put - ;; space between \c| characters. - (forward-char 1)) (insert ?\n) ;; Give newline the properties of the space(s) it replaces (set-text-properties (1- (point)) (point) (text-properties-at (point))) + (and (looking-at "\\( [ \t]*\\)\\(\\c|\\)?") + (or (aref (char-category-set (or (char-before (1- (point))) ?\000)) ?|) + (match-end 2)) + ;; When refilling later on, this newline would normally not be replaced + ;; by a space, so we need to mark it specially to re-install the space + ;; when we unfill. + (put-text-property (1- (point)) (point) 'fill-space (match-string 1))) ;; If we don't want breaks in invisible text, don't insert ;; an invisible newline. (if fill-nobreak-invisible