From 6d54572740b317c835621080adf6e9f707954d19 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Sat, 3 Jul 2021 19:43:44 +0200 Subject: [PATCH] Fix wrong argument type error, vc-registered doesn't accept nil It's also good practice not to use lambdas inside hooks, for readability. --- .config/emacs/config.org | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.config/emacs/config.org b/.config/emacs/config.org index c475fe2..a70f553 100644 --- a/.config/emacs/config.org +++ b/.config/emacs/config.org @@ -72,6 +72,7 @@ - [[#centaur-tabs-functions][Centaur Tabs Functions]] - [[#dap-functions][DAP Functions]] - [[#dashboard-functions][Dashboard Functions]] + - [[#diff-hl-functions][Diff-hl Functions]] - [[#evil-functions][Evil functions]] - [[#lsp-functions][LSP Functions]] - [[#neotree-functions][Neotree Functions]] @@ -760,7 +761,7 @@ Debug Adapter Protocol. (use-package diff-hl :demand :hook (prog-mode . turn-on-diff-hl-mode) - :hook (prog-mode . (lambda () (when (vc-registered buffer-file-name) (diff-hl-flydiff-mode) (dot/toggle-fringe 1))))) + :hook (prog-mode . dot/diff-hl-enable-flydiff-and-fringe)) (use-package transient :defer t @@ -1379,6 +1380,17 @@ Fix keybinds.. (funcall (local-key-binding "r"))) #+END_SRC +*** Diff-hl Functions + +#+BEGIN_SRC emacs-lisp +(defun dot/diff-hl-enable-flydiff-and-fringe () + "Enable on the fly diff checking if file is under version control." + (let ((buffer buffer-file-name)) + (when (and buffer (vc-registered buffer)) + (diff-hl-flydiff-mode) + (dot/toggle-fringe 1)))) +#+END_SRC + *** Evil functions #+BEGIN_SRC emacs-lisp