Skip to content

Commit

Permalink
emacs: dired-rsync, exceptions for index sync
Browse files Browse the repository at this point in the history
  • Loading branch information
SqrtMinusOne committed Aug 24, 2024
1 parent 11fbb5e commit 2cbac89
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 12 deletions.
36 changes: 30 additions & 6 deletions .emacs.d/init.el
Original file line number Diff line number Diff line change
Expand Up @@ -4967,6 +4967,7 @@ Review checklist:
- [ ] Clear email inbox
- [ ] Reconcile ledger
- [ ] Clear [[file:~/Downloads][downloads]] and [[file:~/00-Scratch][scratch]] folders
- [ ] Process [[file:30-39 Life/35 Photos/35.00 Inbox/][photo inbox]]
- [ ] Process [[file:../inbox.org][inbox]]
- [ ] Create [[file:../recurring.org][recurring tasks]] for next week
- [ ] Check agenda (-1 / +2 weeks): priorities, deadlines
Expand Down Expand Up @@ -5245,8 +5246,7 @@ TODO Write something, maybe? "))))
"M-r" #'wdired-change-to-wdired-mode
"<left>" #'dired-up-directory
"<right>" #'dired-find-file
"M-<return>" #'dired-open-xdg)
(dired-async-mode))
"M-<return>" #'dired-open-xdg))

(defun my/dired-home ()
"Open dired at $HOME"
Expand Down Expand Up @@ -5359,6 +5359,22 @@ TODO Write something, maybe? "))))
:init
(my-leader-def "aa" #'avy-dired-goto-line))

(use-package dired-rsync
:straight t
:after (dired)
:config
(add-to-list 'global-mode-string '(:eval dired-rsync-modeline-status))
(general-define-key
:states '(normal)
:keymaps '(dired-mode-map)
"C" #'dired-rsync
"gC" #'dired-rsync-transient
"gd" #'dired-do-copy))

(use-package dired-rsync-transient
:straight t
:after (dired))

(defun my/dired-open-this-subdir ()
(interactive)
(dired (dired-current-directory)))
Expand Down Expand Up @@ -8265,6 +8281,9 @@ See `my/index--tree-get' for the format of TREE."
(lambda (elem) (my/index--tree-narrow-recursive elem (my/system-name)))
(copy-tree tree))))

(defvar my/index-keep-files
'(".dtrash"))

(defun my/index--filesystem-tree-mapping (full-tree tree &optional active-paths)
"Return a \"sync state\" between the filesystem and the tree.

Expand Down Expand Up @@ -8300,10 +8319,15 @@ The return value is a list of alists with the following keys:
(has-to-exist . ,folder-has-to-exist)
(children . ,(append
(cl-loop for f in extra-folders
collect `((path . ,f)
(exists . t)
(has-to-exist . nil)
(extra . t)))
collect
`((path . ,f)
(exists . t)
(has-to-exist
. ,(member
(file-name-nondirectory
(directory-file-name f))
my/index-keep-files))
(extra . t)))
(my/index--filesystem-tree-mapping
(alist-get :children elem) tree active-paths)))))))

Expand Down
41 changes: 35 additions & 6 deletions Emacs.org
Original file line number Diff line number Diff line change
Expand Up @@ -6814,6 +6814,8 @@ I'll use data from git to get the list of what I've been working on. The directo
('weekly (- start-of-day (* 7 24 60 60)))))))
#+end_src



#+begin_src emacs-lisp
(defun my/org-review-set-weekly-record ()
(save-excursion
Expand All @@ -6832,6 +6834,7 @@ Review checklist:
- [ ] Clear email inbox
- [ ] Reconcile ledger
- [ ] Clear [[file:~/Downloads][downloads]] and [[file:~/00-Scratch][scratch]] folders
- [ ] Process [[file:30-39 Life/35 Photos/35.00 Inbox/][photo inbox]]
- [ ] Process [[file:../inbox.org][inbox]]
- [ ] Create [[file:../recurring.org][recurring tasks]] for next week
- [ ] Check agenda (-1 / +2 weeks): priorities, deadlines
Expand Down Expand Up @@ -7304,8 +7307,7 @@ My config mostly follows ranger's and vifm's keybindings which I'm used to.
"M-r" #'wdired-change-to-wdired-mode
"<left>" #'dired-up-directory
"<right>" #'dired-find-file
"M-<return>" #'dired-open-xdg)
(dired-async-mode))
"M-<return>" #'dired-open-xdg))

(defun my/dired-home ()
"Open dired at $HOME"
Expand Down Expand Up @@ -7454,6 +7456,25 @@ Display git info, such as the last commit for file and stuff. It's pretty useful
:init
(my-leader-def "aa" #'avy-dired-goto-line))
#+end_src

[[https://github.com/stsquad/dired-rsync][dired-rsync]] allows using =rsync= instead of the default synchronous copy operation.
#+begin_src emacs-lisp
(use-package dired-rsync
:straight t
:after (dired)
:config
(add-to-list 'global-mode-string '(:eval dired-rsync-modeline-status))
(general-define-key
:states '(normal)
:keymaps '(dired-mode-map)
"C" #'dired-rsync
"gC" #'dired-rsync-transient
"gd" #'dired-do-copy))

(use-package dired-rsync-transient
:straight t
:after (dired))
#+end_src
*** Subdirectories
Subdirectories are one of the interesting features of Dired. It allows displaying multiple folders on the same window.

Expand Down Expand Up @@ -11482,6 +11503,9 @@ First, we need to create non-existing folders and remove folders that aren't sup

To do that, we need to find all such folders:
#+begin_src emacs-lisp
(defvar my/index-keep-files
'(".dtrash"))

(defun my/index--filesystem-tree-mapping (full-tree tree &optional active-paths)
"Return a \"sync state\" between the filesystem and the tree.

Expand Down Expand Up @@ -11517,10 +11541,15 @@ The return value is a list of alists with the following keys:
(has-to-exist . ,folder-has-to-exist)
(children . ,(append
(cl-loop for f in extra-folders
collect `((path . ,f)
(exists . t)
(has-to-exist . nil)
(extra . t)))
collect
`((path . ,f)
(exists . t)
(has-to-exist
. ,(member
(file-name-nondirectory
(directory-file-name f))
my/index-keep-files))
(extra . t)))
(my/index--filesystem-tree-mapping
(alist-get :children elem) tree active-paths)))))))
#+end_src
Expand Down

0 comments on commit 2cbac89

Please sign in to comment.