110 |
(let (fill-pfx) |
(let (fill-pfx) |
111 |
(save-excursion |
(save-excursion |
112 |
(goto-char pos) |
(goto-char pos) |
113 |
;; FIXME: forward-paragraph seems to disregard `use-hard-newlines', |
(unless (or (and (bolp) (eolp)) |
114 |
;; leading to excessive refilling and wrong choice of fill-prefix. |
(save-match-data (looking-at "\n\n"))) |
115 |
;; might be a bug in my paragraphs.el. |
;; FIXME: forward-paragraph seems to disregard `use-hard-newlines', |
116 |
(forward-paragraph) |
;; leading to excessive refilling and wrong choice of fill-prefix. |
117 |
(skip-syntax-backward "-") |
;; might be a bug in my paragraphs.el. |
118 |
(let ((end (point)) |
(forward-paragraph) |
119 |
(beg (progn (backward-paragraph) (point))) |
(skip-syntax-backward "-") |
120 |
(obeg (overlay-start refill-ignorable-overlay)) |
(let ((end (point)) |
121 |
(oend (overlay-end refill-ignorable-overlay))) |
(beg (progn (backward-paragraph) (point))) |
122 |
(goto-char pos) |
(obeg (overlay-start refill-ignorable-overlay)) |
123 |
(if (and (>= beg obeg) (< beg oend)) |
(oend (overlay-end refill-ignorable-overlay))) |
124 |
;; Limit filling to the modified tail of the paragraph. |
(goto-char pos) |
125 |
(let (;; When adaptive-fill-mode is enabled, the filling |
(if (and (>= beg obeg) (< beg oend)) |
126 |
;; functions will attempt to set the fill prefix from |
;; Limit filling to the modified tail of the paragraph. |
127 |
;; the fake paragraph bounds we pass in, so set it |
(let ( ;; When adaptive-fill-mode is enabled, the filling |
128 |
;; ourselves first, using the real paragraph bounds. |
;; functions will attempt to set the fill prefix from |
129 |
(fill-prefix |
;; the fake paragraph bounds we pass in, so set it |
130 |
(if (and adaptive-fill-mode |
;; ourselves first, using the real paragraph bounds. |
131 |
(or (null fill-prefix) (string= fill-prefix ""))) |
(fill-prefix |
132 |
(fill-context-prefix beg end) |
(if (and adaptive-fill-mode |
133 |
fill-prefix)) |
(or (null fill-prefix) (string= fill-prefix ""))) |
134 |
;; Turn off adaptive-fill-mode temporarily |
(fill-context-prefix beg end) |
135 |
(adaptive-fill-mode nil)) |
fill-prefix)) |
136 |
(save-restriction |
;; Turn off adaptive-fill-mode temporarily |
137 |
(if use-hard-newlines |
(adaptive-fill-mode nil)) |
|
(fill-region oend end arg) |
|
|
(fill-region-as-paragraph oend end arg))) |
|
|
(setq fill-pfx fill-prefix) |
|
|
(move-overlay refill-ignorable-overlay obeg (point))) |
|
|
;; Fill the whole paragraph |
|
|
(setq fill-pfx |
|
138 |
(save-restriction |
(save-restriction |
139 |
(if use-hard-newlines |
(if use-hard-newlines |
140 |
(fill-region beg end arg) |
(fill-region oend end arg) |
141 |
(fill-region-as-paragraph beg end arg)))) |
(fill-region-as-paragraph oend end arg))) |
142 |
(move-overlay refill-ignorable-overlay beg (point))))))) |
(setq fill-pfx fill-prefix) |
143 |
|
(move-overlay refill-ignorable-overlay obeg (point))) |
144 |
|
;; Fill the whole paragraph |
145 |
|
(setq fill-pfx |
146 |
|
(save-restriction |
147 |
|
(if use-hard-newlines |
148 |
|
(fill-region beg end arg) |
149 |
|
(fill-region-as-paragraph beg end arg)))) |
150 |
|
(move-overlay refill-ignorable-overlay beg (point)))))))) |
151 |
|
|
152 |
(defun refill-fill-paragraph (arg) |
(defun refill-fill-paragraph (arg) |
153 |
"Like `fill-paragraph' but don't delete whitespace at paragraph end." |
"Like `fill-paragraph' but don't delete whitespace at paragraph end." |
154 |
(refill-fill-paragraph-at (point) arg)) |
(refill-fill-paragraph-at (point) arg)) |
155 |
|
|
156 |
(defvar refill-doit nil |
(defvar refill-doit nil |
157 |
"Non-nil means that `refill-post-command-function' does its processing. |
"Non-nil tells `refill-post-command-function' to do its processing. |
158 |
Set by `refill-after-change-function' in `after-change-functions' and |
Set by `refill-after-change-function' in `after-change-functions' and |
159 |
unset by `refill-post-command-function' in `post-command-hook', and |
unset by `refill-post-command-function' in `post-command-hook', and |
160 |
sometimes `refill-pre-command-function' in `pre-command-hook'. This |
sometimes `refill-pre-command-function' in `pre-command-hook'. This |