Conform many modules to new conventions

This commit is contained in:
Henrik Lissner 2019-07-23 12:30:47 +02:00
parent 20e2aa0b18
commit c795a988e6
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
26 changed files with 161 additions and 165 deletions

View file

@ -56,19 +56,19 @@
;; confusing than helpful.
(advice-add #'dired-k--highlight-by-file-attribyte :override #'ignore)
(defun +dired*interrupt-process (orig-fn &rest args)
(def-advice! +dired-interrupt-process-a (orig-fn &rest args)
"Fixes dired-k killing git processes too abruptly, leaving behind disruptive
.git/index.lock files."
:around #'dired-k--start-git-status
(cl-letf (((symbol-function #'kill-process)
(symbol-function #'interrupt-process)))
(apply orig-fn args)))
(advice-add #'dired-k--start-git-status :around #'+dired*interrupt-process)
(defun +dired*dired-k-highlight (orig-fn &rest args)
(def-advice! +dired-dired-k-highlight-a (orig-fn &rest args)
"Butt out if the requested directory is remote (i.e. through tramp)."
:around #'dired-k--highlight
(unless (file-remote-p default-directory)
(apply orig-fn args)))
(advice-add #'dired-k--highlight :around #'+dired*dired-k-highlight))
(apply orig-fn args))))
(def-package! ranger
@ -84,24 +84,24 @@
(set-popup-rule! "^\\*ranger" :ignore t)
(defun +dired*cleanup-header-line ()
(def-advice! +dired-cleanup-header-line-a ()
"Ranger fails to clean up `header-line-format' when it is closed, so..."
:before #'ranger-revert
(dolist (buffer (buffer-list))
(when (buffer-live-p buffer)
(with-current-buffer buffer
(when (equal header-line-format '(:eval (ranger-header-line)))
(setq header-line-format nil))))))
(advice-add #'ranger-revert :before #'+dired*cleanup-header-line)
(defun +dired*cleanup-mouse1-bind ()
(def-advice! +dired-cleanup-mouse1-bind-a ()
"Ranger binds an anonymous function to mouse-1 after previewing a buffer
that prevents the user from escaping the window with the mouse. This command is
never cleaned up if the buffer already existed before ranger was initialized, so
we have to clean it up ourselves."
:after #'ranger-setup-preview
(when (window-live-p ranger-preview-window)
(with-current-buffer (window-buffer ranger-preview-window)
(local-unset-key [mouse-1]))))
(advice-add #'ranger-setup-preview :after #'+dired*cleanup-mouse1-bind)
(setq ranger-cleanup-on-disable t
ranger-excluded-extensions '("mkv" "iso" "mp4")

View file

@ -10,10 +10,9 @@ current line.")
(after! electric
(setq-default electric-indent-chars '(?\n ?\^?))
(defun +electric-indent|char (_c)
(when (and (eolp) +electric-indent-words)
(save-excursion
(backward-word)
(looking-at-p (concat "\\<" (regexp-opt +electric-indent-words))))))
(add-to-list 'electric-indent-functions #'+electric-indent|char nil #'eq))
(add-hook 'electric-indent-functions
(defun +electric-indent-char-fn (_c)
(when (and (eolp) +electric-indent-words)
(save-excursion
(backward-word)
(looking-at-p (concat "\\<" (regexp-opt +electric-indent-words))))))))

View file

@ -26,7 +26,7 @@ repository root."
(git-link (git-link--select-remote) beg end)))))
;;;###autoload
(defun +vc*update-header-line (revision)
(defun +vc-update-header-line-a (revision)
"Show revision details in the header-line, instead of the minibuffer.
Sometimes I forget `git-timemachine' is enabled in a buffer. Putting revision

View file

@ -10,7 +10,7 @@
(after! git-timemachine
;; HACK Waiting for https://gitlab.com/pidu/git-timemachine/issues/77
(def-advice! +vc--git-timemachine-show-commit-a ()
(def-advice! +vc-git-timemachine-show-commit-a ()
"Fix `git-timemachine-show-commit'."
:override #'git-timemachine-show-commit
(interactive)
@ -29,7 +29,8 @@
;; showing revision details in the minibuffer, show them in
;; `header-line-format', which has better visibility.
(setq git-timemachine-show-minibuffer-details t)
(advice-add #'git-timemachine--show-minibuffer-details :override #'+vc*update-header-line)
(advice-add #'git-timemachine--show-minibuffer-details
:override #'+vc-update-header-line-a)
(after! evil
;; rehash evil keybindings so they are recognized
@ -50,14 +51,14 @@
(set-yas-minor-mode! 'git-commit-mode)
(add-hook 'git-commit-mode-hook
(defun +vc--enforce-git-commit-conventions-h ()
(defun +vc-enforce-git-commit-conventions-h ()
"See https://chris.beams.io/posts/git-commit/"
(setq fill-column 72
git-commit-summary-max-length 50
git-commit-style-convention-checks '(overlong-summary-line non-empty-second-line))))
(add-hook 'git-commit-setup-hook
(defun +vc--start-in-insert-state-maybe ()
(defun +vc-start-in-insert-state-maybe ()
"Start git-commit-mode in insert state if in a blank commit message,
otherwise in default state."
(when (and (bound-and-true-p evil-mode)