From haskell.org-lists at my-post-office.net Fri Nov 1 07:29:03 2024 From: haskell.org-lists at my-post-office.net (Jacek Generowicz) Date: Fri, 01 Nov 2024 08:29:03 +0100 Subject: [xmonad] DynamicProjects: creating a new project that partially matches predefined project In-Reply-To: <874j4s9cuh.fsf@gmail.com> (Ramon Diaz-Uriarte's message of "Thu, 31 Oct 2024 22:33:42 +0100") References: <87bjz01yp4.fsf@gmail.com> <874j4s9cuh.fsf@gmail.com> Message-ID: <87sesbxvi8.fsf@generowicz.net> Ramon Diaz-Uriarte 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. 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. 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`. From rdiaz02 at gmail.com Fri Nov 1 09:26:22 2024 From: rdiaz02 at gmail.com (Ramon Diaz-Uriarte) Date: Fri, 01 Nov 2024 10:26:22 +0100 Subject: [xmonad] DynamicProjects: creating a new project that partially matches predefined project In-Reply-To: <87sesbxvi8.fsf@generowicz.net> (Jacek Generowicz's message of "Fri, 01 Nov 2024 08:29:03 +0100") References: <87bjz01yp4.fsf@gmail.com> <874j4s9cuh.fsf@gmail.com> <87sesbxvi8.fsf@generowicz.net> Message-ID: <87plnf8fup.fsf@gmail.com> 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 wrote: > Ramon Diaz-Uriarte 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. > 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. 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