kiwanami / emacs-calfw

A calendar framework for Emacs
1.17k stars 103 forks source link

Function to open calendar in week mode #138

Closed AtomicNess123 closed 2 years ago

AtomicNess123 commented 2 years ago

Excellent package! Now... how to open in Week mode?

This does not work, it opens in month view. It seems that the (cfw:change-view-week) line is doing nothing.

(defun my-week-calendar ()
  (interactive)
  (cfw:open-calendar-buffer
   :contents-sources
   (list
    (cfw:org-create-source "Green") 
    (cfw:ical-create-source "gcal" "https://calendar.google.com/calendar/ical/XXXXXXXXX/basic.ics" "Red")
    (cfw:change-view-week)
    )))

Thanks!

cdeleuze commented 2 years ago

The call to cfw:change-view-week should be after the one to cfw:open-calendar-buffer!

(defun my-week-calendar ()
  (interactive)
  (cfw:open-calendar-buffer
   :contents-sources
   (list
    (cfw:org-create-source "Green") 
    (cfw:ical-create-source "gcal" "https://calendar.google.com/calendar/ical/XXXXXXXXX/basic.ics" "Red")))
  (cfw:change-view-week))
AtomicNess123 commented 2 years ago

The call to cfw:change-view-week should be after the one to cfw:open-calendar-buffer!

(defun my-week-calendar ()
  (interactive)
  (cfw:open-calendar-buffer
   :contents-sources
   (list
    (cfw:org-create-source "Green") 
    (cfw:ical-create-source "gcal" "https://calendar.google.com/calendar/ical/XXXXXXXXX/basic.ics" "Red")))
  (cfw:change-view-week))

Unfortunately this is not working! I still get the monthly view. Have you tried yourself?

cdeleuze commented 2 years ago

Unfortunately this is not working! I still get the monthly view. Have you tried yourself?

Hum... Where did you put this definition? Are you sure you eval'ed it? You can do that interactively by placing point (ie "cursor") after the last parenthesis and typing C-x C-e (or from menu Emacs-Lisp/Evaluate Last S-expression when in Emacs-lisp mode). Or just restart emacs with the definition in eg your init file.

AtomicNess123 commented 2 years ago

Unfortunately this is not working! I still get the monthly view. Have you tried yourself?

Hum... Where did you put this definition? Are you sure you eval'ed it? You can do that interactively by placing point (ie "cursor") after the last parenthesis and typing C-x C-e (or from menu Emacs-List/Evaluate Last S-expression when in Emacs-lisp mode). Or just restart emacs with the definition in eg your init file.

I put it in my init.el file and I evaluated it, not so newbie at this point :D I see now a behaviour:

when I call M-x my-week-calendar it works. However, I have a keybinding: (global-set-key [f7] 'my-week-calendar)

When I call f7 I get the monthly view and this error in the minibuffer:

Not found cfw:component attribute...

ml729 commented 2 years ago

I had the same problem, I am not sure why it happens. But this worked for me (specify the view type as an argument to cfw:open-calendar-buffer):

(defun my-week-calendar ()
  (interactive)
  (cfw:open-calendar-buffer
   :contents-sources
   (list
    (cfw:org-create-source "Green")
    (cfw:ical-create-source "gcal" "https://calendar.google.com/calendar/ical/XXXXXXXXX/basic.ics" "Red"))
   :view 'week))
AtomicNess123 commented 2 years ago

Yes! It worked! How did you figured this one out? Wonderful, thanks!