gnu-emacs-sources
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Typewriter input simulation for EMACS


From: chipschap
Subject: Typewriter input simulation for EMACS
Date: Thu, 25 Jul 2013 16:13:59 -0700 (PDT)
User-agent: G2/1.0

Perhaps this has been done before but I haven't seen it, and I couldn't resist 
posting it.

This is typewriter input simulation for EMACS. Nothing but printing characters 
and 'return' can be entered. No backspace, arrows, or any other means of 
correction. What you typed stays there until you exit the simulation with C-g.


-----------------------begin writer-typewriter.el---------------
(defun writer-typewriter ()
"Act like a typewriter for input"
 (interactive)

;; Sort of an adjunct to a darkroom mode, maybe.

;; Some people say they are more productive as writers when using an
;; old-fashioned typewriter. They say that the inability to backspace,
;; use arrow keys, or otherwise make corrections or changes while
;; writing is actually an advantage. They say this is because you're
;; careful about what you write and how you write it, knowing that you
;; can't fix it (at least not immediately).

;; I don't know if I agree, and your own mileage will surely vary. But
;; it's sort of fun to try it out. Well, sort of fun.  Maybe not so
;; much.

;; Implementing in elisp is fairly straightforward. The only part of
;; the typewriter simulation that is missing is the need to press the
;; 'enter' key to get lines to break, if you're in a mode that
;; automatically wraps lines for you. It just seemed beyond the scope
;; of this function to try to figure that out and turn off the
;; 'offending' mode ... and afterwards turn it back on again.

;; Typewriter input is started with M-x writer-typewriter. It is
;; exited with the usual C-g.

;; Oh, keyclicks? That's another story. There is stuff around that
;; will do that if you are so inclined. Be careful what you wish for.

 (defvar writer-input-charno)

;; Do forever, which means until C-g is pressed.

 (while t
   (while (input-pending-p)
;;   This returns a number!
     (setq writer-input-charno (read-char-exclusive))
;; Printing characters are just inserted.
     (if (and (>= writer-input-charno 32)
              (<= writer-input-charno 126)
         )
         (progn
           (insert (char-to-string writer-input-charno))
           (redisplay t)
         )
;; The enter key translates to a newline.
         (if (= writer-input-charno 13)
             (progn
               (newline)
               (redisplay t)
             )
         )
      )
    )
  )
)
---------------end writer-typewriter.el-------------


reply via email to

[Prev in Thread] Current Thread [Next in Thread]