prettier / prettier-emacs

Minor mode to format JS code on file save
http://jlongster.com/A-Prettier-Formatter
372 stars 53 forks source link

Handle cloned buffers and give a friendly error message when not visiting a file #76

Open michaeldickens opened 8 months ago

michaeldickens commented 8 months ago

Fix for https://github.com/prettier/prettier-emacs/issues/75.

  1. Get the buffer file using (buffer-file-name (buffer-base-buffer)) instead of buffer-file-name. The new code also works with indirect buffers.
  2. In case the file can't be found, raise a helpful error message.

Note: I am not familiar at all with prettier-js, I just noticed this problem while trying to use it and the fix looked easy enough. Please check to make sure this PR doesn't screw anything up.