-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
Enabling corfu-global-mode during startup #20
Comments
Okay, but |
Yes, I'm starting a GUI Emacs client frame there. As I've said, immediately after startup, if I just run |
I know how to "make it work" if I want to. This is not a "support request", but a "bug report"... The question is then: shouldn't |
I see, I don't think Corfu should handle this. Corfu needs some way to detect if the display is graphic or not. I could perform the check later, but I prefer if Corfu stays completely out of the completion game when running on the terminal. As you see, Corfu does not replace the If you have a concrete proposal how the behavior could be improved I may reconsider. But this seems to be a relatively common problem and the correct solution seems to be the |
Ok, thanks for considering.
No, not really.
I'm fine with that on my side. ;-) Thanks! |
company-box uses the following workaround: |
As you see fit for It seems to me like a sensible way to do it. |
Maybe, I guess my sentiment to add code to handle this use case seamlessly would be different if I would use emacsclient myself. I only use it when calling back into emacs from shell-mode or term-mode. Generally I think it is a better approach to not add special code for setups which deviate heavily from the vanilla emacs configuration. People who use special setups are perfectly capable of doing the necessary adjustments themselves. You may have seen my Consult package - for this package it would be difficult to perfectly support EXWM or mini-frame setups, both are packages/setups which I am not using and which I cannot test without serious effort. |
I personally wouldn't call using Edit: Indeed, it appears more people use |
Okay, I just gave emacsclient another brief try. I cannot help myself but it always leaves me underwhelmed. Since you seem to be an emacsclient proponent, how can I achieve the following?
If I can achieve this, I think I may switch my setup over to use emacsclient. Maybe I am always do something wrong, but it seems that I always hit some roadblocks. I am sure it is doable with some amount of fiddling, which I am usually willing to do (Otherwise I would not write packages). But as you have seen with these overlays/child frame bugs, my patience with Emacs is not endless 🤷 |
Not a proponent, just an user. I'm a proponent that each one uses Emacs as they prefer.
I don't see any relation between this issue and you having to personally switch to
The EmacsWiki has one script that seems to have the same kind of requirement you describe (https://www.emacswiki.org/emacs/EmacsClient, section "Nifty shell function for hassle-free starting of emacsclient"). I'm not sure it meets all your requirements, but it definitely seems overly complicated to me. I believe you could also get the same kind of control for the existing frame on the Lisp side too, and pass it as But what I do think is that you are trying to reproduce a workflow to meet some restrictions which have more importance when you are running Emacs without the daemon, than when you run with it. The Naturally, some data hangs on the frame, like the window configuration. When I want to recover that, I'd resort to the WM (and yes, I'm one of those uncool kids whose WM steals Of course, much of this is very much a matter of taste (and muscle memory). All I'm saying is that perhaps you are trying to bind to a restriction you might not need to.
I hope none of my reports here have tested your patience in the least. If any of them struck you that way, this was unintended. As a matter of fact, had you not requested active reporting, I'd be watching |
Of course, there is no relation. I am just trying things out from time to time to see if it would work out for me. An in order to judge better how a feature should be supported, I have to try it.
No, or at least it was not your fault. I must admit, I got a bit annoyed with Emacs when neither overlay nor child frame worked as I had intended. But this is purely my fault or the fault of some buggy Emacs implementation. Regarding Regarding the work around we are discussing here, my point still stands. If I implement a work around it will either print the "no display available" message when pressing TAB which is worse or it will not print any error message at all as in the case of the company-box workaround. I prefer to keep the display check and the error message. Unfortunately this comes at the cost of the problematic behavior for the scratch buffer of emacsclient users. They are more than I had expected (40% according to the stats you posted). |
I guess the nifty emacs startup script would cover my use case mostly. However I have an issue with emacsclient and the i3 window manager, which ignores I usually keep a single Emacs instance and frame around and do most things from inside Emacs. You are right that the one-frame restriction is artifical. But I simply don't see a benefit in having multiple equivalent Emacs frames around. Some people use a one window per frame configuration, this makes more sense to me (you seem to be using Emacs a bit like this?). But I still wonder why one should prefer the window manager over the Emacs window management. |
I wouldn't even call it a workaround, just taking care of an existing use case. But it is your call, I have nothing further to add here.
Pretty much that's what I do, yes. It's just one way to do it. For me it makes sense because there are other things around besides Emacs, so when it comes to managing windows (non Emacs parlance) I can keep the bindings consistent for Emacs and the rest. The one-window-per-frame works pretty well once each frame shares the overall environment. Of course, some things Emacs window management does better, but I can always resort to that at any time too. It is just not the default, it's called when something particular is required. |
Okay, how should this be resolved then? It should somehow behave like this:
I think putting |
I pushed a fix. Please give it a try. Hopefully it works in most scenarios. |
Thank you. I haven't tested it yet, but I took a look at it and it seems a clever way to do it. You may deem it enough or not, let me elaborate.
Indeed it can. And, thinking this through, it gets more complicated. The daemon is neither GUI nor terminal, and you can have, for the same server, a terminal frame and a GUI one (or more, of course). Making
As far as I get, the comment above suggests In the later case, I would probably not hook it directly, since I would only want to call the mode once, like so: (defun my/corfu-global-mode-enable ()
(corfu-global-mode 1)
(remove-hook 'after-make-frame-functions #'my/corfu-global-mode-enable))
(add-hook 'after-make-frame-functions #'my/corfu-global-mode-enable) But even that is not fully general, and I'd only go for it because I know I only use the GUI. Also, I'm failing to see a way to avoid entirely a message on calling completion. Consider the following case. We have a daemon running and an open terminal frame connected to that server. We now call Or, considering the commit. You did just the previously described in the terminal, got your undesired message and I admit this is an extremely stretched use case (if it deserves that name), I'm just considering the possibilities. |
I think I have a suggestion. I'm not sure you'll like it, but do bear with me. Let the mode (global or otherwise) be enabled regardless of graphic display when the daemon is running, but make Of course, feel free not to like it. ;-) |
Yes, I knew that this will fail the mixed text+gui use case. This is all not good and I hope it gets obvious by now why I was hesitant to handle this in Corfu. I am torn somehow again. I considered to just keep the mode always enabled and always print a message when pressing TAB in non-graphics mode. A text-mode only user will still get an error message when trying to use Corfu. However it annoy users who wants to use the same configuration for text and ui and is okay with the single error message at startup. The whole point of this package is to be small and simple, so I don't want to add a check for interactive calls to the mode. |
… on TUI (See #20) * When using the text-mode UI, fall back to the default value of the `completion-in-region-function' * Since there are mixed setups with daemons/text/gui, don't print an error message but try to do the right thing in any case
… on TUI (See #20) * When using the text-mode UI, fall back to the default value of the `completion-in-region-function'. * Since there are mixed setups with daemons/text/gui, don't print an error message but try to do the right thing in every case.
The more I think of it, the more I'm convinced that the check should be done when completion is called, not when the mode is enabled. As you did. And, in this case, indeed issuing a warning at that time might be a problem for some people. At this point, my view is that this is the only sane way to handle it. I hope you do reconcile with it eventually. :-)
I think the missing warning on enabling the mode for the terminal case is not particularly troubling. It is not like the mode gets enabled by itself. All in all, thank you very much once again! |
Also, now I took it for a spin here, and it's looking good to me.
Thank you very much! |
Hi @minad !
I'm having a hard time trying to enable
corfu-global-mode
during startup. (Yes, it has come to that! ;-)The apparent behavior is, right after startup, though I have enabled
corfu-global-mode
(I tried several alternatives, running the function, customizing it, even running itafter-init-hook
),corfu
does not actually kick in on my scratch buffer. If I runnormal-mode
(my initial major-mode is Org, but it does not matter here), or visit a file, then it is there.As far as I understand, the problem seems to be that I start Emacs with the usual
emacsclient --create-frame --alternate-editor=""
, and the test for graphical display intocorfu-mode
fails during startup in these circumstances. Indeed, immediately after startup I find in the message buffer:Even running
(add-hook 'after-init-hook #'corfu-global-mode)
seems not to be late enough:The text was updated successfully, but these errors were encountered: