emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* adding more color to agenda events
@ 2007-02-27 21:30 Scott Jaderholm
  2007-02-28  8:58 ` Carsten Dominik
  0 siblings, 1 reply; 4+ messages in thread
From: Scott Jaderholm @ 2007-02-27 21:30 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 392 bytes --]

Hi,

Is there an easy way to add new faces to org-agenda?

I would like to add a face for events including the text "meeting" or
"birthday" and other phrases. I'd also like to create a special face for
event subjects, such as Diary, life, or work (the first column in agenda).
It'd also be nice to be able to do faces based on tags.

Is this possible without a lot of hacking?

Thanks,
Scott

[-- Attachment #1.2: Type: text/html, Size: 452 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: adding more color to agenda events
  2007-02-27 21:30 adding more color to agenda events Scott Jaderholm
@ 2007-02-28  8:58 ` Carsten Dominik
  2007-03-01 17:43   ` Scott Jaderholm
  0 siblings, 1 reply; 4+ messages in thread
From: Carsten Dominik @ 2007-02-28  8:58 UTC (permalink / raw)
  To: Scott Jaderholm; +Cc: emacs-orgmode


On Feb 27, 2007, at 22:30, Scott Jaderholm wrote:

> Hi,
>
> Is there an easy way to add new faces to org-agenda?
>
> I would like to add a face for events including the text "meeting" or 
> "birthday" and other phrases. I'd also like to create a special face 
> for event subjects, such as Diary, life, or work (the first column in 
> agenda). It'd also be nice to be able to do faces based on tags.
>
> Is this possible without a lot of hacking?

There is special way of doing this.  In particular, the agenda does
*not* use font-lock, it sets its own faces.

However, there is a hook you can use, and the code to write for it
is relatuvely simple.  For example:

(add-hook 'org-finalize-agenda-hook
    (lambda ()
      (save-excursion
        (goto-char (point-min))
        (while (re-search-forward "\\<birthday\\>  " nil t)
          (add-text-properties (match-beginning 0) (match-end 0)
             '(face secondary-selection)))
        (goto-char (point-min))
        (while (re-search-forward "\\<meeting\\>  " nil t)
          (add-text-properties (match-beginning 0) (match-end 0)
             '(face bold))))))



>
> Thanks,
> Scott
> _______________________________________________
> Emacs-orgmode mailing list
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>

--
Carsten Dominik
Sterrenkundig Instituut "Anton Pannekoek"
Universiteit van Amsterdam
Kruislaan 403
NL-1098SJ Amsterdam
phone: +31 20 525 7477

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

* Re: adding more color to agenda events
  2007-02-28  8:58 ` Carsten Dominik
@ 2007-03-01 17:43   ` Scott Jaderholm
  2007-03-03 15:33     ` Carsten Dominik
  0 siblings, 1 reply; 4+ messages in thread
From: Scott Jaderholm @ 2007-03-01 17:43 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1859 bytes --]

On 2/28/07, Carsten Dominik <dominik@science.uva.nl> wrote:
>
>
> On Feb 27, 2007, at 22:30, Scott Jaderholm wrote:
>
> > Hi,
> >
> > Is there an easy way to add new faces to org-agenda?
> >
> > I would like to add a face for events including the text "meeting" or
> > "birthday" and other phrases. I'd also like to create a special face
> > for event subjects, such as Diary, life, or work (the first column in
> > agenda). It'd also be nice to be able to do faces based on tags.
> >
> > Is this possible without a lot of hacking?
>
> There is special way of doing this.  In particular, the agenda does
> *not* use font-lock, it sets its own faces.
>
> However, there is a hook you can use, and the code to write for it
> is relatuvely simple.  For example:
>
> (add-hook 'org-finalize-agenda-hook
>     (lambda ()
>       (save-excursion
>         (goto-char (point-min))
>         (while (re-search-forward "\\<birthday\\>  " nil t)
>           (add-text-properties (match-beginning 0) (match-end 0)
>              '(face secondary-selection)))
>         (goto-char (point-min))
>         (while (re-search-forward "\\<meeting\\>  " nil t)
>           (add-text-properties (match-beginning 0) (match-end 0)
>              '(face bold))))))
>

Thanks Carsten!

Do you know how to select the whole line instead of just the word?

Also, do you know where I can find more information about the syntax to use
in setting colors in the '(face ) area?

Is there an easy way to not interfere with the other highlighting that's
going to happen? I'd like to highlight stuff in work.org with a different
color, say orange, but I think I'd like TODO to stay red and Scheduled to
stay green but change rest of headline color and the work: column. If
there's a way to do this easily I'd also like to use it when defining
special highlights for tags.

Thanks again,
Scott

[-- Attachment #1.2: Type: text/html, Size: 2913 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: adding more color to agenda events
  2007-03-01 17:43   ` Scott Jaderholm
@ 2007-03-03 15:33     ` Carsten Dominik
  0 siblings, 0 replies; 4+ messages in thread
From: Carsten Dominik @ 2007-03-03 15:33 UTC (permalink / raw)
  To: Scott Jaderholm; +Cc: emacs-orgmode

Hi Scott,


On Mar 1, 2007, at 18:43, Scott Jaderholm wrote:
> Thanks Carsten!
>
> Do you know how to select the whole line instead of just the word?
> Also, do you know where I can find more information about the syntax 
> to use in setting colors in the '(face ) area?
>
> Is there an easy way to not interfere with the other highlighting 
> that's going to happen? I'd like to highlight stuff in work.org with a 
> different color, say orange, but I think I'd like TODO to stay red and 
> Scheduled to stay green but change rest of headline color and the 
> work: column. If there's a way to do this easily I'd also like to use 
> it when defining special highlights for tags.
>
> Thanks again,
> Scott

Well, first you need to lear about regular expressions.
For example to match a line containing the word birthday
you would do

     "^.*\\<birthday\\>.*

To change only part of a line, leave the rest, you can use
groups.  For example, to change everyting in a line except
the word TODO you would match it like

    "\\(^.*\\)\\<TODO\\>\\(.*\\)"

and then use `add-text-properties' twice, first to add the face
property from (match-beginning 1) to (match-end 1), and then
from (match-beginning 2) to (match-end 2).

If you want to change the faces used by Org-mode in normal .org
files, try

    M-x customize-group RET org-faces RET

there you can change all the standard faces used.

If you want to add new stuff to fontification in org-mode,
take a look at the function `font-lock-add-keywords'.

There are quite a few faces already defined in Emacs that you can
use, or you can define your own.

Well, you are entering the world of Emacs hacking here, and the only
way you will get further is by learning about text properties,
regular expressons etc in the Emacs manual and in the Emacs lisp manual.

- Carsten

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

end of thread, other threads:[~2007-03-03 15:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-27 21:30 adding more color to agenda events Scott Jaderholm
2007-02-28  8:58 ` Carsten Dominik
2007-03-01 17:43   ` Scott Jaderholm
2007-03-03 15:33     ` Carsten Dominik

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