Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't disable auto-indent when pasting #8897

Closed
Blaisorblade opened this issue May 14, 2017 · 4 comments
Closed

Can't disable auto-indent when pasting #8897

Blaisorblade opened this issue May 14, 2017 · 4 comments

Comments

@Blaisorblade
Copy link
Contributor

SPC u p should paste without indent, but fails since at least an year.

Spc-u 4 p actually does paste four times without autoindention. Fun.

The relevant issue is #4219, but is mislabeled as question/forum/Python, which might be the reason it's open since a couple of years. There's even a proposed fix at #4219 (comment).

@henriquenj
Copy link
Contributor

I managed to reproduce this problem in the develop branch (3e98896).

Description :octocat:

On master branch, SPC u p fails with ad-Advice-evil-paste-after: Wrong type argument: number-or-marker-p, (4).

On develop branch, it will not fail, instead it will paste the same text 4 times as originally reported, but WITH indentation. This is easy to check on an C++ file, I basically copy some lines starting with "+" (I do this often when I'm copying from git diff buffers) and paste into a C++ buffer. With p, the indentation is performed and the pasted text is all deformed, but this is the expected bahaviour I guess. When using SPC u p, instead of the error, I get four copies of the yanked text, with the same deformation.

Reproduction guide 🪲

  • Start Emacs
  • Copy the following text
+for (auto item : container)
+{
+    std::cout << "items: " << item << std::endl;
+}
  • Paste into a C++ buffer using SPC u p

Observed behaviour: 👀 💔
The text will be pasted 4 times, with indentation.
with_indent

Expected behaviour: ❤️ 😄
The text should be pasted one time, without indentation. This is what I get when adding C++ to spacemacs-indent-sensitive-modes.
without_indent

Analyzing the commands that are bound to p I get the following conclusions: on master branch, p is bound to evil-paste-after (which has specific help text stating how one could paste without indent by using SPC u); however on develop, the command has changed to spacemacs/evil-mc-paste-after, which does not say anything about universal argument, so I'm not sure if this new behaviour of pasting four times is a bug or not, at the very least I think it should be documented somehow.

Workaround

You can somehow work around this bug by modifying the variable spacemacs-indent-sensitive-modes on both develop and master. Here is an example to put into your dotspacemacs/user-config (replace with the modes you intent to paste without formatting)

  ;; I want to disable pasting with formatting on C/C++ buffers
  (add-to-list 'spacemacs-indent-sensitive-modes 'c-mode)
  (add-to-list 'spacemacs-indent-sensitive-modes 'c++-mode)

System Info 💻

  • OS: gnu/linux
  • Emacs: 24.5.1
  • Spacemacs: 0.200.9
  • Spacemacs branch: develop (rev. 3e98896)
  • Graphic display: t
  • Distribution: spacemacs
  • Editing style: vim
  • Completion: ivy
  • Layers:
(ivy emacs-lisp git)

@brabalan
Copy link
Contributor

brabalan commented Mar 1, 2018

I'm also on branch develop (81a931f) and I have the same issue with both SPC u p and SPC u P.

bet4it added a commit to bet4it/spacemacs that referenced this issue Sep 19, 2018
bet4it added a commit to bet4it/spacemacs that referenced this issue Oct 28, 2018
bet4it added a commit to bet4it/spacemacs that referenced this issue Oct 28, 2018
bet4it added a commit to bet4it/spacemacs that referenced this issue Nov 5, 2018
pritambaral added a commit to pritambaral/spacemacs that referenced this issue Jan 17, 2019
The auto-indent advice around evil-paste-{before,after} calls the advised funcs
without removing the universal argument. This results in errors like:

ad-Advice-evil-paste-before: Wrong type argument: number-or-marker-p, (4)

and, ultimately, in the paste failing.

This checks for the universal argument *before* calling the advised funcs,
adjusting the args to remove the universal argument.

Fixes syl20bnr#4219
Fixes syl20bnr#8897
duianto pushed a commit that referenced this issue Apr 25, 2019
@xuhdev
Copy link
Contributor

xuhdev commented Aug 7, 2019

Is this still relevant? I cannot reproduce this issue.

@duianto
Copy link
Contributor

duianto commented Aug 8, 2019

Thanks for testing this, your probably right.

This PR has been merged:
Check for universal argument before paste #11340

It superseeded this PR:
Fix pasting with universal argument #11858
which is marked as fixing this issue.

@duianto duianto closed this as completed Aug 8, 2019
stephanschubert pushed a commit to stephanschubert/spacemacs that referenced this issue Oct 23, 2019
sei40kr pushed a commit to sei40kr/spacemacs that referenced this issue Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants