ch11ng / exwm

Emacs X Window Manager
2.85k stars 135 forks source link

switch-window can not work well with exwm again. #247

Closed tumashu closed 7 years ago

tumashu commented 7 years ago

exwm seem to can not work well with emacs package "switch-window" again, switch-window is not update in the period, so I think it may exwm's problem.

QiangF commented 7 years ago

EXWM floating windows can not work with Ace-window either. With ace-window-display-mode set to t, window labels don't show in modeline of floating windows. Maybe it is related with this issue.

tumashu commented 7 years ago

Switch-window is different from ace-window, maybe they are two different bugs.

tumashu commented 7 years ago

In my opinion, switch-window is more useful to exwm for its bigger guide char. when exwm is enabled, ace-window only use mode-line to show guide-char, toooooo small to watch

tumashu commented 7 years ago

A suggestion is that we can create a. emacs packages list, all package in this list will be checked work status before publish a new exwm version

QiangF commented 7 years ago

The issue is that ace-window doesn't work for frames, see the issue for ace-window (https://github.com/abo-abo/ace-window/issues/88). Maybe you can take the code from switch-window and merge with ace-window to enable guide-char for X window buffer. I think ace-window is a better solution because ace-window has more functionalities than switch-window, eg. you can apply an action char before the guide char of the window to apply actions like split, close the window, the action char can also bring up a hydra which can be configured to resize, move, scroll windows etc. But hydra doesn't work for X window buffers. See the issue here (https://github.com/abo-abo/hydra/issues/243).

tumashu commented 7 years ago

switch-window can do many similar work with different approach, but this is not important, the most important thing for me is that "big guard char", becore "我高度近视" :-)

(use-package switch-window
  :bind (("C-x o" . switch-window)
         ("C-x 1" . switch-window-then-maximize)
         ("C-x 2" . switch-window-then-split-below)
         ("C-x 3" . switch-window-then-split-right)
         ("C-x 0" . switch-window-then-delete))
  :config
  (setq switch-window-increase 6)
  (setq switch-window-shortcut-style 'qwerty))
QiangF commented 7 years ago

@tumashu But you just wasted several keybindings for the window switch. Compare with this:

(use-package ace-window
:ensure t
:defer 1
:bind (("C-x o" . ace-window))
:config
(defun my-ace-window ()
    (interactive)
    (progn
        (hydra-window/body)
        (ace-window 0)))

(set-face-attribute 'aw-leading-char-face nil :foreground "white" :weight 'bold :height 3.0)
(set-face-attribute 'aw-mode-line-face nil :inherit 'mode-line-buffer-id :foreground "red" :weight 'bold)
(setq aw-reverse-frame-list t)
(setq-default cursor-in-non-selected-windows 'hollow)
(setq aw-keys   '(?a ?s ?d ?f ?j ?k ?l)
        aw-dispatch-always t
        aw-dispatch-alist ; key prefix to window label
        '((?x aw-delete-window     "Ace - Delete Window")
        (?c aw-swap-window       "Ace - Swap Window")
        (?n aw-flip-window)
        (?v aw-split-window-vert "Ace - Split Vert Window")
        (?h aw-split-window-horz "Ace - Split Horz Window")
        (?m delete-other-windows "Ace - Maximize Window")
        (?g delete-other-windows)
        (?b balance-windows)
        (?u winner-undo)
        (?r winner-redo)))

(when (package-installed-p 'hydra)
    (defhydra hydra-window (:color blue :hint nil :idle 0.4 :timeout 5)
        "
        [^w^] windows size [^r^] winner redo  [^u^] winner undo  [^g^] max. current
        [^h^] split horz.  [^;^] swap window  [^x^] del. window  [^c^] swap window
        [^v^] split vert.  [^b^] balance win. [^n^] last window  [^m^] max window")
    (defhydra hydra-window-size (:color red)
    "Windows size"
    ("h" shrink-window-horizontally "shrink horizontal")
    ("j" shrink-window "shrink vertical")
    ("k" enlarge-window "enlarge vertical")
    ("l" enlarge-window-horizontally "enlarge horizontal"))
    (defhydra hydra-window-scroll (:color red)
    "Scroll other window"
    ("n" joe-scroll-other-window "scroll")
    ("p" joe-scroll-other-window-down "scroll down"))
    (add-to-list 'aw-dispatch-alist '(?w hydra-window-size/body) t)
    (add-to-list 'aw-dispatch-alist '(?o hydra-window-scroll/body) t))
(ace-window-display-mode t))
tumashu commented 7 years ago

@QiangF When I found the solution of "Big guid char", I will try ace-window :-), let's stop discuss ace-window vs switch-window, and wait @ch11ng to resolve the problem, an advertisement: you can try exwm-x if you interesting it https://github.com/tumashu/exwm-x

ch11ng commented 7 years ago

Could you point out which commit breaks this? I do only a few regression tests before committing. Automated test is not easy for such a graphical application.

ch11ng commented 7 years ago

Please verify if 2b7449ea425df236471496cd96f061d70f3ba15a fixes the problems here.

tumashu commented 7 years ago

I have tested, but the bug is not fixed.

tumashu commented 7 years ago

This bug seem to exist nearly a year :-(

tumashu commented 7 years ago

我英文比较差,下面这段话我只能用中文了:-)

switch-window 的设计理念是不是和 exwm 有冲突? 如果在 exwm 这边不好解决的话, 是不是可以修改 switch-window 的代码来处理这个问题, 要不然你这边一更新,我这边 switch-window 就歇菜, 太麻烦了。

我对按键方面不太了解,我猜测冲突可能出现在下面这段代码:

(defun switch-window--prompt (prompt-message)
  "Display an overlay in each window showing a unique key, then
ask user for the window to select"
  (let ((config (current-window-configuration))
        (num 1)
        (minibuffer-num nil)
        (original-cursor (default-value 'cursor-type))
        (eobps (switch-window--list-eobp))
        (window-configuration-change-hook
         (unless switch-window-configuration-change-hook-inhibit
           window-configuration-change-hook))
        key buffers
        window-points
        dedicated-windows)

    ;; arrange so that C-g will get back to previous window configuration
    (unwind-protect
        (progn
          ;; hide cursor during window selection process
          (setq-default cursor-type nil)
          ;; display big numbers to ease window selection
          (dolist (win (switch-window--list))
            (push (cons win (window-point win)) window-points)
            (when (window-dedicated-p win)
              (push (cons win (window-dedicated-p win)) dedicated-windows)
              (set-window-dedicated-p win nil))
            (if (minibuffer-window-active-p win)
                (setq minibuffer-num num)
              (push (switch-window--display-number win num) buffers))
            (setq num (1+ num)))

          (while (not key)
            (let ((input
                   (event-basic-type
                    (read-event
                     (if minibuffer-num
                         (format "Move to window [minibuffer is %s]: "
                                 (if switch-window-minibuffer-shortcut
                                     (char-to-string switch-window-minibuffer-shortcut)
                                   (switch-window--label minibuffer-num)))
                       prompt-message)
                     nil switch-window-timeout))))

              (if (or (null input) (eq input 'return))
                  (progn
                    (switch-window--restore-eobp eobps)
                    (keyboard-quit))    ; timeout or RET
                (unless (symbolp input)
                  (let* ((wchars (mapcar 'string-to-char
                                         (switch-window--enumerate)))
                         (pos (cl-position input wchars)))
                    (if pos
                        (setq key (1+ pos))
                      (progn
                        (switch-window--restore-eobp eobps)
                        (keyboard-quit)))))))))
      ;; clean input-method-previous-message
      (setq input-method-previous-message nil)
      ;; restore original cursor
      (setq-default cursor-type original-cursor)
      ;; get those huge numbers away
      (mapc 'kill-buffer buffers)
      (set-window-configuration config)
      (dolist (w window-points)
        (set-window-point (car w) (cdr w)))
      (dolist (w dedicated-windows)
        (set-window-dedicated-p (car w) (cdr w))))
key))
tumashu commented 7 years ago

I have hacked switch-window, and use minibuffer instead of read-event to get user's input. Seem to can resolve the problem.

tumashu commented 7 years ago

Install the newest switch-window, and set like the below:

(setq switch-window-input-style 'minibuffer)
ch11ng commented 7 years ago

Thanks! It's always troublesome to modify the input focus code of EXWM.