Overhaul the "Dired: ..." section

This commit is contained in:
Gerard Vermeulen 2024-06-23 20:30:10 +02:00
parent fed52c1248
commit 24ba62322e

View File

@ -800,16 +800,12 @@ Mark this line without new-line as region 2
:CUSTOM_ID: sec:file-manager :CUSTOM_ID: sec:file-manager
:END: :END:
[[info:emacs#Dired][Dired (info)]] and the [[https://github.com/ranger/ranger#readme][ranger]] file manager offer similar capabilities for copying, [[info:emacs#Dired][Dired (info)]] offer capabilities for copying, deleting, opening, renaming, and
deleting, opening, renaming, and viewing files and directories, but the viewing files and directories. For instance, this setup allows to insert an
integration of [[info:emacs#Dired][dired (info)]] in Emacs is obviously much better than the =org-mode= link to a file containing a specific image into an =org-mode= buffer
integration of [[https://github.com/ranger/ranger#readme][ranger]] in Emacs. by means of the facilities of [[info:emacs#Dired][dired (info)]] as follows:
1. Type {{{kbd(C-x d)}}} to open the directory containing the specific image
For instance, this setup allows to insert an =org-mode= link to a file file in a =dired-mode= buffer.
containing a specific image into an =org-mode= buffer by means of the facilities
of [[info:emacs#Dired][dired (info)]] as follows:
1. Type {{{kbd(C-x d)}}} to open the directory containing the file with the
specific image in a =dired-mode= buffer.
2. Start searching for the specific image by navigating to the name of any image 2. Start searching for the specific image by navigating to the name of any image
file. file.
3. Type {{{kbd(v)}}} to switch to view the file in an =image-mode= buffer. 3. Type {{{kbd(v)}}} to switch to view the file in an =image-mode= buffer.
@ -824,13 +820,13 @@ of [[info:emacs#Dired][dired (info)]] as follows:
6. Switch to the =org-mode= buffer and use {{{kbd(C-c C-l)}}} to insert the 6. Switch to the =org-mode= buffer and use {{{kbd(C-c C-l)}}} to insert the
=org-link= into the buffer. =org-link= into the buffer.
Listing [[lst:set-dired-options]] makes the directory editor sort entries Listing [[lst:setup-dired]] makes the directory editor sort entries alphabetically
alphabetically after grouping the directories before grouping the files by by extension after grouping the directories and adds a key binding to
extension. =dired-mode-map= to open files with the [[https://en.wikipedia.org/wiki/Eww_(web_browser)][Emacs Web Wowser]].
#+caption[Set =dired= options]: #+caption[Setup =dired=]:
#+caption: Set =dired= options. #+caption: Setup =dired=.
#+name: lst:set-dired-options #+name: lst:setup-dired
#+begin_src emacs-lisp -n :results silent #+begin_src emacs-lisp -n :results silent
(with-eval-after-load 'dired (with-eval-after-load 'dired
(setopt dired-dwim-target t (setopt dired-dwim-target t
@ -843,20 +839,8 @@ extension.
;; | -1 | list one entry per line | ;; | -1 | list one entry per line |
dired-listing-switches "-alGX1 --group-directories-first" dired-listing-switches "-alGX1 --group-directories-first"
dired-recursive-copies 'always dired-recursive-copies 'always
dired-recursive-deletes 'always)) dired-recursive-deletes 'always)
(with-eval-after-load 'wdired
(setopt wdired-allow-to-change-permissions t))
#+end_src
Listing [[lst:extra-dired-key-bindings]] adds a new key binding to =dired-mode-map=
to open files with the [[https://en.wikipedia.org/wiki/Eww_(web_browser)][Emacs Web Wowser]] inside Emacs.
#+caption[Extra =dired= key bindings]:
#+caption: Extra =dired= key bindings.
#+name: lst:extra-dired-key-bindings
#+begin_src emacs-lisp -n :results silent
(with-eval-after-load 'dired
(defun dired-eww-open-file () (defun dired-eww-open-file ()
"In Dired, open the regular file named on this line with eww" "In Dired, open the regular file named on this line with eww"
(interactive) (interactive)
@ -866,6 +850,9 @@ to open files with the [[https://en.wikipedia.org/wiki/Eww_(web_browser)][Emacs
(error "Eww rejects `%s', since it is not a regular file" file)))) (error "Eww rejects `%s', since it is not a regular file" file))))
(keymap-set dired-mode-map "E" #'dired-eww-open-file)) (keymap-set dired-mode-map "E" #'dired-eww-open-file))
(with-eval-after-load 'wdired
(setopt wdired-allow-to-change-permissions t))
#+end_src #+end_src
* [[info:emacs#Minibuffer][Minibuffer (info)]] * [[info:emacs#Minibuffer][Minibuffer (info)]]