;;; fill.el --- fill commands for Emacs -*- coding: utf-8 -*-
-;; Copyright (C) 1985, 1986, 1992, 1994, 1995, 1996, 1997, 1999, 2001, 2002,
-;; 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 1985-1986, 1992, 1994-1997, 1999, 2001-2013 Free
+;; Software Foundation, Inc.
;; Maintainer: FSF
;; Keywords: wp
+;; Package: emacs
;; This file is part of GNU Emacs.
(setq fill-prefix nil)))
(if fill-prefix
(message "fill-prefix: \"%s\"" fill-prefix)
- (message "fill-prefix cancelled")))
+ (message "fill-prefix canceled")))
(defcustom adaptive-fill-mode t
"Non-nil means determine a paragraph's fill prefix from its text."
;; Added `!' for doxygen comments starting with `//!' or `/*!'.
;; Added `%' for TeX comments.
;; RMS: deleted the code to match `1.' and `(1)'.
- "[ \t]*\\([-!|#%;>*·•‣⁃◦]+[ \t]*\\)*"
+ ;; Update mail-mode's paragraph-separate if you change this.
+ (purecopy "[ \t]*\\([-–!|#%;>*·•‣⁃◦]+[ \t]*\\)*")
"Regexp to match text at start of line that constitutes indentation.
If Adaptive Fill mode is enabled, a prefix matching this pattern
on the first and second lines of a paragraph is used as the
:type 'regexp
:group 'fill)
-(defcustom adaptive-fill-first-line-regexp "\\`[ \t]*\\'"
+(defcustom adaptive-fill-first-line-regexp (purecopy "\\`[ \t]*\\'")
"Regexp specifying whether to set fill prefix from a one-line paragraph.
When a paragraph has just one line, then after `adaptive-fill-regexp'
finds the prefix at the beginning of the line, if it doesn't
number equals or exceeds the local fill-column - right-margin difference."
(save-excursion
(if fill-column
- (let* ((here (progn (beginning-of-line) (point)))
+ (let* ((here (line-beginning-position))
(here-col 0)
(eol (progn (end-of-line) (point)))
margin fill-col change col)
"Char-table of characters that don't use space between words.")
(progn
- ;; Register `kinsoku' for scripts HAN, KANA, BOPOMPFO, and CJK-MISS.
+ ;; Register `kinsoku' for scripts HAN, KANA, BOPOMOFO, and CJK-MISC.
;; Also tell that they don't use space between words.
(map-char-table
#'(lambda (key val)
(goto-char from)
(if enable-multibyte-characters
- ;; Delete unnecessay newlines surrounded by words. The
+ ;; Delete unnecessary newlines surrounded by words. The
;; character category `|' means that we can break a line at the
;; character. And, char-table
;; `fill-nospace-between-words-table' tells how to concatenate
(if (and oneleft
(not (and use-hard-newlines
(get-text-property (1- (point)) 'hard))))
- (delete-backward-char 1)
+ (delete-char -1)
(backward-char 1)
(setq oneleft t)))
(setq to (copy-marker (point) t))
(move-to-column (current-fill-column))
(if (when (< (point) to)
;; Find the position where we'll break the line.
- (forward-char 1) ;Use an immediately following space, if any.
+ ;; Use an immediately following space, if any.
+ ;; However, note that `move-to-column' may overshoot
+ ;; if there are wide characters (Bug#3234).
+ (unless (> (current-column) (current-fill-column))
+ (forward-char 1))
(fill-move-to-break-point linebeg)
;; Check again to see if we got to the end of
;; the paragraph.
(defun fill-region (from to &optional justify nosqueeze to-eop)
"Fill each of the paragraphs in the region.
A prefix arg means justify as well.
-Ordinarily the variable `fill-column' controls the width.
+The `fill-column' variable controls the width.
Noninteractively, the third argument JUSTIFY specifies which
kind of justification to do: `full', `left', `right', `center',
(if current-prefix-arg 'full))))
(unless (memq justify '(t nil none full center left right))
(setq justify 'full))
- (let (max beg fill-pfx)
+ (let ((start-point (point-marker))
+ max beg fill-pfx)
(goto-char (max from to))
(when to-eop
(skip-chars-backward "\n")
(fill-forward-paragraph -1))
(if (< (point) beg)
(goto-char beg))
- (if (>= (point) initial)
+ (if (and (>= (point) initial) (< (point) end))
(setq fill-pfx
(fill-region-as-paragraph (point) end justify nosqueeze))
(goto-char end))))
+ (goto-char start-point)
+ (set-marker start-point nil)
fill-pfx))
\f
(const full)
(const center)
(const none))
+ :safe 'symbolp
:group 'fill)
(make-variable-buffer-local 'default-justification)
(skip-chars-backward " "))
(setq ncols (- fc endcol))
;; Ncols is number of additional space chars needed
- (if (and (> ncols 0) (> nspaces 0) (not eop))
- (progn
- (setq curr-fracspace (+ ncols (/ (1+ nspaces) 2))
- count nspaces)
- (while (> count 0)
- (skip-chars-forward " ")
- (insert-and-inherit
- (make-string (/ curr-fracspace nspaces) ?\s))
- (search-forward " " nil t)
- (setq count (1- count)
- curr-fracspace
- (+ (% curr-fracspace nspaces) ncols)))))))
+ (when (and (> ncols 0) (> nspaces 0) (not eop))
+ (setq curr-fracspace (+ ncols (/ nspaces 2))
+ count nspaces)
+ (while (> count 0)
+ (skip-chars-forward " ")
+ (insert-char ?\s (/ curr-fracspace nspaces) t)
+ (search-forward " " nil t)
+ (setq count (1- count)
+ curr-fracspace
+ (+ (% curr-fracspace nspaces) ncols))))))
(t (error "Unknown justification value"))))
(goto-char pos)
(move-marker pos nil)))
"")
string))
-;; arch-tag: 727ad455-1161-4fa9-8df5-0f74b179216d
;;; fill.el ends here