wasamasa / eyebrowse

A simple-minded way of managing window configs in emacs
GNU General Public License v3.0
437 stars 24 forks source link

Eyebrowse breaks transient-mark-mode #34

Closed dakrone closed 9 years ago

dakrone commented 9 years ago

I have the following in my Emacs init:

(use-package eyebrowse
  :diminish eyebrowse-mode
  :init
  (progn
    (defun my/create-eyebrowse-setup ()
      (interactive)
      "Create a default window config, if none is present"
      (when (not (eyebrowse--window-config-present-p 2))
        ;; there's probably a better way to do this, creating two workspaces
        (eyebrowse-switch-to-window-config-2)
        (eyebrowse-switch-to-window-config-1)))
    (setq eyebrowse-wrap-around t
          eyebrowse-new-workspace t)
    (eyebrowse-mode 1)
    (global-set-key (kbd "C-'") 'eyebrowse-next-window-config)
    (add-hook 'after-init-hook #'my/create-eyebrowse-setup)))

I noticed that just recently, upon executing this, emacs' transient-mark-mode is completely broken, and I can no longer mark regions for killing. If I disable eyebrowse with M-x eyebrowse-mode then transient-mark-mode goes back to working.

I reduced this down to:

(use-package eyebrowse
  :diminish eyebrowse-mode
  :init
  (progn
    (setq eyebrowse-wrap-around t
          eyebrowse-new-workspace t)
    (eyebrowse-mode 1)
    (global-set-key (kbd "C-'") 'eyebrowse-next-window-config)))

And the problem still persists. If I completely remove any configuration I have for eyebrowse, start Emacs, then do eyebrowse-mode and create a second workspace, again, transient-mark-mode stops working.

wasamasa commented 9 years ago

Hmm, I'll see whether I can reproduce this after the weekend. What Emacs and eyebrowse version are you using?

dakrone commented 9 years ago

Thanks for taking a look, here are the versions:

GNU Emacs 24.5.2 (x86_64-unknown-linux-gnu, X toolkit, Xaw3d scroll bars) of 2015-06-05 on Xanadu.domain

And using eyebrowse-20150611.228/ from MELPA.

wasamasa commented 9 years ago

I can reproduce it here as well. That kind of thing shouldn't happen at all as eyebrowse doesn't hook itself into Emacs' command loop or mouse handler functions, but it unfortunately happens. The reason I was asking for versions was because the package did switch backends for storing window configurations and because Emacs 24.4 and 24.5 display bugs involving transient-mark-mode which no longer happen on Emacs 25.1. I'll see whether it's that and I can figure out a workaround once I identify the problematic part.

wasamasa commented 9 years ago

Bisecting with git revealed that this phenomenon was introduced after I implemented tagging and the bug exists in Emacs 24.3 as well.

wasamasa commented 9 years ago

This is unbelievably stupid. The usage of format-spec set deactivate-mark to a truthy value which due to that variable being global causes deactivation of the mark on any subsequent command. And since that code got evaluated on every redrawing of the mode line indicator, it not only manifested itself after opening a second workspace (because only then the mode line indicator is drawn), but also after every command as every command triggers a redraw.

As of Emacs 25.1 (which isn't released yet), deactivate-mark works buffer-locally, so that should no longer happen, but I'll keep this hack as we won't see that release soon and loads of people are on Emacs releases as low as 24.3.

wasamasa commented 9 years ago

Anyways, thank you very much for reporting this as this bug was driving me up the wall and I'm glad to have fixed it (and other similiar ones in different packages).

dakrone commented 9 years ago

Awesome, thanks for fixing this!