syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.67k stars 4.89k forks source link

Unable to use `ediff-region-wordwise/linewise` #12498

Closed c02y closed 4 years ago

c02y commented 5 years ago

Description :octocat:

When I try to use ediff-region-wordwise/linewise in vanilla emacs, emacs asks me to choose buffers and then mark one region, C-M-c, and mark another region, C-M-c again to ediff the regions. This works very well when I try it in emacs -q or emacs with my own init.el, but when I try it in spacemacs with even fresh installation, one of the two regions in ediff session is not right, it is empty or just part of what I marked. I recorded a gif. Sorry about that the keystrokes were not captured, but I did follow the instructions to hit the keystrokes.

Reproduction guide :beetle:

Observed behaviour: :eyes: :broken_heart: One of the two buffers in ediff session is not right, it is empty or just part of what I marked

Expected behaviour: :heart: :smile: Two buffers in ediff session should be exactly what I marked.

System Info :computer:

Backtrace :paw_prints:

<<BACKTRACE IF RELEVANT>>

recorded

duianto commented 5 years ago

Confirmed.

The issue occurs when the dotspacemacs-distribution variable is set to 'spacemacs at the top of .spacemacs.

But it works as expected when it's set to 'spacemacs-base.

So there's some setting/package that causes it.

System Info :computer:

Mikevin commented 5 years ago

'spacemacs-base configures ediff like this

This could explain the difference.

f380cedric commented 5 years ago

On develop branch, commenting spacemacs-purpose in spacemacs/layers/+distributions/spacemacs/layers.el (line) does the trick. There is something to blame in the spacemacs-purpose layer.

duianto commented 5 years ago

@f380cedric Nice catch, it seems like it might be window-purpose related.

@bmag Do you know what could be going on here?

Two example functions:

    (defun clipboard/set (astring)
      "Copy a string to clipboard"
      (with-temp-buffer
        (insert astring)
        (clipboard-kill-region (point-min) (point-max))))

    (defun clipboard/get ()
      "Return the content of clipboard as string"
      (interactive)
      (with-temp-buffer
        (clipboard-yank)
        (buffer-substring-no-properties (point-min) (point-max))))

source: https://caiorss.github.io/Emacs-Elisp-Programming/Elisp_Snippets.html#sec-1-5

Reproduction steps

Observed

With window-purpose (Spacemacs develop branch without any window-purpose changes)

ediff-regions-wordwise

ediff-regions-wordwise

The same steps above except by calling ediff-regions-linewise.

ediff-regions-linewise

With window-purpose excluded (and Spacemacs restarted)

dotspacemacs-excluded-packages '(window-purpose)

ediff-regions-wordwise

ediff-regions-wordwise-window-purpose-excluded

ediff-regions-linewise

ediff-regions-linewise-window-purpose-excluded

bmag commented 5 years ago

Thanks for the report and repro steps everyone. I looked into the matter and found that:

I wasn't able to find what causes the buggy behavior in ediff-clone-buffer-for-region-comparison, but I was to come up with a workaround. Put this in user-config, it disables purpose-mode during the call to ediff-clone-buffer-for-region-comparison:

(defun bm-adv-without-purpose (fn &rest args)
  (without-purpose (apply fn args)))
(advice-add #'ediff-clone-buffer-for-region-comparison :around #'bm-adv-without-purpose)

Are there any more buggy ediff commands other than ediff-region-wordwise/linewise?

duianto commented 5 years ago

Confirmed that snippet seems to fix it.

I tried a couple of the other ediff commands and they seem to work, it might just be the region commands that have this issue.

I'm getting an unrelated issue with ediff3, ediff-buffers3, ediff-files3 and ediff-merge

/usr/bin/diff3: diff failed:

Even though:

(executable-find "diff3")

returns:

"c:/tools/cygwin/bin/diff3.exe"

github-actions[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

c02y commented 4 years ago

This bug seems fixed without the code snippet(bm-adv-without-purpose) posted by @bmag

f380cedric commented 4 years ago

Same here, seems fixed.

duianto commented 4 years ago

Confirmed, it seems to be working as expected without any changes.

Windows 1903, System Info (click to expand)
#### System Info :computer:
- OS: windows-nt
- Emacs: 27.1
- Spacemacs: 0.300.0
- Spacemacs branch: develop (rev. 76301564c)
- Graphic display: t
- Distribution: spacemacs
- Editing style: vim
- Completion: helm
- Layers:
```elisp
(emacs-lisp git helm lsp multiple-cursors org
            (python :variables python-backend 'lsp python-lsp-server 'mspyls)
            version-control treemacs)
```
- System configuration features: XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY W32NOTIFY ACL GNUTLS LIBXML2 HARFBUZZ ZLIB TOOLKIT_SCROLL_BARS MODULES THREADS JSON PDUMPER LCMS2 GMP