aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward M. Reingold1995-06-02 22:02:17 +0000
committerEdward M. Reingold1995-06-02 22:02:17 +0000
commitcbecb9f9f0719e3bf1691fcc7533e7a48b790f7c (patch)
tree6ea0a7aaade74e2089e5f8a1335ced1beda58bc5
parent0f12fdabce436da82c60d31ae63bc731bc54d6a8 (diff)
downloademacs-cbecb9f9f0719e3bf1691fcc7533e7a48b790f7c.tar.gz
emacs-cbecb9f9f0719e3bf1691fcc7533e7a48b790f7c.zip
Fixed calendar-string-spread to allow 0 or 1 string; this simplified several
calls to it.
-rw-r--r--lisp/calendar/calendar.el20
1 files changed, 11 insertions, 9 deletions
diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el
index 659b6610d06..0476a3ddc95 100644
--- a/lisp/calendar/calendar.el
+++ b/lisp/calendar/calendar.el
@@ -1329,7 +1329,7 @@ characters on the line."
1329 (goto-char (point-min)) 1329 (goto-char (point-min))
1330 (calendar-insert-indented 1330 (calendar-insert-indented
1331 (calendar-string-spread 1331 (calendar-string-spread
1332 (list "" (format "%s %d" (calendar-month-name month) year) "") ? 20) 1332 (list (format "%s %d" (calendar-month-name month) year)) ? 20)
1333 indent t) 1333 indent t)
1334 (calendar-insert-indented "" indent);; Go to proper spot 1334 (calendar-insert-indented "" indent);; Go to proper spot
1335 (calendar-for-loop i from 0 to 6 do 1335 (calendar-for-loop i from 0 to 6 do
@@ -1536,16 +1536,18 @@ For a complete description, type \
1536 (make-local-variable 'displayed-year));; Year in middle of window. 1536 (make-local-variable 'displayed-year));; Year in middle of window.
1537 1537
1538(defun calendar-string-spread (strings char length) 1538(defun calendar-string-spread (strings char length)
1539 "Concatenate list of STRINGS separated with copies of CHAR to fill LENGTH 1539 "Concatenate list of STRINGS separated with copies of CHAR to fill LENGTH.
1540There must be at least 2 strings. The effect is like mapconcat but the 1540The effect is like mapconcat but the separating pieces are as balanced as
1541separating pieces are as balanced as possible. Each item of STRINGS is 1541possible. Each item of STRINGS is evaluated before concatenation so it can
1542evaluated before concatenation so it can actually be an expression that 1542actually be an expression that evaluates to a string. If LENGTH is too short,
1543evaluates to a string. If LENGTH is too short, the STRINGS are just 1543the STRINGS are just concatenated and the result truncated."
1544concatenated and the result truncated."
1545;; The algorithm is based on equation (3.25) on page 85 of Concrete 1544;; The algorithm is based on equation (3.25) on page 85 of Concrete
1546;; Mathematics by Ronald L. Graham, Donald E. Knuth, and Oren Patashnik, 1545;; Mathematics by Ronald L. Graham, Donald E. Knuth, and Oren Patashnik,
1547;; Addison-Wesley, Reading, MA, 1989 1546;; Addison-Wesley, Reading, MA, 1989
1548 (let* ((strings (mapcar 'eval strings)) 1547 (let* ((strings (mapcar 'eval
1548 (if (< (length strings) 2)
1549 (append (list "") strings (list ""))
1550 strings)))
1549 (n (- length (length (apply 'concat strings)))) 1551 (n (- length (length (apply 'concat strings))))
1550 (m (1- (length strings))) 1552 (m (1- (length strings)))
1551 (s (car strings)) 1553 (s (car strings))
@@ -2798,7 +2800,7 @@ Driven by the variable `calendar-date-display-form'."
2798(defun calendar-set-mode-line (str) 2800(defun calendar-set-mode-line (str)
2799 "Set mode line to STR, centered, surrounded by dashes." 2801 "Set mode line to STR, centered, surrounded by dashes."
2800 (setq mode-line-format 2802 (setq mode-line-format
2801 (calendar-string-spread (list "" str "") ?- (frame-width)))) 2803 (calendar-string-spread (list str) ?- (frame-width))))
2802 2804
2803;;;###autoload 2805;;;###autoload
2804(defun list-yahrzeit-dates (death-date start-year end-year) 2806(defun list-yahrzeit-dates (death-date start-year end-year)