Re: [O] org-element-at-point and special blocks
Rasmus writes: > Out of curiosity, why is it "more" consistent to return paragraph > here? Notwithstanding this case, if `org-element-at-point' returns `special-block', you /know/ that you are either on block boundaries (#+begin_special or #+end_special) or on any affiliated keyword above, but /never/ within the block. If `org-element-at-point' returns `special-block' here, you create an exception, which you have to handle later on. Besides, the truly empty contents are #+begin_special #+end_special therefore, I'm not shocked if #+begin_special #+end_special is a special block with an empty paragraph instead. Regards,
Re: [O] org-element-at-point and special blocks
Hi Nicolas, Thanks for the helpful reply. Nicolas Goaziou writes: >> Is there a reason why org-element-at-point reports the type to be a >> paragraph for special blocks? E.g. in the examples at the bottom of this >> mail, where | is the cursor, the types are: export-block, src-block and >> paragraph with a nested special block. > > This is a corner-case. `org-element-at-point' returns the closest > element at point, but prefers to see an empty paragraph than a special > block, for consistency. I.e., when point is within block boundaries, you > never return `special-block'. Out of curiosity, why is it "more" consistent to return paragraph here? >> Is there a neat way to detect if point is inside a block? I’m trying to >> write a function for structures (e.g. #+begin_latex) that works like >> org-babel-demarcate-block. > > (org-element-lineage (org-element-at-point) '(special-block) t) That's very cool. Thanks. Rasmus -- Even a three-legged dog has three good legs to lose
Re: [O] org-element-at-point and special blocks
Hello, Rasmus writes: > Is there a reason why org-element-at-point reports the type to be a > paragraph for special blocks? E.g. in the examples at the bottom of this > mail, where | is the cursor, the types are: export-block, src-block and > paragraph with a nested special block. This is a corner-case. `org-element-at-point' returns the closest element at point, but prefers to see an empty paragraph than a special block, for consistency. I.e., when point is within block boundaries, you never return `special-block'. > Is there a neat way to detect if point is inside a block? I’m trying to > write a function for structures (e.g. #+begin_latex) that works like > org-babel-demarcate-block. (org-element-lineage (org-element-at-point) '(special-block) t) Regards, -- Nicolas Goaziou
[O] org-element-at-point and special blocks
Hi, Is there a reason why org-element-at-point reports the type to be a paragraph for special blocks? E.g. in the examples at the bottom of this mail, where | is the cursor, the types are: export-block, src-block and paragraph with a nested special block. Is there a neat way to detect if point is inside a block? I’m trying to write a function for structures (e.g. #+begin_latex) that works like org-babel-demarcate-block. Thanks, Rasmus #+BEGIN_LaTeX | #+END_LaTeX #+BEGIN_SRC emacs-lisp | #+END_SRC #+begin_abstract | #+end_abstract -- Dung makes an excellent fertilizer