kiwanami / emacs-calfw

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

customize width of cells in monthly view? #45

Open holtzermann17 opened 9 years ago

holtzermann17 commented 9 years ago

If I adjust the font size to be very small in a Calfw buffer, the size of the cells stays the same. Accordingly, if I have something scheduled using Org Mode, I just see something like this:

 27 (1) ...
HIGH [#A...

I need to switch to Day mode (D) to see what the item was.

kiwanami commented 9 years ago

Will you try M-x cfw:refresh-calendar-buffer after font size changing? This function re-calculates the cell size according to window dimension and font size.

holtzermann17 commented 9 years ago

That doesn't seem to work for me. If I run C-x C-- this shrinks the size of the current window's font, and then M-x cfw:refresh-calendar-buffer has no effect.

If I set the default font in my ~/.emacs to be smaller, then the calendar window does adjust.

holtzermann17 commented 9 years ago

Perhaps this function would be useful for computing the (scaled) width:

(defun buffer-body-width (&optional buffer pixelwise)
  (let ((width (window-body-width (get-buffer-window (or buffer
                                                         (current-buffer)))
                  pixelwise)))
    (floor (cond 
        ((eq text-scale-mode-amount 0)
         width)
        ((> text-scale-mode-amount 0)
         (/ width (* text-scale-mode-step text-scale-mode-amount)))
        ((< text-scale-mode-amount 0)
         (* width (* -1 text-scale-mode-step text-scale-mode-amount)))))))
kiwanami commented 9 years ago

Thank you for your report and workaround code! I could reproduce the situation. I'll fix it.

Well, I found this discussion: https://lists.gnu.org/archive/html/bug-gnu-emacs/2014-11/msg01277.html I appreciate your elaborate comments for this improvement.

Dabsen commented 9 years ago

What is the current situation on this issue? Is there a workaround, for the time being? I normally work with a big font size, but would like to use a small font size for calfw buffers (otherwise they are unusable). Thanks

Dabsen commented 9 years ago

Here is the workaround I am currently using. As remarked above, the calendar will not adapt to buffer-level zoom-in/zoom-out through the text-scale-adjust command (bound to C-x C-+ / C-x C-- by default). On the other hand, the calendar DOES adjust to frame-wide zooming or de-zooming (for instance via the zoom-frm-out command, or via a font size change through set-face-attribute for the appropriate frame). So what I am doing is launching calfw in a separate dezoomed frame, like this:

  (defun my:open-cal ()
    (interactive)
    (select-frame (make-frame '((name . "calendar")))) ; makes a new frame and selects it
    (set-face-attribute 'default (selected-frame) :height 65) ; reduces the font size of the new frame
    (cfw:open-org-calendar) ; opens the calendar there
    )

Also, I bound q to the following function, which kills the "calendar" frame if that's where we are and otherwise buries the buffer as usual:

  (defun my:close-cal ()
    (interactive)
    (if (string= (frame-parameter (selected-frame) 'name) "calendar")
        (delete-frame)
      (bury-buffer)))

One could also stay in the same frame and rebind the calendar opening and closing commands so as to change the frame-wide font size, I guess.