Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Usage of (save-excursion) SF interferes with format-on-save configuration in Clojure/Cider setups #45

@nsadeh

Description

@nsadeh

This is technically not a bug in super-save but rather an oddity of (save-excursion), but in my Prelude setup it's coming from super-save so I am wondering if it's possible to tinker with super-save to work around it.

Expected behavior

When triggering super-save hooks with a format-on-save hook ((add-hook 'before-save-hook 'cider-format-buffer) in init.el), the file should format and the cursor should stay in its appropriate place, just like it stays there when you run cider-format-buffer or basic-buffer-save without super-save

Actual behavior

Triggering the super-save hook (e.g., navigating to a different application) saves and formats the document, but the cursor yeets to the beginning of the buffer

Steps to reproduce the problem

  1. Install and setup super-save as per the instructions (or by installing Prelude), and add focus-out to the trigger list
  2. Add (add-hook 'before-save-hook 'cider-format-buffer) to init.el to format on save
  3. Test by manually saving and see that the format hook runs
  4. Test the described behavior by navigating to a different application and returning
  5. The cursor should be at the beginning of the buffer

Environment & Version information

super-save version

Version: 20231209.1044

Emacs version

29.1

Operating system

macOS Sonoma 14.1.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions