all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* org-fold-core-region error: missing SPEC
@ 2023-05-29  4:50 420actionunits
  2023-05-29  7:22 ` Ihor Radchenko
  0 siblings, 1 reply; 2+ messages in thread
From: 420actionunits @ 2023-05-29  4:50 UTC (permalink / raw)
  To: emacs-orgmode

I get the following stack trace when calling ORG-JIRA-GET-ISSUES from
org-jira I also get it from similar calls from ejira. After looking at
the code I think it's a problem in org and org-fold.

Debugger entered--Lisp error: (error "Calling ‘org-fold-core-region’ with missing SPEC")
  signal(error ("Calling ‘org-fold-core-region’ with missing SPEC"))
  error("Calling `org-fold-core-region' with missing SPEC")
  org-fold-region(1312 1318 t outline)
  org-insert-property-drawer()
  org-get-property-block(1222 force)
  org-entry-put(1286 "assignee" "Carlos Konstanski")
  org-jira-entry-put(1286 "assignee" "Carlos Konstanski")
  org-jira--render-issue(#<org-jira-sdk-issue org-jira-sdk-issue-156a386e429c>)
  mapc(org-jira--render-issue (#<org-jira-sdk-issue org-jira-sdk-issue-156a386e429c> ...))
  org-jira--render-issues-from-issue-list((#<org-jira-sdk-issue org-jira-sdk-issue-156a386e429c> ...))
  org-jira-get-issues((#<org-jira-sdk-issue org-jira-sdk-issue-156a386e429c> ...))
  #f(compiled-function (&rest rest) "Callback for async, DATA is the response from the request call.\n\nWill send a list of org-jira-sdk-issue objects to the list printer." #<bytecode 0x155bd04851c94e33>)(:data (... ... ... ... ...) :symbol-status success :error-thrown nil :response #s(request-response :status-code 200 :history nil :data ... :error-thrown nil :symbol-status success :url "https://ololab..." :done-p nil :settings ... :-buffer #<killed buffer> :-raw-header "HTTP/2 200 \nda..." :-timer nil :-backend curl))
  apply(#f(compiled-function (&rest rest) "Callback for async, DATA is the response from the request call.\n\nWill send a list of org-jira-sdk-issue objects to the list printer." #<bytecode 0x155bd04851c94e33>) (:data ... :symbol-status success :error-thrown nil :response ...))
  request--callback(#<killed buffer> :sync nil :headers (... ...) :parser jiralib--json-read :complete #f(compiled-function (&rest rest) "Callback for async, DATA is the response from the request call.\n\nWill send a list of org-jira-sdk-issue objects to the list printer." #<bytecode 0x155bd04851c94e33>) :error (lambda ... "\n\n(fn &key DAT..." ...) :type "POST" :data ...)
  apply(request--callback #<killed buffer> (:sync nil :headers (("Authorization" . "Basic Y2FybG9zLmtvbnN0YW5z...") ("Content-Type" . "application/json")) :parser jiralib--json-read :complete #f(compiled-function (&rest rest) "Callback for async, DATA is the response from the request call.\n\nWill send a list of org-jira-sdk-issue objects to the list printer." #<bytecode 0x155bd04851c94e33>) :error (lambda (&rest --cl-rest--) "\n\n(fn &key DATA &allow-oth..." (apply ... ... ... --cl-rest--)) :type "POST" :data "{\"jql\":\"assignee = current..." :url "https://ololabs.atlassian...." :response #s(request-response :status-code 200 :history nil :data (... ... ... ... ...) :error-thrown nil :symbol-status success :url "https://ololabs.atlassian...." :done-p nil :settings #3 :-buffer #<killed buffer> :-raw-header "HTTP/2 200 \ndate: Sat, 27 ..." :-timer nil :-backend curl) :encoding utf-8))
  request--curl-callback("https://ololabs.atlassian.net/rest/api/2/search" #<process request curl<9>> "finished\n")
  apply(request--curl-callback ("https://ololabs.atlassian.net/rest/api/2/search" #<process request curl<9>> "finished\n"))
  #f(compiled-function (&rest args2) #<bytecode -0x190ba810c79ff01c>)(#<process request curl<9>> "finished\n")

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

It will pass in either 'DRAWER or 'OUTLINE, neither of which are valid
given the alist they need to match against.

It would seem that any execution path that goes through
ORG-INSERT-PROPERTY-DRAWER is going to fail.

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?


Emacs  : GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.17.8, Xaw3d scroll bars)
 of 2023-05-27
Package: Org mode version 9.6.6 (release_9.6.6 @ /usr/share/emacs/30.0.50/lisp/org/)

current state:
==============
(setq
 org-link-elisp-confirm-function 'yes-or-no-p
 org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3 "\n\n(fn ENTRY)"]
 org-persist-after-read-hook '(org-element--cache-persist-after-read)
 org-export-before-parsing-hook '(org-attach-expand-links)
 org-cycle-tab-first-hook '(org-babel-hide-result-toggle-maybe org-babel-header-arg-expand)
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-show-empty-lines
                  org-cycle-optimize-window-after-visibility-change org-cycle-display-inline-images)
 org-persist-before-read-hook '(org-element--cache-persist-before-read)
 org-mode-hook '(#[0 "\300\301\302\303\304$\207" [add-hook change-major-mode-hook org-fold-show-all append local] 5]
                 #[0 "\300\301\302\303\304$\207"
                   [add-hook change-major-mode-hook org-babel-show-result-all append local] 5]
                 org-babel-result-hide-spec org-babel-hide-all-hashes
                 #[0 "\301\211\x10\207" [imenu-create-index-function org-imenu-get-tree] 2])
 org-confirm-shell-link-function 'yes-or-no-p
 outline-isearch-open-invisible-function 'outline-isearch-open-invisible
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-src-mode-hook '(org-src-babel-configure-edit-buffer org-src-mode-configure-edit-buffer)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-speed-command-hook '(org-speed-command-activate org-babel-speed-command-activate)
 org-fold-core-isearch-open-function 'org-fold-core--isearch-reveal
 org-persist-before-write-hook '(org-element--cache-persist-before-write)
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe org-babel-header-arg-expand)
 org-link-shell-confirm-function 'yes-or-no-p
 org-babel-pre-tangle-hook '(save-buffer)
 org-agenda-loop-over-headlines-in-active-region nil
 org-occur-hook '(org-first-headline-recenter)
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-link-parameters '(("attachment" :follow org-attach-follow :complete org-attach-complete-link)
                       ("eww" :follow org-eww-open :store org-eww-store-link)
                       ("rmail" :follow org-rmail-open :store org-rmail-store-link)
                       ("mhe" :follow org-mhe-open :store org-mhe-store-link)
                       ("irc" :follow org-irc-visit :store org-irc-store-link :export org-irc-export)
                       ("info" :follow org-info-open :export org-info-export :store org-info-store-link
                        :insert-description org-info-description-as-command)
                       ("gnus" :follow org-gnus-open :store org-gnus-store-link)
                       ("docview" :follow org-docview-open :export org-docview-export :store org-docview-store-link)
                       ("bibtex" :follow org-bibtex-open :store org-bibtex-store-link)
                       ("bbdb" :follow org-bbdb-open :export org-bbdb-export :complete org-bbdb-complete-link
                        :store org-bbdb-store-link)
                       ("w3m" :store org-w3m-store-link)
                       ("doi" :follow org-link-doi-open :export org-link-doi-export)
                       ("jira" :follow org-jira-open :export nil) ("id" :follow org-id-open) ("file+sys")
                       ("file+emacs") ("shell" :follow org-link--open-shell)
                       ("news" :follow
                        #[514 "\301\300\302\x04Q\"\207" ["news" browse-url ":"] 6 "\n\n(fn URL ARG)"])
                       ("mailto" :follow
                        #[514 "\301\300\302\x04Q\"\207" ["mailto" browse-url ":"] 6 "\n\n(fn URL ARG)"])
                       ("https" :follow
                        #[514 "\301\300\302\x04Q\"\207" ["https" browse-url ":"] 6 "\n\n(fn URL ARG)"])
                       ("http" :follow
                        #[514 "\301\300\302\x04Q\"\207" ["http" browse-url ":"] 6 "\n\n(fn URL ARG)"])
                       ("ftp" :follow #[514 "\301\300\302\x04Q\"\207" ["ftp" browse-url ":"] 6 "\n\n(fn URL ARG)"])
                       ("help" :follow org-link--open-help :store org-link--store-help)
                       ("file" :complete org-link-complete-file) ("elisp" :follow org-link--open-elisp))
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-fold-core-style 'text-properties
)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: org-fold-core-region error: missing SPEC
  2023-05-29  4:50 org-fold-core-region error: missing SPEC 420actionunits
@ 2023-05-29  7:22 ` Ihor Radchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2023-05-29  7:22 UTC (permalink / raw)
  To: 420actionunits; +Cc: emacs-orgmode

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>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-29  7:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-29  4:50 org-fold-core-region error: missing SPEC 420actionunits
2023-05-29  7:22 ` Ihor Radchenko

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.