Files
.emacs.d/lisp/init-dired.el
andsy10 b4733718d4 refactor: Reorganize config with use-package and optimize startup hooks
- Split monolithic init-package.el into focused modules
- Convert eager `:init` blocks to lazy `:hook`
- Consolidate UI settings and defer theme loading.
- Remove duplicated config between GUI and terminal paths.
2026-06-04 02:27:20 +08:00

136 lines
4.0 KiB
EmacsLisp
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
;;; init-dired.el --- dired & dirvish -*-lexical-binding: t -*-
;;; Commentary:
;;; Code:
(use-package dired
:straight nil
:config
(when *is-mac*
(setq insert-directory-program "gls"
dired-use-ls-dired t))
(setq dired-dwim-target t
dired-listing-switches
"-l --almost-all --human-readable --group-directories-first --no-group"
dired-recursive-deletes 'always
dired-recursive-copies 'always
dired-mouse-drag-files t
mouse-drag-and-drop-region-cross-program t
dired-compress-file-default-suffix ".zip"
dired-kill-when-opening-new-buffer t
dired-kill-when-opening-new-dired-buffer t)
(put 'dired-find-alternate-file 'disabled nil))
;; dirvish
(use-package dirvish
:hook
(dired-mode-hook . denote-dired-mode)
:init
(dirvish-override-dired-mode)
:config
(require 'vc)
(if *is-windows* (require 'fix-dirvish-preview))
(if (or *is-mac* *is-android*)
(setq dirvish-hide-details t)
(setq dirvish-hide-details '(dirvish-side)))
(setq dirvish-use-mode-line t)
(unless *is-windows*
(setq dirvish-attributes '(file-time file-size)))
(if *is-android*
(setq dirvish-default-layout '(1 0.6))
(setq dirvish-default-layout nil
dirvish-layout-recipes '((1 0.15 0.45))))
(with-eval-after-load 'dirvish
(add-hook 'dired-mode-hook #'dired-hide-details-mode))
:custom
(dirvish-quick-access-entries
(cond
(*is-windows*
'(("h" "~/" "Home")
("e" "~/.emacs.d/" "Emacs config")
("p" "c:/Users/gaozh/Pictures/Screenshots/" "Pictures")
("d" "f:/下载25-2-10/" "Download")
("v" "f:/luping26-1-11/" "Videos")
("n" "h:/emacs/my-org-note/" "Notes")))
(*is-mac*
'(("h" "~/" "Home")
("e" "~/.emacs.d/" "Emacs config")
("p" "~/Pictures/" "Pictures")
("d" "~/Downloads/" "Download")
("v" "~/Movies/" "Videos")
("n" "~/org/my-org-note/" "Notes")
("g" "~/gptel/" "gptel sessions")))
(*is-linux*
'(("h" "~/" "Home")
("e" "~/.emacs.d/" "Emacs config")
("s" "~/.config/guix/" "System config")
("p" "~/Pictures/" "Pictures")
("d" "~/downloads/" "Downloads")
("v" "~/视频/" "Videos")
("n" "~/org/my-org-note/" "Notes")
("g" "~/gptel/" "gptel sessions")))
(*is-android*
'(("h" "~/" "Home")
("e" "~/.emacs.d" "Emacs")
("n" "~/storage/shared/my-org-note/" "Notes")
("g" "~/gptel/" "gptel sessions")))
(t nil))))
;; gitignore
(use-package dired-gitignore
:after
(dirvish dirvish-vc transient)
:demand t
:config
(transient-define-suffix dirvish-toggle-gitignore ()
"Toggle `dired-gitignore-mode' in current Dirvish buffer."
:description
(lambda ()
(format "Gitignore filter (%s)"
(if dired-gitignore-mode
(propertize "+" 'face 'transient-value)
(propertize "-" 'face 'transient-inactive-value))))
:transient t
(interactive)
(dired-gitignore-mode 'toggle))
(transient-append-suffix 'dirvish-vc-menu "v"
'("i" dirvish-toggle-gitignore)))
;; trashed
(use-package trashed
:commands
(trashed)
:config
(setq trashed-action-confirmer 'y-or-n-p
trashed-use-header-line t
trashed-sort-key '("Date deleted" . t)
trashed-date-format "%Y-%m-%d %H:%M:%S"))
;; discomfort挂载硬盘
(use-package debase
:straight
(debase :type git
:host codeberg
:repo "emacs-weirdware/debase"))
(use-package discomfort
:commands discomfort
:straight
(discomfort :type git
:host codeberg
:repo "emacs-weirdware/discomfort"))
(provide 'init-dired)
;;; init-dired.el ends here