[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Open a footnote definition outside a narrowed subtree (workaround)
From: |
Juan Manuel Macías |
Subject: |
Open a footnote definition outside a narrowed subtree (workaround) |
Date: |
Tue, 22 Feb 2022 16:04:13 +0000 |
Hi all,
When I am working on a narrowed subtree and want to open a footnote for
editing (`C-c C-o': `org-open-at-point'), I get the message: "Definition
is outside narrowed part of buffer". I don't know if there is a
"standard" solution for that (aside from cloning the buffer and/or
removing the restrictions)... I’ve written this simple and quick
workaround, and then remapped `C-c C-o' so that:
`C-u C-c C-o'
my function
`C-c C-o'
`org-open-at-point'
┌────
│ (defun my-org-open-fn-indirect-buffer ()
│ (interactive)
│ (if (not (equal (org-element-type (org-element-context))
'footnote-reference))
│ (error "Not in a footnote reference!")
│ (let* ((el (org-element-context))
│ (label (org-element-property :label el))
│ (buf (buffer-name))
│ (format (format "%s | Note %s" buf label)))
│ (when (get-buffer format)
│ (kill-buffer format))
│ (clone-indirect-buffer format t)
│ (setq header-line-format (format "NOTE %s" label))
│ (widen)
│ (org-open-at-point)
│ (recenter 0))))
│
│ (defun my-org-open-at-point ()
│ (interactive)
│ (if (equal current-prefix-arg nil)
│ (org-open-at-point)
│ (my-org-open-fn-indirect-buffer)))
│
│ (with-eval-after-load 'org
│ (define-key org-mode-map (kbd "C-c C-o") nil)
│ (define-key org-mode-map (kbd "C-c C-o") 'my-org-open-at-point))
└────
Best regards,
Juan Manuel
- Open a footnote definition outside a narrowed subtree (workaround),
Juan Manuel Macías <=