From daf9ea5adb79b3927bf63e3753097c44ee0693c2 Mon Sep 17 00:00:00 2001 From: Gregor Grigorjan Date: Wed, 15 May 2024 08:05:26 +0300 Subject: [PATCH] refactor: always remove patches So they are guaranteed to get removed, even after some patches are disabled through custom variables. --- magit-file-icons.el | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/magit-file-icons.el b/magit-file-icons.el index f55429ea..db61043e 100644 --- a/magit-file-icons.el +++ b/magit-file-icons.el @@ -66,25 +66,20 @@ (insert (propertize (el-patch-swap file (format "%s %s" (nerd-icons-icon-for-file file) file)) 'font-lock-face 'magit-filename) sep cnt " ")) -(defvar patched-functions '() - "The Magit functions that should be patched.") - -(when magit-file-icons-enable-diff-file-section-icons (add-to-list 'patched-functions #'magit-diff-insert-file-section)) -(when magit-file-icons-enable-untracked-icons (add-to-list 'patched-functions #'magit-insert-untracked-files)) -(when magit-file-icons-enable-diffstat-icons (add-to-list 'patched-functions #'magit-diff-wash-diffstat)) - ;;;###autoload (define-minor-mode magit-file-icons-mode "Prefix files with icons in Magit buffers." :after-hook (cond (magit-file-icons-mode - (dolist (func patched-functions) - (el-patch-eval-template func 'defun)) + (when magit-file-icons-enable-diff-file-section-icons (el-patch-eval-template #'magit-diff-insert-file-section 'defun)) + (when magit-file-icons-enable-untracked-icons (el-patch-eval-template #'magit-insert-untracked-files 'defun)) + (when magit-file-icons-enable-diffstat-icons (el-patch-eval-template #'magit-diff-wash-diffstat 'defun)) (magit-refresh)) ('deactivate - (dolist (func patched-functions) - (el-patch-unpatch func 'defun nil)) + (el-patch-unpatch #'magit-diff-insert-file-section 'defun nil) + (el-patch-unpatch #'magit-insert-untracked-files 'defun nil) + (el-patch-unpatch #'magit-diff-wash-diffstat 'defun nil) (magit-refresh)))) (provide 'magit-file-icons)