Function: todo-print-buffer

todo-print-buffer is an interactive and byte-compiled function defined in todo-mode.el.gz.

Signature

(todo-print-buffer &optional TO-FILE)

Documentation

Produce a printable version of the current Todo mode buffer.

This converts overlays and soft line wrapping and, depending on the value of todo-print-buffer-function, includes faces. With non-nil argument TO-FILE write the printable version to a file; otherwise, send it to the default printer.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/todo-mode.el.gz
(defun todo-print-buffer (&optional to-file)
  "Produce a printable version of the current Todo mode buffer.
This converts overlays and soft line wrapping and, depending on
the value of `todo-print-buffer-function', includes faces.  With
non-nil argument TO-FILE write the printable version to a file;
otherwise, send it to the default printer."
  (interactive)
  (let ((buf todo-print-buffer)
	(header (cond
		 ((eq major-mode 'todo-mode)
		  (concat "Todo File: "
			  (todo-short-file-name todo-current-todo-file)
			  "\nCategory: " (todo-current-category)))
		 ((eq major-mode 'todo-filtered-items-mode)
		  (buffer-name))))
	(prefix (propertize (concat todo-prefix " ")
			    'face 'todo-prefix-string))
	(num 0)
	(fill-prefix (make-string todo-indent-to-here 32))
	(content (buffer-string)))
    (with-current-buffer (get-buffer-create buf)
      (insert content)
      (goto-char (point-min))
      (while (not (eobp))
	(let ((beg (point))
	      (end (save-excursion (todo-item-end))))
	  (when todo-number-prefix
	    (setq num (1+ num))
	    (setq prefix (propertize (concat (number-to-string num) " ")
				     'face 'todo-prefix-string)))
	  (insert prefix)
	  (fill-region beg end))
	;; Calling todo-forward-item infloops at todo-item-start due to
	;; non-overlay prefix, so search for item start instead.
	(if (re-search-forward todo-item-start nil t)
	    (beginning-of-line)
	  (goto-char (point-max))))
      (if (re-search-backward (concat "^" (regexp-quote todo-category-done))
			      nil t)
	  (replace-match todo-done-separator))
      (goto-char (point-min))
      (insert header)
      (newline 2)
      (funcall todo-print-buffer-function
               (if to-file nil
                 (read-file-name "Print to file: "))))
    (kill-buffer buf)))