chiark / gitweb /
el/dot-emacs.el: Make a section for bug-fixing `defadvice' hacks.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 22 Jun 2024 10:50:36 +0000 (11:50 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 23 Jun 2024 00:00:38 +0000 (01:00 +0100)
el/dot-emacs.el

index 38b4595cbc931008daa56e7a767d9d2756632c20..65069672b567158247d4bed21e9f0e8892e74454 100644 (file)
@@ -182,39 +182,6 @@ (defadvice backward-page (after mdw-fixup compile activate)
 (defadvice forward-page (after mdw-fixup compile activate)
   (mdw-fixup-page-position))
 
-;; Bug fix for markdown-mode, which breaks point positioning during
-;; `query-replace'.
-(defadvice markdown-check-change-for-wiki-link
-    (around mdw-save-match activate compile)
-  "Save match data around the `markdown-mode' `after-change-functions' hook."
-  (save-match-data ad-do-it))
-
-;; Bug fix for `bbdb-canonicalize-address': on Emacs 24, `run-hook-with-args'
-;; always returns nil, with the result that all email addresses are lost.
-;; Replace the function entirely.
-(defadvice bbdb-canonicalize-address
-    (around mdw-bug-fix activate compile)
-  "Don't use `run-hook-with-args', because that doesn't work."
-  (let ((net (ad-get-arg 0)))
-
-    ;; Make sure this is a proper hook list.
-    (if (functionp bbdb-canonicalize-net-hook)
-       (setq bbdb-canonicalize-net-hook (list bbdb-canonicalize-net-hook)))
-
-    ;; Iterate over the hooks until things converge.
-    (let ((donep nil))
-      (while (not donep)
-       (let (next (changep nil)
-             hook (hooks bbdb-canonicalize-net-hook))
-         (while hooks
-           (setq hook (pop hooks))
-           (setq next (funcall hook net))
-           (if (not (equal next net))
-               (setq changep t
-                     net next)))
-         (setq donep (not changep)))))
-    (setq ad-return-value net)))
-
 ;; Transient mark mode hacks.
 
 (defadvice exchange-point-and-mark
@@ -271,6 +238,42 @@ (defadvice rename-file (after mdw-rename-buffers (from to &optional forcep)
          (with-current-buffer buffer
            (set-visited-file-name to nil t)))))))
 
+;;;--------------------------------------------------------------------------
+;;; Miscellaneous bug fixes.
+
+;; Bug fix for markdown-mode, which breaks point positioning during
+;; `query-replace'.
+(defadvice markdown-check-change-for-wiki-link
+    (around mdw-save-match activate compile)
+  "Save match data around the `markdown-mode' `after-change-functions' hook."
+  (save-match-data ad-do-it))
+
+;; Bug fix for `bbdb-canonicalize-address': on Emacs 24, `run-hook-with-args'
+;; always returns nil, with the result that all email addresses are lost.
+;; Replace the function entirely.
+(defadvice bbdb-canonicalize-address
+    (around mdw-bug-fix activate compile)
+  "Don't use `run-hook-with-args', because that doesn't work."
+  (let ((net (ad-get-arg 0)))
+
+    ;; Make sure this is a proper hook list.
+    (if (functionp bbdb-canonicalize-net-hook)
+       (setq bbdb-canonicalize-net-hook (list bbdb-canonicalize-net-hook)))
+
+    ;; Iterate over the hooks until things converge.
+    (let ((donep nil))
+      (while (not donep)
+       (let (next (changep nil)
+             hook (hooks bbdb-canonicalize-net-hook))
+         (while hooks
+           (setq hook (pop hooks))
+           (setq next (funcall hook net))
+           (if (not (equal next net))
+               (setq changep t
+                     net next)))
+         (setq donep (not changep)))))
+    (setq ad-return-value net)))
+
 ;;;--------------------------------------------------------------------------
 ;;; Window management.