Re: [PATCH] Define new face for the contents of #+RESULTS drawers

2023-09-18 Thread Ihor Radchenko
Samuel Wales  writes:

> perhaps a face for results to indicate that it is generated?

May you please elaborate what you mean?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH] Define new face for the contents of #+RESULTS drawers

2023-09-17 Thread Samuel Wales
perhaps a face for results to indicate that it is generated?


On 9/17/23, Ihor Radchenko  wrote:
> Protesilaos Stavrou  writes:
>
>> Though I understand now that there are more cases involved than I had
>> anticipated.  I will need to review everything on offer.  Let's abort
>> this effort for now.
>
> Ok. Closing.
> Canceled.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
>
>


-- 
The Kafka Pandemic

A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com



Re: [PATCH] Define new face for the contents of #+RESULTS drawers

2023-09-17 Thread Ihor Radchenko
Protesilaos Stavrou  writes:

> Though I understand now that there are more cases involved than I had
> anticipated.  I will need to review everything on offer.  Let's abort
> this effort for now.

Ok. Closing.
Canceled.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH] Define new face for the contents of #+RESULTS drawers

2023-09-16 Thread Protesilaos Stavrou
> From: Ihor Radchenko 
> Date: Sat, 16 Sep 2023 12:44:37 +

> [... 79 lines elided]

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

The goal is to make all kinds of evaluation results distinct from their
manually written counterparts.  This is for users who read/interact with
a document and are given basic instructions on what to do while still
not knowing everything Org has to offer.

Though I understand now that there are more cases involved than I had
anticipated.  I will need to review everything on offer.  Let's abort
this effort for now.

Thank you for your time!

-- 
Protesilaos Stavrou
https://protesilaos.com



Re: [PATCH] Define new face for the contents of #+RESULTS drawers

2023-09-16 Thread Ihor Radchenko
Protesilaos Stavrou  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 .
Support Org development at ,
or support my work at 



Re: [PATCH] Define new face for the contents of #+RESULTS drawers

2023-09-16 Thread Protesilaos Stavrou
> From: Ihor Radchenko 
> Date: Sat, 16 Sep 2023 09:49:50 +

> [... 9 lines elided]

>> +(defface org-code-results '((t :inherit org-code))
>> +  "Face for the contents of #+RESULTS drawers."
>> +  :group 'org-faces
>> +  :version "30.1")
>
> 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?

> As for code evaluation results, it can be anything with #+results
> keyword. Like
>
> #+results:
> : fixed width
> : text
>
> or
>
> #+results:
> #+begin_example
> ...
> #+end_example
>
> or
>
> #+results:
> Simple paragraph of text.
>
>>;; Code
>> -  '(org-activate-code (1 'org-code t))
>> +  '(org-activate-code (1 'org-code-results t))
>
> `org-activate-code' only affects fixed-width text
>
> : like
> : this
> :
> : one
>
> It has no relation to code results, except that fixed width is often
> (but not always) used as the default markup for results of evaluation.
>
> If what you are looking for is different formatting for code markup and
> fixed-width markup, `org-fixed-width' would be a better face name.
>
> If you are looking for formatting of results of evaluation, it would
> need to be a completely new, non-trivial, font-lock-keyword.

Thank you for the explanation!  The case I had in mind was indeed the
one where the 'org-code' face now applies.

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.

-- 
Protesilaos Stavrou
https://protesilaos.com



Re: [PATCH] Define new face for the contents of #+RESULTS drawers

2023-09-16 Thread Ihor Radchenko
Protesilaos Stavrou  writes:

> I propose the attached patch.  It gives users/themes the opportunity to
> style the contents of #+RESULTS drawers differently than the face
> applied to ~code~ elements.

Thanks for the patch!

> +(defface org-code-results '((t :inherit org-code))
> +  "Face for the contents of #+RESULTS drawers."
> +  :group 'org-faces
> +  :version "30.1")

I think there is some misunderstanding here.
#+RESULTS is not a drawer. A drawer would be

:results:
...
:end:

As for code evaluation results, it can be anything with #+results
keyword. Like

#+results:
: fixed width
: text

or

#+results:
#+begin_example
...
#+end_example

or

#+results:
Simple paragraph of text.

> ;; Code
> -   '(org-activate-code (1 'org-code t))
> +   '(org-activate-code (1 'org-code-results t))

`org-activate-code' only affects fixed-width text

: like
: this
:
: one

It has no relation to code results, except that fixed width is often
(but not always) used as the default markup for results of evaluation.

If what you are looking for is different formatting for code markup and
fixed-width markup, `org-fixed-width' would be a better face name.

If you are looking for formatting of results of evaluation, it would
need to be a completely new, non-trivial, font-lock-keyword.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at