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

isortify adds escape sequence at end of file #6

Open
Paethon opened this issue Feb 10, 2021 · 2 comments
Open

isortify adds escape sequence at end of file #6

Paethon opened this issue Feb 10, 2021 · 2 comments

Comments

@Paethon
Copy link

Paethon commented Feb 10, 2021

Whenever I run isortify-buffer or have isortify-mode on, an escape sequence is added to the buffer which I have to manually remove.

image

Previously this did not happen. Maybe it is a problem with newer isort-versions? Currently using isort v5.7.0

@Paethon
Copy link
Author

Paethon commented Feb 10, 2021

My solution is to add (replace-string "^[[0m" "") (the ^[ has to be typed using c-q ESC) directly after (kill-buffer tmpbuf) which solves the problem, but is obviously a pretty horrible hack ...

isortify/isortify.el

Lines 119 to 121 in ae7fb71

(kill-buffer tmpbuf)
(goto-char original-point)
(set-window-start (selected-window) original-window-pos))

@Paethon
Copy link
Author

Paethon commented Feb 18, 2021

There is actually a nicer solution using advise-add

(defun isortify-cleanup (x)
  (let* ((original-point (point)))
    (search-forward "^[[0m")
    (replace-match "")
    (goto-char original-point)))

(advice-add 'isortify-buffer :filter-return #'isortify-cleanup)

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

1 participant