all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Help with assigning org-attach-id-dir using directory local variables
@ 2022-06-11  0:44 Alen Alex Ninan
  2022-06-11 11:56 ` [PATCH] " Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Alen Alex Ninan @ 2022-06-11  0:44 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1871 bytes --]

Hi All,

I use org-attach to copy and attach images in my org-mode notes. I would 
like to assign org-attach-id-dir using directory local variable. Please 
find the statements I use in directory local file to define my org-roam 
directory and org-attach-id-dir below for reference.


Directory local configuration:

((nil . ((eval . (setq-local
                   org-roam-directory (expand-file-name 
(locate-dominating-file
default-directory ".dir-locals.el"))))
          (eval . (setq-local
                   org-roam-db-location (expand-file-name "org-roam.db"
org-roam-directory)))
          (eval . (setq-local
                   org-attach-id-dir (expand-file-name "attachments"
org-roam-directory)))
          )))


My Emacs and Org-mode configuration:

Org: 9.6

Emacs: 28.1 (Doom Emacs)


The org-mode file opened from this directory respects the attachment 
location defined in directory local variable when display of inline 
images during start-up is disabled. Org mode displays the attachments 
once the org file is open, and I toggle display of inline image. The 
same files throw an error when I open the file with inline images 
enabled at startup.

1. Have I made an error in how I define the directory local file?

2. If I have not made and error, Is it possible to define the attachment 
directory in directory local variable and have org mode respect the 
location when display of inline images are enabled during startup?

3. If I did make an error, do you have any recommendation on how I can 
resolve this?

I am new to Emacs, and I am not good at Emacs Lisp currently. It's 
something I am trying to learn. Any suggestions or recommendation would 
help. I am open to testing this out in stock Emacs if that's something 
that will help.


Thanks & Regards,

Alen Alex



[-- Attachment #2: Type: text/html, Size: 3113 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] Re: Help with assigning org-attach-id-dir using directory local variables
  2022-06-11  0:44 Help with assigning org-attach-id-dir using directory local variables Alen Alex Ninan
@ 2022-06-11 11:56 ` Ihor Radchenko
  2022-07-31 10:25   ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2022-06-11 11:56 UTC (permalink / raw)
  To: Alen Alex Ninan; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 769 bytes --]

Alen Alex Ninan <alenishere@gmail.com> writes:

> 1. Have I made an error in how I define the directory local file?

No.

> 2. If I have not made and error, Is it possible to define the attachment 
> directory in directory local variable and have org mode respect the 
> location when display of inline images are enabled during startup?

The problem you are seeing is because Emacs assigns directory-local and
buffer-local variables _after_ Org mode (or any other major mode) is
loaded.

Org startup staff happens during loading before directory-local
variables are assigned. Hence error.

I've seen multiple issues coming from the above behavior.
Hence, I'd like to propose Org to call `hack-local-variables' early
during startup. The patch is attached.

Best,
Ihor


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-mode-Make-local-variables-effective-during-Org-s.patch --]
[-- Type: text/x-patch, Size: 1193 bytes --]

From 85af884fcb70cda42acd4cb1610411dcacac82b9 Mon Sep 17 00:00:00 2001
Message-Id: <85af884fcb70cda42acd4cb1610411dcacac82b9.1654948539.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Sat, 11 Jun 2022 19:53:37 +0800
Subject: [PATCH] org-mode: Make local variables effective during Org startup

* lisp/org.el (org-mode): Call `hack-local-variables' early during Org
mode startup.  This way, Org startup options will regard local
variable settings.

Fixes
https://list.orgmode.org/587be554-906c-5370-2cf2-f08b14fa58ff@gmail.com/T/#u
---
 lisp/org.el | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lisp/org.el b/lisp/org.el
index 080962cdb..2b8a6cd10 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4606,6 +4606,10 @@ (define-derived-mode org-mode outline-mode "Org"
 
 \\{org-mode-map}"
   (setq-local org-mode-loading t)
+  ;; Apply file-local and directory-local variables, so that Org
+  ;; startup respects them.  See
+  ;; https://list.orgmode.org/587be554-906c-5370-2cf2-f08b14fa58ff@gmail.com/T/#u
+  (hack-local-variables 'ignore-mode-settings)
   (org-load-modules-maybe)
   (org-install-agenda-files-menu)
   (when (and org-link-descriptive
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Re: Help with assigning org-attach-id-dir using directory local variables
  2022-06-11 11:56 ` [PATCH] " Ihor Radchenko
@ 2022-07-31 10:25   ` Ihor Radchenko
  2022-08-05 11:55     ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2022-07-31 10:25 UTC (permalink / raw)
  To: Alen Alex Ninan; +Cc: emacs-orgmode

Ihor Radchenko <yantar92@gmail.com> writes:

> I've seen multiple issues coming from the above behavior.
> Hence, I'd like to propose Org to call `hack-local-variables' early
> during startup. The patch is attached.

Applied onto main via e22b4eb7a.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e22b4eb7aab9668826dc8ba76ea1d1d7b144a856

Best,
Ihor


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Re: Help with assigning org-attach-id-dir using directory local variables
  2022-07-31 10:25   ` Ihor Radchenko
@ 2022-08-05 11:55     ` Ihor Radchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2022-08-05 11:55 UTC (permalink / raw)
  To: Alen Alex Ninan; +Cc: emacs-orgmode

Ihor Radchenko <yantar92@gmail.com> writes:

> Ihor Radchenko <yantar92@gmail.com> writes:
>
>> I've seen multiple issues coming from the above behavior.
>> Hence, I'd like to propose Org to call `hack-local-variables' early
>> during startup. The patch is attached.
>
> Applied onto main via e22b4eb7a.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e22b4eb7aab9668826dc8ba76ea1d1d7b144a856

Unfortunately, I had to revert the patch.
It creates too many issues with no good workarounds.

I instead asked Emacs devs to implement an API to let major mode decide
when local variables are loaded.
See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=57003

Best,
Ihor


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-08-05 11:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-11  0:44 Help with assigning org-attach-id-dir using directory local variables Alen Alex Ninan
2022-06-11 11:56 ` [PATCH] " Ihor Radchenko
2022-07-31 10:25   ` Ihor Radchenko
2022-08-05 11:55     ` Ihor Radchenko

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.