aboutsummaryrefslogtreecommitdiff
path: root/.emacs.d/init/ycp-dired.el
diff options
context:
space:
mode:
Diffstat (limited to '.emacs.d/init/ycp-dired.el')
-rw-r--r--.emacs.d/init/ycp-dired.el118
1 files changed, 118 insertions, 0 deletions
diff --git a/.emacs.d/init/ycp-dired.el b/.emacs.d/init/ycp-dired.el
new file mode 100644
index 0000000..e8a10ae
--- /dev/null
+++ b/.emacs.d/init/ycp-dired.el
@@ -0,0 +1,118 @@
+;;; ycp-dired.el -- My config for dired and friends -*- lexical-binding: t -*-
+
+;; Copyright (C) 2023 Free Software Foundation.
+
+;; Author: Yuchen Pei <id@ypei.org>
+;; Protesilaos Stavrou <info@protesilaos.com>
+;; Maintainer: Yuchen Pei <id@ypei.org>
+;; Package-Requires: ((emacs "28.2"))
+
+;; This file is part of dotfiles.
+
+;; dotfiles is free software: you can redistribute it and/or modify it under
+;; the terms of the GNU Affero General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; dotfiles 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 Affero General
+;; Public License for more details.
+
+;; You should have received a copy of the GNU Affero General Public
+;; License along with dotfiles. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; My config for dired and friends.
+
+;;; Code:
+
+
+(setq delete-by-moving-to-trash 'always)
+
+(my-package dired
+ (:delay 5)
+ (put 'dired-find-alternate-file 'disabled nil)
+ (setq dired-dwim-target t)
+ (setq dired-recursive-copies 'always)
+ (setq dired-recursive-deletes 'always)
+ (setq dired-listing-switches "-alh")
+ (add-hook 'dired-mode-hook (lambda () (interactive)
+ (auto-revert-mode t)))
+ (add-hook 'dired-mode-hook #'hl-line-mode)
+ (setq dired-listing-switches "-al --block-size='1")
+ (my-keybind dired-mode-map
+ "^" (lambda () (interactive) (find-alternate-file "..")))
+ (my-keybind global-map
+ "C-x C-j" #'dired-jump
+ ;; to open a dir in dired, find-file is more than sufficient
+ "C-x d" #'dired-jump)
+ )
+
+(my-package my-dired
+ (:delay 5)
+ (my-keybind dired-mode-map
+ "a" #'my-dired-find-or-alternate
+ "<return>" #'my-dired-find-or-alternate
+ "r" #'my-dired-do-rename-and-symlink-back
+ "s" #'my-dired-toggle-sorting)
+ )
+
+;;; dired-aux
+(my-package dired-aux
+ (:delay 5)
+ (setq dired-isearch-filenames 'dwim)
+ (setq dired-create-destination-dirs 'ask) ; Emacs 27
+ (setq dired-vc-rename-file t) ; Emacs 27
+ (setq dired-do-revert-buffer (lambda (dir) (not (file-remote-p dir))))
+ (my-keybind dired-mode-map
+ "C-+" #'dired-create-empty-file
+ ;; "M-s f" #'nil
+ "C-x v v" #'dired-vc-next-action)
+ ) ; Emacs 28
+
+
+;;; dired-x
+(my-package dired-x
+ (:delay 5)
+ (add-hook 'dired-mode-hook #'dired-omit-mode)
+ (setq dired-omit-files "\\`[.]?#")
+ (setq dired-clean-up-buffers-too t)
+ (setq dired-clean-confirm-killing-deleted-buffers t)
+ (setq dired-x-hands-off-my-keys t) ; easier to show the keys I use
+ (setq dired-bind-man nil)
+ (setq dired-bind-info nil)
+ (my-keybind dired-mode-map "I" #'dired-info))
+
+;;; required by dired-subtree
+(my-package dash
+ (:delay 5)
+ (:install t))
+
+(my-package dired-subtree
+ (:delay 5)
+ (setq dired-subtree-use-backgrounds nil)
+ (my-keybind dired-mode-map
+ "<tab>" #'dired-subtree-toggle
+ "<backtab>" #'dired-subtree-remove))
+
+;;; image-dired
+(my-package image-dired
+ (:delay 10)
+ (setq image-dired-thumbnail-storage 'standard)
+ (setq image-dired-external-viewer "xdg-open")
+ (setq image-dired-thumb-size 80)
+ (setq image-dired-thumb-margin 2)
+ (setq image-dired-thumb-relief 0)
+ (setq image-dired-thumbs-per-row 4)
+ (my-keybind image-dired-thumbnail-mode-map
+ "<return>" #'image-dired-thumbnail-display-external))
+
+
+;;; dired-du
+(my-package dired-du
+ (require 'dired-du)
+ (setq dired-du-size-format 'comma))
+
+(provide 'ycp-dired)