├── dired-details-s-1.png ├── dired-details-s-2.png ├── dired-details-s-3.png ├── README.org └── dired-details-s.el /dired-details-s-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misohena/dired-details-s/master/dired-details-s-1.png -------------------------------------------------------------------------------- /dired-details-s-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misohena/dired-details-s/master/dired-details-s-2.png -------------------------------------------------------------------------------- /dired-details-s-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misohena/dired-details-s/master/dired-details-s-3.png -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | * dired-details-s.el - Hide Dired Details Separately 2 | ** Screenshots 3 | 4 | Hide permissions, link count, user, group (Show size and timestamp only): 5 | 6 | [[file:./dired-details-s-1.png]] 7 | 8 | Show all: 9 | 10 | [[file:./dired-details-s-2.png]] 11 | 12 | Hide all: 13 | 14 | [[file:./dired-details-s-3.png]] 15 | 16 | 17 | ** Requirements 18 | - Emacs 24.4 19 | 20 | ** Usage 21 | 22 | [[file:./dired-details-s.el]] 23 | 24 | #+BEGIN_SRC elisp 25 | (require 'dired-details-s) 26 | #+END_SRC 27 | 28 | ** Key 29 | 30 | - "(" : Rotate details combination 31 | 32 | ** Customize 33 | 34 | #+BEGIN_SRC elisp 35 | (setq dired-details-s-types 36 | '((size-time . (size time)) 37 | (all . (perms links user group size time)) 38 | (no-details . ()))) 39 | #+END_SRC 40 | ** Related Projects 41 | - [[https://github.com/misohena/dired-details-r/][dired-details-r.el]] :: Show dired details to right of filename 42 | -------------------------------------------------------------------------------- /dired-details-s.el: -------------------------------------------------------------------------------- 1 | ;;; dired-details-1.el --- -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2016 AKIYAMA Kouhei 4 | 5 | ;; Author: AKIYAMA Kouhei 6 | ;; Keywords: 7 | 8 | ;; This program is free software; you can redistribute it and/or modify 9 | ;; it under the terms of the GNU General Public License as published by 10 | ;; the Free Software Foundation, either version 3 of the License, or 11 | ;; (at your option) any later version. 12 | 13 | ;; This program is distributed in the hope that it will be useful, 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ;; GNU General Public License for more details. 17 | 18 | ;; You should have received a copy of the GNU General Public License 19 | ;; along with this program. If not, see . 20 | 21 | ;;; Commentary: 22 | 23 | ;; Hide dired details separately. 24 | 25 | ;;; Code: 26 | 27 | 28 | (defconst dired-details-s-parts '(perms links user group size time) "Definitions of detail parts.") 29 | 30 | (defcustom dired-details-s-types 31 | `((size-time . (size time)) 32 | (all . ,dired-details-s-parts) 33 | (no-details . ())) 34 | "Details combination list." 35 | :group 'dired 36 | :type 'file) 37 | 38 | (defvar dired-details-s-type (caar dired-details-s-types) "Current type of details combination.") 39 | 40 | (defvar dired-details-s-visible-parts (cdr (assq dired-details-s-type dired-details-s-types)) "Current visible parts list.") 41 | 42 | (defconst dired-details-s-regexp 43 | (concat 44 | "\\(\\([^ ][-r][-w][^ ][-r][-w][^ ][-r][-w][^ ]\\) \\)" ;1,2:permissions 45 | "\\( *\\([0-9]+\\) +\\)" ;3,4:link count 46 | "\\(\\([^ ]+\\) +\\)" ;5,6:user 47 | "\\(\\([^ ]+\\) +\\)" ;7,8:group (7 including space before size) 48 | "\\(\\([0-9]+\\) \\)" ;9,10:size 49 | "\\(\\(.+[^ ]\\) +\\)")) ;11,12:time 50 | 51 | (defun dired-details-s-foreach-filenames (beg end fun-at-filename) 52 | (save-excursion 53 | (goto-char beg) 54 | (while (< (point) end) 55 | (ignore-errors 56 | (when (dired-move-to-filename) 57 | (if (looking-back dired-details-s-regexp) 58 | (funcall fun-at-filename)))) 59 | (forward-line 1)))) 60 | 61 | (defun dired-details-s-set-text-properties (beg end) 62 | (let ((group-width 0)) 63 | ;; Calculate group name width 64 | (dired-details-s-foreach-filenames 65 | beg end 66 | #'(lambda () 67 | (setq group-width (max group-width (length (match-string 8)))))) 68 | 69 | ;; Set invisible text properties 70 | (dired-details-s-foreach-filenames 71 | beg end 72 | #'(lambda () 73 | (let ((group-end (+ (match-beginning 7) group-width 1))) 74 | (put-text-property (match-beginning 1) (match-end 1) 'invisible 'dired-details-s-perms) 75 | (put-text-property (match-beginning 3) (match-end 3) 'invisible 'dired-details-s-links) 76 | (put-text-property (match-beginning 5) (match-end 5) 'invisible 'dired-details-s-user) 77 | (put-text-property (match-beginning 7) group-end 'invisible 'dired-details-s-group) 78 | (put-text-property group-end (match-end 9) 'invisible 'dired-details-s-size) 79 | (put-text-property (match-beginning 11) (match-end 11) 'invisible 'dired-details-s-time)))))) 80 | 81 | (defun dired-details-s-update-invisibility-spec () 82 | (mapc 83 | #'(lambda (part) 84 | (funcall 85 | (if (memq part dired-details-s-visible-parts) 'remove-from-invisibility-spec 'add-to-invisibility-spec) 86 | (intern (concat "dired-details-s-" (symbol-name part))))) 87 | dired-details-s-parts)) 88 | 89 | (defun dired-details-s-toggle-type () 90 | (interactive) 91 | ;; Rotate type 92 | (let* ((curr-type-def 93 | (let ((types dired-details-s-types)) 94 | (while (and types (not (eq (caar types) dired-details-s-type))) (setq types (cdr types))) 95 | types)) 96 | (next-type-def (or (cadr curr-type-def) (car dired-details-s-types)))) 97 | (setq dired-details-s-type (car next-type-def)) 98 | (setq dired-details-s-visible-parts (cdr next-type-def)) 99 | 100 | ) 101 | ;; Update invisibility 102 | (dired-details-s-update-invisibility-spec) 103 | ;; Refresh buffer 104 | (revert-buffer)) 105 | 106 | 107 | ;; 108 | ;; Setup 109 | ;; 110 | 111 | (defun dired-details-s-set-text-properties-around (orig-fun beg end) 112 | (dired-details-s-set-text-properties beg end)) 113 | 114 | (defun dired-details-s-install () 115 | (interactive) 116 | (advice-add 'dired-insert-set-properties :around 'dired-details-s-set-text-properties-around) 117 | (define-key dired-mode-map "(" 'dired-details-s-toggle-type) 118 | (add-hook 'dired-mode-hook 'dired-details-s-update-invisibility-spec)) 119 | 120 | (defun dired-details-s-uninstall () 121 | (interactive) 122 | (advice-remove 'dired-insert-set-properties 'dired-details-s-set-text-properties-around) 123 | (define-key dired-mode-map "(" 'dired-hide-details-mode) 124 | (remove-hook 'dired-mode-hook 'dired-details-s-update-invisibility-spec)) 125 | 126 | (dired-details-s-install) 127 | 128 | 129 | (provide 'dired-details-s) 130 | ;;; dired-details-s.el ends here 131 | --------------------------------------------------------------------------------