From 0dc3fe0410145a85ac6979164572d8a1512dad21 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Wed, 10 Dec 2014 17:11:31 +0100 Subject: [PATCH] Add simple multiplication table function --- emacs/.emacs.d/init.el | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/emacs/.emacs.d/init.el b/emacs/.emacs.d/init.el index 3dea91e..099f2b1 100644 --- a/emacs/.emacs.d/init.el +++ b/emacs/.emacs.d/init.el @@ -752,6 +752,16 @@ If no direction is given, don't split." (define-key yas-minor-mode-map [(tab)] nil) (define-key yas-minor-mode-map (kbd "C-\\") 'yas-expand)) +(defun multiplication-table (number &optional upto) + "" + (interactive "nMultiplication table for: \nP") + (let ((upto (or upto 10)) + (buffer (get-buffer-create "*Multiplication*"))) + (with-current-buffer buffer + (erase-buffer) + (cl-loop for i from 1 to upto do (insert (format "%5d: %d\n" i (* number i))))) + (pop-to-buffer buffer))) + ;;;; Tests (stante-after ert