Re: Re: Adding functionality to org-latex-classes

2024-01-01 Thread Pedro Andres Aranda Gutierrez
Thanks, I'll check it out!
Just a way to get over some sleepless nights...

/PA

On Mon, 1 Jan 2024 at 10:17, Ihor Radchenko  wrote:

> Pedro Andres Aranda Gutierrez  writes:
>
> > Attached is a concept which might be useful. At least it detects when
> > variables are set locally and then doesn't attempt anything.
>
> You may rather need to hack on `org-export-get-environment', possibly
> extending it. For example, we may allow more flexible
> `org-export-options-alist'.
>
> > (defun is-in-local-variable-alists (sym)
> >   "Check if symbol is in any local variable alist"
> >   (when
> >   (or (and (boundp 'connection-local-variables-alist)
> >(assoc sym connection-local-variables-alist))
> >   (and (boundp 'file-local-variables-alist)
> >(assoc sym file-local-variables-alist))
> >   (and (boundp 'dir-local-variables-alist)
> >(assoc sym dir-local-variables-alist)))
> > t))
>
> Note that you can simply use `buffer-local-boundp'.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
>


-- 
Fragen sind nicht da, um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler

Headaches with a Juju log:
unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run
a leader-deposed hook here, but we can't yet


Re: Re: Adding functionality to org-latex-classes

2024-01-01 Thread Ihor Radchenko
Pedro Andres Aranda Gutierrez  writes:

> Attached is a concept which might be useful. At least it detects when
> variables are set locally and then doesn't attempt anything.

You may rather need to hack on `org-export-get-environment', possibly
extending it. For example, we may allow more flexible
`org-export-options-alist'. 

> (defun is-in-local-variable-alists (sym)
>   "Check if symbol is in any local variable alist"
>   (when
>   (or (and (boundp 'connection-local-variables-alist)
>(assoc sym connection-local-variables-alist))
>   (and (boundp 'file-local-variables-alist)
>(assoc sym file-local-variables-alist))
>   (and (boundp 'dir-local-variables-alist)
>(assoc sym dir-local-variables-alist)))
> t))

Note that you can simply use `buffer-local-boundp'.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Re: Adding functionality to org-latex-classes

2024-01-01 Thread Pedro Andres Aranda Gutierrez
>Message: 16
>Date: Sun, 31 Dec 2023 14:40:32 +
>From: Ihor Radchenko 
>To: Pedro Andres Aranda Gutierrez 
>Cc: Org Mode List 
>Subject: Re: Adding functionality to org-latex-classes
>Message-ID: <87ttny77vj.fsf@localhost>
>Content-Type: text/plain
>
>Pedro Andres Aranda Gutierrez  writes:
>
>> I was just wondering whether it would be possible to add further
>> functionality to org-latex-classes and would like to start a discussion
;-)
>>
>> My use case is the following:
>>
>> The document class is tightly coupled with  ~org-latex-subtitle-format~
>> and  ~org-latex-subtitle-separate~. Koma-script classes, for example,
need
>> those variables to be defined with file or directory local variables in
>> order to take full profit of the layouts. If we found a way of
>> accommodating them in the class definitions, the fuzz of the extra
>> variables could easily be overcome.
>
>We may extend `org-latex-classes' to allow custom backend option values.
>For example,
>
>  (latex-subtitle-format . value)
>  (latex-subtitle-separate . value)
>
>Then, we can use these values as the overrides when the variables are
>not set explicitly as buffer-locals or as in-buffer/subtree export
>keywords.
>
>--
>Ihor Radchenko // yantar92,
>Org mode contributor,
>Learn more about Org mode at <https://orgmode.org/>.
>Support Org development at <https://liberapay.com/org-mode>,
>or support my work at <https://liberapay.com/yantar92>

Attached is a concept which might be useful. At least it detects when
variables are set locally and then doesn't attempt anything.

Peaceful New Year,
/PA

-- 
Fragen sind nicht da, um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler

Headaches with a Juju log:
unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run
a leader-deposed hook here, but we can't yet
;; This buffer is for text that is not saved, and for Lisp evaluation.
;; To create a file, visit it with 'C-x C-f' and enter text in its buffer.


(defun is-in-local-variable-alists (sym)
  "Check if symbol is in any local variable alist"
  (when
  (or (and (boundp 'connection-local-variables-alist)
   (assoc sym connection-local-variables-alist))
  (and (boundp 'file-local-variables-alist)
   (assoc sym file-local-variables-alist))
  (and (boundp 'dir-local-variables-alist)
   (assoc sym dir-local-variables-alist)))
t))

(defun local-or-latex-class ()
  (interactive)
  ;;
  ;; This would come from ox-latex
  ;;
  (let ((test '((org-latex-subtitle-format . "\\subtitle{%s}")
(org-latex-subtitle-separate . t
(mapcar #'(lambda (element)
(let* ((sym (car element))
   (skip (is-in-local-variable-alists sym))
   (sym-name (symbol-name sym))
   (val (cdr element)))
  ;; (message "--> %s" element)
  ;; (if skip
  ;; (message "%s set as file-local" sym-name)
  ;;   (progn
  ;; (message "Will set %s to %s" sym-name val)
  ;; (eval '(setq sym-name val))
  (unless skip
(eval '(setq sym-name val)
test)
(message "Is separate: %s" org-latex-subtitle-separate)
(message "subtitle: %s" org-latex-subtitle-format))
  )