From 8295973f12d77efa389fffdba5a858d4ba3fd1bb Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Thu, 31 Oct 2019 15:07:10 +0100 Subject: [PATCH] update dired-hacks --- .../dired-hacks-utils-autoloads.el | 23 ------- .../dired-hacks-utils-pkg.el | 2 - .../dired-hacks-utils-autoloads.el | 16 +++++ .../dired-hacks-utils-pkg.el | 2 + .../dired-hacks-utils.el | 65 ++++++++++++++++++- 5 files changed, 82 insertions(+), 26 deletions(-) delete mode 100644 elpa/dired-hacks-utils-20160527.2136/dired-hacks-utils-autoloads.el delete mode 100644 elpa/dired-hacks-utils-20160527.2136/dired-hacks-utils-pkg.el create mode 100644 elpa/dired-hacks-utils-20190522.950/dired-hacks-utils-autoloads.el create mode 100644 elpa/dired-hacks-utils-20190522.950/dired-hacks-utils-pkg.el rename elpa/{dired-hacks-utils-20160527.2136 => dired-hacks-utils-20190522.950}/dired-hacks-utils.el (74%) diff --git a/elpa/dired-hacks-utils-20160527.2136/dired-hacks-utils-autoloads.el b/elpa/dired-hacks-utils-20160527.2136/dired-hacks-utils-autoloads.el deleted file mode 100644 index 6392dd5d..00000000 --- a/elpa/dired-hacks-utils-20160527.2136/dired-hacks-utils-autoloads.el +++ /dev/null @@ -1,23 +0,0 @@ -;;; dired-hacks-utils-autoloads.el --- automatically extracted autoloads -;; -;;; Code: - -(add-to-list 'load-path (directory-file-name - (or (file-name-directory #$) (car load-path)))) - - -;;;### (autoloads nil "dired-hacks-utils" "dired-hacks-utils.el" -;;;;;; (0 0 0 0)) -;;; Generated autoloads from dired-hacks-utils.el - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "dired-hacks-utils" '("dired-"))) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; coding: utf-8 -;; End: -;;; dired-hacks-utils-autoloads.el ends here diff --git a/elpa/dired-hacks-utils-20160527.2136/dired-hacks-utils-pkg.el b/elpa/dired-hacks-utils-20160527.2136/dired-hacks-utils-pkg.el deleted file mode 100644 index 839a2eda..00000000 --- a/elpa/dired-hacks-utils-20160527.2136/dired-hacks-utils-pkg.el +++ /dev/null @@ -1,2 +0,0 @@ -;;; -*- no-byte-compile: t -*- -(define-package "dired-hacks-utils" "20160527.2136" "Utilities and helpers for dired-hacks collection" '((dash "2.5.0")) :commit "c5e9dcdf2ee6fd5660e2bfbb8c635674053df7c9" :keywords '("files") :authors '(("Matúš Goljer" . "matus.goljer@gmail.com")) :maintainer '("Matúš Goljer" . "matus.goljer@gmail.com")) diff --git a/elpa/dired-hacks-utils-20190522.950/dired-hacks-utils-autoloads.el b/elpa/dired-hacks-utils-20190522.950/dired-hacks-utils-autoloads.el new file mode 100644 index 00000000..cc077296 --- /dev/null +++ b/elpa/dired-hacks-utils-20190522.950/dired-hacks-utils-autoloads.el @@ -0,0 +1,16 @@ +;;; dired-hacks-utils-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path)))) + +;;;### (autoloads nil nil ("dired-hacks-utils.el") (23994 46776 937195 +;;;;;; 494000)) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; dired-hacks-utils-autoloads.el ends here diff --git a/elpa/dired-hacks-utils-20190522.950/dired-hacks-utils-pkg.el b/elpa/dired-hacks-utils-20190522.950/dired-hacks-utils-pkg.el new file mode 100644 index 00000000..b14d0108 --- /dev/null +++ b/elpa/dired-hacks-utils-20190522.950/dired-hacks-utils-pkg.el @@ -0,0 +1,2 @@ +;;; -*- no-byte-compile: t -*- +(define-package "dired-hacks-utils" "20190522.950" "Utilities and helpers for dired-hacks collection" '((dash "2.5.0")) :commit "ae39981d7cc58206cfeb377d6621bdd9000fd472" :keywords '("files") :authors '(("Matúš Goljer" . "matus.goljer@gmail.com")) :maintainer '("Matúš Goljer" . "matus.goljer@gmail.com")) diff --git a/elpa/dired-hacks-utils-20160527.2136/dired-hacks-utils.el b/elpa/dired-hacks-utils-20190522.950/dired-hacks-utils.el similarity index 74% rename from elpa/dired-hacks-utils-20160527.2136/dired-hacks-utils.el rename to elpa/dired-hacks-utils-20190522.950/dired-hacks-utils.el index 8d5cbed0..18bacecb 100644 --- a/elpa/dired-hacks-utils-20160527.2136/dired-hacks-utils.el +++ b/elpa/dired-hacks-utils-20190522.950/dired-hacks-utils.el @@ -5,7 +5,7 @@ ;; Author: Matúš Goljer ;; Maintainer: Matúš Goljer ;; Keywords: files -;; Package-Version: 20160527.2136 +;; Package-Version: 20190522.950 ;; Version: 0.0.1 ;; Created: 14th February 2014 ;; Package-requires: ((dash "2.5.0")) @@ -32,6 +32,9 @@ ;; * `dired-hacks-next-file' - go to next file, skipping empty and non-file lines ;; * `dired-hacks-previous-file' - go to previous file, skipping empty ;; and non-file lines +;; * `dired-utils-format-information-line-mode' - Format the information +;; (summary) line file sizes to be human readable (e.g. 1GB instead of 1048576). + ;; See https://github.com/Fuco1/dired-hacks for the entire collection @@ -45,6 +48,42 @@ :group 'dired :prefix "dired-hacks-") +(defcustom dired-hacks-file-size-formatter 'file-size-human-readable + "The function used to format file sizes. + +See `dired-utils-format-file-sizes'." + :type 'symbol + :group 'dired-hacks) + +(defcustom dired-hacks-datetime-regexp + "\\sw\\sw\\sw....\\(?:[0-9][0-9]:[0-9][0-9]\\|.[0-9]\\{4\\}\\)" + "A regexp matching the date/time in the dired listing. + +It is used to determine where the filename starts. It should +*not* match any characters after the last character of the +timestamp. It is assumed that the timestamp is preceded and +followed by at least one space character. You should only use +shy groups (prefixed with ?:) because the first group is used by +the font-lock to determine what portion of the name should be +colored." + :type 'string + :group 'dired-hacks) + +(defalias 'dired-utils--string-trim + (if (and (require 'subr-x nil t) + (fboundp 'string-trim)) + #'string-trim + (lambda (string) + (let ((s string)) + (when (string-match "\\`[ \t\n\r]+" s) + (setq s (replace-match "" t t s))) + (when (string-match "[ \t\n\r]+\\'" s) + (setq s (replace-match "" t t s))) + s))) + "Trim STRING of trailing whitespace. + +\(fn STRING)") + (defun dired-utils-get-filename (&optional localp) "Like `dired-get-filename' but never signal an error. @@ -136,6 +175,22 @@ Each car in ALIST is a string representing file extension (setq done it))) done)) +(defun dired-utils-format-information-line () + "Format the disk space on the Dired information line." + (save-excursion + (goto-char (point-min)) + (forward-line) + (let ((inhibit-read-only t) + (limit (line-end-position))) + (while (re-search-forward "\\(?:directory\\|available\\) \\(\\<[0-9]+\\>\\)" nil t) + (replace-match + (save-match-data + (propertize (dired-utils--string-trim + (funcall dired-hacks-file-size-formatter + (* 1024 (string-to-number (match-string 1))) t)) + 'invisible 'dired-hide-details-information)) + t nil nil 1))))) + ;;; Predicates (defun dired-utils-is-file-p () @@ -206,6 +261,14 @@ line." (car (split-string md5-b))) "probably the same" "different")))) +(define-minor-mode dired-utils-format-information-line-mode + "Toggle formatting of disk space in the Dired information line." + :group 'dired-utils + :lighter "" + (if dired-utils-format-information-line-mode + (add-hook 'dired-after-readin-hook #'dired-utils-format-information-line) + (remove-hook 'dired-after-readin-hook #'dired-utils-format-information-line))) + (provide 'dired-hacks-utils) ;;; dired-hacks-utils.el ends here -- 2.47.3