dired-hide-dotfiles.el (2464B)
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 ;; Hide dotfiles in dired. 29 ;; 30 ;; To activate this mode add something like this to your init.el: 31 ;; 32 ;; (defun my-dired-mode-hook () 33 ;; "My `dired' mode hook." 34 ;; ;; To hide dot-files by default 35 ;; (dired-hide-dotfiles-mode)) 36 ;; 37 ;; ;; To toggle hiding 38 ;; (define-key dired-mode-map "." #'dired-hide-dotfiles-mode) 39 ;; (add-hook 'dired-mode-hook #'my-dired-mode-hook) 40 41 ;;; Note: 42 43 ;;; Code: 44 45 (require 'dired) 46 47 (defgroup dired-hide-dotfiles nil 48 "Dired hide dotfiles." 49 :group 'dired) 50 51 (defcustom dired-hide-dotfiles-verbose t 52 "When non-nil, show how many dotfiles were hidden." 53 :version "0.2" 54 :type 'boolean 55 :group 'dired-hide-dotfiles) 56 57 ;;;###autoload 58 (define-minor-mode dired-hide-dotfiles-mode 59 "Toggle `dired-hide-dotfiles-mode'" 60 :init-value nil 61 :lighter " !." 62 :group 'dired 63 (if dired-hide-dotfiles-mode 64 (progn 65 (add-hook 'dired-after-readin-hook 'dired-hide-dotfiles--hide) 66 (dired-hide-dotfiles--hide)) 67 (remove-hook 'dired-after-readin-hook 'dired-hide-dotfiles--hide) 68 (revert-buffer))) 69 70 (defun dired-hide-dotfiles--hide () 71 "Hide all dot-files in the current `dired' buffer." 72 (let ((inhibit-message t)) 73 (dired-mark-files-regexp "^\\.")) 74 (dired-do-kill-lines nil (if dired-hide-dotfiles-verbose 75 "Hid %d dotfile%s." 76 ""))) 77 78 (provide 'dired-hide-dotfiles) 79 ;;; dired-hide-dotfiles.el ends here