Doom, dired: h and l to navigate, SPC m o to sort

This commit is contained in:
i.ortega 2020-05-07 22:53:43 +02:00
parent 4bc86245c4
commit 58e01b0e61
3 changed files with 72 additions and 0 deletions

View File

@ -47,6 +47,8 @@
(setq my-unignored-buffers '("*ielm*" "*scratch*" "*ansi-term*" "*term*"))
(setq insert-on-mode #s(hash-table size 30 data (shell-mode insert term-mode term-send-raw-string prog-mode insert!)))
(setq compression-extensions '("7z" "7zip" "zip" "zstd" "tar\..*"))
(defun eval-string (string)
"Evals all the commands inside the string"
(eval (car (read-from-string (format "(progn %s)" string)))))
@ -301,6 +303,19 @@
;; i i
(map! :i "i i" #'evil-normal-state)
)
(defun get-file-type (file &optional deref-symlinks)
"Return the type of FILE, according to the `file' command.
If you give a prefix to this command, and FILE is a symbolic
link, then the type of the file linked to by FILE is returned
instead."
(let (process-file-side-effects)
(with-temp-buffer
(if deref-symlinks
(process-file "file" nil t t "-bL" "--" file)
(process-file "file" nil t t "-b" "--" file))
(when (bolp)
(backward-delete-char 1))
(buffer-string))))
(map! :n "g r" #'evil-replace-with-register)
(evil-replace-with-register-install)
(map! :n "SPC w D" #'delete-other-windows)
@ -328,6 +343,23 @@
(interactive)
(mark-real-user-buffer)
))
(map! :map 'dired-mode-map :n "A" (lambda () (interactive) (find-alternate-file "..")))
(map! :map 'dired-mode-map :n "a"
(lambda ()
(interactive)
(if (equal (get-file-type (dired-get-file-for-visit)) "directory")
(dired-find-alternate-file)
(dired-find-file))
))
(map! :map 'dired-mode-map :n "l"
(lambda ()
(interactive)
(if (equal (get-file-type (dired-get-file-for-visit)) "directory")
(dired-find-alternate-file)
(dired-find-file))
))
(map! :map 'dired-mode-map :n "SPC m o" #'hydra-dired-quick-sort/body)
(map! :map 'dired-mode-map :n "h" (lambda () (interactive) (find-alternate-file "..")))
(ii-mode)
;; Why is not working?
;; (ii-mode org-mode-map "org-mode-map")

View File

@ -100,6 +100,8 @@ If you intend to use org, it is recommended you change this!
(setq my-unignored-buffers '("*ielm*" "*scratch*" "*ansi-term*" "*term*"))
(setq insert-on-mode #s(hash-table size 30 data (shell-mode insert term-mode term-send-raw-string prog-mode insert!)))
(setq compression-extensions '("7z" "7zip" "zip" "zstd" "tar\..*"))
#+END_SRC
* Custom functions
@ -372,6 +374,22 @@ ii mode:
#+END_SRC
#+BEGIN_SRC emacs-lisp
(defun get-file-type (file &optional deref-symlinks)
"Return the type of FILE, according to the `file' command.
If you give a prefix to this command, and FILE is a symbolic
link, then the type of the file linked to by FILE is returned
instead."
(let (process-file-side-effects)
(with-temp-buffer
(if deref-symlinks
(process-file "file" nil t t "-bL" "--" file)
(process-file "file" nil t t "-b" "--" file))
(when (bolp)
(backward-delete-char 1))
(buffer-string))))
#+END_SRC
* Custom keybindings
Replace with Regiser:
#+BEGIN_SRC emacs-lisp
@ -431,6 +449,26 @@ Real buffer:
(mark-real-user-buffer)
))
#+END_SRC
** Dired
#+BEGIN_SRC emacs-lisp
(map! :map 'dired-mode-map :n "A" (lambda () (interactive) (find-alternate-file "..")))
(map! :map 'dired-mode-map :n "a"
(lambda ()
(interactive)
(if (equal (get-file-type (dired-get-file-for-visit)) "directory")
(dired-find-alternate-file)
(dired-find-file))
))
(map! :map 'dired-mode-map :n "l"
(lambda ()
(interactive)
(if (equal (get-file-type (dired-get-file-for-visit)) "directory")
(dired-find-alternate-file)
(dired-find-file))
))
(map! :map 'dired-mode-map :n "SPC m o" #'hydra-dired-quick-sort/body)
(map! :map 'dired-mode-map :n "h" (lambda () (interactive) (find-alternate-file "..")))
#+END_SRC
** 'ii' in INSERT mode to escape to NORMAL mode:
#+BEGIN_SRC emacs-lisp

View File

@ -54,4 +54,6 @@
(package! highlight-operators)
(package! highlight)
(package! yafolding)
(package! ranger)
(package! dired-quick-sort)
(package! ido-vertical-mode) ; not being used