💥 Move dired, electric-indent, eshell, imenu, term modules to :emacs
This commit is contained in:
parent
0c0276378f
commit
e2d055a40b
12 changed files with 21 additions and 19 deletions
61
modules/emacs/dired/config.el
Normal file
61
modules/emacs/dired/config.el
Normal file
|
@ -0,0 +1,61 @@
|
|||
;;; tools/dired/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(def-package! dired
|
||||
:defer t
|
||||
:init
|
||||
(setq ;; Always copy/delete recursively
|
||||
dired-recursive-copies 'always
|
||||
dired-recursive-deletes 'top
|
||||
;; Auto refresh dired, but be quiet about it
|
||||
global-auto-revert-non-file-buffers t
|
||||
auto-revert-verbose nil
|
||||
;; files
|
||||
image-dired-dir (concat doom-cache-dir "image-dired/")
|
||||
image-dired-db-file (concat image-dired-dir "db.el")
|
||||
image-dired-gallery-dir (concat image-dired-dir "gallery/")
|
||||
image-dired-temp-image-file (concat image-dired-dir "temp-image")
|
||||
image-dired-temp-rotate-image-file (concat image-dired-dir "temp-rotate-image"))
|
||||
:config
|
||||
(defun +dired|sort-directories-first ()
|
||||
"List directories first in dired buffers."
|
||||
(save-excursion
|
||||
(let (buffer-read-only)
|
||||
(forward-line 2) ;; beyond dir. header
|
||||
(sort-regexp-fields t "^.*$" "[ ]*." (point) (point-max))))
|
||||
(and (featurep 'xemacs)
|
||||
(fboundp 'dired-insert-set-properties)
|
||||
(dired-insert-set-properties (point-min) (point-max)))
|
||||
(set-buffer-modified-p nil))
|
||||
(add-hook 'dired-after-readin-hook #'+dired|sort-directories-first)
|
||||
|
||||
;; Automatically create missing directories when creating new files
|
||||
(defun +dired|create-non-existent-directory ()
|
||||
(let ((parent-directory (file-name-directory buffer-file-name)))
|
||||
(when (and (not (file-exists-p parent-directory))
|
||||
(y-or-n-p (format "Directory `%s' does not exist! Create it?" parent-directory)))
|
||||
(make-directory parent-directory t))))
|
||||
(push #'+dired|create-non-existent-directory find-file-not-found-functions)
|
||||
|
||||
;; Kill buffer when quitting dired buffers
|
||||
(define-key dired-mode-map [remap quit-window] (λ! (quit-window t))))
|
||||
|
||||
|
||||
(def-package! dired-k
|
||||
:after dired
|
||||
:config
|
||||
(add-hook 'dired-initial-position-hook #'dired-k)
|
||||
(add-hook 'dired-after-readin-hook #'dired-k-no-revert)
|
||||
|
||||
(defun +dired*interrupt-process (orig-fn &rest args)
|
||||
"Fixes dired-k killing git processes too abruptly, leaving behind disruptive
|
||||
.git/index.lock files."
|
||||
(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)
|
||||
"Butt out if the requested directory is remote (i.e. through tramp)."
|
||||
(unless (file-remote-p default-directory)
|
||||
(apply orig-fn args)))
|
||||
(advice-add #'dired-k--highlight :around #'+dired*dired-k-highlight))
|
Loading…
Add table
Add a link
Reference in a new issue