;;; dired-custom.el --- Custom dired config -*- lexical-binding: t -*- ;; This file is not part of GNU Emacs ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;; commentary ;;; Code: (require 'dired) (setq dired-listing-switches "-lh") (setq dired-recursive-deletes t) (setq dired-recursive-copies t) (defun dired-init () "Theurgy Dired config." ;; Hide file permissions (dired-hide-details-mode 1) ;; Kill new buffers (when (>= emacs-major-version 28) (setq dired-kill-when-opening-new-dired-buffer t)) (when (< emacs-major-version 28) (progn (define-key dired-mode-map (kbd "RET") 'dired-find-alternate-file) (define-key dired-mode-map (kbd "^") (lambda () (interactive) (find-alternate-file ".."))))) ;; Human readable file size (setq dired-listing-switches "-lh")) (add-hook 'dired-mode-hook 'dired-init) (add-hook 'dired-mode-hook 'auto-revert-mode) ;; Icons in dired (use-package all-the-icons-dired :config (add-hook 'dired-mode-hook 'all-the-icons-dired-mode)) ;; Multimedia and PDF viewing (when (not (equal system-type 'windows-nt)) (use-package ready-player :ensure t :config (setq ready-player-autoplay nil) (ready-player-mode 1)) (use-package pdf-tools :config (pdf-loader-install))) ;; Preview files (defun dired-preview-to-the-right () "My preferred `dired-preview-display-action-alist-function'." '((display-buffer-in-side-window) (side . right) (slot . 0) (window-width . 0.3))) (use-package dired-preview :after (ready-player) :config (setq dired-preview-display-action-alist #'dired-preview-to-the-right) (setq dired-preview-buffer-name-indicator "[Preview]") (setq dired-preview-ignored-extensions-regexp (concat "\\." "\\(gz\\|" "zst\\|" "tar\\|" "xz\\|" "rar\\|" "zip\\|" "iso\\|" "epub" "\\)")) (dired-preview-global-mode 1)) ;; Automatically kill preview buffers when opening a file (add-hook 'find-file-hook (lambda () (dolist (buf (buffer-list)) (when (string-match-p "\\[Preview\\]" (buffer-name buf)) (kill-buffer buf))))) (use-package neotree :config (define-key global-map (kbd "") 'neotree-toggle) (setq neo-theme (if (display-graphic-p) 'icons 'arrow))) (provide 'dired-custom) ;;; dired-custom.el ends here