[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: off-topic. fyi: emacs email view does syntax highlighting of org-mod

From: Corwin Brust
Subject: Re: off-topic. fyi: emacs email view does syntax highlighting of org-mode code blocks
Date: Sun, 6 Feb 2022 14:33:17 -0600

On Sun, Feb 6, 2022 at 1:08 PM Ian Kelling <iank@fsf.org> wrote:
> I just noticed this awesome feature. I will start sending code snippets
> that way.
> GNU Hacker <gnuhacker@member.fsf.org> writes:
> > #+begin_src elisp
> It appears to be initiated by gnus-article-mode, which I use through
> mu4e, which extends it in mu4e-view-mode. My emacs is a recent git
> version 29.0.50.

Thanks Ian.  Yet another reason I need invest in another round of
attempting migration to GNUS ;)

This gives me an idea:

It would be pretty fun to hack something up that allows code snipets
in chat to be font-locked.

I think I'd do it by
1. detecting source and extracting it
2. finding the source type (if possible)
3. creating temp buffer and sett its major mode
4. flow the snippet (grabbed code) into the temp buffer
5. taking buffer-string from temp as replacement (or overlay?) back
into the ERC buffer

This could have a user option that allows configuring the ways it
detect snippets, like an alist of cons cells giving start and end
delimiters?  This could look something like

#+begin_src emacs-lisp
  '(("#+\\([^ \t]+\\)?" . "+#")
  ("```\\([^ \t]+\\)?"))

If a list entry doesn't have an end delimiter I'm SWAGGING that we
would use the start delim as both.  The capture group here could be
optional and when it is both given in the start marker and actually
supplied for the snippet found, it is used to pick up the type, thus
set the mode used to fontify in the temp-buffer.

Perhaps a second defcustom to set the "fallabck" type to assume for
delimiter setts that don't give a way to pickup the src type.

If it this did use overlays for additional fun we could buttonized the
result.  For example using mouse-1 to pop the snippet that was clicked
(back) into a temp buffer or M-<mouse-1> to get back what was
originally typed.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]