emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] 20/117: Add left/right to pretty key descriptions


From: Matthew Fidler
Subject: [elpa] 20/117: Add left/right to pretty key descriptions
Date: Fri, 25 Jul 2014 13:23:56 +0000

mlf176f2 pushed a commit to branch externals/ergoemacs-mode
in repository elpa.

commit 0ef52ce4ca71fc3c33ecf0e5e04bdc48e9dc7472
Author: Matthew L. Fidler <address@hidden>
Date:   Tue Jul 15 13:09:12 2014 -0500

    Add left/right to pretty key descriptions
---
 ergoemacs-translate.el |  175 ++++++++++++++++++++++++++----------------------
 1 files changed, 94 insertions(+), 81 deletions(-)

diff --git a/ergoemacs-translate.el b/ergoemacs-translate.el
index b7dc65c..13b036a 100644
--- a/ergoemacs-translate.el
+++ b/ergoemacs-translate.el
@@ -134,91 +134,104 @@ This assumes `ergoemacs-use-unicode-char' is non-nil.  
When
         (if ergoemacs-use-M-x-p
             code
           (replace-match ergoemacs-M-x t t code))
-      (let* ((ob (or (and ergoemacs-use-unicode-brackets 
(ergoemacs-unicode-char "【" "[")) "["))
-            (cb (or (and ergoemacs-use-unicode-brackets 
(ergoemacs-unicode-char "】" "]")) "]"))
-            (ret (concat ob (replace-regexp-in-string
-                             " +$" "" (replace-regexp-in-string "^ +" "" 
code)) cb))
-            (case-fold-search nil)
-            (pt 0))
-        (when ergoemacs-use-ergoemacs-key-descriptions
-          (while (string-match "<f\\([0-9]+\\)>" ret pt)
-            (setq ret (replace-match "<F\\1>" t nil ret)
-                  pt (match-end 0)))
-          (setq pt 0)
-          (while (string-match "\\(-[A-Z]\\)\\>\\([^-]\\|$\\)" ret pt)
-            (setq pt (+ (match-end 0) 2)
-                  ret (replace-match (format "-S%s%s" (downcase (match-string 
1 ret)) (match-string 2 ret)) t t ret)))
-          (setq pt 0)
-          (while (string-match "\\_<[A-Z]\\_>" ret pt)
-            (setq pt (+ (match-end 0) 2)
-                  ret (replace-match (format "S-%s" (match-string 0 ret)) t t 
ret)))
-          (setq pt 0)
-          (while (string-match "\\(S-\\)\\{2,\\}" ret pt)
-            (setq pt (+ (match-beginning 0) 2)
-                  ret (replace-match "S-" t t ret)))
-          (dolist (args `(("\\<M-" ,(if (eq system-type 'darwin)
-                                       (cond
-                                        ((or (and (boundp 
'mac-command-modifier)
-                                                  (eq mac-command-modifier 
'meta))
-                                             (and (boundp 'ns-command-modifier)
-                                                  (eq ns-command-modifier 
'meta)))
-                                         (format "%sCmd+"
-                                                 (ergoemacs-unicode-char "⌘" 
"")))
-                                        ((or (and (boundp 
'mac-alternate-modifier)
-                                                  (eq mac-alternate-modifier 
'meta))
-                                             (and (boundp 
'ns-alternate-modifier)
-                                                  (eq ns-alternate-modifier 
'meta)))
-                                         (format "%sOpt+"
-                                                 (ergoemacs-unicode-char "⌥" 
"")))
-                                        (t "Alt+"))
-                                      "Alt+"))
-                          ("\\<C-" "Ctrl+")
-                          ("\\<S-" ,(format "%sShift+"
-                                            (ergoemacs-unicode-char "⇧" "")))
-                          ("[<>]" "")
-                          ("\\<\\(RET\\|[Rr]eturn\\)\\>" ,(format "Enter%s"
-                                                                  
(ergoemacs-unicode-char "⏎" "")))
-                          ("\\<TAB\\>" ,(format "%sTab"
-                                                (ergoemacs-unicode-char "↹" 
"")))
-                          ("\\_<\\(menu\\|apps\\)\\_>" ,(format "%s"
-                                                                
(ergoemacs-unicode-char "▤" "Menu")))
-                          ("\\_<prior\\_>" "PgUp")
-                          ("\\_<next\\_>" "PgDn")
-                          (" +" ,(concat cb ob))
-                          (,(regexp-quote (concat cb " +" ob)) ,(concat cb 
ob))))
+      (save-match-data
+        (let* ((ob (or (and ergoemacs-use-unicode-brackets 
(ergoemacs-unicode-char "【" "[")) "["))
+               (cb (or (and ergoemacs-use-unicode-brackets 
(ergoemacs-unicode-char "】" "]")) "]"))
+               (ret (concat ob (replace-regexp-in-string
+                                " +$" "" (replace-regexp-in-string "^ +" "" 
code)) cb))
+               (case-fold-search nil)
+               (pt 0))
+          (when ergoemacs-use-ergoemacs-key-descriptions
+            (while (string-match "<f\\([0-9]+\\)>" ret pt)
+              (setq ret (replace-match "<F\\1>" t nil ret)
+                    pt (match-end 0)))
             (setq pt 0)
-            (while (string-match (nth 0 args) ret pt)
-              (setq pt (+ (length (nth 1 args)) (match-beginning 0))
-                    ret (replace-match (nth 1 args) t t ret))))
-          (setq pt 0)
-          (while (string-match "[+]\\([[:lower:]]\\)\\(】\\|\\]\\)" ret pt)
-            (setq ret (replace-match (upcase (match-string 0 ret)) t t ret)
-                  pt (match-end 0)))
-          (setq pt 0)
-          (cond
-           ((and (eq system-type 'darwin)
-                 (string= "⇧" (ergoemacs-unicode-char "⇧" ""))
-                 (string= "⌘" (ergoemacs-unicode-char "⌘" ""))
-                 (string= "⌥" (ergoemacs-unicode-char "⌥" "")))
-            (dolist (args `((".Opt[+]"  "⌥")
-                            (".Cmd[+]" "⌘")
-                            (".Shift[+]" "⇧")
-                            (".Ctr?l[+]" "^")))
-              (setq pt 0)
-              (while (string-match (nth 0 args) ret pt)
-                (setq pt (+ (length (nth 1 args)) (match-beginning 0))
-                      ret (replace-match (nth 1 args) t t ret)))))
-           ((and ergoemacs-use-small-symbols
-                 (string= "⇧" (ergoemacs-unicode-char "⇧" ""))
-                 (string= "♦" (ergoemacs-unicode-char "♦" "")))
-            (dolist (args `((".Alt[+]"  "♦")
-                            (".Shift[+]" "⇧")
-                            (".Ctr?l[+]" "^")))
+            (while (string-match "\\(-[A-Z]\\)\\>\\([^-]\\|$\\)" ret pt)
+              (setq pt (+ (match-end 0) 2)
+                    ret (replace-match (format "-S%s%s" (downcase 
(match-string 1 ret)) (match-string 2 ret)) t t ret)))
+            (setq pt 0)
+            (while (string-match "\\_<[A-Z]\\_>" ret pt)
+              (setq pt (+ (match-end 0) 2)
+                    ret (replace-match (format "S-%s" (match-string 0 ret)) t 
t ret)))
+            (setq pt 0)
+            (while (string-match "\\(S-\\)\\{2,\\}" ret pt)
+              (setq pt (+ (match-beginning 0) 2)
+                    ret (replace-match "S-" t t ret)))
+            (setq pt 0)
+            (while (string-match "<\\(\\(?:C-\\|S-\\|M-\\)?[A-Za-z0-9]+\\)>" 
ret pt)
+              (setq pt (- (match-end 0) 2)
+                    ret (replace-match (match-string 1 ret) t t ret)))
+            (dolist (args `(("\\<M-" ,(if (eq system-type 'darwin)
+                                          (cond
+                                           ((or (and (boundp 
'mac-command-modifier)
+                                                     (eq mac-command-modifier 
'meta))
+                                                (and (boundp 
'ns-command-modifier)
+                                                     (eq ns-command-modifier 
'meta)))
+                                            (format "%sCmd+"
+                                                    (ergoemacs-unicode-char 
"⌘" "")))
+                                           ((or (and (boundp 
'mac-alternate-modifier)
+                                                     (eq 
mac-alternate-modifier 'meta))
+                                                (and (boundp 
'ns-alternate-modifier)
+                                                     (eq ns-alternate-modifier 
'meta)))
+                                            (format "%sOpt+"
+                                                    (ergoemacs-unicode-char 
"⌥" "")))
+                                           (t "Alt+"))
+                                        "Alt+"))
+                            ("\\<C-" "Ctrl+")
+                            ("\\<S-" ,(format "%sShift+"
+                                              (ergoemacs-unicode-char "⇧" "")))
+                            ("\\<\\(RET\\|[Rr]eturn\\)\\>" ,(format "Enter%s"
+                                                                    
(ergoemacs-unicode-char "⏎" "")))
+                            ("\\<TAB\\>" ,(format "%sTab"
+                                                  (ergoemacs-unicode-char "↹" 
"")))
+                            ("\\_<\\(menu\\|apps\\)\\_>" ,(format "%s"
+                                                                  
(ergoemacs-unicode-char "▤" "Menu")))
+                            ("\\_<prior\\_>" "PgUp")
+                            ("\\_<next\\_>" "PgDn")
+                            ("\\_<left\\_>" ,(ergoemacs-unicode-char "←" 
"left"))
+                            ("\\_<right\\_>" ,(ergoemacs-unicode-char "→" 
"right"))
+                            ("\\_<up\\_>" ,(ergoemacs-unicode-char "↑" "up"))
+                            ("\\_<down\\_>" ,(ergoemacs-unicode-char "↓" 
"down"))
+
+                            ("+left\\_>"  ,(concat "+" (ergoemacs-unicode-char 
"←" "left")))
+                            ("+right\\_>" ,(concat "+" (ergoemacs-unicode-char 
"→" "right")))
+                            ("+up\\_>"    ,(concat "+" (ergoemacs-unicode-char 
"↑" "up")))
+                            ("+down\\_>"  ,(concat "+" (ergoemacs-unicode-char 
"↓" "down")))
+                            (" +" ,(concat cb ob))
+                            (,(regexp-quote (concat cb " +" ob)) ,(concat cb 
ob))))
               (setq pt 0)
               (while (string-match (nth 0 args) ret pt)
                 (setq pt (+ (length (nth 1 args)) (match-beginning 0))
-                      ret (replace-match (nth 1 args) t t ret)))))))
-        ret))))
+                      ret (replace-match (nth 1 args) t t ret))))
+            (setq pt 0)
+            (while (string-match "[+]\\([[:lower:]]\\)\\(】\\|\\]\\)" ret pt)
+              (setq ret (replace-match (upcase (match-string 0 ret)) t t ret)
+                    pt (match-end 0)))
+            (setq pt 0)
+            (cond
+             ((and (eq system-type 'darwin)
+                   (string= "⇧" (ergoemacs-unicode-char "⇧" ""))
+                   (string= "⌘" (ergoemacs-unicode-char "⌘" ""))
+                   (string= "⌥" (ergoemacs-unicode-char "⌥" "")))
+              (dolist (args `((".Opt[+]"  "⌥")
+                              (".Cmd[+]" "⌘")
+                              (".Shift[+]" "⇧")
+                              (".Ctr?l[+]" "^")))
+                (setq pt 0)
+                (while (string-match (nth 0 args) ret pt)
+                  (setq pt (+ (length (nth 1 args)) (match-beginning 0))
+                        ret (replace-match (nth 1 args) t t ret)))))
+             ((and ergoemacs-use-small-symbols
+                   (string= "⇧" (ergoemacs-unicode-char "⇧" ""))
+                   (string= "♦" (ergoemacs-unicode-char "♦" "")))
+              (dolist (args `((".Alt[+]"  "♦")
+                              (".Shift[+]" "⇧")
+                              (".Ctr?l[+]" "^")))
+                (setq pt 0)
+                (while (string-match (nth 0 args) ret pt)
+                  (setq pt (+ (length (nth 1 args)) (match-beginning 0))
+                        ret (replace-match (nth 1 args) t t ret)))))))
+          ret)))))
 
 
 



reply via email to

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