diff --git a/README.md b/README.md index fb58290..b236ed7 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,9 @@ # selectric-mode -Make your Emacs sound like a proper typewriter. + +Make your Emacs sound like a proper typewriter. Extremely useful if you +have a puny, silent, rubberish, non-clicky keyboard. + +The sound of the typewriter was recorded by a person nicknamed +"secretmojo" and is available on +https://www.freesound.org/people/secretmojo/sounds/224012/ under a +Creative Commons license. diff --git a/selectric-mode.el b/selectric-mode.el new file mode 100644 index 0000000..ac7634d --- /dev/null +++ b/selectric-mode.el @@ -0,0 +1,55 @@ +;;; selectric-mode.el --- IBM Selectric mode for Emacs -*- lexical-binding: t; -*- + +;; Copyright (C) 2015 Ricardo Bánffy + +;; Author: Ricardo Bánffy +;; Keywords: multimedia, convenience, typewriter, selectric + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;; This minor mode plays the sound of an IBM Selectric typewriter as +;; you type. + +;;; Code: + +(defun selectric-type-sound () + (start-process-shell-command + "*Messages*" nil (format "aplay %sselectric-type.wav" + (file-name-directory load-file-name)))) + +(define-minor-mode selectric-mode + "Toggle Selectric mode. +Interactively with no argument, this command toggles the mode. +A positive prefix argument enables the mode, any other prefix +argument disables it. From Lisp, argument omitted or nil enables +the mode, `toggle' toggles the state. + +When Selectric mode is enabled, your Emacs will sound like an IBM +Selectric typewriter." + :global t + ;; The initial value. + :init-value nil + ;; The indicator for the mode line. + :lighter " Selectric" + :group 'selectric + + (if selectric-mode + (add-hook 'post-self-insert-hook 'selectric-type-sound) + (remove-hook 'post-self-insert-hook 'selectric-type-sound)) + ) + +(provide 'selectric-mode) +;;; selectric-mode.el ends here diff --git a/selectric-move.wav b/selectric-move.wav new file mode 100644 index 0000000..6eff758 Binary files /dev/null and b/selectric-move.wav differ diff --git a/selectric-type.wav b/selectric-type.wav new file mode 100644 index 0000000..deb8e1c Binary files /dev/null and b/selectric-type.wav differ