bastibe / org-journal

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

org-download behavior differences between org-mode and org-journal-mode #341

Closed jackbaty closed 1 year ago

jackbaty commented 3 years ago

Describe the bug I don't know if this is intended behavior or a bug, but I'm trying to understand why when using org-download the behavior is different when dragging and dropping a file onto an org-journal buffer vs onto an org-mode buffer.

In org-mode buffers, an image file dragged onto the buffer copies the file into my org-attach-dir ("attach/") in a directory such as "attach/52/acfc49-b9e7-4fd2-a740-6d41b0e1ac55/2021-03-31_10-36-58_test.jpg" and the link in the buffer would be [[attachment:2021-03-31_10-36-58_jd.png]].

In org-journal buffers, dragging that same image results in an empty folder created in the "attach/" directory (e.g "attach/0d/ce132b-68b9-4e47-950e-57d9c467b60f") but the actual file is copied to a folder directly in my org-journal-dir named like this "Wednesday,_March_31_2021/". and the link like this: [[attachment:../../../Wednesday,_March_31_2021/2021-03-31_11-10-15_jd.png]].

Expected behavior

Basically I would expect drag-and-drop into an org-journal-mode buffer to behave the same as if it were an org-journal buffer.

Desktop (please complete the following information):

Your Emacs Configuration

Note that I'm using Doom Emacs but not using the built-in configuration for the org packages (so, no +journal or +dragndrop are set in init.el). I've tried various combinations of the doom config, etc.

(setq org-attach-id-dir  "attach/")
(setq org-attach-auto-tag nil)

(use-package! org-download
  :config
  (setq org-download-method 'attach
    org-download-image-dir "attach/"
    org-download-image-org-width 600
    org-download-heading-lvl nil))

(use-package! org-journal
  :config
  (setq org-journal-dir "~/Dropbox/notes/journal"
    org-journal-file-type 'monthly
    org-journal-file-format "%Y-%m.org"
    org-journal-find-file #'find-file
    org-journal-time-prefix ""
    org-journal-time-format ""
    org-journal-enable-agenda-integration nil
    org-journal-enable-encryption nil
    org-journal-date-format "%A, %B %d %Y"))

I feel like this has to be a load order issue or something but it's beyond me. If this not an org-journal issue, maybe point me in the proper direction.

jackbaty commented 3 years ago

Note that if I do use the default Doom configuration (via +journal and +dragndrop) in init.el instead of with just use-package!, the behavior is still different, but in a different way.

Dragging an image into an org-journal-mode buffer using Doom's config still causes an empty folder to be created at e.g. "attach/0d/ce132b-68b9-4e47-950e-57d9c467b60f" but the actual file is copied into the base org-attach-id-dir directory, e.g. "attach/_20210331_115505jd.png" rather than into "journal/Wednesday,_March_31_2021".

bastibe commented 3 years ago

I have no idea what could cause this, honestly. Can you debug this issue further? Presumably, some default path inside org-download or org-attach is probably overwritten somewhere.

casch-at commented 3 years ago

Hmm. I quick test with Emacs-27 on Ubuntu works, although the structure it creates is a little different than it would be in org-mode.

A folder attach and data are created, while in org-mode only the folder data is created. In org-journal the file gets than added to the folder attach and the data/??/ID folder stays empty. In org-mode the file gets added to the data/??/ID folder, and the folder attach is never created. This explains the link url, attachment:../../../attach/FILENAME vs attachment:FILENAME

But, based on your configuration shouldn't it actually be added to the folder attach, instead of data in org-mode too?

.:
 .   ..   20180101   20190101   20200101   20210101   .#20210101  '#20210101#'   attach   data   .dir-locals.el

./attach:
.   2021-04-01_13-29-47_08-002-1920x1100.jpg  2021-04-01_13-30-58_nature-images.jpg
..  2021-04-01_13-30-25_nature-images.jpg     2021-04-01_13-32-58_Natural-World-Wallpaper-HD-.jpg

./data:
.  ..  a2  b6  f4

./data/a2:
.  ..  1f1a62-a99b-423b-b0bf-c4cb5226a1c8

./data/a2/1f1a62-a99b-423b-b0bf-c4cb5226a1c8:
.  ..

./data/b6:
.  ..  233d0b-f89d-41ca-ae20-f8bec7f07fa9

./data/b6/233d0b-f89d-41ca-ae20-f8bec7f07fa9:
.  ..

./data/f4:
.  ..  f17027-5029-485b-928a-95da9259acbd

./data/f4/f17027-5029-485b-928a-95da9259acbd:
.  ..

image

We actually have planned to get rid of the major mode org-journal and make it a minor mode which would solve the problem.

jackbaty commented 3 years ago

Thanks for looking into this. As this is really only a minor annoyance, I think the best answer (for me) is to just wait out the move from major to minor mode and it'll solve itself.