1. Frank Fischer
  2. evil
  3. Issues
Issue #110 resolved

kill-ring-save doesn't work properly in Emacs 24 with (setq x-select-enable-primary t)

created an issue

To reproduce, use Emacs 24, turn on Evil, and evaluate {{{ (setq x-select-enable-primary t)}}}. Now, enter {{{foo<ESC>v^<M-w>P}}}.

Expected output: {{{foofoo}}}, actual output: {{{fofoo}}}.

Oddly enough, if {{{y}}} is used instead of {{{M-w}}}, things work as expected. Still reporting it as a (possibly obscure) bug in case Emacs users prefer to use {{{M-w}}} instead of {{{y}}} for copying.

Comments (5)

  1. Frank Fischer repo owner
    • changed status to open

    I've looked into this and it seems to be a non-trivial issue. As far as I can tell the problem is that Emacs always submits the internally exclusive selected region to X when the region is actually selected, not when the kill-ring-save command is run (otherwise the region should be correct because Evil normalizes the region to be Emacs-like exclusive just before this command runs). Currently I have no idea how to hook into this behavior, it seems somehow hard-wired into core Emacs code, but I do not really know. The best "fix" in the meantime I can think of is to bind "M-w" to evil-yank and "C-w" to evil-delete.

  2. Frank Fischer repo owner

    Update X selection according to visual state region

    When *selecting* some visual region then the X selection should be updated according to the values of `x-select-enable-primary' and `x-select-enable-clipboard'.

    The default Emacs behavior is to update the X selection whenever the mark is changed if `select-active-regions' is non-nil. This usually interferes with Evil visual state because then the visual selection does not correspond to the Emacs region. This patch sets this variable to temporarily to nil during visual state so Evil takes responsibility for the X selection. The X selection is updated in `evil-visual-post-command' by calling `x-select-text' with the appropriate values.

    This update does not work in block visual state.

    This addresses issue #110. This addresses issue #158.

    Wiki macro error: Changeset 358f9da39a06 not found.

  3. Log in to comment