0

I have Emacs installed with brew install emacs-mac --HEAD --with-cocoa --with-gnutls --with-librsvg --with-imagemagick. I have the final .app binary in the OS X Dock.

If I drag a file onto the Dock icon, the default behavior opens it in the last-activated frame, even if it is on a different desktop. I'd like files to open in a new frame in the current desktop when drag-and-dropped onto the icon. Is this behavior possible? Yes, because this is emacs. Can anyone suggest a place to begin implementing this?

1
  • 1
    I don't use the Brew or dropping stuff in Dock icons, but I have looked into altering ns-find-file so that files opened from the Finder.app get displayed in certain select frames (using a custom function and let-binding the display-buffer-alist). Why not try adding a message to ns-find-file and drop your file on the Dock and see if the message gets displayed? If it does, then "Bingo!". If not, then "Go Fish!". Here is a link to a modified version of ns-find-file: stackoverflow.com/questions/18346785/… Commented Jul 7, 2016 at 16:39

1 Answer 1

0

Until someone suggest a better implementation, I over-write dnd-open-local-file to open in a new frame instead of a new window:

(setq dnd-open-file-other-frame t) (defun dnd-open-local-file (uri _action) (let* ((f (dnd-get-local-file-name uri t))) (if (and f (file-readable-p f)) (progn (if dnd-open-file-other-frame (find-file-other-frame f) (find-file f)) 'private) (error "Can not read %s" uri)))) 
3
  • It seems like the default behavior has changed to this since the answer was written. I would like it to open in my existing frame, but it always opens a new frame. I don't see any relevant variables in Emacs 29.2. Commented May 2, 2024 at 20:07
  • I think dnd isn't a default package. Needs to be installed. Commented May 3, 2024 at 22:05
  • apropos-variable finds other dnd-XXX variables, such as dnd-open-file-other-window so I think it's loaded. Commented May 3, 2024 at 22:09

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.