Function: treemacs--drag-move-files

treemacs--drag-move-files is a byte-compiled function defined in treemacs-mouse-interface.el.

Signature

(treemacs--drag-move-files SOURCE-POS TARGET-POS)

Documentation

Move files with a mouse-drag action.

SOURCE-POS: Start position of the mouse drag. TARGET-POS: End position of the mouse drag.

Source Code

;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-mouse-interface.el
(defun treemacs--drag-move-files (source-pos target-pos)
  "Move files with a mouse-drag action.
SOURCE-POS: Start position of the mouse drag.
TARGET-POS: End position of the mouse drag."
  (let* ((source-btn (treemacs--button-in-line source-pos))
         (target-btn (treemacs--button-in-line target-pos))
         (source-key (-some-> source-btn (treemacs-button-get :key)))
         (target-key (-some-> target-btn (treemacs-button-get :key)))
         (target-dir (and target-key
                          (if (file-directory-p target-key)
                              target-key
                            (treemacs--parent-dir target-key))))
         (target-file (and source-key target-key
                           (treemacs-join-path target-dir (treemacs--filename source-key)))))
    (when (and treemacs-move-files-by-mouse-dragging
               source-key target-key
               (not (string= source-key target-key))
               (not (treemacs-is-path source-key :directly-in target-dir)))
      (treemacs-do-delete-single-node source-key)
      (treemacs--without-filewatch
       (rename-file source-key target-file))
      (run-hook-with-args 'treemacs-copy-file-functions source-key target-dir)
      (treemacs-do-insert-single-node target-file target-dir)
      (treemacs-update-single-file-git-state source-key)
      (treemacs-update-single-file-git-state target-file)
      (treemacs--on-file-deletion source-key)
      (treemacs-goto-file-node target-file)
      (treemacs-pulse-on-success "Moved %s to %s"
        (propertize (treemacs--filename target-file) 'face 'font-lock-string-face)
        (propertize target-dir 'face 'font-lock-string-face)))))