Advertisement
mark-naylor-1701

get fortune

Mar 11th, 2024 (edited)
1,567
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.75 KB | None | 0 0
  1. ;; Designed on a full Slackware 15 install.
  2. ;; Relies on the fortune application.
  3.  
  4. ;; Parameters to control the output of fortune.
  5. ;; 'safe
  6. ;; 'maybe-offensive
  7. ;; 'offensive
  8. ;; 'star-trek
  9.  
  10. (cl-defun get-fortune (&optional (category 'safe))
  11.   "Use the included fortune application to return a saying."
  12.   (with-temp-buffer
  13.     (let* ((db (cond
  14.                 ((eq category 'safe)            "all")
  15.                 ((eq category 'maybe-offensive) "-a")
  16.                 ((eq category 'offensive)       "-o")
  17.                 ((eq category 'star-trek)       "startrek")
  18.                 (t                              "all"))))
  19.       (call-process "fortune" nil (current-buffer) nil db)
  20.       (buffer-substring-no-properties (point-min) (point-max)))))
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement