mirror of
https://gitlab.com/dwt1/dotfiles.git
synced 2026-04-23 11:30:23 +10:00
Updating Doom Emacs.
This commit is contained in:
56
.emacs.d/modules/emacs/dired/config.el
Executable file → Normal file
56
.emacs.d/modules/emacs/dired/config.el
Executable file → Normal file
@@ -3,47 +3,44 @@
|
||||
(use-package! dired
|
||||
:commands dired-jump
|
||||
:init
|
||||
(setq ;; Always copy/delete recursively
|
||||
(setq dired-auto-revert-buffer t ; don't prompt to revert; just do it
|
||||
dired-dwim-target t ; suggest a target for moving/copying intelligently
|
||||
dired-hide-details-hide-symlink-targets nil
|
||||
;; Always copy/delete recursively
|
||||
dired-recursive-copies 'always
|
||||
dired-recursive-deletes 'top
|
||||
;; Instantly revert Dired buffers on re-visiting them, with no message.
|
||||
;; (A message is shown if insta-revert is either disabled or determined
|
||||
;; dynamically by setting this variable to a function.)
|
||||
dired-auto-revert-buffer t
|
||||
;; Auto refresh dired, but be quiet about it
|
||||
dired-hide-details-hide-symlink-targets nil
|
||||
;; make dired suggest a target for moving/copying intelligently
|
||||
dired-dwim-target t
|
||||
;; files
|
||||
;; Where to store image caches
|
||||
image-dired-dir (concat doom-cache-dir "image-dired/")
|
||||
image-dired-db-file (concat image-dired-dir "db.el")
|
||||
image-dired-gallery-dir (concat image-dired-dir "gallery/")
|
||||
image-dired-temp-image-file (concat image-dired-dir "temp-image")
|
||||
image-dired-temp-rotate-image-file (concat image-dired-dir "temp-rotate-image"))
|
||||
image-dired-temp-rotate-image-file (concat image-dired-dir "temp-rotate-image")
|
||||
;; Screens are larger nowadays, we can afford slightly larger thumbnails
|
||||
image-dired-thumb-size 150)
|
||||
:config
|
||||
(let ((args (list "-aBhl" "--group-directories-first")))
|
||||
(set-popup-rule! "^\\*image-dired"
|
||||
:slot 20 :size 0.8 :select t :quit nil :ttl 0)
|
||||
(set-evil-initial-state! 'image-dired-display-image-mode 'emacs)
|
||||
|
||||
(let ((args (list "-ahl" "-v" "--group-directories-first")))
|
||||
(when IS-BSD
|
||||
;; Use GNU ls as `gls' from `coreutils' if available. Add `(setq
|
||||
;; dired-use-ls-dired nil)' to your config to suppress the Dired warning
|
||||
;; when not using GNU ls.
|
||||
(if-let (gls (executable-find "gls"))
|
||||
(setq insert-directory-program gls)
|
||||
;; BSD ls doesn't support --group-directories-first
|
||||
(setq args (delete "--group-directories-first" args))))
|
||||
(setq dired-listing-switches (string-join args " ")))
|
||||
;; BSD ls doesn't support -v or --group-directories-first
|
||||
(setq args (list (car args)))))
|
||||
(setq dired-listing-switches (string-join args " "))
|
||||
|
||||
(add-hook! 'dired-mode-hook
|
||||
(defun +dired-disable-gnu-ls-flags-in-tramp-buffers-h ()
|
||||
"Fix #1703: dired over TRAMP displays a blank screen.
|
||||
(add-hook! 'dired-mode-hook
|
||||
(defun +dired-disable-gnu-ls-flags-in-tramp-buffers-h ()
|
||||
"Fix #1703: dired over TRAMP displays a blank screen.
|
||||
|
||||
This is because there's no guarantee the remote system has GNU ls, which is the
|
||||
only variant that supports --group-directories-first."
|
||||
(when (file-remote-p default-directory)
|
||||
(setq-local dired-listing-switches
|
||||
(string-join
|
||||
(split-string dired-listing-switches
|
||||
"--group-directories-first")
|
||||
" ")))))
|
||||
(when (file-remote-p default-directory)
|
||||
(setq-local dired-actual-switches (car args))))))
|
||||
|
||||
;; Don't complain about this command being disabled when we use it
|
||||
(put 'dired-find-alternate-file 'disabled nil)
|
||||
@@ -64,7 +61,7 @@ only variant that supports --group-directories-first."
|
||||
|
||||
|
||||
(use-package! diff-hl
|
||||
:hook (dired-mode . diff-hl-dired-mode)
|
||||
:hook (dired-mode . diff-hl-dired-mode-unless-remote)
|
||||
:hook (magit-post-refresh . diff-hl-magit-post-refresh)
|
||||
:config
|
||||
;; use margin instead of fringe
|
||||
@@ -74,10 +71,7 @@ only variant that supports --group-directories-first."
|
||||
(use-package! ranger
|
||||
:when (featurep! +ranger)
|
||||
:after dired
|
||||
:init
|
||||
;; set up image-dired to allow picture resize
|
||||
(setq image-dired-dir (concat doom-cache-dir "image-dir")
|
||||
ranger-override-dired t)
|
||||
:init (setq ranger-override-dired t)
|
||||
:config
|
||||
(unless (file-directory-p image-dired-dir)
|
||||
(make-directory image-dired-dir))
|
||||
@@ -122,13 +116,13 @@ we have to clean it up ourselves."
|
||||
(defvar +wdired-icons-enabled -1)
|
||||
|
||||
(defadvice! +dired-disable-icons-in-wdired-mode-a (&rest _)
|
||||
:before #'+wdired-before-start-advice
|
||||
:before #'wdired-change-to-wdired-mode
|
||||
(setq-local +wdired-icons-enabled (if all-the-icons-dired-mode 1 -1))
|
||||
(when all-the-icons-dired-mode
|
||||
(all-the-icons-dired-mode -1)))
|
||||
|
||||
(defadvice! +dired-restore-icons-after-wdired-mode-a (&rest _)
|
||||
:after #'+wdired-after-finish-advice
|
||||
:after #'wdired-change-to-dired-mode
|
||||
(all-the-icons-dired-mode +wdired-icons-enabled))))
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
;; -*- no-byte-compile: t; -*-
|
||||
;;; emacs/dired/packages.el
|
||||
|
||||
(package! diredfl)
|
||||
(package! dired-git-info)
|
||||
(package! diff-hl)
|
||||
(package! dired-rsync)
|
||||
(package! diredfl :pin "83567d00affce66a4e501563eddd0bd436ac48d0")
|
||||
(package! dired-git-info :pin "b47f2b0c3a6cb9b7a62a4ee2605a492e512d40a9")
|
||||
(package! diff-hl :pin "a625033fb1dde83f6e4c2fc21f632b22ec34b609")
|
||||
(package! dired-rsync :pin "bfd5c155be1cb6b71c83e5f41116c81b6532b6d5")
|
||||
(when (featurep! +ranger)
|
||||
(package! ranger))
|
||||
(package! ranger :pin "ae9b3816a6da927cca5beb62c45400103797a2da"))
|
||||
(when (featurep! +icons)
|
||||
(package! all-the-icons-dired))
|
||||
(package! fd-dired)
|
||||
(package! all-the-icons-dired :pin "fc2dfa1e9eb8bf1c402a675e7089638d702a27a5"))
|
||||
(package! fd-dired :pin "001cc95effdd5c4d9974b3f2c40b2ddf1f0e3de2")
|
||||
|
||||
@@ -39,6 +39,23 @@
|
||||
:header-mouse-map ibuffer-size-header-map)
|
||||
(file-size-human-readable (buffer-size)))
|
||||
|
||||
(when (featurep! :ui workspaces)
|
||||
(define-ibuffer-filter workspace-buffers
|
||||
"Filter for workspace buffers"
|
||||
(:reader (+workspace-get (read-string "workspace name: "))
|
||||
:description "workspace")
|
||||
(memq buf (+workspace-buffer-list qualifier)))
|
||||
|
||||
(defun +ibuffer-workspace (workspace-name)
|
||||
"Open an ibuffer window for a workspace"
|
||||
(ibuffer nil (format "%s buffers" workspace-name)
|
||||
(list (cons 'workspace-buffers (+workspace-get workspace-name)))))
|
||||
|
||||
(defun +ibuffer/open-for-current-workspace ()
|
||||
"Open an ibuffer window for the current workspace"
|
||||
(interactive)
|
||||
(+ibuffer-workspace (+workspace-current-name))))
|
||||
|
||||
(when (featurep! :completion ivy)
|
||||
(defadvice! +ibuffer-use-counsel-maybe-a (_file &optional _wildcards)
|
||||
"Use `counsel-find-file' instead of `find-file'."
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
;; -*- no-byte-compile: t; -*-
|
||||
;;; emacs/ibuffer/packages.el
|
||||
|
||||
(package! ibuffer-projectile)
|
||||
(package! ibuffer-vc)
|
||||
(package! ibuffer-projectile :pin "504b0edaa0d937ce60ccc8fdf09f2dae0a90fbaf")
|
||||
(package! ibuffer-vc :pin "1249c1e30cf11badfe032ac3b1058f24ba510ace")
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
;;; emacs/vc/autoload/evil.el -*- lexical-binding: t; -*-
|
||||
;;;###if (featurep! :editor evil)
|
||||
|
||||
;;;###autoload (autoload '+vc:git-browse "emacs/vc/autoload/evil" nil t)
|
||||
(evil-define-command +vc:git-browse (bang)
|
||||
"Ex interface to `+vc/git-browse-region-or-line'."
|
||||
(interactive "<!>")
|
||||
(+vc/git-browse-region-or-line bang))
|
||||
@@ -1,30 +1,5 @@
|
||||
;;; emacs/vc/autoload/vc.el -*- lexical-binding: t; -*-
|
||||
|
||||
(autoload 'browse-at-remote--file-url "browse-at-remote")
|
||||
|
||||
;;;###autoload
|
||||
(defun +vc/browse-at-remote-file-or-region ()
|
||||
"Open the current file at remote in your browser.
|
||||
If a selection is active, highlight them. Otherwise omits the #L<N> suffix in
|
||||
the URL."
|
||||
(interactive)
|
||||
(if (or (use-region-p)
|
||||
(ignore-errors (evil-visual-state-p)))
|
||||
(browse-at-remote)
|
||||
(browse-url (browse-at-remote--file-url (buffer-file-name)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +vc/browse-at-remote-kill-file-or-region ()
|
||||
"Copy the current file's remote URL to your clipboard.
|
||||
If a selection is active, highlight them. Otherwise omits the #L<N> suffix in
|
||||
the URL."
|
||||
(interactive)
|
||||
(if (or (use-region-p)
|
||||
(ignore-errors (evil-visual-state-p)))
|
||||
(browse-at-remote-kill)
|
||||
(kill-new (browse-at-remote--file-url (buffer-file-name)))))
|
||||
|
||||
|
||||
(defun +vc--remote-homepage ()
|
||||
(or (let ((url (browse-at-remote--remote-ref)))
|
||||
(cdr (browse-at-remote--get-url-from-remote (car url))))
|
||||
@@ -40,4 +15,6 @@ the URL."
|
||||
(defun +vc/browse-at-remote-kill-homepage ()
|
||||
"Copy homepage URL of current project to clipboard."
|
||||
(interactive)
|
||||
(kill-new (+vc--remote-homepage)))
|
||||
(let ((url (+vc--remote-homepage)))
|
||||
(kill-new url)
|
||||
(message "Copied to clipboard: %S" url)))
|
||||
|
||||
@@ -4,18 +4,33 @@
|
||||
(setenv "GIT_ASKPASS" "git-gui--askpass"))
|
||||
|
||||
|
||||
(after! log-view
|
||||
(set-evil-initial-state!
|
||||
'(log-view-mode
|
||||
vc-git-log-view-mode
|
||||
vc-hg-log-view-mode
|
||||
vc-bzr-log-view-mode
|
||||
vc-svn-log-view-mode)
|
||||
'emacs)
|
||||
(map! :map log-view-mode-map
|
||||
"j" #'log-view-msg-next
|
||||
"k" #'log-view-msg-prev))
|
||||
|
||||
|
||||
(after! vc-annotate
|
||||
(set-popup-rules!
|
||||
'(("^\\vc-d" :select nil) ; *vc-diff*
|
||||
("^\\vc-c" :select t))) ; *vc-change-log*
|
||||
(set-evil-initial-state!
|
||||
'(vc-annotate-mode vc-git-log-view-mode)
|
||||
'normal)
|
||||
'(("^\\*vc-diff" :select nil) ; *vc-diff*
|
||||
("^\\*vc-change" :select t))) ; *vc-change-log*
|
||||
(set-evil-initial-state! 'vc-annotate-mode 'normal)
|
||||
|
||||
;; Clean up after itself
|
||||
(define-key vc-annotate-mode-map [remap quit-window] #'kill-current-buffer))
|
||||
|
||||
|
||||
(after! vc-dir
|
||||
(set-evil-initial-state! 'vc-dir-mode 'emacs))
|
||||
|
||||
|
||||
(after! git-timemachine
|
||||
;; Sometimes I forget `git-timemachine' is enabled in a buffer, so instead of
|
||||
;; showing revision details in the minibuffer, show them in
|
||||
@@ -53,9 +68,8 @@ info in the `header-line-format' is a good indication."
|
||||
|
||||
|
||||
(use-package! git-commit
|
||||
:after-call after-find-file
|
||||
:hook (doom-first-file . global-git-commit-mode)
|
||||
:config
|
||||
(global-git-commit-mode +1)
|
||||
(set-yas-minor-mode! 'git-commit-mode)
|
||||
|
||||
;; Enforce git commit conventions.
|
||||
@@ -71,3 +85,15 @@ otherwise in default state."
|
||||
(when (and (bound-and-true-p evil-mode)
|
||||
(bobp) (eolp))
|
||||
(evil-insert-state)))))
|
||||
|
||||
|
||||
(after! browse-at-remote
|
||||
(setq browse-at-remote-add-line-number-if-no-region-selected nil)
|
||||
|
||||
;; HACK `browse-at-remote' produces urls with `nil' in them, when the repo is
|
||||
;; detached. This creates broken links. I think it is more sensible to
|
||||
;; fall back to master in those cases.
|
||||
(defadvice! +vc--fallback-to-master-branch-a ()
|
||||
"Return 'master' in detached state."
|
||||
:after-until #'browse-at-remote--get-local-branch
|
||||
"master"))
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
(package! vc-annotate :built-in t)
|
||||
(package! smerge-mode :built-in t)
|
||||
|
||||
(package! browse-at-remote)
|
||||
(package! git-timemachine)
|
||||
(package! gitconfig-mode)
|
||||
(package! gitignore-mode)
|
||||
(package! browse-at-remote :pin "6aecae4b5d202e582425fc8aa2c9c2b6a4779f25")
|
||||
(package! git-commit :pin "d459e528f46423f1976e5fa415e64f8f7162b473")
|
||||
(package! git-timemachine :pin "391eb61050de321101e631fcf373fc70ec6e7700")
|
||||
(package! gitconfig-mode :pin "55468314a5f6b77d2c96be62c7005ac94545e217")
|
||||
(package! gitignore-mode :pin "55468314a5f6b77d2c96be62c7005ac94545e217")
|
||||
|
||||
Reference in New Issue
Block a user