From: Mark Wooding Date: Sat, 22 Jun 2024 10:50:36 +0000 (+0100) Subject: el/dot-emacs.el: Make a section for bug-fixing `defadvice' hacks. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/profile/commitdiff_plain/ab9abde6dd2e5f3e83b41d6499c2ac187b804010?ds=sidebyside el/dot-emacs.el: Make a section for bug-fixing `defadvice' hacks. --- diff --git a/el/dot-emacs.el b/el/dot-emacs.el index 38b4595..6506967 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -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.