summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1993-03-28 22:07:36 +0000
committerRichard M. Stallman <rms@gnu.org>1993-03-28 22:07:36 +0000
commitcc1344d5cf511bf95a3776084b84bcbeda0cc385 (patch)
tree60a11579770e105c733df7f0455ffd49a48f8e0b
parent4c53bd2bb08b166f271b3acfb8381064dc3e8089 (diff)
downloademacs-cc1344d5cf511bf95a3776084b84bcbeda0cc385.tar.gz
Cancel previous change; this version should be identical to version 1.17.
-rw-r--r--lisp/textmodes/fill.el64
1 files changed, 25 insertions, 39 deletions
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el
index f1669d7b049..a905bef78d1 100644
--- a/lisp/textmodes/fill.el
+++ b/lisp/textmodes/fill.el
@@ -66,7 +66,7 @@ From program, pass args FROM, TO and JUSTIFY-FLAG."
(if (and buffer-undo-list (not (eq buffer-undo-list t)))
(setq buffer-undo-list (cons (point) buffer-undo-list)))
;; Don't let Adaptive Fill mode alter the fill prefix permanently.
- (let ((fill-prefix fill-prefix) spc)
+ (let ((fill-prefix fill-prefix))
;; Figure out how this paragraph is indented, if desired.
(if (and adaptive-fill-mode
(or (null fill-prefix) (string= fill-prefix "")))
@@ -114,48 +114,34 @@ From program, pass args FROM, TO and JUSTIFY-FLAG."
;; from is now before the text to fill,
;; but after any fill prefix on the first line.
- ;; spc (our filler character) is normally SPC;
- ;; if SPC does not have syntax class whitespace, find a filler that does.
- (if (= (char-syntax ?\ ) ?\ )
- (setq spc ?\ )
- (setq spc 0)
- (while (not (= (char-syntax spc) ?\ ))
- (setq spc (1+ spc))))
-
;; Make sure sentences ending at end of line get an extra space.
- ;; loses on split abbrevs ("Mr.\nSmith"). This is fairly specific
- ;; to text mode.
+ ;; loses on split abbrevs ("Mr.\nSmith")
(goto-char from)
(while (re-search-forward "[.?!][])}\"']*$" nil t)
- (insert spc))
+ (insert ? ))
;; Then change all newlines to spaces.
- (subst-char-in-region from to ?\n spc)
+ (subst-char-in-region from (point-max) ?\n ?\ )
- ;; Go to beginning of paragraph (after indent)
+ ;; Flush excess spaces, except in the paragraph indentation.
(goto-char from)
- (skip-syntax-forward " ")
-
- ;; If tabs have whitespace class, nuke them; they get screwed up
- ;; in a fill. This is quick, but loses when a sole tab follows
- ;; the end of a sentence. actually, it is difficult to tell
- ;; that from "Mr.\tSmith". Blame the typist.
- (if (= (char-syntax ?\t) ?\ )
- (subst-char-in-region (point) to ?\t spc))
-
- ;; Flush excess whitespace, except in the paragraph indentation.
- (while (re-search-forward "\\s-\\s-\\s-*" nil t)
+ (skip-chars-forward " \t")
+ ;; nuke tabs while we're at it; they get screwed up in a fill
+ ;; this is quick, but loses when a sole tab follows the end of a sentence.
+ ;; actually, it is difficult to tell that from "Mr.\tSmith".
+ ;; blame the typist.
+ (subst-char-in-region (point) (point-max) ?\t ?\ )
+ (while (re-search-forward " *" nil t)
(delete-region
(+ (match-beginning 0)
(if (save-excursion
- (skip-syntax-backward " ).")
+ (skip-chars-backward " ]})\"'")
(memq (preceding-char) '(?. ?? ?!)))
2 1))
(match-end 0)))
(goto-char (point-max))
(delete-horizontal-space)
- (insert spc)
- (insert spc)
+ (insert " ")
(goto-char (point-min))
;; This is the actual filling loop.
@@ -166,7 +152,7 @@ From program, pass args FROM, TO and JUSTIFY-FLAG."
(if (eobp)
nil
;; Move back to start of word.
- (skip-syntax-backward "^ " linebeg)
+ (skip-chars-backward "^ \n" linebeg)
;; Don't break after a period followed by just one space.
;; Move back to the previous place to break.
;; The reason is that if a period ends up at the end of a line,
@@ -174,16 +160,16 @@ From program, pass args FROM, TO and JUSTIFY-FLAG."
;; If we now know it does not end a sentence,
;; avoid putting it at the end of the line.
(while (and (> (point) (+ linebeg 2))
- (eq (char-syntax (preceding-char)) ?\ )
+ (eq (preceding-char) ?\ )
(eq (char-after (- (point) 2)) ?\.))
(forward-char -2)
- (skip-syntax-backward "^ " linebeg))
+ (skip-chars-backward "^ \n" linebeg))
(if (if (zerop prefixcol) (bolp) (>= prefixcol (current-column)))
;; Keep at least one word even if fill prefix exceeds margin.
;; This handles all but the first line of the paragraph.
(progn
- (skip-syntax-forward " ")
- (skip-syntax-forward "^ "))
+ (skip-chars-forward " ")
+ (skip-chars-forward "^ \n"))
;; Normally, move back over the single space between the words.
(forward-char -1)))
(if (and fill-prefix (zerop prefixcol)
@@ -193,12 +179,12 @@ From program, pass args FROM, TO and JUSTIFY-FLAG."
;; Keep at least one word even if fill prefix exceeds margin.
;; This handles the first line of the paragraph.
(progn
- (skip-syntax-forward " ")
- (skip-syntax-forward "^ ")))
+ (skip-chars-forward " ")
+ (skip-chars-forward "^ \n")))
;; Replace all whitespace here with one newline.
;; Insert before deleting, so we don't forget which side of
;; the whitespace point or markers used to be on.
- (skip-syntax-backward " ")
+ (skip-chars-backward " ")
(insert ?\n)
(delete-horizontal-space)
;; Insert the fill prefix at start of each line.
@@ -250,17 +236,17 @@ Prefix arg (non-nil third arg, if called from program) means justify as well."
(let (ncols beg indent)
(beginning-of-line)
(forward-char (length fill-prefix))
- (skip-syntax-forward " " (save-excursion (end-of-line) (point)))
+ (skip-chars-forward " \t")
(setq indent (current-column))
(setq beg (point))
(end-of-line)
(narrow-to-region beg (point))
(goto-char beg)
- (while (re-search-forward "\\s-\\s-\\s-*" nil t)
+ (while (re-search-forward " *" nil t)
(delete-region
(+ (match-beginning 0)
(if (save-excursion
- (skip-syntax-backward " ).")
+ (skip-chars-backward " ])\"'")
(memq (preceding-char) '(?. ?? ?!)))
2 1))
(match-end 0)))