Visitar URL original
Buffer does not revert or update instantly after formatting buffer · Issue #88 · godotengine/emacs-gdscript-mode · GitHub
Skip to content

Buffer does not revert or update instantly after formatting buffer #88

Open

Description

@NathanLovato

Running gdscript-format-buffer, once the formatting operation completed, does not revert the buffer instantly, letting you type characters that can get lost. That is unlike gdscript-format-region, that locks Emacs until the formatter finished its work (which takes a split second now).

Activity

  1. rileyrg commented on Sep 9, 2020

    @rileyrg
    Contributor

    When using gdscript-format-buffer from "current buffer" then the comint stuff seems overkill. A possibly naive, but functional fix is

    (defun gdscript-format-buffer()
      "Format the current buffer using `gdformat'."
      (interactive)
      (save-mark-and-excursion
        (mark-whole-buffer)
        (gdscript-format-region))
      (when (buffer-modified-p)
        (save-buffer)))
    
    

    It's not saving the point for some reason but it's a start.

    (ps I dont think it should auto save - if I was to PR this I would suggest we remove the buffer-modified-p check - I like to save the buffer myself )

  2. NathanLovato commented on Sep 10, 2020

    @NathanLovato
    CollaboratorAuthor

    gdscript-format--save-buffer saves the buffer before running gdformat, which is necessary: if you run gdformat on a file with unsaved changes, you'll lose your work.

    There are some improvements that comint brought that were a pain before, like gdformat inserting ['-'] at the start of the file. It makes error handling consistent in the package.

    Sure, it was more work, but @VlachJosef did it and did it well. This issue is just a detail: you can type a few characters while gdformat is running in the background and have the buffer revert after a second, which doesn't feel great.

    Note: instead of save-mark-and-excursion, I'd recommend using buffer-end, which returns a position without changing the state of point.

  3. rileyrg commented on Sep 10, 2020

    @rileyrg
    Contributor

    Sure, my observation is not about gdscript-format--save-buffer - just the interactive call to gdscript-format-buffer running on a buffer and not a file. I'll have a look at buffer-end, thanks for the pointer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions