Function: fortune-from-region
fortune-from-region is an autoloaded, interactive and byte-compiled
function defined in fortune.el.gz.
Signature
(fortune-from-region BEG END FILE)
Documentation
Append the current region to a local fortune-like data file.
Interactively, if called with a prefix argument,
read the file name to use. Otherwise use the value of fortune-file.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/play/fortune.el.gz
;;;###autoload
(defun fortune-from-region (beg end file)
"Append the current region to a local fortune-like data file.
Interactively, if called with a prefix argument,
read the file name to use. Otherwise use the value of `fortune-file'."
(interactive
(list (region-beginning) (region-end)
(if current-prefix-arg (fortune-ask-file))))
(let ((string (buffer-substring beg end))
author newsgroup help-point)
;; try to determine author ...
(save-excursion
(goto-char (point-min))
(setq help-point
(search-forward-regexp
"^From: \\(.*\\)$"
(point-max) t))
(if help-point
(setq author (buffer-substring (match-beginning 1) help-point))
(setq author "An unknown author")))
;; ... and newsgroup
(save-excursion
(goto-char (point-min))
(setq help-point
(search-forward-regexp
"^Newsgroups: \\(.*\\)$"
(point-max) t))
(if help-point
(setq newsgroup (buffer-substring (match-beginning 1) help-point))
(setq newsgroup (if (or (eq major-mode 'gnus-article-mode)
(eq major-mode 'vm-mode)
(eq major-mode 'rmail-mode))
fortune-from-mail
"unknown"))))
;; append entry to end of fortune file, and display result
(setq string (concat "\"" string "\""
"\n"
fortune-author-line-prefix
author " in " newsgroup))
(fortune-append string t file)))