emacs-dired and globalff - emacs

How can I pass the output of globalff to emacs-dired. Essentially I am looking for something corresponding to find-name-dired that works with output of globalff.

I just tried it. I have a directory named WebServiceHost, and I typed
M-x globalff RET webservicehost RET
and it displayed that directory's name -- along with all the files inside it -- in the *globalff* buffer. Happily, the directory was the selected item, so I just hit RET, and Emacs then showed me the dired buffer for that directory.

I don't have a globalff answer for you. But you can do the same thing that globalff does, using Icicles instead. And you can open Dired on a set of files from Icicles.
See http://www.emacswiki.org/emacs/Icicles_-_File-Name_Input for using Icicles instead of globalff. (And see http://www.emacswiki.org/emacs/LocateFilesAnywhere for a comparison).
See http://www.emacswiki.org/emacs/Icicles_-_Dired_Enhancements#OpenDiredOnSavedFiles for opening Dired on a set of files that match your minibuffer input in Icicles.

Related

Emacs Dired - C-x C-f to create a new file gives me suggestions of existing files

I'm trying to create a file in dired mode in emacs. I am in the right directory and when I press C-x C-f as suggested elsewhere on SO and type 'img' (that's the name of the file I want to create), it tries to find existing files from other directories including the pattern 'img'. Then I'm stuck as if I press enter, it'll open the first suggested file containing the pattern 'img' from other directories, TAB will just go over the suggestions.
Please advise.
You are probably using ido-find-file with which you can interactively select a file by typing a substring of that file name.
If you want to temporarily disable this feature (i.e. for your current search only) just press C-f before typing the name of your new file (i.e. immediatly after C-x C-f).

Find files whos filenames match pattern in emacs

I am using Linux version of emacs and I would like to use its grep (or rgrep) function to list all filenames matching a pattern, and ideally this should be recursive. I want to be able to call this from the eshell. I'm an emacs newb so if there are more convenient ways of doing this please list those as well, thanks!
EDIT: The purpose in this case is to ensure there are no binary executables in the file list, I don't need the output to go anywhere.
M-x find-name-dired RET is what you want.
Use the command M-x grep-find and then tweak the find command with the -executable flag to suit your need.
There's one more way (as is common) to do this using Dired. Suppose you have the directory you want to search in now visible in Dired buffer. Move the point to it and do C-u iRRET - this will expand all subdirectories recursively in the same buffer. Now * * will select all executable files in all subdirectories.
If you then want to hide the rest, do tk.
PS. For your purpose, Dired will report in the minibuffer how many executable files it found, so you'd not need to do the second step. Second step is for the case if you wanted to further work with the files.

When I create one file in Emacs, I can not open the directory

I use C-x C-f and C-X C-s to save a file to directory "test", then I can not open the test directory with "tab", it says "Dired (directory): ~/test.....".
I want to know what is the wrong and the correct method to create a file in emacs, thanks!
Emacs distinguishes between files and buffers. You do all your editing in buffers, which do not necessarily have to be associated with a file (see, e.g., the *scratch* buffer). However, you often want to edit a buffer that is associated with a file. In that case you visit (Emacs lingo for "open") said file with C-x C-f.
Let's say you have a directory "test" in your home directory, and in that directory a single file "foo.txt". If you want to edit the contents of that file, visit it by typing:
C-x C-f ~/test/foo.txt RET
That's easy enough: now you get a new buffer in Emacs which is conveniently named after the file you're visiting ("foo.txt"). If you want to store changes you've made in the buffer back to the associated file, you type C-x C-s, and Emacs will write the contents of the buffer to the file "~/test/foo.txt".
This mechanism also works for files that do not exist when you start editing!
If you type, say,
C-x C-f ~/test/bar.txt RET
You get a buffer associated with a (yet non-existent) file "bar.txt" in the directory "~/test". Again, you can edit that buffer to your liking and then save the buffer with C-x C-s. The first time you do that, a new file is created.
If you want to create a buffer named "baz" that is not associated with any file, type
C-x b baz RET
Since it is not associated with a file yet, typing C-x C-s in that buffer will prompt you to specify a file-name. After saving, the buffer will be associated with the file you specified.
Finally, if you're in a buffer that is associated with a file, but you want to save it to a different file, you can do so with C-x C-w, which will give you the same prompt as in the previous case. Again, the buffer will be associated after saving with the file you provide.
Tab completion does work in all of the commands that ask you for a file name. If you think it doesn't then it might be because the file you think should be completed does not exist (also beware of upper-/lower-case distinctions in file names), or because another file with the same prefix forbids further disambiguation. Tapping TAB twice should list the available completions in a temporary buffer, letting you continue specifying the path name until it is complete.
Dired mode is pretty much orthogonal to all of the above. It is a mode for "editing" directories, i.e., doing file system operations. You invoke it by typing C-x d, which you may have typed accidentally?! It is quite powerful, but also quite complex. See here for its documentation.

How to find a file in Emacs without known exact directory?

In vim it's very easy to find a file without knowing which directory the file is in. Doing this ":args **/file.hpp" if the file exists, it will get it open.
Is there any substitution in Emacs to do so? The find-file seems work for wildcards, but it doesn't do the tricky like vim does with **.
M-x find-name-dired looks like what You want (You will be prompted for root directory to start search with and a file mask)
A more blunt but still handy tool: M-x locate
Using OS X? This makes emacs use spotlight instead of the standard locate:
(setq locate-command "mdfind")
A good tip if you use ido-find-file:
From a known root directory, you can use ido-wide-find-file-or-pop-dir, which by default is bound to M-f.
FindFileInProject may also be worth looking at.
In Icicles you can find files by matching not just the relative file name but any parts of the path. You can use substring, regexp, and fuzzy matching. You can AND together multiple search patterns (progressive completion). See multi-command icicle-locate-file. And you can even search against file contents, as well as or instead of file name.
http://www.emacswiki.org/emacs/Icicles_-_File-Name_Input
I like
M-x ifind /some/path/to/start/file.hpp
or just
M-x ifind file.hpp
using the ifind package found here. Note: it does open up a *ifind* buffer which displays the results, which you can either select with the mouse, or navigate using C-x ` (aka M-x next-error).

Opening multiple files at once in Emacs

In Emacs using ido-mode allows me to open a file from the minibuffer with C-xC-f. This method opens only one file at a time.
How do I open all the files in a directory or specify more than one file to open?
You can just provide * as the file name and press Enter; you'll be asked for a confirmation and if you press Enter a second time, all files in the directory will be opened.
Note that "opening all files in a directory" involves opening dired buffers for all of its subdirectories.
When not using ido-mode -- at the basic Emacs find-file prompt -- you can use the same * to open all files in a directory. When you do use ido-mode to find files, you can always press C-f to drop back to the usual Emacs find-file prompt. (You can use ido to speed up getting to some directory you're interested in first and drop to the basic find-file in there.) That's one way of creating a new file with ido (the other being the C-j binding); also, it gives you another way of using the above mentioned * trick.
File-name groking is nowhere near as useful as more general pattern-matching.
In Icicles file-name completion, you can open any number of files matching any number of patterns, from the same minibuffer. Pattern-matching can be substring, regexp, fuzzy, or prefix, and you can combine patterns using intersection and complementing.
Just as in Ido, in Icicles your minibuffer input dynamically filters the file-name candidates. You can choose individual candidates or choose all that currently match (using C-!).
(You can of course use file-name groking also. As with Emacs file-name input generally, hitting RET on a wildcard (grok) pattern sends it to find-file, which opens all matching files.)