emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Akash <akashpaul21@gmail.com>
To: akashpaul21@gmail.com
Cc: emacs-orgmode@gnu.org
Subject: Re: org-element-cache error when storing footnotes using capture buffer
Date: Fri,  4 Oct 2024 16:13:57 +0530	[thread overview]
Message-ID: <20241004104357.119625-1-akashpaul21@gmail.com> (raw)
In-Reply-To: <CA+6WspJ8J+iBzL+CQr5JTZUE5hhhHBrUunLw2naKpxwpv1DNqA@mail.gmail.com>


Dear Maintainers,

I seem to have been able to solve this issue through some brute force debugging.
The problem emanates from when copying over the local variables, especially the `buffer-file-name' variable

The function definition `org-src--edit-element' contains a provision to make the said variable nil - but it is quickly reset during initialisation of the buffer just 1 line downstream. Moving the setq statement 4 lines below seems to solve the issue,

Herein I give the patch,

```
--- org-src.el	2024-10-04 15:54:11.357117268 +0530
+++ org-src-patched.el	2024-10-04 15:55:24.041730163 +0530
@@ -609,7 +609,6 @@
 	(let ((lf (eq type 'latex-fragment)))
           (unless preserve-ind (org-do-remove-indentation (and lf block-ind) lf)))
 	(set-buffer-modified-p nil)
-	(setq buffer-file-name nil)
 	;; Initialize buffer.
 	(when (functionp initialize)
 	  (let ((org-inhibit-startup t))
@@ -617,6 +616,7 @@
 		(funcall initialize)
 	      (error (message "Initialization fails with: %S"
 			      (error-message-string e))))))
+	(setq buffer-file-name nil)
 	;; Transmit buffer-local variables for exit function.  It must
 	;; be done after initializing major mode, as this operation
 	;; may reset them otherwise.

```

The following in .init can also be done by users not willing to patch the source file `org-src.el'

;; HHHH---------------------------------------------------

(defun patch/org-src--edit-element (&rest args)
  (setq-local buffer-file-name nil))
(advice-add 'org-src--edit-element
	    :after
	    #'patch/org-src--edit-element)

;; HHHH---------------------------------------------------


Thank you,
Akash P



  reply	other threads:[~2024-10-04 10:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-02 18:35 org-element-cache error when storing footnotes using capture buffer Akash Pal
2024-10-04 10:43 ` Akash [this message]
2024-10-13 10:20 ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241004104357.119625-1-akashpaul21@gmail.com \
    --to=akashpaul21@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).