diff options
Diffstat (limited to '.emacs.d/lisp/my/my-dired.el')
-rw-r--r-- | .emacs.d/lisp/my/my-dired.el | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/.emacs.d/lisp/my/my-dired.el b/.emacs.d/lisp/my/my-dired.el deleted file mode 100644 index 21240e1..0000000 --- a/.emacs.d/lisp/my/my-dired.el +++ /dev/null @@ -1,109 +0,0 @@ -;;; my-dired.el -- Extension for dired -*- lexical-binding: t -*- - -;; Copyright (C) 2023 Free Software Foundation. - -;; Author: 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: - -;; Extension for dired. - -;;; Code: - - -(require 'my-utils) - -(defvar my-dired-reverse-sorting nil) - -(defun my-dired-find-or-alternate (arg) - "Find if file, alternate find if dir. -If prefix then xdg-open, dir or file." - (interactive "P") - (if arg (call-process "xdg-open" nil 0 nil (dired-get-filename nil t)) - (if (file-directory-p (dired-get-filename nil t)) - (dired-find-alternate-file) - (dired-find-file)))) - -(defun my-dired-do-rename-and-symlink-back (arg) - (interactive "P") - (dired-do-create-files 'move-and-symlink #'my-rename-and-symlink-back - "Move and symlink back" arg dired-keep-marker-rename - "Rename and symlink")) - -(defun my-dired-sort-by-size () - (interactive) - (setq dired-actual-switches - (concat dired-listing-switches " -S" - (when my-dired-reverse-sorting "r"))) - (revert-buffer) - (setq mode-name "Dired by size")) - -(defun my-dired-sort-by-time () - (interactive) - (setq dired-actual-switches - (concat dired-listing-switches " -t" - (when my-dired-reverse-sorting "r"))) - (revert-buffer) - (setq mode-name "Dired by time")) - -(defun my-dired-sort-by-extension () - (interactive) - (setq dired-actual-switches - ;; FIXME: reverse sorting not working - (concat dired-listing-switches " -X" - (when my-dired-reverse-sorting "r"))) - (revert-buffer) - (setq mode-name "Dired by extension")) - -(defun my-dired-sort-by-name () - (interactive) - (setq dired-actual-switches - (concat dired-listing-switches - (when my-dired-reverse-sorting " -r"))) - (revert-buffer) - (setq mode-name "Dired by name")) - -(defun my-dired-toggle-sorting (arg) - "Cycle dired sorting methods. - -With a prefix arg, toggle `my-dired-reverse-sorting' instead." - (interactive "P") - (if arg - (progn - (setq my-dired-reverse-sorting - (not my-dired-reverse-sorting)) - (cond ((equal mode-name "Dired by name") - (my-dired-sort-by-name)) - ((equal mode-name "Dired by time") - (my-dired-sort-by-time)) - ((equal mode-name "Dired by size") - (my-dired-sort-by-size)) - ((equal mode-name "Dired by extension") - (my-dired-sort-by-extension)))) - (cond ((equal mode-name "Dired by name") - (my-dired-sort-by-time)) - ((equal mode-name "Dired by time") - (my-dired-sort-by-size)) - ((equal mode-name "Dired by size") - (my-dired-sort-by-extension)) - ((equal mode-name "Dired by extension") - (my-dired-sort-by-name))))) - -(provide 'my-dired) -;;; my-dired.el ends here |