unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#14915: [PATCH] Enhancement to fortune.el
@ 2013-07-20  3:01 Joshua Datko
  2016-02-24  4:42 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Joshua Datko @ 2013-07-20  3:01 UTC (permalink / raw)
  To: 14915

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.





^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#14915: [PATCH] Enhancement to fortune.el
  2013-07-20  3:01 bug#14915: [PATCH] Enhancement to fortune.el Joshua Datko
@ 2016-02-24  4:42 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2016-02-24  4:42 UTC (permalink / raw)
  To: Joshua Datko; +Cc: 14915

Joshua Datko <jbdatko@gmail.com> writes:

> 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.

Thanks for the patch.  I installed a variant of it on the Emacs trunk.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-02-24  4:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-20  3:01 bug#14915: [PATCH] Enhancement to fortune.el Joshua Datko
2016-02-24  4:42 ` Lars Ingebrigtsen

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).