bastibe / org-journal

A simple org-mode based journaling mode
BSD 3-Clause "New" or "Revised" License
1.25k stars 124 forks source link

`org-journal-new-entry` insert duplicate header on narrowed journal buffer #437

Open snowman opened 7 months ago

snowman commented 7 months ago

Describe the bug org-journal-new-entry insert duplicate header on narrowed journal buffer

To Reproduce

$ emacs -Q -l /path/to/org-journal.el
;; M-x eval-expression RET (  shortcut M-:  )
(progn
  (call-interactively 'org-journal-new-entry)
  (end-of-buffer)
  (shr-ensure-newline)
  (skip-chars-backward "[ \n]")
  ;; narrow down to last entry
  (narrow-to-region (pos-bol) (point-max))
  (call-interactively 'org-journal-new-entry)
  (widen)
)

buffer content

* Sunday, 03/31/2024
** 17:41 
* Sunday, 03/31/2024
** 17:41

Expected behavior do NOT insert duplicate daily header, widen before calling function

* Sunday, 03/31/2024
** 17:41
** 17:41
(defun org-journal-new-entry
  (save-restriction
    (widen)
     ...))

Screenshots no

Desktop (please complete the following information):

Your Emacs Configuration no