aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2001-10-13 19:16:56 +0000
committerStefan Monnier2001-10-13 19:16:56 +0000
commitd1a27f1dd8c4cc89de0d58ef65a2b08c709ca201 (patch)
tree13abc326923c1c31d67ac6175be80bee946da66d
parentffe7a2a203b61a126a0a6a47782e325a65bfdec3 (diff)
downloademacs-d1a27f1dd8c4cc89de0d58ef65a2b08c709ca201.tar.gz
emacs-d1a27f1dd8c4cc89de0d58ef65a2b08c709ca201.zip
(refill-mode): Bind DEL to backward-delete-char-untabify.
Set backward-delete-char-untabify-method to `hungry'.
-rw-r--r--lisp/textmodes/refill.el38
1 files changed, 36 insertions, 2 deletions
diff --git a/lisp/textmodes/refill.el b/lisp/textmodes/refill.el
index 8bf5a03f221..345c9fca5bc 100644
--- a/lisp/textmodes/refill.el
+++ b/lisp/textmodes/refill.el
@@ -56,6 +56,32 @@
56;; some Emacs bug at the time. ISTR maniac has problems with 56;; some Emacs bug at the time. ISTR maniac has problems with
57;; whitespace at the end of paragraphs.] 57;; whitespace at the end of paragraphs.]
58 58
59;;; Todo/Bugs:
60
61;; - When deleting the first word on a line, the space after that word tends
62;; to become part of the fill-prefix, causing either wrong filling of the
63;; remaining text, or causing the cursor to move unexpectedly. Ex:
64;; Start with
65;; I>< blabla
66;;
67;; and hit backspace. We end up with
68;;
69;; ><blabla
70;; instead of
71;; >< blabla
72;;
73;; Other example. Start with
74;;
75;; Foo bar blablabla asdgf
76;; word>< asdfas dfasdfasd
77;; asd asdfa sdfasd sdf
78;;
79;; and hit M-backspace. We end up with
80;;
81;; Foo bar blablabla asdgf
82;; ><asdfas dfasdfasd asd
83;; asdfa sdfasd sdf
84
59;;; Code: 85;;; Code:
60 86
61(defvar refill-ignorable-overlay nil 87(defvar refill-ignorable-overlay nil
@@ -80,6 +106,9 @@ This is used to optimize refilling.")
80 (let (fill-pfx) 106 (let (fill-pfx)
81 (save-excursion 107 (save-excursion
82 (goto-char pos) 108 (goto-char pos)
109 ;; FIXME: forward-paragraph seems to disregard `use-hard-newlines',
110 ;; leading to excessive refilling and wrong choice of fill-prefix.
111 ;; might be a bug in my paragraphs.el.
83 (forward-paragraph) 112 (forward-paragraph)
84 (skip-syntax-backward "-") 113 (skip-syntax-backward "-")
85 (let ((end (point)) 114 (let ((end (point))
@@ -192,7 +221,7 @@ With prefix arg, turn Refill mode on iff arg is positive.
192When Refill mode is on, the current paragraph will be formatted when 221When Refill mode is on, the current paragraph will be formatted when
193changes are made within it. Self-inserting characters only cause 222changes are made within it. Self-inserting characters only cause
194refilling if they would cause auto-filling." 223refilling if they would cause auto-filling."
195 nil " Refill" nil 224 nil " Refill" '(("\177" . backward-delete-char-untabify))
196 ;; This provides the test for recursive paragraph filling. 225 ;; This provides the test for recursive paragraph filling.
197 (make-local-variable 'fill-paragraph-function) 226 (make-local-variable 'fill-paragraph-function)
198 (if refill-mode 227 (if refill-mode
@@ -204,6 +233,10 @@ refilling if they would cause auto-filling."
204 fill-paragraph-function) 233 fill-paragraph-function)
205 (set (make-local-variable 'fill-paragraph-function) 234 (set (make-local-variable 'fill-paragraph-function)
206 'refill-fill-paragraph) 235 'refill-fill-paragraph)
236 ;; When using justification, doing DEL on 2 spaces should remove
237 ;; both, otherwise, the subsequent refill will undo the DEL.
238 (set (make-local-variable 'backward-delete-char-untabify-method)
239 'hungry)
207 (setq refill-ignorable-overlay (make-overlay 1 1 nil nil t)) 240 (setq refill-ignorable-overlay (make-overlay 1 1 nil nil t))
208 (overlay-put refill-ignorable-overlay 'modification-hooks 241 (overlay-put refill-ignorable-overlay 'modification-hooks
209 '(refill-adjust-ignorable-overlay)) 242 '(refill-adjust-ignorable-overlay))
@@ -213,7 +246,8 @@ refilling if they would cause auto-filling."
213 (remove-hook 'after-change-functions 'refill-after-change-function t) 246 (remove-hook 'after-change-functions 'refill-after-change-function t)
214 (remove-hook 'post-command-hook 'refill-post-command-function t) 247 (remove-hook 'post-command-hook 'refill-post-command-function t)
215 (delete-overlay refill-ignorable-overlay) 248 (delete-overlay refill-ignorable-overlay)
216 (setq fill-paragraph-function refill-late-fill-paragraph-function))) 249 (setq fill-paragraph-function refill-late-fill-paragraph-function)
250 (kill-local-variable 'backward-delete-char-untabify-method)))
217 251
218(provide 'refill) 252(provide 'refill)
219 253