emacs-calfw icon indicating copy to clipboard operation
emacs-calfw copied to clipboard

customize width of cells in monthly view?

Open holtzermann17 opened this issue 9 years ago • 6 comments

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.

holtzermann17 avatar Nov 26 '14 13:11 holtzermann17

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.

kiwanami avatar Nov 27 '14 00:11 kiwanami

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 avatar Nov 27 '14 08:11 holtzermann17

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

holtzermann17 avatar Nov 27 '14 10:11 holtzermann17

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.

kiwanami avatar Dec 02 '14 00:12 kiwanami

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 avatar Jul 26 '15 08:07 Dabsen

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.

Dabsen avatar Sep 13 '15 14:09 Dabsen