unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Joshua Datko <jbdatko@gmail.com>
To: 14915@debbugs.gnu.org
Subject: bug#14915: [PATCH] Enhancement to fortune.el
Date: Fri, 19 Jul 2013 21:01:30 -0600	[thread overview]
Message-ID: <m038ra2aut.fsf@gmail.com> (raw)

So, this is my first time submitting a patch.  I believe I followed the
CONTRIBUTE instructions and I built this to the latest source in bzr but
please let me know if I need to correct anything.

It's a small change, but I'm willing to sign a copyright assignment
(hopefully, it's not my last submission.)

-Josh


** Description

This is an enhancement to fortune.el to display fortunes in the
mini-buffer.  The original implementation generates fortunes and
displays them to the buffer *fortune* (this behavior did not change),
but it would change the focus to the *fortune* buffer as well.

Sometimes, I would just want to see my fortune but NOT switch over to
that buffer, hence this patch which adds an interactive function (and
small helper function) to display the fortune in the mini-buffer.

** Changelog

2013-07-20  Josh Datko  <jbdatko@gmail.com>

	* fortune.el: Added fortune-message which displays fortunes to the
	minibuffer.

** Patch

=== modified file 'lisp/play/fortune.el'
*** lisp/play/fortune.el	2013-02-15 01:30:11 +0000
--- lisp/play/fortune.el	2013-07-20 02:25:53 +0000
*************** specifies the file to choose the fortune
*** 302,307 ****
--- 302,325 ----
                             (split-string fortune-program-options)
                           fortune-program-options) (list fort-file)))))))

+ (defun fortune-generate (&optional file)
+   "Generate a new fortune and return it as a string.
+ Without an optional FILE argument it will use the value of `fortune-file'."
+   (save-excursion
+     (progn (fortune-in-buffer t file)
+            (with-current-buffer fortune-buffer-name
+              (buffer-string)))))
+
+ ;;;###autoload
+ (defun fortune-message (&optional file)
+   "Display a fortune cookie to the mini-buffer.
+ If called with a prefix, it has the same behavior as `fortune'.
+ Optional FILE is a fortune file from which a cookie will be selected."
+   (interactive (list (if current-prefix-arg
+                          (fortune-ask-file)
+                        fortune-file)))
+   (message (fortune-generate file)))
+
  ;;;###autoload
  (defun fortune (&optional file)
    "Display a fortune cookie.





             reply	other threads:[~2013-07-20  3:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-20  3:01 Joshua Datko [this message]
2016-02-24  4:42 ` bug#14915: [PATCH] Enhancement to fortune.el Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m038ra2aut.fsf@gmail.com \
    --to=jbdatko@gmail.com \
    --cc=14915@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).