pashinin / workgroups2

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

Extra InactiveMinibuffer when posframe is enabled #119

Closed allenryb closed 1 year ago

allenryb commented 2 years ago

When posframe is enabled, by first wg-create-workgroup and then wg-open-workgroup, one extra frame named by Minibuf-1 InactiveMinibuffer will appear as follows (LEFT is desired and RIGHT is extra):

image

The following little config can reproduce this issue:

;; -*- lexical-binding: t; -*-
(tool-bar-mode 0)
(scroll-bar-mode 0)
(menu-bar-mode 0)

(require 'package)
(setq package-enable-at-startup nil)

(package-initialize)

;; Bootstrap `use-package'
(unless (package-installed-p 'use-package) 
  (package-refresh-contents) 
  (package-install 'use-package))

(use-package vertico
  :init
  (vertico-mode))

(use-package vertico-posframe
  :init
  (vertico-posframe-mode 1))

;; workgroups2 ------------------

(use-package workgroups2
  :ensure t
  :init
  (workgroups-mode 1))

One can also find this issue when using pyim by (setq pyim-page-tooltip 'posframe). Is it possible to ignore all posframes?

redguardtoo commented 2 years ago

9d0cf89 user can choose frames not to save (Chen Bin)

allenryb commented 2 years ago

Thanks for your reply! I'm sorry to have failed to make myself clear.

image

I use wg-create-workgroup to save the left one frame, but by wg-open-workgroup, I get the right two. The new frame Minibuf-1 InactiveMinibuffer is undesired; It is given by posframe in the initial. So the parttern wg-frame-name-regexp-excludes and the following new code can't filter the ones by posframe

      (mapc (lambda (frame)
              (when (cl-find-if (lambda (regexp)
                                  (string-match regexp (terminal-name frame)))
                                wg-frame-name-regexp-excludes)
                (delete frame fl)))
            fl)
redguardtoo commented 2 years ago

Looks you gave me wrong buffer name of postframe.

Try (push "\*Minibuf-1\*" wg-frame-name-regexp-excludes)

allenryb commented 2 years ago

Looks you gave me wrong buffer name of postframe.

Try (push "\*Minibuf-1\*" wg-frame-name-regexp-excludes)

The issue is same after (push "\*Minibuf-1\*" wg-frame-name-regexp-excludes). By startup, The frame list is (#<frame 0x562f05c38d00> #<frame *Minibuf-1* - GNU Emacs at archlinux 0x562f04a64e00>) Both of their terminal names are :0 which doesn't match wg-frame-name-regexp-excludes. I use emacs GUI.

By the way, if I clear posframe before wg-create-workgroup by the following code, then the issue is gone:

(defun my-posframe-clear (name)
  (interactive (list (wg-read-new-workgroup-name)))
  (posframe-delete-all))

(advice-add 'wg-create-workgroup :before #'my-posframe-clear)

But I think this is not a normal way to solve this problem.

redguardtoo commented 2 years ago

Yes, maybe I could add some hook before create workgroup.

But it's better no setup is required. Let me ask the developer of postframe.

redguardtoo commented 2 years ago

892f2dd donot save minibuffer (Chen Bin)

allenryb commented 2 years ago

892f2dd donot save minibuffer (Chen Bin)

It doesn't seem to work. Under a clean startup, buffer-list provide (#<buffer *scratch*> #<buffer *Minibuf-0*> #<buffer *Messages*> #<buffer *Echo Area 0*> #<buffer *Echo Area 1*> #<buffer *eldoc for buffer-list*>) But after M-x which actives vertico-posframe, do buffer-list again and it gives (#<buffer *scratch*> #<buffer *Minibuf-1*> #<buffer *Minibuf-0*> #<buffer *Messages*> #<buffer *Echo Area 0*> #<buffer *Echo Area 1*> #<buffer *eldoc for buffer-list*>) The new buffer-list doesn't filter #<buffer *Minibuf-1*>

redguardtoo commented 2 years ago

Have you tested from the scratch?

allenryb commented 2 years ago

The correct major-mode for #<buffer *Minibuf-1*> is minibuffer-inactive-mode

allenryb commented 2 years ago

Have you tested from the scratch?

Yes, I only load vertico, workgroups2 and then verico-posframe

allenryb commented 2 years ago

It doesn't seems to work yet, even if I put minibuffer-inactive-mode into the definition of buffer-list.

The buffer-list function give the same list.

allenryb commented 2 years ago

In the body of buffer-list, the result of applying wg-buffer-uid-or-add to each of (wg-buffer-list-emacs) returns Wrong type argument: wg-session, nil

redguardtoo commented 2 years ago

a8a4d07 donot save minibuffer (Chen Bin)

allenryb commented 2 years ago

a8a4d07 donot save minibuffer (Chen Bin)

Thanks for your kindness! This commit doesn't seems to work. buffer-list may be not the problem, since no buffer of major-mode in wg-major-mode-excludes is filtered if buffer-list is executed alone. I have no idea for this issue. Please let me copy my different .emacs_workgroups which may be useful.

First, I start up emacs by emacs -q -l testInit.el:

testInit.el
---------------------------------------------
;; -*- lexical-binding: t; -*-
(tool-bar-mode 0)
(scroll-bar-mode 0)
(menu-bar-mode 0)

(require 'package)
(setq package-enable-at-startup nil)

(package-initialize)

;; Bootstrap `use-package'
(unless (package-installed-p 'use-package) 
  (package-refresh-contents) 
  (package-install 'use-package))

(use-package vertico
  :init
  (vertico-mode))

(use-package vertico-posframe
  :init
  (vertico-posframe-mode 1))

;; workgroups2 ------------------

(use-package workgroups2
  :ensure t
  :init
  (workgroups-mode 1))

Second, remove the original .emacs_workgroups file and do wg-create-workgroups. The following is the new .emacs_workgroups file

.emacs_workgroups
---------------------------------------
#s(wg-session "JI81AZQENP7144G-2WMUA" nil nil
          (~pickel!~
        (5 nil 4
           (d "#s(wg-wconfig \"JI81D4XEGOI9CF4-31YV6\" nil ((fullscreen)) 734 864 148 11 nil 16 #s(wg-win nil nil (0 0 148 11) :max 1 0 t nil nil \"JI81D4XEGNQ8NQ8-31YSU\"))")
           3
           (c)
           2 frame-list 1
           (c)
           0
           (c))
        (c 3 4 5 c 1 2 3 c 0 1 5)
        0)
          "~/.emacs_workgroups" "1.2.1"
          (#s(wg-workgroup "JI81D4XEFVXEX1C-31XW6" "wg0" t nil #s(wg-wconfig "JI81D4XEG774V5K-31YAR" nil
                                         ((fullscreen))
                                         0 42 239 60 nil 16 #s(wg-win nil nil
                                                          (0 0 240 59)
                                                          :max 1 0 nil t nil "JI81AZQETXV8CXC-2X7GQ"))
                   nil nil nil nil))
          (#s(wg-buf "JI81D4XEGNQ8NQ8-31YSU" " *Minibuf-1*" nil 1 nil
             ((major-mode . minibuffer-inactive-mode)
              nil nil nil nil nil nil nil)
             nil nil)
         #s(wg-buf "JI81AZQETXV8CXC-2X7GQ" "testInit.el" "/home/allen/.emacs.d/testInit.el" 524 524
               ((major-mode . emacs-lisp-mode)
                (mark-ring 1 524)
                nil nil nil nil nil nil)
               nil nil)))

Third, execute the following code

(defun my-posframe-clear (name)
  (interactive (list (wg-read-new-workgroup-name)))
  (posframe-delete-all))

(advice-add 'wg-create-workgroup :before #'my-posframe-clear)

and repeat the second step again. The new .emacs_workgroups file is

.emacs_workgroups
---------------------------------------
#s(wg-session "JI81AZQENP7144G-2WMUA" nil nil
          (~pickel!~
        (3 nil 2 frame-list 1
           (c)
           0
           (c))
        (c 1 2 3 c 0 1 3)
        0)
          "~/.emacs_workgroups" "1.2.1"
          (#s(wg-workgroup "JI81DAY7W6OAJMO-3A5UV" "wg0" t nil #s(wg-wconfig "JI81DAY7WIN7ACG-3A68K" nil
                                         ((fullscreen))
                                         0 42 239 60 nil 16 #s(wg-win nil nil
                                                          (0 0 240 59)
                                                          :max 1 0 nil t nil "JI81AZQETXV8CXC-2X7GQ"))
                   nil nil nil nil))
          (#s(wg-buf "JI81AZQETXV8CXC-2X7GQ" "testInit.el" "/home/allen/.emacs.d/testInit.el" 524 524
             ((major-mode . emacs-lisp-mode)
              (mark-ring 1 524)
              nil nil nil nil nil nil)
             nil nil)))

In the second step, the difference is *Minibuf-1*

allenryb commented 1 year ago

It's fixed in a8a4d07bff27f72970fe7e204997f1ba0e80263b