branch: externals/ergoemacs-mode commit 876e40ef6daf4c83b673a85bbd0b806b643fc91b Merge: 87a332c 97ac03f Author: Walter Landry <wlan...@caltech.edu> Commit: Walter Landry <wlan...@caltech.edu>
Merge branch 'master' into ergoterm --- ergoemacs-command-loop.el | 38 +--- ergoemacs-component.el | 9 - ergoemacs-mode.el | 6 - ergoemacs-score.el | 439 ---------------------------------------------- ergoemacs-themes.el | 98 +++++------ ergoemacs-translate.el | 40 +---- 6 files changed, 47 insertions(+), 583 deletions(-) diff --git a/ergoemacs-command-loop.el b/ergoemacs-command-loop.el index 4e91b05..959e4b4 100644 --- a/ergoemacs-command-loop.el +++ b/ergoemacs-command-loop.el @@ -173,7 +173,6 @@ ignore the post-command hooks.") (defvar ergoemacs-command-loop-time-before-blink) (defvar ergoemacs-command-loop-blink-character) (defvar ergoemacs-command-loop-blink-rate) -(defvar ergoemacs-command-loop-hide-shift-translations) (defvar ergoemacs-mode) (defvar ergoemacs-command-loop-type) (defvar ergoemacs-keymap) @@ -703,9 +702,6 @@ KEYS is the keys information" (push 'ergoemacs-timeout unread-command-events)) (setq ergoemacs-command--timeout-keys nil)))) -(defvar ergoemacs-this-command-keys-shift-translated nil - "ergoemacs override of shift translation in command loop.") - (defun ergoemacs-command--echo-prefix () "Echos prefix keys in the ergoemacs-mode way." (let ((keys (this-single-command-keys))) @@ -787,8 +783,7 @@ read." ;; Don't echo the uncommon hyper/super/alt translations (alt is ;; not the alt key...) (dolist (tr trans) - (unless (or (memq 'hyper (nth 0 tr)) (memq 'super (nth 0 tr)) (memq 'alt (nth 0 tr)) - (and ergoemacs-command-loop-hide-shift-translations (memq 'shift (nth 0 tr)))) + (unless (or (memq 'hyper (nth 0 tr)) (memq 'super (nth 0 tr)) (memq 'alt (nth 0 tr))) (if (member (list (nth 1 tr) (nth 0 tr)) trans) (when (not (member (list (nth 1 tr) (nth 0 tr)) double)) (push tr double)) @@ -1431,8 +1426,7 @@ needed (and resotre them to the original values)." "Call the COMMAND interactively. Also handle mouse events (if possible.) The RECORD-FLAG and KEYS are sent to `ergoemacs-command-loop--grow-interactive'." (ergoemacs-command-loop--sync-point) - (setq ergoemacs-last-command-was-ergoemacs-ignore-p nil - this-command-keys-shift-translated (or ergoemacs-this-command-keys-shift-translated this-command-keys-shift-translated)) + (setq ergoemacs-last-command-was-ergoemacs-ignore-p nil) (cond ((and (eventp last-command-event) (consp last-command-event) @@ -1449,7 +1443,7 @@ The RECORD-FLAG and KEYS are sent to `ergoemacs-command-loop--grow-interactive'. (ergoemacs-command-loop--grow-interactive command record-flag keys))) (t (ergoemacs-command-loop--grow-interactive command record-flag keys))) - (setq ergoemacs-this-command-keys-shift-translated nil)) + ) (defun ergoemacs-command-loop-start () @@ -1676,8 +1670,7 @@ Emacs versions)." "Key sequence %s aborted by %s" (ergoemacs-key-description last-current-key) (ergoemacs-key-description raw-key)) - (setq quit-flag t - ergoemacs-this-command-keys-shift-translated nil)) + (setq quit-flag t)) ;; Handle local commands. ((and (not (equal current-key raw-key)) (setq command (lookup-key local-keymap raw-key)) @@ -1981,8 +1974,7 @@ pressed the translated key by changing ;; Make sure to lookup the keys in the selected buffer (ergoemacs-command-loop--sync-point) (let ((trials (ergoemacs-translate--trials key)) - tmp ret) - (setq this-command-keys-shift-translated nil) + tmp ret) (catch 'found-command (dolist (cur-key trials) (when cur-key @@ -2027,11 +2019,6 @@ pressed the translated key by changing ((equal orig-key (nth 0 trials)) (setq ergoemacs-command-loop--single-command-keys new-key) (ergoemacs-command-loop--message-binding new-key ret)) - ((equal orig-key (nth 1 trials)) ;; `ergoemacs-mode' shift translation - (setq this-command-keys-shift-translated t - ergoemacs-command-loop--single-command-keys (nth 0 trials)) - - (ergoemacs-command-loop--message-binding new-key ret key)) (t (ergoemacs-command-loop--message-binding new-key ret key) (setq ergoemacs-command-loop--single-command-keys new-key))) @@ -2091,22 +2078,7 @@ pressed the translated key by changing (setq ergoemacs-command-loop--single-command-keys nil))))) ;; (ergoemacs-command-loop--spinner-end) )) -(defun ergoemacs-command-loop--shift-timeout () - "This is the shift-timeout function for a key." - (interactive) - (let ((shift-trans (ergoemacs-translate--emacs-shift (this-single-command-keys)))) - (setq ergoemacs-this-command-keys-shift-translated t) - (ergoemacs-command-loop--internal shift-trans))) -(defun ergoemacs-command-loop--shift-translate () - "Shift translation." - (interactive) - (let ((shift-trans (ergoemacs-translate--emacs-shift (this-single-command-keys) 'ergoemacs-shift))) - (message "%s->%s" (key-description (this-single-command-keys)) - (key-description shift-trans)) - (setq ergoemacs-this-command-keys-shift-translated t - this-command-keys-shift-translated t) - (ergoemacs-command-loop--call-interactively (key-binding shift-trans)))) (provide 'ergoemacs-command-loop) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ergoemacs-command-loop.el ends here diff --git a/ergoemacs-component.el b/ergoemacs-component.el index fb89e6e..5dbfd80 100644 --- a/ergoemacs-component.el +++ b/ergoemacs-component.el @@ -369,15 +369,6 @@ Allows the component not to be calculated." (setq tmp (lookup-key global-map (read-kbd-macro (nth 0 def)))) (commandp tmp)) tmp) - ((and (consp def) - (= 2 (length def)) - (stringp (nth 0 def)) - (or (not (nth 1 def)) - (ergoemacs-gethash (nth 1 def) ergoemacs-translation-hash))) - `(lambda(&optional arg) - (interactive "P") - (setq ergoemacs-this-command-keys-shift-translated t) - (ergoemacs-command-loop ,(nth 0 def) ',(nth 1 def)))) ((ergoemacs-keymapp (ergoemacs-sv def)) (ergoemacs-sv def)) (t def)))) diff --git a/ergoemacs-mode.el b/ergoemacs-mode.el index ea98246..76534a8 100644 --- a/ergoemacs-mode.el +++ b/ergoemacs-mode.el @@ -941,12 +941,6 @@ Valid values are: (const :tag "No command loop support" nil)) :group 'ergoemacs-comamnd-loop) -(defcustom ergoemacs-command-loop-hide-shift-translations t - "Hide shift translations in the command loop help." - :type 'boolean - :group 'ergoemacs-command-loop) - - (defcustom ergoemacs-command-loop-echo-keystrokes 1 "The amount of time before `ergoemacs-mode' displays keystrokes." :type 'number diff --git a/ergoemacs-score.el b/ergoemacs-score.el deleted file mode 100644 index f647926..0000000 --- a/ergoemacs-score.el +++ /dev/null @@ -1,439 +0,0 @@ -;;; ergoemacs-score.el --- Ergoemacs ergonomic score -*- lexical-binding: t -*- - -;; Copyright © 2013-2015 Free Software Foundation, Inc. - -;; Filename: ergoemacs-score.el -;; Author: Matthew L. Fidler -;; Maintainer: -;; -;;; Commentary: -;; -;; -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; Change Log: -;; -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; 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, 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 <http://www.gnu.org/licenses/>. -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; Code: -(defvar ergoemacs-track-hand - '(0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 - 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 - 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 - 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 - 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 - 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 - 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 - 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1) - "Based on ergoemcs-layouts, which hand is typing? -0 represents left, 1 represents right.") - -(defvar ergoemacs-track-row - '(1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 - 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 - 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 - 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 - 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 - 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 - 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 - 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4) - "Based on ergoemacs-layouts, what row is being used? -1 = 1st row/number row -2 = 2nd row -3 = 3rd row/home row -4 = 4th row") - -(defvar ergoemacs-track-finger - ' (0 0 0 1 2 3 3 4 4 5 6 7 7 7 7 - 0 0 0 1 2 3 3 4 4 5 6 7 7 7 7 - 0 0 0 1 2 3 3 4 4 5 6 7 7 7 7 - 0 0 0 1 2 3 3 4 4 5 6 7 7 7 7 - 0 0 0 1 2 3 3 4 4 5 6 7 7 7 7 - 0 0 0 1 2 3 3 4 4 5 6 7 7 7 7 - 0 0 0 1 2 3 3 4 4 5 6 7 7 7 7 - 0 0 0 1 2 3 3 4 4 5 6 7 7 7 7) - "Track the finger based on the ergoemacs-layout. -0 = left pinky, -1 = left ring -2 = left middle -3 = left pointer -4 = right pointer -5 = right middle -6 = right ring -7 = right pinky -") - -;; These are taken from http://www.colemak.com/wiki/index.php?title=Compare -(defvar ergoemacs-key-width 18.0 - "Assumption of key width (in px)") - -(defvar ergoemacs-key-height 22.0 - "Assumption of key height (in px)") - -(defvar ergoemacs-tab-key-width 28.0 - "Assumption of key width (in px)") - -(defvar ergoemacs-lock-key-width 34.0 - "Assumption of lock key width (in px)") - -(defvar ergoemacs-shift-key-width 26.0 - "Assumption of shift key width (in px)") - -(defvar ergoemacs-return-key-width 36.0 - "Assumption of return key width (in px)") - -(defvar ergoemacs-tab-key-width 28.0 - "Assumption of tab key width (in px)") - -(defvar ergoemacs-key-width-m 0.010 - "Default key width (in m)") - -(defvar ergoemacs-keyboard-coordinates-x nil - "Keyboard x-coordinates (in m)") - -(defvar ergoemacs-keyboard-coordinates-y nil - "Keyboard y-coordinates (in m)") - -(defun ergoemacs-calculate-keyboard-coordinates () - "Calculates `ergoemacs-keyboard-coordinates-x' and -`ergoemacs-keyboard-coordintes-y'" - (setq ergoemacs-keyboard-coordinates-x - (let ((i 0) - (last 0) - curr) - (mapcar - (lambda(_x) - (setq i (+ i 1)) - (setq curr (+ last (/ ergoemacs-tab-key-width 2))) - (cond - ((or (= 17 i) (= 58 i)) - (setq last ergoemacs-tab-key-width)) - ((or (= 34 i) (= 75 i)) - (setq last ergoemacs-lock-key-width)) - ((or (= 41 i) (= 92 i)) - (setq last ergoemacs-shift-key-width)) - (t - (setq last (+ last ergoemacs-key-width)))) - (* (/ ergoemacs-key-width-m ergoemacs-key-width) curr)) - ergoemacs-track-finger))) - - (setq ergoemacs-keyboard-coordinates-y - (let ((i 0) - (last 0) - curr) - (mapcar - (lambda(_x) - (setq i (+ i 1)) - (setq curr (+ last (/ ergoemacs-tab-key-width 2))) - (cond - ((= 58 i) - (setq last 0)) - ((or (= 17 i) (= 34 i) (= 75 i)(= 41 i) (= 92 i)) - (setq last (+ last ergoemacs-tab-key-width)))) - (* (/ ergoemacs-key-width-m ergoemacs-key-width) curr)) - ergoemacs-track-finger)))) - -(ergoemacs-calculate-keyboard-coordinates) - -(defun ergoemacs-key-properties (key layout &optional curr-i) - "Key the KEY properties based on ergoemacs LAYOUT" - (let ((i 0) - (lay (intern-soft (format "ergoemacs-layout-%s" layout))) - wi xh yh xc yc - dx dy - ret) - (when lay - (if curr-i - (setq wi curr-i) - (dolist (x (ergoemacs-sv lay)) - (when (string= key x) - (setq wi i)) - (setq i (+ i 1)))) - (setq i wi) - (setq xh (nth (if (<= (nth i ergoemacs-track-finger) 3) - (+ 32 (nth i ergoemacs-track-finger)) - (+ 38 (- (nth i ergoemacs-track-finger) 4))) - ergoemacs-keyboard-coordinates-x)) - (setq yh (nth (if (<= (nth i ergoemacs-track-finger) 3) - (+ 32 (nth i ergoemacs-track-finger)) - (+ 38 (- (nth i ergoemacs-track-finger) 4))) - ergoemacs-keyboard-coordinates-y)) - (setq xc (nth i ergoemacs-keyboard-coordinates-x)) - (setq yc (nth i ergoemacs-keyboard-coordinates-y)) - (setq dx (- xc xh)) - (setq dy (- yc yh)) - - (setq ret - `(:x ,xc - :y ,yc - :x-home ,xh - :y-home ,yh - :d-home ,(sqrt (+ (* dx dx) (* dy dy))) - - :hand ,(if (= 0 (nth i ergoemacs-track-hand)) - 'left - 'right) - - :finger ,(cond - ((or (= 0 (nth i ergoemacs-track-finger)) - (= 7 (nth i ergoemacs-track-finger))) - 'pinky) - ((or (= 1 (nth i ergoemacs-track-finger)) - (= 6 (nth i ergoemacs-track-finger))) - 'ring) - ((or (= 2 (nth i ergoemacs-track-finger)) - (= 5 (nth i ergoemacs-track-finger))) - 'middle) - (t - 'pointer)) - - :finger-n ,(nth i ergoemacs-track-finger) - - :row-n ,(nth i ergoemacs-track-row) - - :row ,(cond - ((= 1 (nth i ergoemacs-track-row)) - 'number) - ((= 2 (nth i ergoemacs-track-row)) - 'top) - ((= 3 (nth i ergoemacs-track-row)) - 'home) - ((= 4 (nth i ergoemacs-track-row)) - 'bottom)))) - ret))) - -(defvar ergoemacs-key-hash nil - "Key hash") - -(defvar ergoemacs-distance-hash nil - "Distance hash.") - -(setq ergoemacs-distance-hash (make-hash-table :test 'equal)) - -(setq ergoemacs-key-hash (make-hash-table :test 'equal)) - -(declare-function ergoemacs-get-layouts "ergoemacs-layouts.el") -(dolist (layout (ergoemacs-get-layouts t)) - (let ((lay (intern-soft (format "ergoemacs-layout-%s" layout)))) - (when lay - (dolist (key (ergoemacs-sv lay)) - (unless (string= key "") - (puthash (cons layout key) - (ergoemacs-key-properties key layout) - ergoemacs-key-hash)))))) - -(defun ergoemacs-key-distance (key1 key2 &optional last-plist layout) - "Gets the key distance based on the layout. -KEY1 is the first key pressed. -KEY2 is the second key pressed. -LAYOUT is the ergoemacs-layout used. -LAST-PLIST is the last property list returned by this function or nil if nothing was returned previously." - (if layout - (let ((ret (ergoemacs-gethash (cons (cons key1 key2) (cons last-plist layout)) ergoemacs-key-hash))) - (if ret - ret - (let ((kp1 (ergoemacs-gethash (cons layout key1) ergoemacs-key-hash)) - (kp2 (ergoemacs-gethash (cons layout key2) ergoemacs-key-hash)) - kpl kpl1 - (kp12 (ergoemacs-gethash (cons layout (cons key1 key2)) ergoemacs-key-hash)) - dx dy) - - (when (and (not kp12) kp1 kp2 - (eq (plist-get kp1 :finger-n) (plist-get kp2 :finger-n))) - (setq dx (- (plist-get kp1 :x) (plist-get kp2 :x))) - (setq dy (- (plist-get kp1 :y) (plist-get kp2 :y))) - (setq kp12 (sqrt (+ (* dx dx) (* dy dy)))) - (puthash (cons layout (cons key1 key2)) kp12 ergoemacs-key-hash)) - - (cond - ((and (not last-plist) (not kp1) (not kp2)) - (setq ret `(:d 0 :dh 0 - :finger-n -10 - :key ,key2))) - ((and last-plist (not kp1) (not kp2)) - (setq ret `(:d ,(plist-get last-plist :dh) :dh 0 - :finger-n -10 - :key ,key2))) - ((and (not last-plist) kp1 (not kp2)) - - ;; kp2 is not defined. Assume space or no-length character. - (setq ret `(:d ,(* 2 (plist-get kp1 :d-home)) :dh 0 - :finger-n -10 - :key ,key2))) - - ((and (not last-plist) (not kp1) kp2) - ;; kp1 is not defined. Assume space or no-length character. - (setq ret `(:d ,(plist-get kp2 :d-home) :dh ,(plist-get kp2 :d-home) - :finger-n ,(plist-get kp2 :finger-n) - :key ,key2))) - - ((and last-plist (not kp1) kp2) - ;; kp1 is not defined. Assume space or no-length character. - (setq ret `(:d ,(+ (plist-get last-plist :dh) - (plist-get kp2 :d-home)) - :dh ,(plist-get kp2 :d-home) - :finger-n ,(plist-get kp2 :finger-n) - :key ,key2))) - - ((and last-plist kp1 (not kp2) - (eq (plist-get last-plist :finger-n) (plist-get kp1 :finger-n))) - - ;; Last keypress was on the same finger as kp1. kp2 is a reset. - (setq kpl (ergoemacs-gethash (cons layout (plist-get last-plist :key)) ergoemacs-key-hash)) - (setq kpl1 (ergoemacs-gethash (cons layout (cons (plist-get last-plist :key) key1)) - ergoemacs-key-hash)) - - (when (not kpl1) - (setq dx (- (plist-get kpl :x) (plist-get kp1 :x))) - (setq dy (- (plist-get kpl :y) (plist-get kp1 :y))) - (setq kpl1 (sqrt (+ (* dx dx) (* dy dy)))) - (puthash (cons layout - (cons (plist-get last-plist :key) - key1)) kp12 ergoemacs-key-hash)) - (setq ret `(:d ,(+ kpl1 (plist-get kp1 :d-home)) :dh 0 - :finger-n -10 - :key ,key2))) - ((and last-plist kp1 (not kp2)) - ;; last keypress was not on the same finger as kp1. kp2 is a - ;; reset - (setq ret `(:d ,(+ (plist-get last-plist :dh) - (* 2 (plist-get kp1 :d-home))) - :dh 0 - :finger-n -10 - :key ,key2))) - ((and (not last-plist) - (eq (plist-get kp1 :finger-n) (plist-get kp2 :finger-n))) - - ;; Distance when key1 and key2 are on the same finger is: - ;; D(Home,Key1)+D(Key1,Key2) - ;; Residual is D(Key2, Home) - - (setq ret `(:d ,(+ (plist-get kp1 :d-home) kp12) :dh ,(plist-get kp2 :d-home) - :finger-n ,(plist-get kp2 :finger-n) - :key ,key2))) - ((not last-plist) - - ;; Distance when key1 and key2 are on a different finger is: - ;; 2*D(Home,Key1)+D(Home,Key2) - ;; Residual is D(Key2,Home) - - (setq ret `(:d ,(+ (* 2 (plist-get kp1 :d-home)) - (plist-get kp2 :d-home)) - :dh ,(plist-get kp2 :d-home) - :finger-n ,(plist-get kp2 :finger-n) - :key ,key2))) - - ((and (eq (plist-get last-plist :finger-n) (plist-get kp1 :finger-n)) - (eq (plist-get last-plist :finger-n) (plist-get kp2 :finger-n))) - - ;; The last finger called is the same as the current finger - ;; Key1 and Key 2 are on the same finger - ;; Distance is D(Last-Key,Key1)+D(Key1,Key2) - ;; Residual Distance is D(Key2,Home) - - (setq kpl (ergoemacs-gethash (cons layout (plist-get last-plist :key)) ergoemacs-key-hash)) - (setq kpl1 (ergoemacs-gethash (cons layout (cons (plist-get last-plist :key) key1)) - ergoemacs-key-hash)) - - (when (not kpl1) - (setq dx (- (plist-get kpl :x) (plist-get kp1 :x))) - (setq dy (- (plist-get kpl :y) (plist-get kp1 :y))) - (setq kpl1 (sqrt (+ (* dx dx) (* dy dy)))) - (puthash (cons layout - (cons (plist-get last-plist :key) - key1)) kp12 ergoemacs-key-hash)) - - (setq ret `(:d ,(+ kpl1 kp12) - :dh ,(plist-get kp2 :d-home) - :finger-n ,(plist-get kp2 :finger-n) - :key ,key2))) - ((and (eq (plist-get last-plist :finger-n) (plist-get kp1 :finger-n))) - ;; The last finger is the same as kp1. the kp1 finger is - ;; different from kp2. - ;; - ;; Distance is D(Last,kp1)+D(kp1,home)+D(kp2,home) - ;; Residual is D(kp2,home) - (setq kpl (ergoemacs-gethash (cons layout (plist-get last-plist :key)) ergoemacs-key-hash)) - (setq kpl1 (ergoemacs-gethash (cons layout (cons (plist-get last-plist :key) key1)) - ergoemacs-key-hash)) - - (when (not kpl1) - (setq dx (- (plist-get kpl :x) (plist-get kp1 :x))) - (setq dy (- (plist-get kpl :y) (plist-get kp1 :y))) - (setq kpl1 (sqrt (+ (* dx dx) (* dy dy)))) - (puthash (cons layout - (cons (plist-get last-plist :key) - key1)) kp12 ergoemacs-key-hash)) - - (setq ret `(:d ,(+ kpl1 (plist-get kp1 :d-home) (plist-get kp2 :d-home)) - :dh ,(plist-get kp2 :d-home) - :finger-n ,(plist-get kp2 :finger-n) - :key ,key2))) - ((and - (not (eq (plist-get last-plist :finger-n) (plist-get kp1 :finger-n))) - (eq (plist-get kp1 :finger-n) (plist-get kp2 :finger-n))) - ;; The last finger called not the same as kp1 - ;; key1 and key2 are on the same finger. - ;; Distance is D(Last-Key,home)+D(Key1,Key2) - ;; Residual Distance is D(Key2,Home) - (setq ret `(:d ,(+ (plist-get last-plist :dh) kp12) - :dh ,(plist-get kp2 :d-home) - :finger-n ,(plist-get kp2 :finger-n) - :key ,key2))) - (t - ;; The three fingers are on different hands or the last finger - ;; pressed and kp2 are on the same hand. For this layout the - ;; distance is given by: - ;; d(Last,Home)+2*D(home,kp1)+D(home,kp2) - ;; Residual distance is D(kp2,home) - (setq ret `(:d ,(+ (plist-get last-plist :dh) - (* 2 (plist-get kp1 :d-home)) - (plist-get kp2 :d-home)) - :dh ,(plist-get kp2 :d-home) - :finger-n ,(plist-get kp2 :finger-n) - :key ,key2))))) - (puthash (cons (cons key1 key2) (cons last-plist layout)) ret ergoemacs-key-hash) - ret)) - (let (ret) - (setq ret - (mapcar - (lambda(lay) - (let (last-p - (dist (ergoemacs-gethash lay ergoemacs-distance-hash 0)) - ret) - (when last-plist - (setq last-p (assoc lay last-plist)) - (when last-p - (setq last-p (cadr last-p)))) - (setq ret (ergoemacs-key-distance key1 key2 last-p lay)) - (puthash lay (+ dist (plist-get ret :d)) ergoemacs-distance-hash) - `(,lay ,ret))) - (ergoemacs-get-layouts))) - ret))) - -(defvar ergoemacs-last-distance-plist nil - "Last distance plist") - -(defvar ergoemacs-last-key-press nil) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; ergoemacs-score.el ends here -;; Local Variables: -;; coding: utf-8-emacs -;; End: diff --git a/ergoemacs-themes.el b/ergoemacs-themes.el index 7d4ef7d..05aef05 100644 --- a/ergoemacs-themes.el +++ b/ergoemacs-themes.el @@ -39,7 +39,6 @@ (require 'advice) (require 'ibuffer) -(require 'ibuf-ext) (ergoemacs-component standard-vars () "Enabled/changed variables/modes" @@ -176,25 +175,25 @@ (global-set-key (kbd "C-n") 'ergoemacs-new-empty-buffer) (global-set-key (kbd "C-x C-f") nil) ;; Remove Emacs Method - (global-set-key (kbd "C-o") ("C-o" :emacs)) + (global-set-key (kbd "C-o") 'find-file) (global-set-key (kbd "C-S-o") 'ergoemacs-open-in-desktop) (global-set-key (kbd "C-S-t") 'ergoemacs-open-last-closed) (global-set-key (kbd "C-w") 'ergoemacs-close-current-buffer) (global-set-key (kbd "C-s") nil) ;; Search Forward - (global-set-key (kbd "C-f") ("C-s" :emacs)) + (global-set-key (kbd "C-f") 'isearch-forward) (global-set-key (kbd "C-x C-s") nil) ;; Save File - (global-set-key (kbd "C-s") ("C-x C-s" :emacs)) + (global-set-key (kbd "C-s") 'save-buffer) (global-set-key (kbd "C-x C-w") nil) ;; Write File - (global-set-key (kbd "C-S-s") ("C-x C-w" :emacs)) + (global-set-key (kbd "C-S-s") 'write-file) (global-set-key (kbd "C-p") 'ergoemacs-print-buffer-confirm) (global-set-key (kbd "C-x h") nil) ;; Mark whole buffer - (global-set-key (kbd "C-a") ("C-x h" :emacs)) + (global-set-key (kbd "C-a") 'mark-whole-buffer) (global-set-key (kbd "C-z") 'undo) @@ -397,7 +396,7 @@ (ergoemacs-component fixed-newline () "Newline and indent" - (global-set-key (kbd "M-RET") ("C-j" :emacs)) + (global-set-key (kbd "M-RET") 'electric-newline-and-maybe-indent) (define-key helm-map (kbd "M-RET") 'helm-execute-persistent-action) (define-key helm-map (kbd "<M-return>") 'helm-execute-persistent-action) (define-key helm-map (kbd "M-S-RET") "C-u M-RET") @@ -536,30 +535,30 @@ (ergoemacs-component move-char () "Movement by Characters & Set Mark" (global-set-key (kbd "C-b") nil) - (global-set-key (kbd "M-j") ("C-b" :emacs)) + (global-set-key (kbd "M-j") 'backward-char) (global-set-key (kbd "C-f") nil) - (define-key global-map (kbd "M-l") ("C-f" :emacs)) + (define-key global-map (kbd "M-l") 'forward-char) (global-set-key (kbd "C-p") nil) - (define-key (current-global-map) (kbd "M-i") ("C-p" :emacs)) + (define-key (current-global-map) (kbd "M-i") 'previous-line) (global-set-key (kbd "C-n") nil) - (define-key ergoemacs-keymap (kbd "M-k") ("C-n" :emacs)) + (define-key ergoemacs-keymap (kbd "M-k") 'next-line) ;; These are here so that C-M-i will translate to C-<up> for modes ;; like inferior R mode. That allows the command to be the last ;; command. ;; Not sure it belongs here or not... - (global-set-key (kbd "M-C-j") ("<C-left>" :emacs)) - (global-set-key (kbd "M-C-l") ("<C-right>" :emacs)) - (global-set-key (kbd "M-C-i") ("<C-up>" :emacs)) - (global-set-key (kbd "M-C-k") ("<C-down>" :emacs)) + (global-set-key (kbd "M-C-j") 'left-word) + (global-set-key (kbd "M-C-l") 'right-word) + (global-set-key (kbd "M-C-i") 'backward-paragraph) + (global-set-key (kbd "M-C-k") 'forward-paragraph) (global-set-key (kbd "C-SPC") nil) ;; Set Mark - (global-set-key (kbd "M-SPC") ("C-SPC" :emacs)) + (global-set-key (kbd "M-SPC") 'set-mark-command) ;; Delete previous/next char. (global-set-key (kbd "M-d") 'delete-backward-char) @@ -628,21 +627,20 @@ "Move by Paragraph" (global-unset-key (kbd "M-{")) (global-unset-key (kbd "M-}")) - (global-set-key (kbd "M-U") ("M-{" :emacs)) - (global-set-key (kbd "M-O") ("M-}" :emacs)) + (global-set-key (kbd "M-U") 'backward-paragraph) + (global-set-key (kbd "M-O") 'forward-paragraph) ;; Mode specific movement (define-key term-raw-map (kbd "M-U") ("M-{" :emacs)) (define-key term-raw-map (kbd "M-O") ("M-}" :emacs)) - ) +) (ergoemacs-component move-line () "Move by Line" (global-unset-key (kbd "C-a")) (global-unset-key (kbd "C-e")) - (global-set-key (kbd "M-h") ("C-a" :emacs)) - (global-set-key (kbd "M-H") ("C-e" :emacs)) - + (global-set-key (kbd "M-h") 'move-beginning-of-line) + (global-set-key (kbd "M-H") 'move-end-of-line) ;; Mode specific movement (define-key eshell-mode-map [remap move-beginning-of-line] 'eshell-bol) (define-key comint-mode-map [remap move-beginning-of-line] 'comint-bol) @@ -667,10 +665,10 @@ (global-unset-key (kbd "C-M-v")) ;; Not sure I like the scroll other window placment... C+M+ argh. (global-set-key (kbd "C-M-I") 'scroll-other-window-down) - (global-set-key (kbd "C-M-K") ("C-M-v" :emacs)) + (global-set-key (kbd "C-M-K") 'scroll-other-window) ;; These are OK - (global-set-key (kbd "M-I") ("M-v" :emacs)) - (global-set-key (kbd "M-K") ("C-v" :emacs)) + (global-set-key (kbd "M-I") 'scroll-down-command) + (global-set-key (kbd "M-K") 'scroll-up-command) ;; Mode specific movement (define-key term-raw-map (kbd "M-I") 'scroll-down) @@ -722,15 +720,15 @@ (global-set-key (kbd "M-C") 'ergoemacs-copy-all) (global-set-key (kbd "M-X") 'ergoemacs-cut-all) - (global-set-key (kbd "M-Z") '("C-_" :emacs)) + (global-set-key (kbd "M-Z") 'undo-tree-redo) ;; Undo (global-set-key (kbd "C-_") nil) (global-set-key (kbd "C-/") nil) (global-set-key (kbd "C-x u") nil) - (global-set-key (kbd "M-z") '("C-_" :emacs)) + (global-set-key (kbd "M-z") 'undo) - (global-set-key (kbd "C-S-x") ("C-x" :normal)) + (global-set-key (kbd "C-S-x") 'execute-extended-command) (global-set-key (kbd "C-z") 'undo) (global-set-key (kbd "C-S-z") '(redo undo-tree-redo)) (global-set-key (kbd "C-y") '(redo undo-tree-redo)) @@ -762,16 +760,16 @@ (ergoemacs-component search () "Search and Replace" (global-set-key (kbd "C-s") nil) - (global-set-key (kbd "M-y") '("C-s" :emacs)) + (global-set-key (kbd "M-y") 'isearch-forward) (global-set-key (kbd "C-r") nil) - (global-set-key (kbd "M-Y") '("C-r" :emacs)) + (global-set-key (kbd "M-Y") 'isearch-backward) (global-set-key (kbd "M-%") nil) - (global-set-key (kbd "M-5") '("M-%" :emacs)) + (global-set-key (kbd "M-5") 'query-replace) (global-set-key (kbd "C-M-%") nil) - (global-set-key (kbd "M-%") '("C-M-%" :emacs)) + (global-set-key (kbd "M-%") 'query-replace-regexp) ;; Mode specific changes (define-key term-raw-map (kbd "M-y") '("C-s" :emacs)) @@ -799,14 +797,10 @@ (global-set-key [remap isearch-backward] 'isearch-backward-regexp) (global-set-key (kbd "M-%") nil) - (global-set-key (kbd "M-5") '("C-M-%" :emacs)) + (global-set-key (kbd "M-5") 'query-replace-regexp) (global-set-key (kbd "C-M-%") nil) - (global-set-key (kbd "M-%") '("M-%" :emacs)) - - ;; Mode specific changes - (define-key term-raw-map (kbd "M-5") '("M-%" :emacs)) - (define-key term-raw-map (kbd "M-%") '("C-M-%" :emacs)) + (global-set-key (kbd "M-%") 'query-replace) ) @@ -850,37 +844,27 @@ (ergoemacs-component execute () "Execute Commands" (global-unset-key (kbd "M-x")) - (global-set-key (kbd "M-a") '("M-x" :emacs)) + (global-set-key (kbd "M-a") 'execute-extended-command) (global-unset-key (kbd "M-!")) - (global-set-key (kbd "M-A") '("M-!" :emacs)) - - ;; Mode specific changes - (define-key term-raw-map (kbd "M-a") '("M-x" :emacs)) - (define-key term-raw-map (kbd "M-A") '("M-!" :emacs)) - ) + (global-set-key (kbd "M-A") 'shell-command)) -(ergoemacs-component misc () +(ergoemacs-component misc () "Misc Commands" (global-unset-key (kbd "C-l")) - (global-set-key (kbd "M-p") '("C-l" :emacs)) + (global-set-key (kbd "M-p") 'recenter-top-bottom) (global-set-key (kbd "M-b") 'avy-goto-word-or-subword-1)) (ergoemacs-component kill-line () "Kill Line" (global-unset-key (kbd "C-k")) - (global-set-key (kbd "M-g") '("C-k" :emacs)) - (global-set-key (kbd "M-G") 'ergoemacs-kill-line-backward) - - ;; Mode specific changes - (define-key term-raw-map (kbd "M-g") nil) - (define-key term-raw-map (kbd "M-G") nil) - ) + (global-set-key (kbd "M-g") 'kill-line) + (global-set-key (kbd "M-G") 'ergoemacs-kill-line-backward)) (ergoemacs-component text-transform () "Text Transformation" (global-unset-key (kbd "M-;")) - (global-set-key (kbd "M-'") '("M-;" :emacs)) - (global-set-key (kbd "M-\"") '("M-;" :emacs)) + (global-set-key (kbd "M-'") 'comment-dwim) + (global-set-key (kbd "M-\"") 'delete-horizontal-space) (global-set-key (kbd "M-w") 'ergoemacs-shrink-whitespaces) @@ -943,7 +927,7 @@ "<apps> TAB" indent-region ;; Already in CUA "<apps> SPC" set-mark-command "<apps> a" mark-whole-buffer - "<apps> d" ("C-x" :ctl-to-alt) + "<apps> d" execute-extended-command "<apps> h" help-map "<apps> h '" ergoemacs-describe-current-theme "<apps> h 1" describe-function diff --git a/ergoemacs-translate.el b/ergoemacs-translate.el index 09281d2..de4e8c1 100644 --- a/ergoemacs-translate.el +++ b/ergoemacs-translate.el @@ -230,43 +230,6 @@ If no changes are performed, return nil." (setq ret new-key)) ret))) -(defun ergoemacs-translate--ergoemacs-shift-select (key) - "Translate KEY to allow `ergoemacs-mode' shift translation. - -This will shift translate Alt+# to Alt+3." - (let (modifiers basic) - (when (and (vectorp key) - ;; only makes sense for single key combinations. - (= (length key) 1) - ;; Doesn't make sense if shifted... - (not (or (memq 'shift (setq modifiers (ergoemacs-translate--event-modifiers (aref key 0)))) - (memq 'ergoemacs-shift modifiers))) - ;; Only define if emacs doesn't handle shift selection. - (not (eq (event-convert-list (list 'shift (setq basic (event-basic-type (aref key 0))))) - (ergoemacs-translate--event-convert-list (list 'ergoemacs-shift basic))))) - (setq ergoemacs-translate--define-key-if-defined-p nil - ergoemacs-translate--define-key-replacement-function 'ergoemacs-command-loop--shift-translate) - (vector (ergoemacs-translate--event-convert-list (append modifiers (list 'ergoemacs-shift basic))))))) - -(defun ergoemacs-translate--ergoemacs-timeout (key) - "Translates KEY to allow Shift translation to default to key sequence. - -This is done for key sequences like Ctrl+Shift+c which should -allow the Ctrl+c key sequence to be called when text is -seleceted (instead of copying the text)." - (let (modifiers basic) - (when (and (vectorp key) - ;; only makes sense for single key combinations. - (= (length key) 2) - (eq 'ergoemacs-timeout (aref key 1)) - ;; Doesn't make sense if shifted... - (not (or (memq 'shift (setq modifiers (ergoemacs-translate--event-modifiers (aref key 0)))) - (memq 'ergoemacs-shift modifiers)))) - (setq basic (ergoemacs-translate--event-basic-type (aref key 0)) - ergoemacs-translate--define-key-if-defined-p nil - ergoemacs-translate--define-key-replacement-function 'ergoemacs-command-loop--shift-timeout) - (vector (ergoemacs-translate--event-convert-list (append modifiers (list 'shift basic))))))) - (defun ergoemacs-translate--to-string (key) "Translates KEY to string format. @@ -286,8 +249,7 @@ If no chanegs are performed, return nil." ergoemacs-translate--swap-menu ergoemacs-translate--to-string ergoemacs-translate--to-vector - ergoemacs-translate--ergoemacs-timeout - ergoemacs-translate--ergoemacs-shift-select) + ) "Functions to apply to key. These functions take a key as an argument and translate it in