emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Highlighting and Background Colour for Source Code
@ 2021-05-10  3:48 Christopher Dimech
  2021-05-11  4:50 ` Tim Cross
  0 siblings, 1 reply; 8+ messages in thread
From: Christopher Dimech @ 2021-05-10  3:48 UTC (permalink / raw)
  To: Help Emacs Orgmode

Currently currently handles the highlighting of programming languages through
"Code Blocks".  Could org-mode have the capability of highlighting a whole buffer
with a particular language highlight typeface.

I have also seen that within code blocks, the background is uses a colour that is
different from the background colour of the buffer.  Is there a capability that
the code block background is set to the buffer background colour.




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Highlighting and Background Colour for Source Code
  2021-05-10  3:48 Highlighting and Background Colour for Source Code Christopher Dimech
@ 2021-05-11  4:50 ` Tim Cross
  2021-05-11  5:13   ` Christopher Dimech
  0 siblings, 1 reply; 8+ messages in thread
From: Tim Cross @ 2021-05-11  4:50 UTC (permalink / raw)
  To: emacs-orgmode


Christopher Dimech <dimech@gmx.com> writes:

> Currently currently handles the highlighting of programming languages through
> "Code Blocks".  Could org-mode have the capability of highlighting a whole buffer
> with a particular language highlight typeface.
>

Sorry, I don't quite understand what exactly your asking for?

> I have also seen that within code blocks, the background is uses a colour that is
> different from the background colour of the buffer.  Is there a capability that
> the code block background is set to the buffer background colour.

I think more often than not, this is determined by the Emacs colour
theme your using. I've noticed that some themes colour src block
backgrounds differently from the rest of the buffer background and some
don't. I noticed this because I do like src blocks to have a different
background and some of the themes I like fail to do this, so I had to
customize them. 

You can try customizing your theme. Have a look at 

M-x list-colors-display

to see a list of all the faces being used. Look for ones with your theme
name or a name which looks like it might be the background face for src
blocks (you can also see the colours and look for that. Once you have
made the changes, look at 

M-x customize-theme

and save your changes as a new customized theme.



-- 
Tim Cross


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Highlighting and Background Colour for Source Code
  2021-05-11  4:50 ` Tim Cross
@ 2021-05-11  5:13   ` Christopher Dimech
  2021-05-11  5:50     ` Tim Cross
  2021-05-12 12:08     ` Ihor Radchenko
  0 siblings, 2 replies; 8+ messages in thread
From: Christopher Dimech @ 2021-05-11  5:13 UTC (permalink / raw)
  To: Tim Cross; +Cc: emacs-orgmode



> Sent: Tuesday, May 11, 2021 at 4:50 PM
> From: "Tim Cross" <theophilusx@gmail.com>
> To: emacs-orgmode@gnu.org
> Subject: Re: Highlighting and Background Colour for Source Code
>
>
> Christopher Dimech <dimech@gmx.com> writes:
>
> > Currently currently handles the highlighting of programming languages through
> > "Code Blocks".  Could org-mode have the capability of highlighting a whole buffer
> > with a particular language highlight typeface.
> >
>
> Sorry, I don't quite understand what exactly your asking for?

Suppose I have an elisp file and I change to org-mode by hitting "M-x org-mode".
The code does not get highlighted because it is not embedded within org-babel
construct.

If I have a programming language file with some org-mode heading commands in it,
and change to org-mode, it would be neat to have language highlighting available.

> > I have also seen that within code blocks, the background is uses a colour that is
> > different from the background colour of the buffer.  Is there a capability that
> > the code block background is set to the buffer background colour.
>
> I think more often than not, this is determined by the Emacs colour
> theme your using. I've noticed that some themes colour src block
> backgrounds differently from the rest of the buffer background and some
> don't. I noticed this because I do like src blocks to have a different
> background and some of the themes I like fail to do this, so I had to
> customize them.

It is certainly useful but not always.  Outline could have a switch, that
toggles between highlight and no-highlight.

> You can try customizing your theme. Have a look at
>
> M-x list-colors-display
>
> to see a list of all the faces being used. Look for ones with your theme
> name or a name which looks like it might be the background face for src
> blocks (you can also see the colours and look for that. Once you have
> made the changes, look at
>
> M-x customize-theme
>
> and save your changes as a new customized theme.
>
>
>
> --
> Tim Cross
>
>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Highlighting and Background Colour for Source Code
  2021-05-11  5:13   ` Christopher Dimech
@ 2021-05-11  5:50     ` Tim Cross
  2021-05-11  6:39       ` Christopher Dimech
  2021-05-12 12:08     ` Ihor Radchenko
  1 sibling, 1 reply; 8+ messages in thread
From: Tim Cross @ 2021-05-11  5:50 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: emacs-orgmode


Christopher Dimech <dimech@gmx.com> writes:

>> Sent: Tuesday, May 11, 2021 at 4:50 PM
>> From: "Tim Cross" <theophilusx@gmail.com>
>> To: emacs-orgmode@gnu.org
>> Subject: Re: Highlighting and Background Colour for Source Code
>>
>>
>> Christopher Dimech <dimech@gmx.com> writes:
>>
>> > Currently currently handles the highlighting of programming languages through
>> > "Code Blocks".  Could org-mode have the capability of highlighting a whole buffer
>> > with a particular language highlight typeface.
>> >
>>
>> Sorry, I don't quite understand what exactly your asking for?
>
> Suppose I have an elisp file and I change to org-mode by hitting "M-x org-mode".
> The code does not get highlighted because it is not embedded within org-babel
> construct.
>
> If I have a programming language file with some org-mode heading commands in it,
> and change to org-mode, it would be neat to have language highlighting available.
>

OK, now I think I understand.

Basically, with full org-mode, this is not possible and I don't think it
is actually want you want. Once you switch modes, say from elisp mode to
org mode, a lot more changes than just the font locking. Keybindings,
various support minor modes and lots more.

The 'normal' Emacs way to handle what you are looking for is to add a
minor mode. A minor mode is used to add some level of functionality to a
buffer without losing the major mode settings. Normally, you only have
one major mode associated with a buffer and often that mode is augmented
with a bunch of minor modes. For example, outshine mode is a minor mode
which adds some org-like functionality to non org-mode buffers.

Have a look at

https://orgmode.org/worg/org-tutorials/org-outside-org.html

I think that might give you some ideas to get you started. You may need
a few different minor modes to get the full setup you want and you will
likely need to do some customisation of key bindings etc to get things
how you like it. 

-- 
Tim Cross


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Highlighting and Background Colour for Source Code
  2021-05-11  5:50     ` Tim Cross
@ 2021-05-11  6:39       ` Christopher Dimech
  0 siblings, 0 replies; 8+ messages in thread
From: Christopher Dimech @ 2021-05-11  6:39 UTC (permalink / raw)
  To: Tim Cross, bzg; +Cc: emacs-orgmode


> Sent: Tuesday, May 11, 2021 at 5:50 PM
> From: "Tim Cross" <theophilusx@gmail.com>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: emacs-orgmode@gnu.org
> Subject: Re: Highlighting and Background Colour for Source Code
>
>
> Christopher Dimech <dimech@gmx.com> writes:
>
> >> Sent: Tuesday, May 11, 2021 at 4:50 PM
> >> From: "Tim Cross" <theophilusx@gmail.com>
> >> To: emacs-orgmode@gnu.org
> >> Subject: Re: Highlighting and Background Colour for Source Code
> >>
> >>
> >> Christopher Dimech <dimech@gmx.com> writes:
> >>
> >> > Currently currently handles the highlighting of programming languages through
> >> > "Code Blocks".  Could org-mode have the capability of highlighting a whole buffer
> >> > with a particular language highlight typeface.
> >> >
> >>
> >> Sorry, I don't quite understand what exactly your asking for?
> >
> > Suppose I have an elisp file and I change to org-mode by hitting "M-x org-mode".
> > The code does not get highlighted because it is not embedded within org-babel
> > construct.
> >
> > If I have a programming language file with some org-mode heading commands in it,
> > and change to org-mode, it would be neat to have language highlighting available.
> >
>
> OK, now I think I understand.
>
> Basically, with full org-mode, this is not possible and I don't think it
> is actually want you want. Once you switch modes, say from elisp mode to
> org mode, a lot more changes than just the font locking. Keybindings,
> various support minor modes and lots more.
>
> The 'normal' Emacs way to handle what you are looking for is to add a
> minor mode. A minor mode is used to add some level of functionality to a
> buffer without losing the major mode settings. Normally, you only have
> one major mode associated with a buffer and often that mode is augmented
> with a bunch of minor modes. For example, outshine mode is a minor mode
> which adds some org-like functionality to non org-mode buffers.
>
> Have a look at
>
> https://orgmode.org/worg/org-tutorials/org-outside-org.html
>
> I think that might give you some ideas to get you started. You may need
> a few different minor modes to get the full setup you want and you will
> likely need to do some customisation of key bindings etc to get things
> how you like it.

I agree that some features of org-mode (e.ge heading folding, code folding)
would be good to have available in emacs-lisp-mode, texinfo-mode, ...
The use of general minor-mode such as outline-minor-mode would be a good place
to handle the various programming languages.

Currently, there in outline-minor-mode and various others (outline-magic, outshine).
Things are all over the place.  I know that Carsten was keen to persuade for ideas in
org-mode to be included in outline-minor-mode.  This has not happened.  I am convinced
that the developers of org-mode could make valuable contributions to outline-minor-mode,
because currently the ideas there are extremely convoluted and writing an outline setup
is difficult.

There will be a number of capabilities to consider

1. Heading Levels using comment lines (e.g. ";;; * Heahding", ";;; ** Subheading", ...)

2. Folding of headings and subheadings only (cycling using single key)

3. Folding of code structures only (cycling using single key)

That would be valuable for starters.  Then we can look at more beef later
on.

What do you think?  Would the org-team be willing and able to assist a re-development
of outline-minor-mode?

> --
> Tim Cross
>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Highlighting and Background Colour for Source Code
  2021-05-11  5:13   ` Christopher Dimech
  2021-05-11  5:50     ` Tim Cross
@ 2021-05-12 12:08     ` Ihor Radchenko
  2021-05-12 12:11       ` Christopher Dimech
  1 sibling, 1 reply; 8+ messages in thread
From: Ihor Radchenko @ 2021-05-12 12:08 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: Tim Cross, emacs-orgmode

Christopher Dimech <dimech@gmx.com> writes:
> Suppose I have an elisp file and I change to org-mode by hitting "M-x org-mode".
> The code does not get highlighted because it is not embedded within org-babel
> construct.
>
> If I have a programming language file with some org-mode heading commands in it,
> and change to org-mode, it would be neat to have language highlighting available.

Hmm. What about polymode [1]?

[1] https://github.com/polymode/polymode


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Highlighting and Background Colour for Source Code
  2021-05-12 12:08     ` Ihor Radchenko
@ 2021-05-12 12:11       ` Christopher Dimech
  2021-05-12 12:27         ` Christopher Dimech
  0 siblings, 1 reply; 8+ messages in thread
From: Christopher Dimech @ 2021-05-12 12:11 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Tim Cross, emacs-orgmode

Have been looking at texinfo-mode a bit to see how to set outline-heading-alist.
But not been very successful.  Could need some help.

> Sent: Thursday, May 13, 2021 at 12:08 AM
> From: "Ihor Radchenko" <yantar92@gmail.com>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: "Tim Cross" <theophilusx@gmail.com>, emacs-orgmode@gnu.org
> Subject: Re: Highlighting and Background Colour for Source Code
>
> Christopher Dimech <dimech@gmx.com> writes:
> > Suppose I have an elisp file and I change to org-mode by hitting "M-x org-mode".
> > The code does not get highlighted because it is not embedded within org-babel
> > construct.
> >
> > If I have a programming language file with some org-mode heading commands in it,
> > and change to org-mode, it would be neat to have language highlighting available.
>
> Hmm. What about polymode [1]?
>
> [1] https://github.com/polymode/polymode
>
>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Highlighting and Background Colour for Source Code
  2021-05-12 12:11       ` Christopher Dimech
@ 2021-05-12 12:27         ` Christopher Dimech
  0 siblings, 0 replies; 8+ messages in thread
From: Christopher Dimech @ 2021-05-12 12:27 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: Tim Cross, emacs-orgmode, Ihor Radchenko

Did some more thinking on this and trying to set up outline-heading-alist
for texinfo, so I can get headlines similar to org mode.

Have seen people trying to do this lately but there is some problem with it that I
cannot understand right now.

(defvar gilgamesh-texinfo-hdlevels
'( ("@chapter" . 2)
("@section" . 3)
("@subsection" . 4)
("@subsubsection" . 5)
;; --------------------------------------------------
("@unnumbered" . 2)
("@unnumberedsec" . 3)
("@unnumberedsubsec" . 4)
("@unnumberedsubsubsec" . 5)
;; --------------------------------------------------
("@appendix" . 2)
("@appendixsec" . 3)
("@appendixsubsec" . 4)
("@appendixsubsubsec" . 5)
;; --------------------------------------------------
("majorheading" 2)
;; --------------------------------------------------
("chapheading" 2)
("heading" 3)
("subheading" 4)
("subsubheading" 5)
;; --------------------------------------------------
("@uchap" . 2)
("@usec" . 3)
("@usubsec" . 4)
("@usubsubsec" . 5) ))

(setq-local outline-heading-alist
;; We should merge `outline-heading-alist' and
;; `texinfo-section-list'. But in the mean time, let's
;; just generate one from the other.
(mapcar (lambda (x) (cons (concat "@" (car x)) (cadr x)))
gilgamesh-texinfo-hdlevels))

;;(defun gilgamesh-faddeev-texinfo ()
;; "todo"
;; (add-hook 'texinfo-mode-hook #'gilgamesh-texinfo-hdlevels) )


> Sent: Thursday, May 13, 2021 at 12:11 AM
> From: "Christopher Dimech" <dimech@gmx.com>
> To: "Ihor Radchenko" <yantar92@gmail.com>
> Cc: "Tim Cross" <theophilusx@gmail.com>, emacs-orgmode@gnu.org
> Subject: Re: Highlighting and Background Colour for Source Code
>
> Have been looking at texinfo-mode a bit to see how to set outline-heading-alist.
> But not been very successful.  Could need some help.
>
> > Sent: Thursday, May 13, 2021 at 12:08 AM
> > From: "Ihor Radchenko" <yantar92@gmail.com>
> > To: "Christopher Dimech" <dimech@gmx.com>
> > Cc: "Tim Cross" <theophilusx@gmail.com>, emacs-orgmode@gnu.org
> > Subject: Re: Highlighting and Background Colour for Source Code
> >
> > Christopher Dimech <dimech@gmx.com> writes:
> > > Suppose I have an elisp file and I change to org-mode by hitting "M-x org-mode".
> > > The code does not get highlighted because it is not embedded within org-babel
> > > construct.
> > >
> > > If I have a programming language file with some org-mode heading commands in it,
> > > and change to org-mode, it would be neat to have language highlighting available.
> >
> > Hmm. What about polymode [1]?
> >
> > [1] https://github.com/polymode/polymode
> >
> >
>
>


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-05-12 12:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-10  3:48 Highlighting and Background Colour for Source Code Christopher Dimech
2021-05-11  4:50 ` Tim Cross
2021-05-11  5:13   ` Christopher Dimech
2021-05-11  5:50     ` Tim Cross
2021-05-11  6:39       ` Christopher Dimech
2021-05-12 12:08     ` Ihor Radchenko
2021-05-12 12:11       ` Christopher Dimech
2021-05-12 12:27         ` Christopher Dimech

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).