;; #### - this is still weak. Yeah, there's filladapt, but this should
;; still be better... --Stig
-(defcustom adaptive-fill-regexp (purecopy "[ \t]*\\([#;>*]+ +\\)?")
+(defcustom adaptive-fill-regexp "[ \t]*\\([#;>*]+ +\\)?"
"*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
:type 'function
:group 'fill)
-;; Added for kinsoku processing. Use this instead of
+;; Added for kinsoku processing. Use this instead of
;; (skip-chars-backward "^ \t\n")
;; (skip-chars-backward "^ \n" linebeg)
(defun fill-move-backward-to-break-point (regexp &optional lim)
here-col col))
(max here-col fill-col)))))
-(defun canonically-space-region (beg end)
+(defun canonically-space-region (start end)
"Remove extra spaces between words in region.
Leave one space between words, two at end of sentences or after colons
\(depending on values of `sentence-end-double-space' and `colon-double-space').
(interactive "r")
;;;### 97/3/14 jhod: Do I have to add anything here for kinsoku?
(save-excursion
- (goto-char beg)
+ (goto-char start)
;; XEmacs - (ENE/stig from fa-extras.el): Skip the start of a comment.
(and comment-start-skip
(looking-at comment-start-skip)
;; This is quick, but loses when a tab follows the end of a sentence.
;; Actually, it is difficult to tell that from "Mr.\tSmith".
;; Blame the typist.
- (subst-char-in-region beg end ?\t ?\ )
+ (subst-char-in-region start end ?\t ?\ )
(while (and (< (point) end)
(re-search-forward " *" end t))
(delete-region
(match-end 0)))
;; Make sure sentences ending at end of line get an extra space.
;; loses on split abbrevs ("Mr.\nSmith")
- (goto-char beg)
+ (goto-char start)
(while (and (< (point) end)
(re-search-forward "[.?!][])}\"']*$" end t))
;; We insert before markers in case a caller such as
(beginning-of-line)
(setq from (point))
-
+
;; Delete all but one soft newline at end of region.
;; And leave TO before that one.
(goto-char to)
(skip-chars-forward " \t")
;; Then change all newlines to spaces.
;;; 97/3/14 jhod: Kinsoku change
- ;; Spacing is not necessary for charcters of no word-separater.
+ ;; Spacing is not necessary for characters of no word-separator.
;; The regexp word-across-newline is used for this check.
(defvar word-across-newline)
(if (not (and (featurep 'mule)
(forward-paragraph)
(or (bolp) (newline 1))
(let ((end (point))
- (beg (progn (backward-paragraph) (point))))
+ (start (progn (backward-paragraph) (point))))
(goto-char before)
(if use-hard-newlines
;; Can't use fill-region-as-paragraph, since this paragraph may
;; still contain hard newlines. See fill-region.
- (fill-region beg end arg)
- (fill-region-as-paragraph beg end arg)))))))
+ (fill-region start end arg)
+ (fill-region-as-paragraph start end arg)))))))
(defun fill-region (from to &optional justify nosqueeze to-eop)
"Fill each of the paragraphs in the region.
(barf-if-buffer-read-only nil (region-beginning) (region-end))
(list (region-beginning) (region-end)
(if current-prefix-arg 'full))))
- (let (end beg)
+ (let (end start)
(save-restriction
(goto-char (max from to))
(if to-eop
(progn (skip-chars-backward "\n")
(forward-paragraph)))
(setq end (point))
- (goto-char (setq beg (min from to)))
+ (goto-char (setq start (min from to)))
(beginning-of-line)
(narrow-to-region (point) end)
(while (not (eobp))
(let ((initial (point))
end)
;; If using hard newlines, break at every one for filling
- ;; purposes rather than using paragraph breaks.
+ ;; purposes rather than using paragraph breaks.
(if use-hard-newlines
- (progn
+ (progn
(while (and (setq end (text-property-any (point) (point-max)
'hard t))
(not (eq ?\n (char-after end)))
(forward-paragraph 1)
(setq end (point))
(forward-paragraph -1))
- (if (< (point) beg)
- (goto-char beg))
+ (if (< (point) start)
+ (goto-char start))
(if (>= (point) initial)
(fill-region-as-paragraph (point) end justify nosqueeze)
(goto-char end)))))))
(fill-region (point) (mark) arg)
(fill-paragraph arg)))
-\f
+\f
(defconst default-justification 'left
"*Method of justifying text not otherwise specified.
Possible values are `left', `right', `full', `center', or `none'.
This returns the value of the text-property `justification',
or the variable `default-justification' if there is no text-property.
However, it returns nil rather than `none' to mean \"don't justify\"."
- (let ((j (or (get-text-property
+ (let ((j (or (get-text-property
;; Make sure we're looking at paragraph body.
- (save-excursion (skip-chars-forward " \t")
+ (save-excursion (skip-chars-forward " \t")
(if (and (eobp) (not (bobp)))
(1- (point)) (point)))
'justification)
(save-restriction
(if whole-par
(let ((paragraph-start (if use-hard-newlines "." paragraph-start))
- (paragraph-ignore-fill-prefix (if use-hard-newlines t
+ (paragraph-ignore-fill-prefix (if use-hard-newlines t
paragraph-ignore-fill-prefix)))
(goto-char begin)
(while (and (bolp) (not (eobp))) (forward-char 1))
;; 97/3/14 jhod: This functions are added for Kinsoku support
(defun find-space-insertable-point ()
- "Search backward for a permissible point for inserting justification spaces"
+ "Search backward for a permissible point for inserting justification spaces."
(if (boundp 'space-insertable)
(if (re-search-backward space-insertable nil t)
(progn (forward-char 1)
;; A line has up to six parts:
;;
-;; >>> hello.
+;; >>> hello.
;; [Indent-1][FP][ Indent-2 ][text][trailing whitespace][newline]
;;
;; "Indent-1" is the left-margin indentation; normally it ends at column
;; Trailing whitespace is not counted as part of the line length when
;; center- or right-justifying.
;;
-;; All parts of the line are optional, although the final newline can
+;; All parts of the line are optional, although the final newline can
;; only be missing on the last line of the buffer.
(defun justify-current-line (&optional how eop nosqueeze)
Normally does full justification: adds spaces to the line to make it end at
the column given by `current-fill-column'.
Optional first argument HOW specifies alternate type of justification:
-it can be `left', `right', `full', `center', or `none'.
+it can be `left', `right', `full', `center', or `none'.
If HOW is t, will justify however the `current-justification' function says to.
If HOW is nil or missing, full justification is done by default.
Second arg EOP non-nil means that this is the last line of the paragraph, so
(let ((fc (current-fill-column))
(pos (point-marker))
fp-end ; point at end of fill prefix
- beg ; point at beginning of line's text
+ start ; point at beginning of line's text
end ; point at end of line's text
- indent ; column of `beg'
+ indent ; column of `start'
endcol ; column of `end'
ncols) ; new indent point or offset
(end-of-line)
;; Check if this is the last line of the paragraph.
- (if (and use-hard-newlines (null eop)
+ (if (and use-hard-newlines (null eop)
(get-text-property (point) 'hard))
(setq eop t))
(skip-chars-backward " \t")
(beginning-of-line)
(skip-chars-forward " \t")
;; Skip over fill-prefix.
- (if (and fill-prefix
+ (if (and fill-prefix
(not (string-equal fill-prefix ""))
(equal fill-prefix
- (buffer-substring
+ (buffer-substring
(point) (min (point-max) (+ (length fill-prefix)
(point))))))
(forward-char (length fill-prefix))
- (if (and adaptive-fill-mode
+ (if (and adaptive-fill-mode
(looking-at adaptive-fill-regexp))
(goto-char (match-end 0))))
(setq fp-end (point))
(skip-chars-forward " \t")
;; This is beginning of the line's text.
(setq indent (current-column))
- (setq beg (point))
+ (setq start (point))
(goto-char end)
(setq endcol (current-column))
;; HOW can't be null or left--we would have exited already
- (cond ((eq 'right how)
+ (cond ((eq 'right how)
(setq ncols (- fc endcol))
(if (< ncols 0)
;; Need to remove some indentation
- (delete-region
+ (delete-region
(progn (goto-char fp-end)
(if (< (current-column) (+ indent ncols))
(move-to-column (+ indent ncols) t))
(point))
(progn (move-to-column indent) (point)))
;; Need to add some
- (goto-char beg)
+ (goto-char start)
(indent-to (+ indent ncols))
;; If point was at beginning of text, keep it there.
- (if (= beg pos)
+ (if (= start pos)
(move-marker pos (point)))))
((eq 'center how)
(point))
(progn (move-to-column indent) (point)))
;; Have too little - add some
- (goto-char beg)
+ (goto-char start)
(indent-to ncols)
;; If point was at beginning of text, keep it there.
- (if (= beg pos)
+ (if (= start pos)
(move-marker pos (point)))))
((eq 'full how)
;; Insert extra spaces between words to justify line
(save-restriction
- (narrow-to-region beg end)
+ (narrow-to-region start end)
(or nosqueeze
- (canonically-space-region beg end))
+ (canonically-space-region start end))
(goto-char (point-max))
(setq ncols (- fc endcol))
;; Ncols is number of additional spaces needed
(save-excursion
(move-to-left-margin nil t)
;; Position ourselves after any fill-prefix.
- (if (and fill-prefix
+ (if (and fill-prefix
(not (string-equal fill-prefix ""))
(equal fill-prefix
- (buffer-substring
+ (buffer-substring
(point) (min (point-max) (+ (length fill-prefix)
(point))))))
(forward-char (length fill-prefix)))
(defun unjustify-region (&optional begin end)
"Remove justification whitespace from region.
For centered or right-justified regions, this function removes any indentation
-past the left margin from each line. For full-justified lines, it removes
+past the left margin from each line. For full-justified lines, it removes
extra spaces between words. It does nothing in other justification modes.
Arguments BEGIN and END are optional; default is the whole buffer."
(save-excursion
(goto-char min)
(beginning-of-line)
(narrow-to-region (point) max)
- (if mailp
+ (if mailp
(while (and (not (eobp))
(or (looking-at "[ \t]*[^ \t\n]+:")
(looking-at "[ \t]*$")))
(if (and adaptive-fill-mode adaptive-fill-regexp
(looking-at adaptive-fill-regexp))
(match-string 0)
- (buffer-substring
+ (buffer-substring
(point)
(save-excursion (skip-chars-forward " \t")
(point))))
(if fill-individual-varying-indent
;; If this line is a separator line, with or
;; without prefix, end the paragraph.
- (and
+ (and
(not (looking-at paragraph-separate))
(save-excursion
(not (and (looking-at fill-prefix-regexp)