.emacs.d

the most bloated Emacs config on this planet
git clone https://git.trogloxene.org/.emacs.d.git
Log | Files | Refs

init-dired.el (5056B)


      1 ;;; init-dired.el --- dired & dirvish -*-lexical-binding: t -*-
      2 
      3 ;;; Commentary:
      4 
      5 ;;; Code:
      6 
      7 (use-package dired
      8   :straight nil
      9   :config
     10   (when *is-mac*
     11     (setq insert-directory-program "gls"
     12           dired-use-ls-dired t))
     13   (setq dired-dwim-target t
     14         dired-listing-switches
     15         "-l --almost-all --human-readable --group-directories-first --no-group"
     16         dired-switches-in-mode-line 0
     17         dired-recursive-deletes 'always
     18         dired-recursive-copies 'always
     19         dired-mouse-drag-files t
     20         mouse-drag-and-drop-region-cross-program t
     21         dired-compress-file-default-suffix ".zip"
     22         dired-kill-when-opening-new-dired-buffer nil
     23         dired-auto-revert-buffer t
     24         dired-create-destination-dirs 'ask
     25         dired-create-destination-dirs-on-trailing-dirsep t
     26         remote-file-name-inhibit-delete-by-moving-to-trash t)
     27   (put 'dired-find-alternate-file 'disabled nil))
     28 
     29 ;; dirvish
     30 (use-package dirvish
     31   :init
     32   (dirvish-override-dired-mode)
     33   :config
     34   (defun my-dirvish-layout-toggle ()
     35     "Toggle layout using first recipe in `dirvish-layout-recipes' instead of
     36 fallback."
     37     (interactive)
     38     (let ((dv (dirvish-curr)))
     39       (unless dv (user-error "Not a dirvish buffer"))
     40       (unless (dv-curr-layout dv)
     41         (setf (dv-ff-layout dv) (car dirvish-layout-recipes)))
     42       (dirvish-layout-toggle)))
     43 
     44   (require 'vc)
     45 
     46   (if (or *is-mac* *is-android*)
     47       (setq dirvish-hide-details t)
     48     (setq dirvish-hide-details '(dirvish-side)))
     49 
     50   (if *is-android*
     51       (setq dirvish-default-layout nil
     52             dirvish-layout-recipes '((1 0.6)))
     53     (setq dirvish-default-layout nil
     54           dirvish-layout-recipes '((1 0.15 0.45))))
     55 
     56   (setq dirvish-use-mode-line nil
     57         dirvish-mode-line-format '(:left (sort omit symlink) :right (free-space index))
     58         dirvish-attributes '(file-time file-size)
     59         dirvish-yank-sources 'session
     60         dirvish-hide-cursor nil)
     61 
     62   :custom
     63   (dirvish-quick-access-entries
     64    (cond
     65     (*is-windows*
     66      '(("h" "~/"                                   "Home")
     67        ("e" "~/.emacs.d/"                          "Emacs config")
     68        ("p" "c:/Users/gaozh/Pictures/Screenshots/" "Pictures")
     69        ("d" "f:/下载25-2-10/"                      "Download")
     70        ("v" "f:/luping26-1-11/"                    "Videos")
     71        ("n" "h:/emacs/my-org-note/"                "Notes")))
     72 
     73     (*is-mac*
     74      '(("h" "~/"                          "Home")
     75        ("e" "~/.emacs.d/"                 "Emacs config")
     76        ("p" "~/Pictures/"                 "Pictures")
     77        ("d" "~/Downloads/"                "Download")
     78        ("v" "~/Movies/"                   "Videos")
     79        ("n" "~/org/my-org-note/"          "Notes")
     80        ("g" "~/gptel/"                    "gptel sessions")))
     81 
     82     (*is-linux*
     83      '(("h" "~/"                          "Home")
     84        ("e" "~/.emacs.d/"                 "Emacs config")
     85        ("s" "~/.config/guix/"             "System config")
     86        ("p" "~/Pictures/"                 "Pictures")
     87        ("d" "~/downloads/"                "Downloads")
     88        ("v" "~/视频/"                     "Videos")
     89        ("n" "~/org/my-org-note/"          "Notes")
     90        ("g" "~/gptel/"                    "gptel sessions")))
     91 
     92     (*is-android*
     93      '(("h" "~/"                            "Home")
     94        ("e" "~/.emacs.d"                    "Emacs")
     95        ("n" "~/storage/shared/my-org-note/" "Notes")
     96        ("g" "~/gptel/"                      "gptel sessions")))
     97     (t nil))))
     98 
     99 ;; gitignore
    100 (use-package dired-gitignore
    101   :after
    102   (dirvish dirvish-vc transient)
    103   :demand t
    104   :config
    105   (transient-define-suffix dirvish-toggle-gitignore ()
    106     "Toggle `dired-gitignore-mode' in current Dirvish buffer."
    107     :description
    108     (lambda ()
    109       (format "Gitignore filter (%s)"
    110               (if dired-gitignore-mode
    111                   (propertize "+" 'face 'transient-value)
    112                 (propertize "-" 'face 'transient-inactive-value))))
    113     :transient t
    114     (interactive)
    115     (dired-gitignore-mode 'toggle))
    116 
    117   (transient-append-suffix 'dirvish-vc-menu "v"
    118     '("i" dirvish-toggle-gitignore)))
    119 
    120 ;; trashed
    121 (unless *is-mac*
    122   (use-package trashed
    123     :commands
    124     (trashed)
    125     :config
    126     (setq trashed-action-confirmer 'y-or-n-p
    127           trashed-use-header-line t
    128           trashed-sort-key '("Date deleted" . t)
    129           trashed-date-format "%Y-%m-%d %H:%M:%S")))
    130 
    131 ;; dired-async
    132 (use-package dired-rsync
    133   :config
    134   (setq dired-rsync-options "-az -e ssh")
    135   (setq-default mode-line-format
    136                 (append mode-line-format
    137                         '((:eval (propertize dired-rsync-modeline-status 'face 'dired-async-mode-message))))))
    138 
    139 ;; mount disk
    140 (when *is-linux*
    141   (use-package debase
    142     :straight
    143     (debase :type git
    144             :host codeberg
    145             :repo "emacs-weirdware/debase"))
    146 
    147   (use-package discomfort
    148     :commands discomfort
    149     :straight
    150     (discomfort :type git
    151                 :host codeberg
    152                 :repo "emacs-weirdware/discomfort")))
    153 
    154 (provide 'init-dired)
    155 ;;; init-dired.el ends here