emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/textmodes/fill.el,v


From: Stefan Monnier
Subject: [Emacs-diffs] Changes to emacs/lisp/textmodes/fill.el,v
Date: Fri, 11 Apr 2008 15:34:18 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Stefan Monnier <monnier>        08/04/11 15:34:17

Index: lisp/textmodes/fill.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/textmodes/fill.el,v
retrieving revision 1.218
retrieving revision 1.219
diff -u -b -r1.218 -r1.219
--- lisp/textmodes/fill.el      14 Mar 2008 17:42:15 -0000      1.218
+++ lisp/textmodes/fill.el      11 Apr 2008 15:34:17 -0000      1.219
@@ -53,7 +53,10 @@
 (defvar fill-paragraph-function nil
   "Mode-specific function to fill a paragraph, or nil if there is none.
 If the function returns nil, then `fill-paragraph' does its normal work.
-A value of t means explicitly \"do nothing special\".")
+A value of t means explicitly \"do nothing special\".
+Note: This only affects `fill-paragraph' and not `fill-region'
+nor `auto-fill-mode', so it is often better to use some other hook,
+such as `fill-forward-paragraph-function'.")
 
 (defvar fill-paragraph-handle-comment t
   "Non-nil means paragraph filling will try to pay attention to comments.")
@@ -757,6 +760,15 @@
     (narrow-to-region (minibuffer-prompt-end) (point-max))
     (fill-paragraph arg)))
 
+(defvar fill-forward-paragraph-function 'forward-paragraph
+  "Function to move over paragraphs used by the filling code.
+It is called with a single argument specifying the number of paragraphs to 
move.
+Just like `forward-paragraph', it should return the number of paragraphs
+left to move.")
+
+(defun fill-forward-paragraph (arg)
+  (funcall fill-forward-paragraph-function arg))
+
 (defun fill-paragraph (&optional justify region)
   "Fill paragraph at or after point.
 
@@ -821,11 +833,11 @@
        ;; a paragraph (and not skipping any chars at EOB would not count
        ;; as a paragraph even if it is).
        (move-to-left-margin)
-       (if (not (zerop (forward-paragraph)))
+       (if (not (zerop (fill-forward-paragraph 1)))
           ;; There's no paragraph at or after point: give up.
           (setq fill-pfx "")
         (let ((end (point))
-              (beg (progn (backward-paragraph) (point))))
+               (beg (progn (fill-forward-paragraph -1) (point))))
           (goto-char before)
           (setq fill-pfx
                 (if use-hard-newlines
@@ -1002,7 +1014,7 @@
     (goto-char (max from to))
     (when to-eop
       (skip-chars-backward "\n")
-      (forward-paragraph))
+      (fill-forward-paragraph 1))
     (setq max (copy-marker (point) t))
     (goto-char (setq beg (min from to)))
     (beginning-of-line)
@@ -1020,9 +1032,9 @@
                (goto-char (1+ end)))
              (setq end (if end (min max (1+ end)) max))
              (goto-char initial))
-         (forward-paragraph 1)
+         (fill-forward-paragraph 1)
          (setq end (min max (point)))
-         (forward-paragraph -1))
+         (fill-forward-paragraph -1))
        (if (< (point) beg)
            (goto-char beg))
        (if (>= (point) initial)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]