Malabarba / aggressive-indent-mode

Emacs minor mode that keeps your code always indented. More reliable than electric-indent-mode.
850 stars 36 forks source link

query-replace with ido-hacks-mode corrupts text #130

Open oscarfv opened 4 years ago

oscarfv commented 4 years ago

Save this code to foo.el after adjusting the first line if needed:

(load-library "~/aggressive-indent.el")
(aggressive-indent-mode 1)
(query-replace "foo" "x")

(when nil
  (foo c
       "hello")
  (foo c))

Now invoke Emacs:

emacs -Q foo.el

Now M-x eval-buffer. Press y to accept the first replacement; the line "hello" is re-indented. Press y again to accept the second replacement. The line (foo c) is replaced with (fox.

oscarfv commented 4 years ago

I see aggressive-indent-protected-current-commands contains query-replace. I don't know why it is ignored.

BTW, this was tested with Emacs 26 and 27. a-i-m is up to date.

oscarfv commented 4 years ago

Nevermind. The recipe above is not valid because query-replace is not called interactively.

In my case the problem was observed while executing query-replace interactively. The cause was ido-hacks-mode, which makes this-command return ido-exit-minibuffer.

(add-to-list 'aggressive-indent-protected-current-commands 'ido-exit-minibuffer)

fixes the problem, although I don't know if it has implications elsewhere.