Comments (19)
If it is not our bug, I would not fix it here. As long as we are sure we did everything alright.
from consult.
Workaround: Remove this clause:
Lines 627 to 632 in b5cbc61
More practical workaround:
(add-hook 'eshell-mode-hook
(lambda ()
(setq-local completion-in-region-function 'completion--in-region)))
from consult.
Exploiting the undefined behavior seems to work just fine, and it really isn't likely to change any time soon. I'll make a pull request.
from consult.
@oantolin ideas?
from consult.
Huh. Like @tomfitzhenry pointed out, it's read-file-name that's doing that! I don't know why, but it chooses to put point before the argument initial
rather than at the end of the minibuffer. That doesn't seem like a very good default. We could just not use read-file-name
, but it is nice to have your special keybindings from minibuffer-local-filename-completion-map
present.
How about just forcing the move to the end of line? We can wrap the call to read-file-name
in (minibuffer-with-setup-hook #'end-of-line _____)
.
from consult.
@tomfitzhenry are you using selectrum or icomplete btw?
from consult.
@tomfitzhenry are you using selectrum or icomplete btw?
I can reproduce this issue with emacs -q
(so not even icomplete is enabled), and with icomplete
. I haven't tried selectrum.
from consult.
It's definitely something that read-file-name-default
does. Selectrum uses its own setting for read-file-name-function
, so it's possible it behaves differently.
from consult.
Huh. Like @tomfitzhenry pointed out, it's read-file-name that's doing that! I don't know why, but it chooses to put point before the argument initial rather than at the end of the minibuffer. That doesn't seem like a very good default.
I'll try to reproduce this using just read-file-name
, and raise that issue upstream. Working around bugs long-term isn't sustainable.
from consult.
The steps to reproduce are simple. I'll raise this upstream.
(read-file-name-default "Read File: " nil nil nil "Initial" nil)
from consult.
Regarding the initial value - this has been deprecated for the completing-read API, but for the read-file-name API it is fine? The docs only say "Please note: we recommend using default rather than initial in most cases". See https://www.gnu.org/software/emacs/manual/html_node/elisp/Reading-File-Names.html.
from consult.
Further, that page says "If you specify initial, that is an initial file name to insert in the buffer (after directory, if that is inserted). In this case, point goes at the beginning of initial."
That is, the behaviour we observe is the expected behaviour. I can't tell why that is desirable behaviour (even given the described example of find-alternate-file).
I won't raise this upstream: it's working as intended.
Our options:
i. don't use read-file-name
ii. figure out a way to do this via default
. I can't see how we would. default
appears to be used for when selection fails, not as a means of pre-populating the minibuffer UI (it doesn't).
iii. It looks like we can include the file name in the dir argument: (read-file-name-default "Read File: " "~/foo" nil nil nil nil)
does put point where we expect, and matches file "~/foobar". This appears to be undefined behaviour.
iv. Advise, as in #48 (comment)
from consult.
I lean towards (i) since:
- It's cleanest.
- It's easier to add read-file-name later (if we figure out a clean way to do it), than to remove it later when people may depend on it, if supporting this unclean solution proves too burdensome.
it is nice to have your special keybindings from minibuffer-local-filename-completion-map present
How important is this usecase? Are there file-specific bindings that people would want during a completion-at-point?
from consult.
Why not raise it upstream, if you think it is bad behavior? Option (i) would revert the special behavior for files, which has been done for consistency with how selectrum. It and it also makes sense to use read-file for the file category, I think. But I was not really involved the design of this function, @oantolin made it and we got some feedback by @clemera.
from consult.
I think I've found a way to avoid using read-file-name
, but keep minibuffer-local-filename-completion-map
bindings. It looks like we can set minibuffer-completing-file-name to t to tell the minibuffer to treat this as a filename.
Update: This works, but prompts with a relative path (and so doesn't look like a prompt for a filename). Try to make that an absolute prompt, and then results are absolute. Fixing that partly amounts to reimplementing read-file-name!
from consult.
@tomfitzhenry Since this already has issues and it won't work nicely with recursive minibuffer I think it would be better to keep using read-file-name or not use it at all. But this has to be discussed. See #31 for the original discussion.
from consult.
Personally, I'd go with @tomfitzhenry's option (iii), use the directory argument: even if this behavior is not documented it seems unlikely to change.
from consult.
Haha, the undefined behavior. I am fine with it as long as it works. If at some point it stops working we can file a bugreport to upstream 🙈
from consult.
Closed by #63
from consult.
Related Issues (20)
- How to add advice to achieve for org buffer like to collapse all the headings after executing 'consult-org-heading'?
- How do I use `consult-line` (with live previews) with `ivy`?
- [Q] How do I hide the line numbers in, e.g., `consult-outline`?
- [Q/Bug] consult-grep (with ripgrep or ugrep) is slower than counsel-rg
- consult preview: "PDF document is damaged" but no problem viewing it directly from pdf-tools HOT 4
- [FR] Add the ability to change the initial query in `consult-completion-in-region` HOT 1
- how to use consult-fd on a list of files? HOT 6
- additional set of buffers in consult-buffer-sources
- How to search for upercase letters with outline-regexp?
- [feature request] preselect the item that is most close to current point in consult-imenu and consult-outline HOT 3
- Where is the cached stored?
- Intragration with package Breadcrumb
- Disable consult buffer preview for remote buffers
- Support project.el external roots
- consult-rg wiki advice
- [request] allow `:lookup` in `consult--multi` sources
- Handling buffer renames while switching buffers
- Decorating consult-imenu-multi output with the origin
- Add support to display the matched heading's sub-headings also as candidates in the consult-outline's completion HOT 3
- NetBSD/OpenBSD: find(1) does not support -iwholename
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from consult.