chiark / gitweb /
el/dot-emacs.el: Use advice to hack the fill prefix.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 9 Oct 2017 11:25:52 +0000 (12:25 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 9 Oct 2017 11:25:52 +0000 (12:25 +0100)
The old thing with `fset' was awful, and presumably dates back to before
I knew about advice.

el/dot-emacs.el

index 0e93221f87984dc0af5ccdd61e56b727c398c514..1be574660d3059c2e8dde15b0fe3455d2a9f076f 100644 (file)
@@ -1009,10 +1009,6 @@ (defvar mdw-hanging-indents
   "*Standard regexp matching parts of a hanging indent.
 This is mainly useful in `auto-fill-mode'.")
 
-;; Setting things up.
-
-(fset 'mdw-do-auto-fill (symbol-function 'do-auto-fill))
-
 ;; Utility functions.
 
 (defun mdw-maybe-tabify (s)
@@ -1068,11 +1064,11 @@ (defun mdw-choose-dynamic-fill-prefix ()
             (save-match-data
               (mdw-examine-fill-prefixes mdw-fill-prefix))))))
 
-(defun do-auto-fill ()
+(defadvice do-auto-fill (around mdw-dynamic-fill-prefix () activate compile)
   "Handle auto-filling, working out a dynamic fill prefix in the
 case where there isn't a sensible static one."
   (let ((fill-prefix (mdw-choose-dynamic-fill-prefix)))
-    (mdw-do-auto-fill)))
+    ad-do-it))
 
 (defun mdw-fill-paragraph ()
   "Fill paragraph, getting a dynamic fill prefix."