help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

TIP: Opening selected files with ROX file manager


From: Jean Louis
Subject: TIP: Opening selected files with ROX file manager
Date: Wed, 07 Sep 2022 21:38:08 +0300

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/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]