Skip to content

Commit

Permalink
BREAKING: dirvish-yank -> multi-stage+async+TRAMP (alexluigit#26 alex…
Browse files Browse the repository at this point in the history
…luigit#30 alexluigit#34 alexluigit#37)

We already have multi-stage and asynchronous copy/paste facilities in
Dirvish (`dirvish-yank` command). This commit brings a few new commands that
serve for other purposes but have similar mechanism as `dirvish-yank`, they are:

- `dirvish-move`
- `dirvish-symlink`
- `dirvish-relative-symlink`
- `dirvish-hardlink`

Note that all of them are also asynchronous and work on both localhost and
remote host.


Former-commit-id: 3837ecf
  • Loading branch information
alexluigit committed May 5, 2022
1 parent bcfbf25 commit 0d3aaa5
Show file tree
Hide file tree
Showing 4 changed files with 258 additions and 88 deletions.
2 changes: 1 addition & 1 deletion Configuration.org
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ https://user-images.githubusercontent.com/16313743/159040575-44485f8e-291b-43dc-
([remap dired-sort-toggle-or-edit] . dirvish-quicksort)
([remap dired-do-redisplay] . dirvish-ls-switches-menu)
([remap dired-summary] . dirvish-dispatch)
([remap dired-do-copy] . dirvish-yank)
([remap dired-do-copy] . dirvish-yank-menu)
([remap mode-line-other-buffer] . dirvish-other-buffer)))
#+end_src

Expand Down
17 changes: 17 additions & 0 deletions dirvish.el
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,23 @@ ALIST is window arguments passed to `window--display-buffer'."
entry
(complete-with-action action completions string pred)))))

(defun dirvish--marked-files (&optional range)
"Get all marked filenames in RANGE.
RANGE can be `buffer', `session', `frame', `all'."
(cl-loop
with case-fold-search = nil
with regexp = (dired-marker-regexp)
with buffers = (pcase range
('buffer (list (current-buffer)))
('session (dv-dired-buffers (dirvish-curr)))
('frame (dirvish-get-all 'dired-buffers nil t))
('all (dirvish-get-all 'dired-buffers t t)))
for buffer in (or buffers (list (current-buffer))) append
(with-current-buffer buffer
(when (save-excursion (goto-char (point-min))
(re-search-forward regexp nil t))
(dired-map-over-marks (dired-get-filename) nil)))))

;;;; Core

(defun dirvish-curr (&optional frame)
Expand Down
21 changes: 20 additions & 1 deletion extensions/dirvish-menu.el
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
(require 'transient)
(require 'dirvish)
(defvar dirvish-menu-available-prefixs
'(dirvish-setup-menu dirvish-ls-switches-menu dirvish-goto-bookmark))
'(dirvish-setup-menu dirvish-ls-switches-menu dirvish-yank-menu dirvish-goto-bookmark))

(defclass dirvish-menu:toggle (transient-infix)
((variable :initarg :variable)
Expand Down Expand Up @@ -376,6 +376,25 @@ invoke the sort function, SWITCHES is the the sort flags for
(interactive)
(dirvish-quicksort--do-sort ,switches))))]))))

;;;###autoload (autoload 'dirvish-yank-menu "dirvish-menu" nil t)
(defcustom dirvish-yank-keys
'(("y" "Yank (paste) here" dirvish-yank)
("m" "Move here" dirvish-move)
("s" "Make symlinks here" dirvish-symlink)
("r" "Make relative symlinks here" dirvish-relative-symlink)
("h" "Make hardlinks here" dirvish-hardlink))
"YANK-KEYs for command `dirvish-yank-menu'.
A YANK-KEY is a (KEY DOC CMD) alist where KEY is the key to
invoke the CMD, DOC is the documentation string."
:group 'dirvish :type 'alist
:set
(lambda (k v)
(set k v)
(eval
`(transient-define-prefix dirvish-yank-menu ()
"Yank commands menu."
["Select yank operation on marked files:" ,@v]))))

;;;###autoload (autoload 'dirvish-goto-bookmark "dirvish-menu" nil t)
(defcustom dirvish-bookmarks-alist
'(("h" "~/" "Home")
Expand Down
Loading

0 comments on commit 0d3aaa5

Please sign in to comment.