Dired improvements: Dired-X and functions that respect the current dir
This commit is contained in:
parent
e842f3175a
commit
c3d334502d
@ -4715,14 +4715,53 @@ Or Gnus can read RSS feeds directly:
|
||||
#+END_SRC
|
||||
|
||||
* Dired
|
||||
** Dired-X
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun dired-x-load-setup ()
|
||||
(require "dired-x"))
|
||||
|
||||
(defun dired-x-setup ()
|
||||
(dired-omit-mode 1))
|
||||
|
||||
(add-hook 'dired-load-hook #'dired-x-load-setup)
|
||||
(add-hook 'dired-mode-hook #'dired-x-setup)
|
||||
#+END_SRC
|
||||
|
||||
** Utility functions
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun dired-counsel-find-file (&optional initial-input)
|
||||
(interactive)
|
||||
(let ((default-directory (dired-current-directory)))
|
||||
(counsel-find-file initial-input)))
|
||||
|
||||
(defun dired-create-empty-file-in-current-dir (file)
|
||||
(interactive (list (let ((default-directory (dired-current-directory)))
|
||||
(read-file-name "Create empty file: "))))
|
||||
(dired-create-empty-file file))
|
||||
|
||||
(defun dired-do-rename-in-current-dir (&optional arg)
|
||||
(interactive "P")
|
||||
(let ((default-directory (dired-current-directory)))
|
||||
(dired-do-rename arg)))
|
||||
#+END_SRC
|
||||
|
||||
** Keybindings
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(general-def 'normal dired-mode-map "f" #'dired-create-empty-file)
|
||||
(general-def 'normal dired-mode-map
|
||||
"f" #'dired-create-empty-file-in-current-dir
|
||||
[remap find-file] 'dired-counsel-find-file
|
||||
[remap counsel-find-file] 'dired-counsel-find-file
|
||||
[remap dired-do-rename] 'dired-do-rename-in-current-dir)
|
||||
#+END_SRC
|
||||
|
||||
** Dired subtree
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package dired-subtree
|
||||
:init
|
||||
(defun dired-counsel-find-file (&optional initial-input)
|
||||
(interactive)
|
||||
(let ((default-directory (dired-current-directory)))
|
||||
(counsel-find-file initial-input)))
|
||||
:general
|
||||
(normal dired-mode-map "TAB" 'dired-subtree-toggle)
|
||||
:config
|
||||
|
Loading…
Reference in New Issue
Block a user