1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-26 07:33:39 +00:00

org-attach-tag: Work around error when before first heading

* lisp/org-attach.el (org-attach-tag): Avoid error thrown when trying
to set tags before first heading.  This is not a proper fix, but it
will at least allow attaching files to Org file.  The tagging will be
skipped for now, until setting FILETAGS is supported by Org API.
This commit is contained in:
Ihor Radchenko 2023-04-28 12:52:09 +02:00
parent 7e75571f02
commit f067a4bd43
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B

View File

@ -513,9 +513,13 @@ DIR-property exists (that is different from the unset one)."
(defun org-attach-tag (&optional off)
"Turn the autotag on or (if OFF is set) off."
(when org-attach-auto-tag
(save-excursion
(org-back-to-heading t)
(org-toggle-tag org-attach-auto-tag (if off 'off 'on)))))
;; FIXME: There is currently no way to set #+FILETAGS
;; programatically. Do nothing when before first heading
;; (attaching to file) to avoid blocking error.
(unless (org-before-first-heading-p)
(save-excursion
(org-back-to-heading t)
(org-toggle-tag org-attach-auto-tag (if off 'off 'on))))))
(defun org-attach-untag ()
"Turn the autotag off."