emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: org-fold-core-region error: missing SPEC


From: Ihor Radchenko
Subject: Re: org-fold-core-region error: missing SPEC
Date: Mon, 29 May 2023 07:22:39 +0000

420actionunits@gmail.com writes:

> I set a breakpoint at the beginning of function
> ORG-FOLD-CORE-GET-FOLDING-SPEC-FROM-ALIAS. It runs quite a few times
> successfully. Every time the input argument SPEC-OR-ALIAS has one of
> these values: 'ORG-FOLD-VISIBLE or 'ORG-FOLD-HIDDEN. But at some point
> the function runs with a value of 'DRAWER, and that's when it returns
> NIL and the error is thrown higher up in ORG-FOLD-CORE-REGION when it
> explicitly tests for a NIL result.
>
> ORG-FOLD-CORE--SPEC-SYMBOLS has the value:
>
> ((HIDDEN . ORG-FOLD-HIDDEN) (:ALIAS . ORG-FOLD-HIDDEN)
> (ORG-FOLD-HIDDEN . ORG-FOLD-HIDDEN) (VISIBLE . ORG-FOLD-VISIBLE)
> (:ALIAS . ORG-FOLD-VISIBLE) (ORG-FOLD-VISIBLE . ORG-FOLD-VISIBLE))
>
> But when a drawer wants to be added we call ORG-FOLD-REGION like this:
>
> (ORG-FOLD-REGION (LINE-END-POSITION 0) (POINT) T (IF (EQ
> ORG-FOLD-CORE-STYLE 'TEXT-PROPERTIES) 'DRAWER 'OUTLINE))

This implies that the buffer where `org-fold-region' is called is not in
Org mode or did not have Org property initialized.
`org-insert-property-drawer' expects the buffer to be in Org mode.

> I'm still unclear on how ORG-FOLD-CORE--SPEC-SYMBOLS gets set with
> this alist. Is there is an opportunity for callers to customize it?
> What would be appropriate values to add for 'DRAWER and 'OUTLINE?

The answer to this question is described in the top commentary of
org-fold-core.el. Also, see `org-fold-initialize'.

However, the problem is not just with folding. As I said,
`org-insert-property-drawer' expect the major mode to be Org mode. Your
backtrace implies that either the buffer is not in Org mode or something
strange was done when initializing Org. Either way, random failures may
happen - Org mode APIS, unless explicitly stated, expect major mode to
be Org.

-- 
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>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]