[xmonad] DynamicProjects: creating a new project that partially matches predefined project
Ramon Diaz-Uriarte
rdiaz02 at gmail.com
Fri Nov 1 09:26:22 UTC 2024
Thanks! Your practical solution works. Actually, it works with what is, for me, an even simpler trick.
On Fri, 01-November-2024, at 08:29:03, Jacek Generowicz <haskell.org-lists at my-post-office.net> wrote:
> Ramon Diaz-Uriarte <rdiaz02 at gmail.com> writes:
>
>> I use XMonad.Actions.DynamicProjects.
>
> I do not, but I do use XMonad.Actions.DynamicWorkspaces ...
>
>> Now, when I use switchProjectPrompt, I do not know how to create a new
>> (not predefined) project called "em": as soon as I type "em" it
>> matches "emacs" and on pressing enter the "emacs" project is created.
>
> ... which has similar issues.
>
> I'll try to find and describe the "official" solution I have in my
> config, below, but in practice I don't use it, because I hack around the
> problem with the following trick:
>
> 1. start the new dynamic namespace name with an underscore
> 2. type exactly the new name you want after the underscore
> 3. C-a to the beginning and delete the underscore
> 4. <RET>
>
1. start the new dynamic namespace name
2. type exactly the new name you want and add, at end, any one character that prevents the match
3. delete the last character
4. <RET>
It never occurred to me to try this until I read your approach!
So the difference with respect to your procedure is that I do not start with an underscore, but prevent the match at the very end; this has two benefits for me:
a) I do not need to C-a to the beginning;
b) I can decide, or realize, while typing that there is/there is not a matching name, so sometimes I do not need to add anything since there is no matching name.
> Now for the official solution, lemme see ... the relevant bits are
> something like
>
> gotoWorkspace = selectWorkspace myXPConfig
> makeWorkspace = selectWorkspace myXPConfig { autoComplete = Nothing }
>
> which I have bound to two different keys, with the latter not suffering
> from the problem you describe.
>
> selectWorkspace` is imported from XMonad.Actions.DynamicWorkspaces, so I
> guess it's equivalent to `switchProjectPrompt`.
>
> `myXPConfig` starts with
>
> myXPConfig = def {
> -- If only one completion remains, auto-select it after 1
> -- microsecond. Increasing the delay could help to stop accidentally
> -- sending keypresses to the newly focused window, but with my
> -- current usage, 1 microsecond is working just fine.
> autoComplete = Just 1
>
> and I now recall playing around with increasing the delay as an
> alternative solution, and not liking it.
>
In myXPConfig for DynamicProjects I can comment out the "autoComplete = Nothing" (or leave it as Nothing). And this is the setting that I like best (I did not like using other delays).
If I am understanding correctly, by setting "autoComplete = Nothing" I can break the match by adding something, and that broken match is not rematched when I delete the last char. If I were to use "autoComplete = Just 1" (or any other delay) I'd need to start with the underscore, as otherwise I'd be taken (after the delay) to a matching project.
> Git tells me that I created `makeWorkspace` & friends over 12 years ago,
> but, in practice, I've been using the underscore hack ever since,
> because, on the rare occasions that I need it, it's easier to remember
> the hack than the keybinding of `makeWorkspace`.
The trick will be very easy for me to use (and I end up being in this situation often).
Best,
R.
--
Ramon Diaz-Uriarte
Department of Biochemistry, Lab B-31
Facultad de Medicina
Universidad Autónoma de Madrid
Arzobispo Morcillo, 4
28029 Madrid
Spain
Phone: +34-91-497-2412
Email: rdiaz02 at gmail.com
r.diaz at uam.es
ramon.diaz at iib.uam.es
https://ligarto.org/rdiaz
More information about the xmonad
mailing list