ch11ng / exwm

Emacs X Window Manager
2.85k stars 134 forks source link

Is it possible to rename workspaces? #530

Closed ArenT1981 closed 5 years ago

ArenT1981 commented 5 years ago

Hello

Fantastic project, thank you very much.

Quick question, as looking around I haven't been able to determine whether or not it is possible.

Is it possible to rename/create custom names/aliases for the workspaces, rather than just [0] [1] [2] etc.

I'd ideally like to pull-up the workspace switcher and see something like:

[sys] [edit] [www] [email]

etc.

Thanks

Aren.

ch11ng commented 5 years ago

Yes you can name workspaces with exwm-workspace-index-map.

(setq exwm-workspace-index-map
      (lambda (index)
        (let ((named-workspaces ["sys" "edit" "www" "email"]))
          (if (< index (length named-workspaces))
              (elt named-workspaces index)
            (number-to-string index)))))
ArenT1981 commented 5 years ago

Brilliant, thank you!

The only problem I have is that I have had to set the initial workspaces to 1, as they are loading with a different font size in the modeline upon first launch of EXWM/Spacemacs. It seems that Spacemacs is setting my chosen font size after EXWM has already loaded, which means that workspace 0 has font size 10 (as I want), but that the initial font size on workspaces 1, 2, and 3 are still on the initial inbuilt default of 12 (presumably because Spacemacs itself doesn't know about multiple workspaces).

However, each workspace I then subsequently create/delete after the initial start up is loading the correct/newly set font size exactly as it should. So the problem is only on initial first start up.

Anyway, I'll give your code a try. Does it set that as a 'permanent' map as a naming convention? i.e. Even if I start with one workspace, does then adding a new workspace name it as per the next in the map? If so, that behaviour will be perfect, as it is almost instantaneous to just create workspaces anyway -- i.e. if I hit , I instantly get 7 new workspaces created... Being able to define a predefined naming map would be pretty sweet, if that is how the map works... I'll create a named map for ten desktops, which is about the maximum I would ever likely use/need.

I'm finding EXWM brilliant overall, so thanks for all the hard work creating this.

ArenT1981 commented 5 years ago

Yep, that persistent naming map works perfectly :-)

The font size issue is no issue, I have EXWM set to create one initial desktop, then simply hit super-9 and it immediately creates 10 workspaces as per my naming convention.

Having named workspaces is a very small but immensely valuable feature to me... Otherwise I tend to get myself muddled with what buffer/application I have on which desktop, etc...!

I'm guessing if I dig around enough through the threads on here, it is presumably possible to set rules for default application loading workspaces/move buffers, e.g. such that firefox always loads on a given workspace, one that you've also happened to call "www" (or whatever canonical name one happens to find pleasing).

I'm still an Emacs/lisp novice, but learning a bit more each day.

ch11ng commented 5 years ago

I'm guessing if I dig around enough through the threads on here, it is presumably possible to set rules for default application loading workspaces/move buffers, e.g. such that firefox always loads on a given workspace, one that you've also happened to call "www" (or whatever canonical name one happens to find pleasing).

This is possible by customizing exwm-manage-configurations which has a workspace property to specify which workspace a matching application should be created on.

vonHabsi commented 5 years ago

Can this function work in the scratchpad on its own? I get syntax error when I apply C-x C-e to it

(setq exwm-workspace-index-map
      (lambda (index)
        (let ((named-workspaces ["sys" "edit" "www" "email"]))
          (if (< index (length named-workspaces))
              (elt named-workspaces index)
            (number-to-string index)))))
ch11ng commented 5 years ago

I copied and tried your snippet and saw no error. What was Emacs complained about? You may try putting it in your init file directly.

vonHabsi commented 5 years ago

I copied and tried your snippet and saw no error. What was Emacs complained about? You may try putting it in your init file directly.

Yes I think something is misbehaving in emacs. When select the whole region there is no syntax error. It is when place the cursor at the end to execute via C-x C-e does the problem arise.

ch11ng commented 5 years ago

I've been playing with C-x C-e quite often and have never noticed such problem. Perhaps you should turn on show-paren-mode; it highlights the matching parenthesis and can be helpful to pick out unbalanced ones.

As the problem has been resolved, I'm closing this issue now.