[OS X Emacs] How to efficiently work with shells/term? drag & drop, history, several instances

Hofert Jan Marius marius.hofert at math.ethz.ch
Thu Sep 22 16:26:58 EDT 2011

Okay, here are my latest trials:

1) download smart-dnd.el and put it in ~/.emacs.d/smart-dnd
2) tried to execute M-x smart-dnd-setup and obtained: "Wrong number of arguments: (lambda (alist) "Install smart-dnd feature to the local buffer."...
3) tried to comment in the 8 lines after "(require 'smart-dnd)" => same behavior
4) tried to call the function smart-dnd-string via M-x smart-dnd-string [but I don't know how I can specify %F: one cannot type in a space after the command, and executing the command first does not ask for an argument]
5) when I drag-and-drop a .png file for example, an additional buffer is opened showing the .png (as a real picture). For text files, a new buffer is opened showing the content of the text file. However, I couldn't manage so far to (a) *not* open an additional buffer but simply taking the shell that is open; then put in the filename, not the content of the file  or (b) open a new shell buffer, but cd into that. 

This is certainly a good feature if you want to edit a file, for example, a text file. Simply drag and drop it to aquamacs and a new buffer opens ready for editing the file. Very useful. But I couldn't manage to solve my original problem of navigating to a folder through the shell/terminal yet. Everytime I drop something, a new buffer is opened. So the first task should be to avoid this. Or maybe I'm thinking in the wrong direction and the first task should be to tell emacs that:
a) all files are opened in a new buffer (say, in text-mode) 
b) all *folders* are opened in a new buffer running a shell and cd into the folder's directory
That would also be nice since one then is not even required to type in M-x shell first. Currently, dropping a folder opens dired mode for which I also don't see how it helps in solving this problem (although also helpful for editing directory names etc. as I learned today).

Update: I could finally find out how to navigate backwards in dired mode: Each click on a folder navigates you in that particular folder, [to my confusion] not in the current buffer but in a new buffer. Then change the focus of the buffers (go to the other buffer) and click there on the next folder. Again, it will open in another new buffer. So go there... Now: to navigate backwards, do exactly the same thing backwards. So after hitting "..", hitting it again in the same buffer does not work. Rather, go to the other open buffer and hit ".." there. Then go the buffer that is opened next and hit ".." there => that's how one can navigate backwards towards the root directory. To avoid having new buffers being opened on navigating, I tried the code on http://www.emacswiki.org/emacs/DiredPower under "Navigating through directories" but it didn't work as expected (I also don't have a mouse :-) ). I also installed dired-single.el (http://www.northbound-train.com/emacs/dired-single.el) but again, new buffers are opened. If someone knows how to prevent all the new buffers from opening, I'd love to hear that [but it's not related to the original problem and maybe should go in another thread]. 



On 2011-09-22, at 16:30 , David Reitter wrote:

> On Sep 22, 2011, at 10:24 AM, Hofert Jan Marius wrote:
>> Okay, I also tried eshell. With shell, eshell, and term, I can drag-in folders, but that just opens a new tab showing the path to the folder and its contents. Is there any simple way to get just the file path? 
> Yes, there is.
> Aquamacs comes with smart-dnd, which allows you to add a handler for drag-and-drop events for just shell-mode.  This is how dragging and dropping into LaTeX and HTML buffers works.  The manual comes with the package:
> http://braeburn.aquamacs.org/code/master/aquamacs/src/site-lisp/smart-dnd.el
> When you've written this and it works, post it here so others may benefit (and I'll probably add it to Aquamacs in that case).
> --
> http://aquamacs.org -- Aquamacs: Emacs on Mac OS X
> http://aquamacs.org/donate -- Could we help you? Return the favor and support the Aquamacs Project!_____________________________________________________________
> MacOSX-Emacs mailing list
> MacOSX-Emacs at email.esm.psu.edu
> http://email.esm.psu.edu/mailman/listinfo/macosx-emacs
> List Archives: http://dir.gmane.org/gmane.emacs.macintosh.osx

More information about the MacOSX-Emacs mailing list