Add the dired-by-newest' and dired-by-oldest' functions

This commit is contained in:
Gerard Vermeulen 2024-06-24 16:13:35 +02:00
parent 6f7516ecd7
commit c2a3b1feba

View File

@ -822,7 +822,8 @@ by means of the facilities of [[info:emacs#Dired][dired (info)]] as follows:
Listing [[lst:setup-dired]] makes the directory editor group the directories in
front of the files and sort each group alphabetically. It also adds a key
binding to =dired-mode-map= to open files with the [[https://en.wikipedia.org/wiki/Eww_(web_browser)][Emacs Web Wowser]].
binding to =dired-mode-map= to open files with the [[https://en.wikipedia.org/wiki/Eww_(web_browser)][Emacs Web Wowser]]. Listing
[[lst:wrap-dired]] wraps =dired= to sort the directory entries in different ways.
#+caption[Setup =dired=]:
#+caption: Setup =dired=.
@ -854,6 +855,23 @@ binding to =dired-mode-map= to open files with the [[https://en.wikipedia.org/wi
(setopt wdired-allow-to-change-permissions t))
#+end_src
#+caption[Wrap =dired=]:
#+caption: Wrap =dired=.
#+name: lst:wrap-dired
#+begin_src emacs-lisp -n :results silent
(defun dired-by-newest ()
"Wrap dired to sort directory entries by newest first."
(interactive)
(when-let ((dir (read-directory-name "Dired-by-newest (directory): ")))
(dired dir "-alt")))
(defun dired-by-oldest ()
"Wrap dired to sort directory entries by oldest first."
(interactive)
(when-let ((dir (read-directory-name "Dired-by-oldest (directory): ")))
(dired dir "-altr")))
#+end_src
* [[info:emacs#Minibuffer][Minibuffer (info)]]
:PROPERTIES:
:CUSTOM_ID: sec:minibuffer-completion-styles