From 3e8808468e0476e3752d80c083f98ceb551a9db4 Mon Sep 17 00:00:00 2001 From: Peter Mao Date: Fri, 30 Jun 2023 21:45:44 -0700 Subject: [PATCH] bugfix: insertion of new headline title In the original code, if there is whitespace on the last line of the file, then the headline will be improperly inserted *after* the whitespace. In this bugfix, we look for `\n` as the last character of the file and add `\n` before "* " if the last character is anything else. --- org-noter.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org-noter.el b/org-noter.el index 2693098..f464214 100644 --- a/org-noter.el +++ b/org-noter.el @@ -266,7 +266,7 @@ DOCUMENT-FILE-NAME is the document filename." (setq notes-files-annotating notes-files) (with-current-buffer (find-file-noselect (car notes-files)) (goto-char (point-max)) - (insert (if (save-excursion (beginning-of-line) (looking-at "[[:space:]]*$")) "" "\n") + (insert (if (save-excursion (backward-char) (looking-at-p "\n")) "" "\n") "* " document-base) (org-entry-put nil org-noter-property-doc-file (file-relative-name document-used-path