dired-hide-dotfiles.el (2813B)
1 ;;; dired-hide-dotfiles.el --- Hide dotfiles in dired -*- lexical-binding: t; -*- 2 3 ;; Copyright ⓒ 2017 Mattias Bengtsson 4 ;; 5 ;; This program is free software: you can redistribute it and/or modify 6 ;; it under the terms of the GNU General Public License as published by 7 ;; the Free Software Foundation, either version 3 of the License, or 8 ;; (at your option) any later version. 9 ;; 10 ;; This program is distributed in the hope that it will be useful, 11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 ;; GNU General Public License for more details. 14 ;; 15 ;; You should have received a copy of the GNU General Public License 16 ;; along with This program. If not, see <http://www.gnu.org/licenses/>. 17 ;; 18 ;; Author: Mattias Bengtsson <mattias.jc.bengtsson@gmail.com> 19 20 ;; Version : 0.1 21 ;; Keywords : files 22 ;; Package-Requires : ((emacs "25.1")) 23 ;; URL : https://github.com/mattiasb/dired-hide-dotfiles 24 ;; Doc URL : TBA 25 26 ;;; Commentary: 27 28 ;; This package is deprecated but can rather easily be replaced by 29 ;; `dired-omit-mode` like this: 30 ;; 31 ;; ```emacs-lisp 32 ;; (use-package dired 33 ;; :hook (dired-mode . dired-omit-mode)) 34 ;; :bind (:map dired-mode-map 35 ;; ( "." . dired-omit-mode)) 36 ;; :custom (dired-omit-files (rx (seq bol "."))) 37 ;; ``` 38 ;; 39 ;; Also see [#8][issue-8]. 40 41 ;; Hide dotfiles in Dired. 42 ;; 43 ;; To activate this mode add something like this to your init.el: 44 ;; 45 ;; (defun my-dired-mode-hook () 46 ;; "My `dired' mode hook." 47 ;; ;; To hide dot-files by default 48 ;; (dired-hide-dotfiles-mode)) 49 ;; 50 ;; ;; To toggle hiding 51 ;; (define-key dired-mode-map "." #'dired-hide-dotfiles-mode) 52 ;; (add-hook 'dired-mode-hook #'my-dired-mode-hook) 53 54 ;;; Note: 55 56 ;;; Code: 57 58 (require 'dired) 59 60 (defgroup dired-hide-dotfiles nil 61 "Dired hide dotfiles." 62 :group 'dired) 63 64 (defcustom dired-hide-dotfiles-verbose t 65 "When non-nil, show how many dotfiles were hidden." 66 :version "0.2" 67 :type 'boolean 68 :group 'dired-hide-dotfiles) 69 70 ;;;###autoload 71 (define-minor-mode dired-hide-dotfiles-mode 72 "Toggle `dired-hide-dotfiles-mode'." 73 :init-value nil 74 :lighter " !." 75 :group 'dired 76 (if dired-hide-dotfiles-mode 77 (progn 78 (add-hook 'dired-after-readin-hook 'dired-hide-dotfiles--hide) 79 (dired-hide-dotfiles--hide)) 80 (remove-hook 'dired-after-readin-hook 'dired-hide-dotfiles--hide) 81 (revert-buffer))) 82 83 (defun dired-hide-dotfiles--hide () 84 "Hide all dot-files in the current `dired' buffer." 85 (let ((inhibit-message t)) 86 (dired-mark-files-regexp "^\\.")) 87 (dired-do-kill-lines nil (if dired-hide-dotfiles-verbose 88 "Hid %d dotfile%s." 89 ""))) 90 91 (provide 'dired-hide-dotfiles) 92 ;;; dired-hide-dotfiles.el ends here