all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Protesilaos Stavrou <info@protesilaos.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Define new face for the contents of #+RESULTS drawers
Date: Sat, 16 Sep 2023 12:44:37 +0000	[thread overview]
Message-ID: <87wmwqnv7u.fsf@localhost> (raw)
In-Reply-To: <87msxm5mh7.fsf@protesilaos.com>

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>


  reply	other threads:[~2023-09-16 12:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-16  9:38 [PATCH] Define new face for the contents of #+RESULTS drawers Protesilaos Stavrou
2023-09-16  9:49 ` Ihor Radchenko
2023-09-16 12:30   ` Protesilaos Stavrou
2023-09-16 12:44     ` Ihor Radchenko [this message]
2023-09-16 12:52       ` Protesilaos Stavrou
2023-09-17  9:53         ` Ihor Radchenko
2023-09-17 21:36           ` Samuel Wales
2023-09-18  8:39             ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wmwqnv7u.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=info@protesilaos.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.