Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:candera/emacs

  • Loading branch information...
commit 1ca7714618c1a5ef698fd635dc47f008eb4c4042 2 parents 5208260 + 55ae6d7
@candera authored
Showing with 57 additions and 43 deletions.
  1. +3 −0  .gitmodules
  2. +43 −43 candera/typing-speed.el
  3. +10 −0 init.el
  4. +1 −0  show-keys.el
View
3  .gitmodules
@@ -52,3 +52,6 @@
[submodule "popup-el"]
path = popup-el
url = https://github.com/auto-complete/popup-el.git
+[submodule "show-keys.el"]
+ path = show-keys.el
+ url = git@github.com:candera/show-keys.el.git
View
86 candera/typing-speed.el
@@ -25,9 +25,9 @@
;; Author: Craig Andera <candera@wangdera.com>
-;; Commentary: Invoke this minor mode to have your typing speed
+;; Commentary: Invoke this minor mode to have your typing speed
;; continuously displayed in the mode line, in the format [75 WPM]
-;; To use, just load this file and invoke (typing-speed-mode) or
+;; To use, just load this file and invoke (typing-speed-mode) or
;; (turn-on-typing-speed-mode)
(define-minor-mode typing-speed-mode
@@ -35,26 +35,26 @@
:lighter typing-speed-mode-text
:group 'typing-speed
(if typing-speed-mode
- (progn
- (add-hook 'post-command-hook 'typing-speed-post-command-hook)
- (setq typing-speed-event-queue '())
- (setq typing-speed-update-timer (run-with-timer 0 typing-speed-update-interval 'typing-speed-update)))
- (progn
- (remove-hook 'post-command-hook 'typing-speed-post-command-hook)
- (cancel-timer typing-speed-update-timer))))
-
-(defcustom typing-speed-window 5
+ (progn
+ (add-hook 'post-command-hook 'typing-speed-post-command-hook)
+ (setq typing-speed-event-queue '())
+ (setq typing-speed-update-timer (run-with-timer 0 typing-speed-update-interval 'typing-speed-update)))
+ (progn
+ (remove-hook 'post-command-hook 'typing-speed-post-command-hook)
+ (cancel-timer typing-speed-update-timer))))
+
+(defcustom typing-speed-window 5
"The window (in seconds) over which typing speed should be evaluated."
:group 'typing-speed)
-(defcustom typing-speed-mode-text-format " [%s/%s WPM]"
- "A format string that controls how the typing speed is displayed in the mode line.
-Must contain at least one %s delimeter. Typing speed will be inserted at the first
+(defcustom typing-speed-mode-text-format " [%s/%s WPM]"
+ "A format string that controls how the typing speed is displayed in the mode line.
+Must contain at least one %s delimeter. Typing speed will be inserted at the first
delimiter, and peak typing speed at the second."
:group 'typing-speed)
(defcustom typing-speed-update-interval 1
- "How often the typing speed will update in the mode line, in seconds.
+ "How often the typing speed will update in the mode line, in seconds.
It will always also update after every command."
:group 'typing-speed)
@@ -70,51 +70,51 @@ It will always also update after every command."
(make-variable-buffer-local 'typing-speed-event-queue)
(defun typing-speed-post-command-hook ()
- "When typing-speed-mode is enabled, fires after every command. If the
-command is self-insert-command, log it as a keystroke and update the
+ "When typing-speed-mode is enabled, fires after every command. If the
+command is self-insert-command, log it as a keystroke and update the
typing speed."
- (cond ((eq this-command 'self-insert-command)
- (let ((current-time (float-time)))
- (push current-time typing-speed-event-queue)
- (typing-speed-update)))
- ((member this-command '(delete-backward-char backward-delete-char-untabify))
- (progn
- (pop typing-speed-event-queue)
- (typing-speed-update)))))
+ (cond ((eq this-command 'self-insert-command)
+ (let ((current-time (float-time)))
+ (push current-time typing-speed-event-queue)
+ (typing-speed-update)))
+ ((member this-command '(delete-backward-char backward-delete-char-untabify))
+ (progn
+ (pop typing-speed-event-queue)
+ (typing-speed-update)))))
(defun typing-speed-update ()
"Calculate and display the typing speed."
(let ((current-time (float-time)))
- (setq typing-speed-event-queue
- (typing-speed-remove-old-events
- (- current-time typing-speed-window)
- typing-speed-event-queue))
+ (setq typing-speed-event-queue
+ (typing-speed-remove-old-events
+ (- current-time typing-speed-window)
+ typing-speed-event-queue))
(typing-speed-message-update)))
(defun typing-speed-message-update ()
"Updates the status bar with the current typing speed"
(let* ((chars-per-second (/ (length typing-speed-event-queue) (float typing-speed-window)))
- (chars-per-min (* chars-per-second 60))
- (words-per-min (/ chars-per-min 5)))
+ (chars-per-min (* chars-per-second 60))
+ (words-per-min (/ chars-per-min 5)))
(setq typing-speed-peak-speed (max words-per-min typing-speed-peak-speed))
- (setq typing-speed-mode-text
- (if (minibufferp (current-buffer))
- ""
- (format typing-speed-mode-text-format (floor words-per-min) (floor typing-speed-peak-speed))))
- ;; Attempt to prevent unnecessary flicker in the menu bar. Doesn't seem to help, though.
+ (setq typing-speed-mode-text
+ (if (minibufferp (current-buffer))
+ ""
+ (format typing-speed-mode-text-format (floor words-per-min) (floor typing-speed-peak-speed))))
+ ;; Attempt to prevent unnecessary flicker in the menu bar. Doesn't seem to help, though.
(if (not (string-equal typing-speed-mode-text typing-speed-previous-mode-text))
- (progn
- (setq typing-speed-previous-mode-text typing-speed-mode-text)
- (force-mode-line-update)))))
+ (progn
+ (setq typing-speed-previous-mode-text typing-speed-mode-text)
+ (force-mode-line-update)))))
(defun typing-speed-remove-old-events (threshold queue)
"Removes events older than than the threshold (in seconds) from the specified queue"
(if (or (null queue)
- (> threshold (car queue)))
+ (> threshold (car queue)))
nil
- (cons (car queue)
- (typing-speed-remove-old-events threshold (cdr queue)))))
+ (cons (car queue)
+ (typing-speed-remove-old-events threshold (cdr queue)))))
(defun turn-on-typing-speed ()
"Turns on typing-speed-mode"
@@ -124,4 +124,4 @@ typing speed."
(defun turn-off-typing-speed ()
"Turns off typing-speed-mode"
(if typing-speed-mode
- (typing-speed-mode)))
+ (typing-speed-mode)))
View
10 init.el
@@ -1065,6 +1065,16 @@ if the major mode is one of 'delete-trailing-whitespace-modes'"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
+;; show-keys global minor mode
+;; https://github.com/candera/show-keys.el
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(add-to-list 'load-path "~/.emacs.d/custom/show-keys.el/")
+(require 'show-keys)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
;; Miscellaneous customizations
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1  show-keys.el
@@ -0,0 +1 @@
+Subproject commit 8a70fee65dcda7303a0d52ae6196cfa22438747e
Please sign in to comment.
Something went wrong with that request. Please try again.