From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Modi Subject: Re: Buffer local value lost when exporting? (was Evaluate all org tables in file before exporting) Date: Fri, 13 May 2016 16:33:05 +0000 Message-ID: References: <1ce7789874d84d4d861eabf587693621@HE1PR01MB1898.eurprd01.prod.exchangelabs.com> <87mvnujv5j.fsf@ucl.ac.uk> <87lh3e7wn8.fsf@saiph.selenimh> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a1137be76d5d4d60532bbd4b4 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:33628) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b1G1d-00065j-3c for emacs-orgmode@gnu.org; Fri, 13 May 2016 12:33:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b1G1b-0005x5-G1 for emacs-orgmode@gnu.org; Fri, 13 May 2016 12:33:16 -0400 Received: from mail-oi0-x230.google.com ([2607:f8b0:4003:c06::230]:33461) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b1G1b-0005wx-8E for emacs-orgmode@gnu.org; Fri, 13 May 2016 12:33:15 -0400 Received: by mail-oi0-x230.google.com with SMTP id v145so178554759oie.0 for ; Fri, 13 May 2016 09:33:15 -0700 (PDT) In-Reply-To: <87lh3e7wn8.fsf@saiph.selenimh> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-org list , Nicolas Goaziou , Eric S Fraga --001a1137be76d5d4d60532bbd4b4 Content-Type: text/plain; charset=UTF-8 On Fri, May 13, 2016 at 12:25 PM Nicolas Goaziou wrote: > For completeness, export process actually inherits some buffer local > values. See `org-export--generate-copy-script', in particular > > ;; Copy specific buffer local variables and variables set > ;; through BIND keywords. > ,@(let ((bound-variables (org-export--list-bound-variables)) > vars) > (dolist (entry (buffer-local-variables (buffer-base-buffer)) vars) > (when (consp entry) > (let ((var (car entry)) > (val (cdr entry))) > (and (not (memq var org-export-ignored-local-variables)) > (or (memq var > '(default-directory > buffer-file-name > buffer-file-coding-system)) > (assq var bound-variables) > (string-match "^\\(org-\\|orgtbl-\\)" > (symbol-name var))) > ;; Skip unreadable values, as they cannot be > ;; sent to external process. > (or (not val) (ignore-errors (read (format "%S" val)))) > (push `(set (make-local-variable (quote ,var)) > (quote ,val)) > vars)))))) > > So basically, it copies all Org related variables, default directory, > buffer-file-name buffer-file-coding-system and any variable defined as > a BIND keyword, provided their value is `read'-able (e.g., not a hash > table). > Thanks for that info guys! It got it working after setting org-export-allow-bind-keywords to t BUT now I need to set the buffer local value twice: (1) Using the Local Variables footer style so that that local value is effective when before-save-hook is run (2) Using #+BIND so that that value is effective when org-export-before-processing-hook is run. Below is the MWE now: ===== | N | |---| | | | | | | | | #+TBLFM: $1=@#-1 #+BIND: modi/org-table-enable-buffer-wide-recalculation nil # Local Variables: # modi/org-table-enable-buffer-wide-recalculation: nil # End: ===== -- -- Kaushal Modi --001a1137be76d5d4d60532bbd4b4 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Fri, May 13= , 2016 at 12:25 PM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
For completeness, export process actually inherits some buffer loc= al
values. See `org-export--generate-copy-script', in particular

=C2=A0 ;; Copy specific buffer local variables and variables set
=C2=A0 ;; through BIND keywords.
=C2=A0 ,@(let ((bound-variables (org-export--list-bound-variables))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 vars)
=C2=A0 =C2=A0 =C2=A0 (dolist (entry (buffer-local-variables (buffer-base-bu= ffer)) vars)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (when (consp entry)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (let ((var (car entry))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (val (cdr entry)))<= br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (and (not (memq var org-export-ig= nored-local-variables))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(or (memq var=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0'(default-directory
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 buffer-file-name
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 buffer-file-coding-system))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0(assq var bound-variables)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0(string-match "^\\(org-\\|orgtbl-\\)"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(symbol-name var)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; Skip unrea= dable values, as they cannot be
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; sent to ex= ternal process.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(or (not val)= (ignore-errors (read (format "%S" val))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(push `(set (= make-local-variable (quote ,var))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(quote ,val))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0vars))))))

So basically, it copies all Org related variables, default directory,
buffer-file-name buffer-file-coding-system and any variable defined as
a BIND keyword, provided their value is `read'-able (e.g., not a hash table).

Thanks for that info guys!

It got it working after setting org-export-allow-bind-= keywords to t BUT now I need to set the buffer local value twice: (1) Using= the Local Variables footer style so that that local value is effective whe= n before-save-hook is run (2) Using #+BIND so that that value is effective = when =C2=A0org-export-before-processing-hook is run.

Below is the MWE now:

=3D=3D=3D=3D=3D
| N |
|---|
| =C2=A0 |
| =C2=A0 |
=
| =C2=A0 |
| =C2=A0 |
#+TBLFM: $1=3D@#-1

#+BIND: modi/org-table-enable-buffer-wide-recalculation nil=
# Local Variables:
# modi/org-table-enable-buffer-wide= -recalculation: nil
# End:
=3D=3D=3D=3D=3D
<= div>
--

-- <= br> Kaushal Modi

--001a1137be76d5d4d60532bbd4b4--