emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Mark vacation days
@ 2019-01-27 15:20 JRSS
  2019-01-27 19:27 ` Ken Mankoff
  0 siblings, 1 reply; 6+ messages in thread
From: JRSS @ 2019-01-27 15:20 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

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

I tried to post to stackoverflow but I'm not sure it took, so I'm trying here as well:

I'm looking for a way to mark vacation days in my agenda view in different color. This would probably be triggered best by category (so when a header is marked as a vacation).

I found [this post](https://julien.danjou.info/org-mode-and-holidays/) which is getting quite old, and he says it has been implemented into Emacs but I can't see it anywhere. It's based on Orgs ability to mark weekends in different color.

Ideally, I'd like to have different colors for day headers in the agenda correspond to different categories. Vacation is just the one prime example for that.

Does anyone know where I start getting something like this working? Programming is not my strong suit, but I can slowly wrap my head around some bits of code.

Thanks!

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

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

* Re: Mark vacation days
  2019-01-27 15:20 Mark vacation days JRSS
@ 2019-01-27 19:27 ` Ken Mankoff
  2019-01-27 20:20   ` JRSS
  0 siblings, 1 reply; 6+ messages in thread
From: Ken Mankoff @ 2019-01-27 19:27 UTC (permalink / raw)
  To: JRSS; +Cc: emacs-orgmode@gnu.org

Hi,

On 2019-01-27 at 07:20 -0800, JRSS <jarss@protonmail.com> wrote...
> Does anyone know where I start getting something like this working?
> Programming is not my strong suit, but I can slowly wrap my head
> around some bits of code.

It looks like this function might be a good place to start:

https://emacs.stackexchange.com/questions/28905/color-specific-days-in-different-background-in-org-agenda

  -k.

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

* Re: Mark vacation days
  2019-01-27 19:27 ` Ken Mankoff
@ 2019-01-27 20:20   ` JRSS
  2019-01-27 20:35     ` Ken Mankoff
  0 siblings, 1 reply; 6+ messages in thread
From: JRSS @ 2019-01-27 20:20 UTC (permalink / raw)
  To: Ken Mankoff; +Cc: emacs-orgmode\@gnu.org

Thanks Ken,

This is a bit over my head still. I'm trying to wrap my head around it.

I see what it does (colors day-of-the-week 1 and day-of-the-week-3, which are Monday and Wednesday, red) but not sure how to tie it to a category (so say, category "vacation" would be red).

Once I have the function do that, I can go in and change it so that different categories will be different colors.

BTW - can (background: ) take hex-color values?

Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Sunday, January 27, 2019 2:27 PM, Ken Mankoff <mankoff@gmail.com> wrote:

> Hi,
>
> On 2019-01-27 at 07:20 -0800, JRSS jarss@protonmail.com wrote...
>
> > Does anyone know where I start getting something like this working?
> > Programming is not my strong suit, but I can slowly wrap my head
> > around some bits of code.
>
> It looks like this function might be a good place to start:
>
> https://emacs.stackexchange.com/questions/28905/color-specific-days-in-different-background-in-org-agenda
>
> -k.

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

* Re: Mark vacation days
  2019-01-27 20:20   ` JRSS
@ 2019-01-27 20:35     ` Ken Mankoff
  2019-01-27 20:41       ` JRSS
  0 siblings, 1 reply; 6+ messages in thread
From: Ken Mankoff @ 2019-01-27 20:35 UTC (permalink / raw)
  To: JRSS; +Cc: emacs-orgmode@gnu.org

Hi,

On 2019-01-27 at 12:20 -0800, JRSS <jarss@protonmail.com> wrote...
> This is a bit over my head still. I'm trying to wrap my head around it.
>
> I see what it does (colors day-of-the-week 1 and day-of-the-week-3,
> which are Monday and Wednesday, red) but not sure how to tie it to a
> category (so say, category "vacation" would be red).
>
> Once I have the function do that, I can go in and change it so that
> different categories will be different colors.

It's a bit over my head for this use case too. Sorry. When I saw it I thought the use case was a list of holidays, which is easier to implement. You could maintain this list in an easy-to-access format as a variable near where you implement this function. A dynamic list based on tagged Org items is certainly more complicated.

  -k.

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

* Re: Mark vacation days
  2019-01-27 20:35     ` Ken Mankoff
@ 2019-01-27 20:41       ` JRSS
  2019-02-03 14:49         ` John Lee
  0 siblings, 1 reply; 6+ messages in thread
From: JRSS @ 2019-01-27 20:41 UTC (permalink / raw)
  To: mankoff; +Cc: emacs-orgmode

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

What if you set the category in the function? So the function has something like cond (( or (org-category vacation) (org-category f_event)
(background: red))

I obviously don't know how to write it, but the idea is that the categories are already set in the function. I won't have many, three tops, and I won't change them often -- no need to be fully dynamic.

Sent from ProtonMail mobile

-------- Original Message --------
On Jan 27, 2019, 15:35, Ken Mankoff wrote:

> Hi,
>
> On 2019-01-27 at 12:20 -0800, JRSS <jarss@protonmail.com> wrote...
>> This is a bit over my head still. I'm trying to wrap my head around it.
>>
>> I see what it does (colors day-of-the-week 1 and day-of-the-week-3,
>> which are Monday and Wednesday, red) but not sure how to tie it to a
>> category (so say, category "vacation" would be red).
>>
>> Once I have the function do that, I can go in and change it so that
>> different categories will be different colors.
>
> It's a bit over my head for this use case too. Sorry. When I saw it I thought the use case was a list of holidays, which is easier to implement. You could maintain this list in an easy-to-access format as a variable near where you implement this function. A dynamic list based on tagged Org items is certainly more complicated.
>
> -k.

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

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

* Re: Mark vacation days
  2019-01-27 20:41       ` JRSS
@ 2019-02-03 14:49         ` John Lee
  0 siblings, 0 replies; 6+ messages in thread
From: John Lee @ 2019-02-03 14:49 UTC (permalink / raw)
  To: emacs-orgmode

I don't know a good way to do this out of the box.  Here are two ways you could go about it, but they both involve a bit of programming.  They would all use org-agenda-day-face-function similar to the code you already posted.

1. Least programming: Add emacs diary entries (rather than recording the days using org datestamps -- see https://www.gnu.org/software/emacs/manual/html_node/emacs/Special-Diary-Entries.html) and adapt https://emacs.stackexchange.com/a/45778/5495 to check diary-lib.el instead of holidays.el .  Note this won't work by using the support for adding diary sexps directly to org files (https://orgmode.org/manual/Weekly_002fdaily-agenda.html#Calendar_002fDiary-integration) without something extra, because then the diary sexp information is only in org, not in the emacs diary itself, so you can't just look in diary-entries-list.  All pretty confusing I know.

Untested (!) based on adapting the stack exchange answer above to extend that (which pulls in holiday.el holidays + tests whether the day is a weekend -- the following is intended to hint how to extend that to pull in diary-lib.el dates too):

Note I'm guessing you'd have to set org-agenda-include-diary for this to work, but I have not tested this *at all*, so this really is all just a hint.  Also, watch out for the weird dependence of diary-lib.el on calendar-date-style.

(defface my/org-agenda-holiday '((t (:inherit default)))
  "Base face used in agenda for holidays, whether today's date or not."
  :group 'org-faces)
(defface my/org-agenda-holiday-not-today '((t (:inherit (my/org-agenda-holiday org-agenda-date))))
  "Face used in agenda for holidays other than for today's date."
  :group 'org-faces)
(defface my/org-agenda-holiday-today '((t (:inherit (my/org-agenda-holiday org-agenda-date-today))))
  "Face used in agenda for holidays for today's date."
  :group 'org-faces)

(defun my/in-diary-p (date)
  (car (alist-get date diary-entries-list nil nil #'equal)))

(defun my/day-face (day)
  (let* ((abs (calendar-absolute-from-gregorian day))
         (todayp (org-agenda-today-p abs))
         (day-of-week (calendar-day-of-week day))
         (holidayp (or
                    (= day-of-week 0) (= day-of-week 6)
                    (holiday-in-range abs abs)
                    (my/in-diary-p day))))
    (cond ((and todayp holidayp) 'my/org-agenda-holiday-today)
          (holidayp 'my/org-agenda-holiday-not-today)
          (todayp 'org-agenda-date-today)
          (t 'org-agenda-date))))
(setq org-agenda-day-face-function #'my/day-face)


2. Maybe nicer: write something similar to org-agenda-to-appt that generates a list of holiday days rather than appointments, then run that code from places like 'after-save-hook.  Then consult that list in your org-agenda-day-face-function.

On Sun, 27 Jan 2019, at 20:41, JRSS wrote:
> What if you set the category in the function? So the function has 
> something like cond (( or (org-category vacation) (org-category f_event)
> (background: red))
> 
> I obviously don't know how to write it, but the idea is that the 
> categories are already set in the function. I won't have many, three 
> tops, and I won't change them often -- no need to be fully dynamic.
> 
> Sent from ProtonMail mobile
> 
> -------- Original Message --------
> On Jan 27, 2019, 15:35, Ken Mankoff wrote:
> 
> > Hi,
> >
> > On 2019-01-27 at 12:20 -0800, JRSS <jarss@protonmail.com> wrote...
> >> This is a bit over my head still. I'm trying to wrap my head around it.
> >>
> >> I see what it does (colors day-of-the-week 1 and day-of-the-week-3,
> >> which are Monday and Wednesday, red) but not sure how to tie it to a
> >> category (so say, category "vacation" would be red).
> >>
> >> Once I have the function do that, I can go in and change it so that
> >> different categories will be different colors.
> >
> > It's a bit over my head for this use case too. Sorry. When I saw it I thought the use case was a list of holidays, which is easier to implement. You could maintain this list in an easy-to-access format as a variable near where you implement this function. A dynamic list based on tagged Org items is certainly more complicated.
> >
> > -k.

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

end of thread, other threads:[~2019-02-03 14:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-27 15:20 Mark vacation days JRSS
2019-01-27 19:27 ` Ken Mankoff
2019-01-27 20:20   ` JRSS
2019-01-27 20:35     ` Ken Mankoff
2019-01-27 20:41       ` JRSS
2019-02-03 14:49         ` John Lee

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