A function to make multiple workspaces and open files in them

I’m trying to make a function that would open new frames (with a new (emacs) workspace in each) and open the specified files in that workspace. I also added some wmctrl commands to move the frame to the (DE) workspace I want.

The opening and moving works, but all the files are opened in the last workspace, no matter where I put find-file. Even progn does not help. I would like the file to be visible, and not have to select it with switch-to-buffer.

  (defun make-init-frames-c ()
    "Init frames that I want when emacs starts. Opening files doesn't
work."
    (interactive)
    (progn
      (if (string-equal (+workspace-current-name) "#1")
          (funcall-interactively #'+workspace-delete "#1")) ;;only for the daemon
      (funcall-interactively #'+workspace-switch "main")
      (shell-command-to-string "wmctrl -i -r `xdotool getactivewindow` -b add,hidden")
      (funcall-interactively #'make-frame)
      (funcall-interactively #'+workspace-rename "#1" "Agenda")
      (find-file "~/org")
      (shell-command-to-string "wmctrl -i -r `xdotool getactivewindow` -b add,fullscreen")
      (shell-command-to-string "wmctrl -i -r `xdotool getactivewindow` -t 11")
      (funcall-interactively #'make-frame)
      (funcall-interactively #'+workspace-rename "#1" "one")
      (find-file "~/one")
      (shell-command-to-string "wmctrl -i -r `xdotool getactivewindow` -b add,fullscreen")
      (shell-command-to-string "wmctrl -i -r `xdotool getactivewindow` -t 2")))

Any help is appreciated.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.