pashinin / workgroups2

Workgroups2 - Emacs session manager
http://workgroups2.rtfd.org/
GNU General Public License v3.0
297 stars 42 forks source link

workgroups2 undesirably makes my Emacs to open another frame #92

Closed fu123456 closed 2 years ago

fu123456 commented 4 years ago

Hi, my emacs have two frames when I use this package. However, I only want to show a frame. That's OK. The version of my emacs is 28, and system is Manjaro. My config is:

;; to see @https://github.com/pashinin/workgroups2
(require 'workgroups2)

;; Change prefix key (before activating WG)
(setq wg-prefix-key (kbd "C-c z"))

;; Change workgroups session file
(setq wg-session-file "~/.emacs.d/.emacs_workgroups")

;; ;; Set your own keyboard shortcuts to reload/save/switch WGs:
;; ;; "s" == "Super" or "Win"-key, "S" == Shift, "C" == Control
;; (global-set-key (kbd "<pause>")     'wg-reload-session)
;; (global-set-key (kbd "C-S-<pause>") 'wg-save-session)
(global-set-key (kbd "s-z")         'wg-switch-to-workgroup)
;; (global-set-key (kbd "s-/")         'wg-switch-to-previous-workgroup)

(workgroups-mode 1)   ; put this one at the bottom of .emacs

;; What to do on Emacs exit / workgroups-mode exit?
(setq wg-emacs-exit-save-behavior           'save)      ; Options: 'save 'ask nil
(setq wg-workgroups-mode-exit-save-behavior 'save)      ; Options: 'save 'ask nil

;; Mode Line changes
;; Display workgroups in Mode Line?
(setq wg-mode-line-display-on t)          ; Default: (not (featurep 'powerline))
(setq wg-flag-modified t)                 ; Display modified flags as well
(setq wg-mode-line-decor-left-brace "["
      wg-mode-line-decor-right-brace "]"  ; how to surround it
      wg-mode-line-decor-divider ":")

So, how to solve it?

redguardtoo commented 4 years ago

Check latest version 1.2.1. See the README Quick start, that's how I use workgroups2.

fu123456 commented 4 years ago

Yes, I have used the latest version. I cannot still solve this problem. Once I start my Emacs, it shows three frames, but I only want to show a frame. The undesirable situation is as follows: https://drive.google.com/file/d/1q1JfRJZA8V-m5e7Yg3FFPjjSSPOdJ9mO/view?usp=sharing

rdiaz02 commented 3 years ago

I experience a similar problem with the latest (as of 2021-05-10) version: two frames. What I do is call delete-other-frames immediately after opening the session file. I have a function like this to reload specific sessions:

(defun my-wg-something-reload ()
"Reload wg something"
  (interactive)
  (find-file "some_file")
  (require 'workgroups2)
  (setq wg-session-file "some_wg_file")
  (wg-open-session)
  (delete-other-frames)
)
redguardtoo commented 3 years ago

There are only two public commands: wg-create-workgroup and wg-open-workgroup (wg-switch-to-workgroup is alias of wg-open-workgroup). One is to save the current frame/window layout, one is to load layout.

As I tested, above commands do work. The load command will open exactly same window layout last time you saved.

command wg-open-session is not supposed to be used by user. The key idea is user should not worry about tech details of session. When calling wg-create-workgroup will automatically save the session.

rdiaz02 commented 3 years ago

Thanks for your comments. However, I do not think that wg-open-workgroup allows me to do what I want: start emacs and reopen an emacs frame with a particular set of windows and buffers, in an unattended way (e.g., from a script).

This is often what I do (from a script)

emacs --eval "(progn (my-wg-something-reload))"
redguardtoo commented 3 years ago

f74a58f can run wg-open-workgroup programmically (Chen Bin)

rdiaz02 commented 3 years ago

Thanks. It does work (though I still need to delete-other-frames).