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

Editorconfig causes 'Revert buffer from file ...' #246

Closed
melias122 opened this issue Feb 2, 2021 · 11 comments
Closed

Editorconfig causes 'Revert buffer from file ...' #246

melias122 opened this issue Feb 2, 2021 · 11 comments
Assignees

Comments

@melias122
Copy link

melias122 commented Feb 2, 2021

Hey found that editroconfig started to cause this when doing magit interactive rebase. xref-find-references is also affected in some modes in elisp.

Found that something was already done in #240. Tried to with miniconfig:

init-mini.el

(setq package-archives
      '(("gnu"   . "http://elpa.gnu.org/packages/")
        ("melpa" . "http://melpa.org/packages/")))

(package-initialize)

;; editorconfig here
(editorconfig-mode 1)
(require 'magit)

Steps to reproduce similar as in #240

  • emacs -Q -l init-mini.el
  • install editorconfig and `magit
  • in git repo M-x magit-status and r i (rebase interactive) on any git hash.
  • you should see somethig like Revert buffer from file .../.emacs.d/.git/rebase-merge/git-rebase-todo? (y or n)
@stsquad
Copy link
Contributor

stsquad commented Feb 8, 2021

So I've run into this and I think the problem is a combination of having a [*] entry in the project's .editorconfig which causes editorconfig to attempt to reset the mode every time the git-rebase-todo file is loaded. The short term fix is to exclude git-rebase-mode:

(add-to-list 'editorconfig-exclude-modes 'git-rebase-mode)

However I think editorconfig could be a lot smarter here. git-rebase-mode along with other "interactive" style modes are derived from special-mode. I think it would probably make sense for editorconfig-mode-apply to skip settings if any mode is (derived-mode-p 'special-mode).

stsquad added a commit to stsquad/editorconfig-emacs that referenced this issue Feb 8, 2021
…g#246)

Some buffers get confused if you keep setting their mode, one example
is git-rebase-mode. This is an example buffer of a class of
special-mode buffers which are usually (but not always) non-file
buffers. Either way these buffers are usually special purpose
interactive buffers that will only get confused if editorconfig tries
to mess around with them.
@melias122
Copy link
Author

Hey @stsquad, I tried your fix. It helps with magit, but xref-find-references e.g. in .emacs.d is still affected. I tried to remove [*] from editorconfig but that does not help.

For me until now I will stick to d73333c until we have proper fix.

10sr pushed a commit that referenced this issue Feb 9, 2021
Some buffers get confused if you keep setting their mode, one example
is git-rebase-mode. This is an example buffer of a class of
special-mode buffers which are usually (but not always) non-file
buffers. Either way these buffers are usually special purpose
interactive buffers that will only get confused if editorconfig tries
to mess around with them.
@10sr 10sr self-assigned this Feb 9, 2021
@stsquad
Copy link
Contributor

stsquad commented Feb 9, 2021

@melias122 I can use xref-find-references fine in my .emacs.d but perhaps it's a function of how it's setup. I don't have .editorconfig files for it for example. Can you explain in more detail what goes wrong?

@melias122
Copy link
Author

melias122 commented Feb 9, 2021

@stsquad, so I tried everything again and you were right with [*] after removing

[*]
- charset = utf-8

xref works fine on f830b86,

but I still believe this is regression and charset = utf-8 should works just fine with "temporary" buffers like xref.

@10sr
Copy link
Member

10sr commented Feb 12, 2021

Thanks for reporting your issue, and sorry for inconvenience.
I'm planning to change the way how charset will be applied to buffers, so that issues caused by setting buffer charset should be fixed...

@NicolasPetton
Copy link

I haven't looked into exactly which commit introduced the issue, but editorconfig seems to be breaking https://github.com/NicolasPetton/Indium as well.

It seems that when entering indium-debugger-mode, with editorconfig-mode turned on, the buffer gets reverted, losing the debugger mode, which in turn immediately resumes the JavaScript runtime.

I'm not sure if it's the exact same issue as reported by the OP, and I could git bisect the problem if that helps.

@10sr
Copy link
Member

10sr commented Feb 22, 2021

I started testing a new implementation of editorconfig-mode, in hope that the issue reported in #242, #244 and #246 would be solved.
This can be enabled by setting (setq editorconfig--enable-20210221-testing t) before enabling editorconfig-mode.

It is not so tested very well yet, but currently I'm using this impl several days without any problem.
If you are ok with it, I'd be very glad if you try this new version and see if it works better.
Thanks!

@melias122
Copy link
Author

Thanks @10sr, I will do testing and let you know if something is broken (in my case).

benmezger added a commit to benmezger/dotfiles that referenced this issue Apr 17, 2021
benmezger added a commit to benmezger/blog that referenced this issue Apr 17, 2021
@10sr
Copy link
Member

10sr commented Aug 30, 2021

I just merged #263 so this is now enabled by default 🙌 (set editorconfig--legacy-version to disable this and use old version)

@benmezger
Copy link

benmezger commented Aug 30, 2021 via email

@10sr
Copy link
Member

10sr commented Oct 11, 2021

Closing this now.
Please reopen this issue if the problem still exists, thanks!

@10sr 10sr closed this as completed Oct 11, 2021
10sr pushed a commit to 10sr/editorconfig-emacs that referenced this issue Jun 12, 2024
* editorconfig.el: Drop redundant `require`s of pcase, nadvice, rx.
Remove unnecessary (and incorrect) `defvar`s in `eval-when-compile`.
(recentf): Remove `with-eval-after-load` workaround introduced for
issue editorconfig#240 since a real fix was installed (for issue editorconfig#246) since then.
(editorconfig--get-indentation): Use `derived-mode-all-parents` when
available.
(find-library-name, lm-version): Move declarations to right after
the corresponding `require` so we have a reason to believe they're defined.
(editorconfig-version): Use `package-get-version` when available.

* ert-tests/editorconfig-fnmatch.el: Prefer #' to quote function names.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants