diff --git a/.doom.d/config.el b/.doom.d/config.el index 2ea8cfc..ff7e07b 100644 --- a/.doom.d/config.el +++ b/.doom.d/config.el @@ -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") diff --git a/.doom.d/config.org b/.doom.d/config.org index f2e1a2f..af07208 100644 --- a/.doom.d/config.org +++ b/.doom.d/config.org @@ -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 diff --git a/.doom.d/packages.el b/.doom.d/packages.el index 9c303a0..e50f8a1 100644 --- a/.doom.d/packages.el +++ b/.doom.d/packages.el @@ -54,4 +54,6 @@ (package! highlight-operators) (package! highlight) (package! yafolding) +(package! ranger) +(package! dired-quick-sort) (package! ido-vertical-mode) ; not being used