[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Define new face for the contents of #+RESULTS drawers
From: |
Ihor Radchenko |
Subject: |
Re: [PATCH] Define new face for the contents of #+RESULTS drawers |
Date: |
Sat, 16 Sep 2023 12:44:37 +0000 |
Protesilaos Stavrou <info@protesilaos.com> writes:
>> I think there is some misunderstanding here.
>> #+RESULTS is not a drawer. A drawer would be
>>
>> :results:
>> ...
>> :end:
>
> Oh, I see. How do we describe it? A keyword, perhaps?
Affiliated keyword.
Org allows attaching arbitrary metadata to syntax elements. For example,
we can assign name and header via affiliated keywords:
#+name: src-block-name
#+header: :var x=1
#+begin_src elisp
(+ 1 x)
#+end_src
#+results is a special affiliated keyword that marks syntax elements
generated by evaluating code blocks:
#+results:
I am generated paragraph
#+results:
:drawer:
I am generated drawer
:end:
#+results:
: I am generated fixed-width
#+results:
#+begin_latex
I am generated latex snippet
#+end_latex
etc.
>> `org-activate-code' only affects fixed-width text
>>
>> : like
>> : this
>> :
>> : one
> ...
> Thank you for the explanation! The case I had in mind was indeed the
> one where the 'org-code' face now applies.
I am a bit confused. Now, `org-code' applies to all fixed-width
constructs, not just the ones generated by code blocks.
: I can just manually write this, and it will have ~code-block~ face.
#+begin_src ...
...
#+end_src
#+results:
: And this is generated src block result.
: It is also using ~code-block~ face (as all fixed-width blocks do).
> I am interested in making the results display as distinct elements. The
> reason is that it can sometimes be hard to tell what was there before
> and what was generated by 'org-babel-execute-buffer' and related.
>
> You are right to point out that adding font-lock rules for all the
> possible #+results is not trivial. Better leave it as-is.
Not very hard. Basically, we can write a custom activate function that
will search for "^#\\+results:" lines and prepend/append an extra custom
face to whatever that #+results is a part of (affiliated keyword is
never standalone - it is attached to whatever is a result of evaluation).
I am still not 100% sure what exactly you want to achieve - just
highlight evaluation results that are _also_ fixed-width or all kinds of
evaluation results.
--
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>