Closed andreyorst closed 2 years ago
ox-hugo
doesn't distinguish between first and later exports.
Were your initial exports on the same day? I am wondering a scenario where you probably had require-final-newline
set to t
, but then you removed it later before your later exports.
oh right, you're correct, there's no newline at the end of the file after the initial export too, I just never noticed this. require-final-newline
is set to t
by default, and I never touch this variable.
require-final-newline is set to t by default, and I never touch this variable
ox-hugo
doesn't touch this variable either. Is it possible you inherited that variable through some config suite like Spacemacs or Doom?
In any case, if you add (setq require-final-newline t)
to your config and evaluate that, you will always have empty newlines at the end of your files after each save. The default of this variable is nil
and in that, the file save operation doesn't modify the end of file newlines.
FWIW I like to end files with newlines and I have (setq require-final-newline t)
in my Emacs config.
ox-hugo
doesn't touch this variable either. Is it possible you inherited that variable through some config suite like Spacemacs or Doom?
no, I don't use any distributions. I now see that this variable is modified by some major modes, and my assumption that it's t
by default was misled. Thanks for the suggestion, I'll add this variable to my init. Closing.
this variable is modified by some major modes
That should be reported as a bug. That variable should be changed only by the user.
That variable should be changed only by the user.
Correcting myself a bit. A major mode should not change that variable to nil.
From https://www.gnu.org/software/emacs/manual/html_node/emacs/Customize-Save.html,
Some major modes are designed for specific kinds of files that are always supposed to end in newlines. Such major modes set the variable require-final-newline to the value of mode-require-final-newline, which defaults to t. By setting the latter variable, you can control how these modes handle final newlines.
Actual Behavior
Unlike initial export, after re-exporting a buffer, either from a file or from a subtree, the resulting file has no newline at the end.
Magit complains about it:
(In the old times, the absence of a final newline meant that the file is a binary data)
Expected Behavior
Newline is appended.
How to Reproduce the Issue
Re-export any existing file.
Ox-Hugo Debug Information
Debug Info
# Debug information for `ox-hugo` ## Emacs Version GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.30, cairo version 1.17.4) of 2022-08-09 (commit 2504d19dade7bcfcce7cd93011edf06f3c955a50) ## Org Version Org mode version 9.5.4 (release_9.5.4-17-g6e991f @ /home/alist/.local/share/emacs/29.0.50/lisp/org/) ## Hugo Version hugo v0.93.3+extended linux/amd64 BuildDate=unknown ### Org `load-path` shadows No Org mode shadows found in `load-path` ## `ox-hugo` defcustoms