summaryrefslogtreecommitdiff
path: root/lisp/textmodes/fill.el
diff options
context:
space:
mode:
authorKarl Heuer <kwzh@gnu.org>1995-07-17 22:50:30 +0000
committerKarl Heuer <kwzh@gnu.org>1995-07-17 22:50:30 +0000
commit5c718abcdaaede4caf38a2a36ecfe73be9cf2ea7 (patch)
tree875b1f849aa28d7492fbc6568dd44f43589fe31c /lisp/textmodes/fill.el
parentb60d7a257287c332fcaf30f155494eff1f6cc71b (diff)
downloademacs-5c718abcdaaede4caf38a2a36ecfe73be9cf2ea7.tar.gz
(canonically-space-region): Doc fix.
(fill-region-as-paragraph): In adaptive-fill-mode, if paragraph has one line, take the fill prefix from it. (adaptive-fill-regexp): Doc fix. (fill-individual-paragraphs): Use `adaptive-fill-regexp' to determine `fill-prefix' if `adaptive-fill-mode' is non-nil.
Diffstat (limited to 'lisp/textmodes/fill.el')
-rw-r--r--lisp/textmodes/fill.el32
1 files changed, 18 insertions, 14 deletions
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el
index 81791f0c506..a384125db90 100644
--- a/lisp/textmodes/fill.el
+++ b/lisp/textmodes/fill.el
@@ -61,7 +61,8 @@ reinserts the fill prefix in each resulting line."
"*Regexp to match text at start of line that constitutes indentation.
If Adaptive Fill mode is enabled, whatever text matches this pattern
on the second line of a paragraph is used as the standard indentation
-for the paragraph.")
+for the paragraph. If the paragraph has just one line, the indentation
+is taken from that line.")
(defun current-fill-column ()
"Return the fill-column to use for this line.
@@ -92,7 +93,7 @@ number equals or exceeds the local fill-column - right-margin difference."
(defun canonically-space-region (beg end)
"Remove extra spaces between words in region.
Puts one space between words in region; two between sentences.
-Remove indenation from each line."
+Remove indentation from each line."
(interactive "r")
(save-excursion
(goto-char beg)
@@ -180,17 +181,17 @@ space does not end a sentence, so don't break a line there."
(save-excursion
(goto-char from)
(if (eolp) (forward-line 1))
- (forward-line 1)
+ ;; Move to the second line unless there is just one.
+ (let ((firstline (point)))
+ (forward-line 1)
+ (if (>= (point) to)
+ (goto-char firstline)))
(move-to-left-margin)
- (if (< (point) to)
- (let ((start (point)))
- (re-search-forward adaptive-fill-regexp)
- (setq fill-prefix (buffer-substring start (point)))
- (set-text-properties 0 (length fill-prefix) nil
- fill-prefix)))
- ;; If paragraph has only one line, don't assume in general
- ;; that additional lines would have the same starting
- ;; decoration. Assume no indentation.
+ (let ((start (point)))
+ (re-search-forward adaptive-fill-regexp)
+ (setq fill-prefix (buffer-substring start (point)))
+ (set-text-properties 0 (length fill-prefix) nil
+ fill-prefix))
))
(save-restriction
@@ -762,8 +763,11 @@ MAIL-FLAG for a mail message, i. e. don't fill header lines."
(if (not (and fill-prefix
(looking-at fill-prefix-regexp)))
(setq fill-prefix
- (buffer-substring (point)
- (save-excursion (skip-chars-forward " \t") (point)))
+ (if (and adaptive-fill-mode adaptive-fill-regexp
+ (looking-at (concat "\\(" adaptive-fill-regexp "\\)")))
+ (match-string 1)
+ (buffer-substring (point)
+ (save-excursion (skip-chars-forward " \t") (point))))
fill-prefix-regexp
(regexp-quote fill-prefix)))
(forward-line 1)