emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Would it be possible to color horizontal lines in org mode?
@ 2021-09-27 18:49 Alper Alimoglu
  2021-09-28  7:59 ` Eric S Fraga
  0 siblings, 1 reply; 5+ messages in thread
From: Alper Alimoglu @ 2021-09-27 18:49 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 378 bytes --]

In markdown mode when I enter `---` (3 dash lines or more), the horizontal
line becomes green.

Would it be possible to obtain the same behavior in `org-mode` where
horizontal lines become colorful?
-------
https://orgmode.org/manual/Horizontal-Rules.html

> 12.9 Horizontal Rules:
> A line consisting of only dashes, and at least 5 of them, is exported
> as a horizontal line.

[-- Attachment #2: Type: text/html, Size: 606 bytes --]

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

* Re: Would it be possible to color horizontal lines in org mode?
  2021-09-27 18:49 Would it be possible to color horizontal lines in org mode? Alper Alimoglu
@ 2021-09-28  7:59 ` Eric S Fraga
  2021-09-28 17:17   ` John Kitchin
  0 siblings, 1 reply; 5+ messages in thread
From: Eric S Fraga @ 2021-09-28  7:59 UTC (permalink / raw)
  To: Alper Alimoglu; +Cc: emacs-orgmode

You could use hi-lock-mode to define your own colouring for such
lines.  But I'm sure those that under font-locking better might be able
to add appropriate rules for this horizontal line construct.

-- 
: Eric S Fraga via Emacs 28.0.50, Org 9.5-g9a4a24
: Latest paper written in org: https://arxiv.org/abs/2106.05096


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

* Re: Would it be possible to color horizontal lines in org mode?
  2021-09-28  7:59 ` Eric S Fraga
@ 2021-09-28 17:17   ` John Kitchin
  2021-09-29 12:22     ` Alper Alimoglu
  0 siblings, 1 reply; 5+ messages in thread
From: John Kitchin @ 2021-09-28 17:17 UTC (permalink / raw)
  To: Org Mode List; +Cc: Alper Alimoglu

[-- Attachment #1: Type: text/plain, Size: 912 bytes --]

you can add a rule like this in an org-mode hook:

#+BEGIN_SRC emacs-lisp :results silent
(font-lock-add-keywords
 nil
 '(("^-\\{5,\\}"  0 '(:foreground "red" :weight bold))))
#+END_SRC

that will make a line starting with at least 5 - be red and bold in color.

John

-----------------------------------
Professor John Kitchin (he/him/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



On Tue, Sep 28, 2021 at 4:00 AM Eric S Fraga <e.fraga@ucl.ac.uk> wrote:

> You could use hi-lock-mode to define your own colouring for such
> lines.  But I'm sure those that under font-locking better might be able
> to add appropriate rules for this horizontal line construct.
>
> --
> : Eric S Fraga via Emacs 28.0.50, Org 9.5-g9a4a24
> : Latest paper written in org: https://arxiv.org/abs/2106.05096
>
>

[-- Attachment #2: Type: text/html, Size: 1678 bytes --]

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

* Re: Would it be possible to color horizontal lines in org mode?
  2021-09-28 17:17   ` John Kitchin
@ 2021-09-29 12:22     ` Alper Alimoglu
  2021-09-30 19:14       ` John Kitchin
  0 siblings, 1 reply; 5+ messages in thread
From: Alper Alimoglu @ 2021-09-29 12:22 UTC (permalink / raw)
  To: John Kitchin, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1370 bytes --]

Thank you Professor Kitchin. Would something like follows would work?
#+BEGIN_SRC emacs-lisp :results silent
(add-hook 'org-mode-hook (lambda () (font-lock-add-keywords
                                     nil
                                     '(("^-\\{5,\\}"  0 '(:foreground "red"
:weight bold))))))
#+END_SRC

-Alper



On Tue, Sep 28, 2021 at 8:18 PM John Kitchin <jkitchin@andrew.cmu.edu>
wrote:

> you can add a rule like this in an org-mode hook:
>
> #+BEGIN_SRC emacs-lisp :results silent
> (font-lock-add-keywords
>  nil
>  '(("^-\\{5,\\}"  0 '(:foreground "red" :weight bold))))
> #+END_SRC
>
> that will make a line starting with at least 5 - be red and bold in color.
>
> John
>
> -----------------------------------
> Professor John Kitchin (he/him/his)
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> @johnkitchin
> http://kitchingroup.cheme.cmu.edu
>
>
>
> On Tue, Sep 28, 2021 at 4:00 AM Eric S Fraga <e.fraga@ucl.ac.uk> wrote:
>
>> You could use hi-lock-mode to define your own colouring for such
>> lines.  But I'm sure those that under font-locking better might be able
>> to add appropriate rules for this horizontal line construct.
>>
>> --
>> : Eric S Fraga via Emacs 28.0.50, Org 9.5-g9a4a24
>> : Latest paper written in org: https://arxiv.org/abs/2106.05096
>>
>>

[-- Attachment #2: Type: text/html, Size: 3668 bytes --]

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

* Re: Would it be possible to color horizontal lines in org mode?
  2021-09-29 12:22     ` Alper Alimoglu
@ 2021-09-30 19:14       ` John Kitchin
  0 siblings, 0 replies; 5+ messages in thread
From: John Kitchin @ 2021-09-30 19:14 UTC (permalink / raw)
  To: Alper Alimoglu; +Cc: emacs-orgmode

This looks correct. Some people prefer to use named functions for this,
so it is easier to remove them, but this works fine.

Alper Alimoglu <alper.alimoglu@gmail.com> writes:

> Thank you Professor Kitchin. Would something like follows would work?
> #+BEGIN_SRC emacs-lisp :results silent
> (add-hook 'org-mode-hook (lambda () (font-lock-add-keywords
>                                      nil
>                                      '(("^-\\{5,\\}"  0 '(:foreground "red" :weight bold))))))
> #+END_SRC
>
> -Alper 
>
> On Tue, Sep 28, 2021 at 8:18 PM John Kitchin <jkitchin@andrew.cmu.edu> wrote:
>
>  you can add a rule like this in an org-mode hook:
>
>  #+BEGIN_SRC emacs-lisp :results silent
>  (font-lock-add-keywords
>   nil
>   '(("^-\\{5,\\}"  0 '(:foreground "red" :weight bold))))
>  #+END_SRC
>
>  that will make a line starting with at least 5 - be red and bold in color.
>
>  John
>
>  -----------------------------------
>  Professor John Kitchin (he/him/his)
>  Doherty Hall A207F
>  Department of Chemical Engineering
>  Carnegie Mellon University
>  Pittsburgh, PA 15213
>  412-268-7803
>  @johnkitchin
>  http://kitchingroup.cheme.cmu.edu
>
>  On Tue, Sep 28, 2021 at 4:00 AM Eric S Fraga <e.fraga@ucl.ac.uk> wrote:
>
>  You could use hi-lock-mode to define your own colouring for such
>  lines.  But I'm sure those that under font-locking better might be able
>  to add appropriate rules for this horizontal line construct.
>
>  -- 
>  : Eric S Fraga via Emacs 28.0.50, Org 9.5-g9a4a24
>  : Latest paper written in org: https://arxiv.org/abs/2106.05096


-- 
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu
Pronouns: he/him/his


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

end of thread, other threads:[~2021-09-30 19:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-27 18:49 Would it be possible to color horizontal lines in org mode? Alper Alimoglu
2021-09-28  7:59 ` Eric S Fraga
2021-09-28 17:17   ` John Kitchin
2021-09-29 12:22     ` Alper Alimoglu
2021-09-30 19:14       ` John Kitchin

Code repositories for project(s) associated with this 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).