unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* TIP: Opening selected files with ROX file manager
@ 2022-09-07 18:38 Jean Louis
  2022-09-08  1:28 ` Po Lu
  0 siblings, 1 reply; 18+ messages in thread
From: Jean Louis @ 2022-09-07 18:38 UTC (permalink / raw)
  To: Help GNU Emacs

I often have case where I locate files by using Emacs and Dired, and
need to drag and drop those files to other application in X.

For dragging and dropping I like to use ROX file manager.

Problem is when files are many, or there are many images, then opening
of files takes longer time and visually it is not possible to locate
the same files which I wanted to drop or share into chat window of
other application.

Solution is to create temporary directory and make symbolic links
from it.

(defun rcd-temp-directory-name (&optional directory-name)
  "Return temporary directory name."
  (let ((name (concat (file-name-as-directory (or (getenv "TMPDIR") "/tmp/"))
		      "temp-dirs/"
		      (file-name-as-directory (or directory-name (format-time-string "%A-%B-%d-%Y-%H-%M-%S"))))))
    name))

(rcd-temp-directory-name) ⇒ "/home/data1/protected/tmp/temp-dirs/Wednesday-September-07-2022-21-35-24/"

The following function opens ROX Filer.

(defun rox (&optional file)
  "Start ROX Filer with optional FILE.

FILE can be directory."
  (interactive)
  (if file
      (start-process "Rox" "Rox" "rox" "-n" "-s" file)
    (start-process "Rox" "Rox" "rox" "-n")))

And following function is the key function that creates temporary
directory and opens it with graphical file manager containing only
files selected within Dired.

(defun rox-dired-files ()
  "Generate temporary directory with selected files in Dired."
  (interactive)
  (let ((files (dired-get-marked-files)))
    (when filesn
      (let ((directory (rcd-temp-directory-name)))
	(mkdir directory t)
	(while files
	  (let* ((target (pop files))
		 (linkname (concat (file-name-as-directory directory)
				   (file-name-nondirectory target))))
	    (make-symbolic-link target linkname t)))
	(rox (expand-file-name directory))))))

It is very hand to assign key in dired to this function, so that
marked files simply appear in new Rox file window.

(keymap-set dired-mode-map "C-c r" #'rox-dired-files)

One can replace Rox with other file managers.


Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2022-09-12 11:09 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-07 18:38 TIP: Opening selected files with ROX file manager Jean Louis
2022-09-08  1:28 ` Po Lu
2022-09-08 11:12   ` Jean Louis
2022-09-09  1:45     ` Po Lu
2022-09-09  4:17       ` Jean Louis
2022-09-09  7:26         ` Po Lu
2022-09-09 12:15           ` Jean Louis
2022-09-09 13:40             ` Po Lu
2022-09-11  6:14               ` Jean Louis
2022-09-11  7:48                 ` Po Lu
2022-09-11 10:34                   ` Jean Louis
2022-09-11 12:01                     ` Po Lu
2022-09-11 13:21                       ` Jean Louis
2022-09-12  1:21                         ` Po Lu
2022-09-12  5:45                           ` Jean Louis
2022-09-12 10:00                             ` Po Lu
2022-09-12 10:44                               ` Jean Louis
2022-09-12 11:09                                 ` Po Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).