all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#14509: Centerd calendar buffer
@ 2013-05-29 23:11 E Sabof
  2020-05-06 23:32 ` Stefan Kangas
  0 siblings, 1 reply; 3+ messages in thread
From: E Sabof @ 2013-05-29 23:11 UTC (permalink / raw)
  To: 14509

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

The following snippet will center the content of the calendar window. If
there is interest in integrating this into emacs, I can reformat it as a
patch. A possible interface to enable it could be
(setq calendar-left-margin 'auto)

Evgeni

(require 'cl-lib)

(defun calendar-mode-options ()
  (setq calendar-left-margin 1)
  (add-hook 'window-configuration-change-hook
            'es-calendar-win-config-hook nil t))
(add-hook 'calendar-mode-hook 'calendar-mode-options)

(defun es-calendar-win-config-hook ()
  (catch 'exit
    (with-current-buffer
        (or (get-buffer calendar-buffer)
            (throw 'exit nil))
      (dolist (win (get-buffer-window-list nil nil t))
        (with-selected-window win
          (let* (( max (+ (* 7 3 3)
                          (* 2 calendar-intermonth-spacing)
                          -1))
                 ( left (max 0 (/ (- (window-body-width) max) 2))))
            (dolist (ov (overlays-in (point-min) (point-max)))
              (when (and (overlay-get ov 'left-center-margin)
                         (eq (selected-window)
                             (overlay-get ov 'window)))
                (delete-overlay ov)))
            (save-excursion
              (goto-char (point-min))
              (cl-loop for ov
                       = (make-overlay
                          (line-beginning-position)
                          (1+ (line-beginning-position)))
                       do (progn
                            (overlay-put ov 'window (selected-window))
                            (overlay-put ov 'display (make-string left ?\s
))
                            (overlay-put ov 'left-center-margin t)
                            )
                       while (zerop (forward-line))
                       ))))))))

(defadvice calendar-generate (after center-calendar activate)
  (es-calendar-win-config-hook))

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

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

end of thread, other threads:[~2020-07-22 17:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-29 23:11 bug#14509: Centerd calendar buffer E Sabof
2020-05-06 23:32 ` Stefan Kangas
2020-07-22 17:01   ` Stefan Kangas

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.