Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable helm-completion for creating directory in Dired #910

Closed
Plypy opened this issue Mar 12, 2015 · 25 comments
Closed

Disable helm-completion for creating directory in Dired #910

Plypy opened this issue Mar 12, 2015 · 25 comments
Labels

Comments

@Plypy
Copy link

Plypy commented Mar 12, 2015

When I want to use + to create a new directory in dired mode, the completion is very annoying.

@thierryvolpiatto
Copy link
Member

Weihua Cheung notifications@github.com writes:

When I want to use + to create a new directory in dired mode, the
completion is very annoying.

I don't see why the completion is annoying, specially if you want to
create a nested directory in one of the subdirs listed in your dired
buffer, but well, if you really don't want this, use:

(add-to-list 'helm-completing-read-handlers-alist
'(dired-create-directory . nil))

or even better use the customize interface, to customize
`helm-completing-read-handlers-alist'.

Note: If you use helm-find-files you can create directories in a
much better way than with dired, among other things.

Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997

@Plypy
Copy link
Author

Plypy commented Mar 12, 2015

I don't see why the completion is annoying, specially if you want to
create a nested directory in one of the subdirs listed in your dired
buffer

Thanks for your fast response.

The completion is indeed useful for subdirectory creation. However, supposing I've already haven a directory named apple, it will be impossible for me to create another one named app in dired. In general, you can't create a new directory whose name is by accidentally some sub-sequences of other existing files/directories.

@thierryvolpiatto
Copy link
Member

Weihua Cheung notifications@github.com writes:

I don't see why the completion is annoying, specially if you want to
create a nested directory in one of the subdirs listed in your dired
buffer

The completion is indeed useful for subdirectory creation. However,
supposing I've already haven a directory named apple, it will be
impossible for me to create another one named app in dired.

Huh! Why? of course you can create a directory named "app"!

In general, you can't create a new directory whose name is by
accidentally some sub-sequences of other existing files/directories.

Yes you can!

Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997

@thierryvolpiatto
Copy link
Member

After hitting "+" from dired, I guess that as soon you enter "app" helm is completing to "apple" , right ?
So at this time (or before entering "app") hit C-<backspace> now you can write "app" without helm completing to "apple".

@thierryvolpiatto
Copy link
Member

From helm-find-files you can do the same, and after "app" add a "/" and hit RET.
If you don't disable auto update with C-<backspace>, you can hit C-b as many time as needed to reach the end of "app", add a "/" C-k and RET.

@thierryvolpiatto
Copy link
Member

Note also that auto update is controlled by helm-ff-auto-update-initial-value which is, I guess, non--nil in your configuration, which is not bad, I use it too.
Just to be sure you know you can disable it if you don't like it.

@michael-heerdegen
Copy link
Contributor

This is not only about auto updating. When hitting + in dired, with helm completion, helm always preselects the first (existing) completion candidate, which is nonsense when you need to specify a new dir name. You need to explicitly select the first (uncompleted) candidate, which is annoying.

This problem more or less also applies to S, Y, C, R etc. I do the following in my init file:

   (cl-callf2 nconc
       (cl-loop for s being the symbols
        if (and (string-match-p "dired" (symbol-name s))
            (commandp s))
        collect (list s))
       helm-completing-read-handlers-alist)

@thierryvolpiatto
Copy link
Member

Michael Heerdegen notifications@github.com writes:

This is not only about auto updating. When hitting + in dired, with
helm completion, helm always preselects the first (existing)
completion candidate, which is nonsense when you need to specify a new
dir name. You need to explicitly select the first (uncompleted)
candidate, which is annoying.

Sorry but I don't see this here, probably due to something in your own
settings.

Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997

@tuhdo
Copy link
Contributor

tuhdo commented Mar 13, 2015

@thierryvolpiatto if you type a name that has common prefix with other items in the directory, Helm always pre-selects the second line (the first line is for creating new item). Only when we enter non-existing item, our choice is selected because there's nothing else. I think for commands that creates things, Helm should prioritize the first item. That is, the line with [?] before it.

@thierryvolpiatto
Copy link
Member

Tu Do notifications@github.com writes:

@thierryvolpiatto if you type a name that has common prefix with other
items in the directory, Helm always pre-selects the second line (the
first line is for creating new item).

Really a minor annoyance, and in most cases it is an advantage.
(This feature was not existing before and I have implemented it after
requests from many users).
And for the case of directory creation, adding a final slash fix the problem.

Only when we enter non-existing item, our choice is selected because
there's nothing else. I think for commands that creates things,

You can't know in advance the intention of user.

Helm should prioritize the first item. That is, the line with [?]
before it.

I think the current behavior is more than reasonable.

Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997

@michael-heerdegen
Copy link
Contributor

It is like helm-M-x: it's not problematic per se, but breaking with keystrokes practiced for thousands of times.

thierryvolpiatto pushed a commit that referenced this issue Mar 14, 2015
* helm-files.el (helm-ff--move-to-first-real-candidate): New internal flag.
(helm-ff-move-to-first-real-candidate): Use it.
(helm-find-files-do-action): Use it.
@thierryvolpiatto
Copy link
Member

Tu Do notifications@github.com writes:

@thierryvolpiatto if you type a name that has common prefix with other
items in the directory, Helm always pre-selects the second line (the
first line is for creating new item). Only when we enter non-existing
item, our choice is selected because there's nothing else. I think for
commands that creates things, Helm should prioritize the first
item. That is, the line with [?] before it.

I have finally fixed this one.

Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997

@michael-heerdegen
Copy link
Contributor

Thanks, I've commented out my "fix" in my init file to test your change.

@michael-heerdegen
Copy link
Contributor

Mmh, it seems the problem the problem is back, the behavior is as it was before.

@michael-heerdegen
Copy link
Contributor

Short version so that you don't have to re-read everything: you made the dired functions (like rename, copy) not prefer the first match as input (which makes not much sense for e.g. adding a new directory or renaming) in the helminized version but to default to the plain user input. That worked quite a time, but it stopped working some while ago (maybe two months or so).

The reason why I reopen it now is that there was a question about the issue in gnu.emacs.help.

@thierryvolpiatto
Copy link
Member

Michael Heerdegen notifications@github.com writes:

Short version so that you don't have to re-read everything: you made
the dired functions (like rename, copy) not prefer the first match as
input (which makes not much sense for e.g. adding a new directory or
renaming) in the helminized version but to default to the plain user
input. That worked quite a time, but it stopped working some while ago
(maybe two months or so).

Thanks.

This start happening 3 months ago at e1cd1ee when fixing #1099.

Will have a look soon.

Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997

thierryvolpiatto pushed a commit that referenced this issue Oct 12, 2015
Was broken by commit e1cd1ee.

* helm-files.el (helm-ff-update-when-only-one-matched):
Check if less than two candidates remaining before jumping
to next line.
@michael-heerdegen
Copy link
Contributor

Looks good. Though, in a few cases, fuzzy matching still seems to make trouble.
For example, I have a file named "Rathenow" in a dir, and when I enter "rthn", this candidate is still selected. If I enter "rathenow" (the exact string, or a substring), or any random string, it behaves as we want after your fix.

Anyway, thanks for your work so far.

@michael-heerdegen
Copy link
Contributor

Correction of my example: until "rathe", the "Rathenow" file line is not selected, but hitting the next letter "n" then selects it. But this is just a random example, you probably already know where to dig.

thierryvolpiatto pushed a commit that referenced this issue Oct 13, 2015
* helm-files.el (helm-ff-update-when-only-one-matched):
Use helm-ff-move-to-first-real-candidate instead of helm-next-line.
@michael-heerdegen
Copy link
Contributor

Ok, so far, it seems to be completely fixed. Many thanks!

thierryvolpiatto pushed a commit that referenced this issue Jan 4, 2016
* helm-files.el (helm-ff-move-to-first-real-candidate):
Preselect non existing file for "dired-<something>"
commands but not for plain "dired".
@zw963
Copy link
Contributor

zw963 commented Dec 9, 2016

After hitting "+" from dired, I guess that as soon you enter "app" helm is completing to "apple" , right ?
So at this time (or before entering "app") hit C- now you can write "app" without helm completing to "apple".

This help me a lot, Thanks.

@cute-jumper
Copy link

@thierryvolpiatto I wonder whether it is worth making the regexp customizable? Currently it makes all commands starting with dired- behave the same. When using +, R, this is nice. But when using j, it's kind of annoying.

I ask this because this is kind of an "undocumented" feature. I'm surprised to see the helm-read-file-name behave differently when using dired commands. After some sort of efforts I finally figured out the dired- commands are explicitly excluded in helm-ff-move-to-first-real-candidate. If the feature can be controlled by the users, it would be nice.

xuchunyang added a commit that referenced this issue Feb 14, 2017
Suggested in
#910 (comment)

* helm-files.el (helm-ff-move-to-first-real-candidate): Do it.
@xuchunyang
Copy link
Member

I pushed a fix for j. However, user still can't control it.

@thierryvolpiatto
Copy link
Member

thierryvolpiatto commented Feb 14, 2017 via email

@thierryvolpiatto
Copy link
Member

thierryvolpiatto commented Feb 14, 2017 via email

@cute-jumper
Copy link

You ask in the subject how to disable helm-completion for creating directories in Dired, then you ask for customizing the regexp preventing to go to first real candidate in dired saying that "+" (create directory) is nice, an then you say that it's annoying only with "j". So I guess what you really want is disabling helm for "j" only, right ?

I forgot to mention the context. In fact, I'm trying to discuss about this line from helm-ff-move-to-first-real-candidate:

(not (string-match "\\`[Dd]ired-" (assoc-default 'name (helm-get-current-source))))

Two commits, 01205d2 and 0278d3c, are related to this issue so I guess it would be nice to continue here. And yes, I would like to make j behave differently from +. (And thanks, @xuchunyang 's newest commit seems to fix this particular problem.)

thierryvolpiatto pushed a commit that referenced this issue Feb 14, 2017
…).

* helm-files.el (helm-ff-goto-first-real-dired-exceptions): New user var.
(helm-ff-move-to-first-real-candidate): Use it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants