Not selecting what emacs ido is suggesting? [duplicate] - emacs

This question already has an answer here:
Ido mode is too smart, can I get it to NOT complete a filename?
(1 answer)
Closed 9 years ago.
In my current working directory ~/WD there is a abc.txt file. Now I want to make another abc.txt under a sub directory ~/WD/NEW/. As I type C-x C-f and the directory ~/WD/NEW/abc.txt, ido is changing the string into ~/WD/abc.txt, which is not what I want to open. As I try to modify the string back, ido automatically "correct" my input into the wrong string again.
Is there any way to solve this issue?

If you're using ido to open a file and you want to "step out" of ido in the middle of completing, you can use C-f. For example:
Ctrl+X Ctrl+F (find-file)
Find file: ~/{ .emacs.d/ | bin/ | some-file.txt | tmp/ ... }
T Enter (narrow options with ido)
Find file: ~/tmp/{ file1.txt | file2.txt | subdir/ }
Ctrl+F ("step out" of ido mode)
Find file: ~/tmp/

Another way of avoiding the completion proposed by ido is to validate your entry using C-j instead of RET
Example, in a case where file foobar already exists and you want to create file foo
C-xC-f (find-file)
Find file: ~/{.emacs.d | ... | foobar}
foo (ido narrows options)
Find file: ~/foo[foobar]
C-j (ido-select-text)
This creates file foo instead of accepting ido's foobar completion

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).

How do I search and copy in emacs? [duplicate]

This question already has answers here:
Emacs copy matching lines
(5 answers)
Closed 9 years ago.
My text follows the format:
HEADER hello
...
...
HEADER neighbour
...
...
...
HEADER test1
HEADER test2
I want to select all instances of HEADER*\n and copy them to a new document. So, the result would look like:
HEADER hello
HEADER neighbour
HEADER test1
HEADER test2
It doesn't matter if the spaces are preserved. Is this possible with standard emacs functionality?
It might be easier to copy the whole document to a new document, and then use delete-non-matching-lines.
M-x delete-non-matching-lines<RET> ^HEADER<RET>
Not so trivial, but you can define such a function by yourself. Like the one here: Emacs copy matching lines
In the buffer, try
C-u M-x occur RET ^HEADER.* RET
It should create a new buffer with just the output you want. Then you can switch to that buffer and save it as a file, or mark it with C-x h and M-w and then yank it into a new buffer or whatever you need.
By the way, not a bare out-of-the-box answer, but for what it's worth, there is a nice library called all.el that gives Emacs the rather useful "all" command that was used on (if I remember correctly) xedit (an old mainframe text editor). The library is here -- you might like that for this sort of thing too.

Emacs will not visit new file but insists on opening a similar one

The problem is quite simple but frustrating. When I try to visit a new file with C-x C-f which is named basis.m emacs keeps visiting the similar named file haarbasis.m which already exists in the same directory. It keeps prompting me for similar names and I am unable to visit a new empty file. I had recently installed elpy for a python IDE if it makes any difference.
How can I force emacs not to visit a file with C-x C-f unless I explicitly state which file to visit?
elpy loads idomenu which in turn loads ido. What you are describing sounds like ido-powered completion of file names. You can disable it after C-x C-f by pressing C-f.
As Alex mentions the string of packages that brought you to ido-mode, this answer depends on the answer to your statement below, which may be why something is happening to you when you do C-x C-f
When I try to visit a new file...
When your pointer/cursor is at the end of a word, idowill look for a file in the current directory with that name. It may even traverse down the relative path too if it's set up like a file directory structure e.g. show/basis.m
The commentor Jon O says, Even if this is happening C-j will create a new file for you.

emacs-dired and globalff

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.

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.)