Skip to content

Apply patch instead of replacing whole bufferΒ #15

@bdarnell

Description

@bdarnell

Replacing the entire buffer with copy-to-buffer is disruptive: It's a delete followed by a replace, and many links within emacs (including compilation, grep, and occur buffers) will overreact to the deletion by redirecting all links to the beginning of the file. (Reinserting the whole file also causes it to be reparsed for syntax highlighting, which can be kind of slow)

The support for gofmt in go-mode shows a better way, although it's unfortunately a nontrivial amount of code. go-mode asks for a diff instead of rewriting the whole file, then parses the diff and translates it into editing commands. It would be nice if blacken did the same (It would be even nicer if there were one meta-fmt mode for emacs so that this wheel doesn't have to be reinvented for every formatting tool).

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions