[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 57/117: Add first keyword, and use in minibuffer-setup-hook
From: |
Matthew Fidler |
Subject: |
[elpa] 57/117: Add first keyword, and use in minibuffer-setup-hook |
Date: |
Fri, 25 Jul 2014 13:24:13 +0000 |
mlf176f2 pushed a commit to branch externals/ergoemacs-mode
in repository elpa.
commit 61d9825dfb7ee773fedcc73499922e27dd4c44f7
Author: Matthew L. Fidler <address@hidden>
Date: Thu Jul 17 15:37:57 2014 -0500
Add first keyword, and use in minibuffer-setup-hook
---
ergoemacs-mode.el | 6 ++
ergoemacs-test.el | 4 +-
ergoemacs-theme-engine.el | 137 +++++++++++++++++++++++++++++++++++++++------
ergoemacs-themes.el | 3 +
4 files changed, 131 insertions(+), 19 deletions(-)
diff --git a/ergoemacs-mode.el b/ergoemacs-mode.el
index bd504c9..9beacda 100644
--- a/ergoemacs-mode.el
+++ b/ergoemacs-mode.el
@@ -682,10 +682,16 @@ This is done by checking if this is a command that
supports shift selection or c
(defvar ergoemacs-repeat-keymap)
(defvar ergoemacs-read-key-overriding-overlay-save)
(defvar ergoemacs-read-key-overriding-terminal-local-save)
+(defvar ergoemacs-first-keymaps)
(declare-function ergoemacs-restore-post-command-hook "ergoemacs-shortcuts.el")
(declare-function ergoemacs-install-shortcuts-up "ergoemacs-shortcuts.el")
(defun ergoemacs-pre-command-hook ()
"Ergoemacs pre-command-hook."
+ (dolist (item ergoemacs-first-keymaps)
+ (let ((hook (car item)))
+ (dolist (fn (cdr item))
+ (remove-hook hook fn)
+ (add-hook hook fn))))
(when (and ergoemacs-mark-active
(not ergoemacs-read-input-keys)
(not mark-active))
diff --git a/ergoemacs-test.el b/ergoemacs-test.el
index a73d723..24467a3 100644
--- a/ergoemacs-test.el
+++ b/ergoemacs-test.el
@@ -1017,7 +1017,6 @@ Selected mark would not be cleared after paste."
:expected-result :failed ;; Not sure why... But for now ignore the error
(ergoemacs-test-layout ;; Us/standard
(ergoemacs-shortcut-for-command 'goto-line) ;;
- (should (string= (ergoemacs-shortcut-for-command 'goto-line)
(ergoemacs-kbd-to-key "C-l")))
(should (string= (ergoemacs-shortcut-for-command
'ergoemacs-new-empty-buffer) (ergoemacs-kbd-to-key "C-n")))
(should (string= (ergoemacs-shortcut-for-command 'make-frame-command)
(ergoemacs-kbd-to-key "C-N")))
(should (string= (ergoemacs-shortcut-for-command 'find-file)
(ergoemacs-kbd-to-key "C-o")))
@@ -1030,7 +1029,8 @@ Selected mark would not be cleared after paste."
(should (string= (ergoemacs-shortcut-for-command 'split-window-below)
(ergoemacs-kbd-to-key "M-4")))
(should (string= (ergoemacs-shortcut-for-command 'split-window-right)
(ergoemacs-kbd-to-key "M-$")))
(should (string= (ergoemacs-shortcut-for-command 'delete-other-windows)
(ergoemacs-kbd-to-key "M-3")))
- (should (string= (ergoemacs-shortcut-for-command 'execute-extended-command)
(ergoemacs-kbd-to-key "M-a")))))
+ (should (string= (ergoemacs-shortcut-for-command 'execute-extended-command)
(ergoemacs-kbd-to-key "M-a")))
+ (should (string= (ergoemacs-shortcut-for-command 'goto-line)
(ergoemacs-kbd-to-key "C-l")))))
;; (ert-deftest ergoemacs-test-5.3.7 ()
;; "Test Ergoemacs 5.3.7 keys"
diff --git a/ergoemacs-theme-engine.el b/ergoemacs-theme-engine.el
index 20e39c4..8d474b4 100644
--- a/ergoemacs-theme-engine.el
+++ b/ergoemacs-theme-engine.el
@@ -247,6 +247,9 @@
(always :initarg :always
:initform nil
:type boolean)
+ (first :initarg :first
+ :initform nil
+ :type boolean)
(deferred-keys :initarg :deferred-keys
:initform '()
:type list))
@@ -312,6 +315,7 @@ The elements of LIST are not copied, just the list
structure itself."
read-map
unbind-map
always
+ first
modify-map
deferred-keys
full-map) obj
@@ -322,6 +326,7 @@ The elements of LIST are not copied, just the list
structure itself."
((ergoemacs-keymap-empty-p read-map)
(ergoemacs-debug "Modify Keymap: %s" modify-map)
(ergoemacs-debug "Always Modify Keymap: %s" always)
+ (ergoemacs-debug "Run this hook first? %s" first)
(ergoemacs-debug "Add all ergoemacs-mode keys (override): %s" full-map)
(ergoemacs-debug "%s\n" map)
(ergoemacs-debug-keymap map))
@@ -589,6 +594,9 @@ DEF is anything that can be a key's definition:
(full-map :initarg :full-map
:initform nil
:type boolean)
+ (first :initarg :first
+ :initform nil
+ :type boolean)
(always :initarg :always
:initform nil
:type boolean))
@@ -679,6 +687,7 @@ Optionally use DESC when another description isn't found in
`ergoemacs-function-
modify-map
full-map
always
+ first
global-map-p
keymap-hash) obj
(let* ((lay (or layout ergoemacs-keyboard-layout))
@@ -695,7 +704,8 @@ Optionally use DESC when another description isn't found in
`ergoemacs-function-
:global-map-p global-map-p
:modify-map modify-map
:full-map full-map
- :always always))
+ :always always
+ :first first))
(ergoemacs-setup-translation lay "us")
(dolist (cmd (reverse cmd-list))
(ergoemacs-define-map ret (ergoemacs-kbd (nth 0 cmd) nil (nth 3 cmd))
@@ -728,6 +738,9 @@ Optionally use DESC when another description isn't found in
`ergoemacs-function-
(always :initarg :always
:initform nil
:type boolean)
+ (first :initarg :first
+ :initform nil
+ :type boolean)
(fixed :initarg :fixed
:type ergoemacs-fixed-map)
(keymap-hash :initarg :keymap-hash
@@ -751,7 +764,8 @@ Optionally use DESC when another description isn't found in
`ergoemacs-function-
:global-map-p (oref obj global-map-p)
:modify-map (oref obj modify-map)
:full-map (oref obj full-map)
- :always (oref obj always))))
+ :always (oref obj always)
+ :first (oref obj first))))
(when (slot-boundp obj 'hook)
(oset fixed hook (oref obj hook)))
(oset obj fixed fixed)))
@@ -763,7 +777,8 @@ Optionally use DESC when another description isn't found in
`ergoemacs-function-
:layout (oref obj layout)
:modify-map (oref obj modify-map)
:full-map (oref obj full-map)
- :always (oref obj always))))
+ :always (oref obj always)
+ :first (oref obj first))))
(when (slot-boundp obj 'hook)
(oset var hook (oref obj hook)))
(oset obj variable var))))
@@ -823,7 +838,7 @@ Assumes maps are orthogonal."
(defmethod ergoemacs-get-fixed-map ((obj ergoemacs-composite-map) &optional
layout)
(ergoemacs-composite-map--ini obj)
- (with-slots (variable object-name fixed modify-map full-map always
+ (with-slots (variable object-name fixed modify-map full-map always first
global-map-p keymap-hash) obj
(let* ((lay (or layout ergoemacs-keyboard-layout))
read
@@ -846,6 +861,7 @@ Assumes maps are orthogonal."
:modify-map modify-map
:full-map full-map
:always always
+ :first first
:read-map read
:read-list (append (oref var read-list) (oref fix
read-list))
:shortcut-map (ergoemacs-get-fixed-map--combine-maps (oref
var shortcut-map) (oref fix shortcut-map))
@@ -947,6 +963,7 @@ Assumes maps are orthogonal."
(ergoemacs-theme-component-maps--save-hash obj))))
(defvar ergoemacs-theme-component-maps--always nil)
+(defvar ergoemacs-theme-component-maps--first nil)
(defvar ergoemacs-theme-component-maps--full-map nil)
(defvar ergoemacs-theme-component-maps--modify-map nil)
(defvar ergoemacs-theme-component-maps--global-map nil)
@@ -969,6 +986,7 @@ Assumes maps are orthogonal."
:just-first just-first
:layout layout
:always ergoemacs-theme-component-maps--always
+ :first ergoemacs-theme-component-maps--first
:full-map ergoemacs-theme-component-maps--full-map
:modify-map ergoemacs-theme-component-maps--modify-map))
(if ergoemacs-theme-component-maps--hook
@@ -1011,6 +1029,26 @@ Assumes maps are orthogonal."
(ergoemacs-theme-component-maps--save-hash obj)
ret)))
+(defmethod ergoemacs-is-first-p ((obj ergoemacs-theme-component-maps)
+ hook map-name)
+ "See if the HOOK and MAP-NAME combination should be the first run."
+ (ergoemacs-theme-component-maps--ini obj)
+ (let (ret)
+ (with-slots (maps) obj
+ (catch 'found-hook
+ (maphash
+ (lambda (map-n map-obj)
+ (setq ret
+ (or ret
+ (and (eq map-name map-n)
+ (slot-boundp map-obj 'hook)
+ (eq (oref map-obj hook) hook)
+ (oref map-obj first))))
+ (when ret
+ (throw 'found-hook t)))
+ maps))
+ ret)))
+
(defmethod ergoemacs-get-hooks ((obj ergoemacs-theme-component-maps) &optional
match ret keymaps)
(ergoemacs-theme-component-maps--ini obj)
(with-slots (maps hooks) obj
@@ -1078,6 +1116,34 @@ Assumes maps are orthogonal."
(pushnew ver ret :test 'equal)))))
(sort ret 'string<))))
+(defmethod ergoemacs-is-first-p ((obj ergoemacs-theme-component-map-list)
+ hook map-name)
+ "See if the HOOK and MAP-NAME combination should be the first run."
+ (with-slots (map-list hooks) obj
+ (let* ((final (gethash (list hook map-name 'first-p) hooks)))
+ (unless final
+ (catch 'is-first-p
+ (dolist (map map-list)
+ (when (ergoemacs-theme-component-maps-p map)
+ (setq final (ergoemacs-is-first-p map hook map-name))
+ (when final
+ (throw 'is-first-p t)))))
+ (puthash (list hook map-name 'first-p) final hooks))
+ final)))
+
+(defmethod ergoemacs-get-hooks ((obj ergoemacs-theme-component-map-list)
&optional match keymaps)
+ (with-slots (map-list hooks) obj
+ (let* ((final (gethash (list match keymaps) hooks))
+ ret)
+ (unless final
+ (dolist (map map-list)
+ (when (ergoemacs-theme-component-maps-p map)
+ (setq ret (ergoemacs-get-hooks map match ret keymaps))))
+ (dolist (item ret)
+ (pushnew item final :test 'equal))
+ (puthash (list match keymaps) final hooks))
+ final)))
+
(defmethod ergoemacs-get-hooks ((obj ergoemacs-theme-component-map-list)
&optional match keymaps)
(with-slots (map-list hooks) obj
(let* ((final (gethash (list match keymaps) hooks))
@@ -1206,6 +1272,8 @@ FULL-SHORTCUT-MAP-P "
(defvar ergoemacs-deferred-keys '()
"List of keys that have deferred bindings.")
+(defvar ergoemacs-first-keymaps '()
+ "list of hooks that should be first.")
(defvar ergoemacs-original-keys-to-shortcut-keys-regexp ""
"Regular expression of original keys that have shortcuts.")
@@ -1290,14 +1358,19 @@ If it is not a composed KEYMAP, return the keymap as
is."
modify-map
full-map
always
+ first
cmd-list
deferred-keys) (ergoemacs-get-fixed-map obj map-name)
(cond
((and modify-map always)
;; Maps that are always modified.
- (let ((fn-name (intern (concat (symbol-name emulation-var)
"-and-" (symbol-name map-name)))))
+ (let ((fn-name
+ (intern
+ (concat
+ (symbol-name emulation-var) "-and-"
+ (symbol-name map-name)))))
(fset fn-name
- `(lambda() ,(format "Turn on `ergoemacs-mode' for `%s'
during the hook `%s'.\n Map is stored in `'"
+ `(lambda() ,(format "Turn on `ergoemacs-mode' for `%s'
during the hook `%s'."
(symbol-name map-name) (symbol-name
hook))
(let ((new-map ',map))
(ergoemacs-theme--install-shortcuts-list
@@ -1308,13 +1381,24 @@ If it is not a composed KEYMAP, return the keymap as
is."
(when (commandp fn t)
(define-key new-map (nth 0 item) fn)
(throw 'found-bound-command t)))))
- (set ',map-name
- (ergoemacs-flatten-composed-keymap
(make-composed-keymap new-map ,map-name)))
- ,(when (eq map-name 'iswitchb-mode-map)
- `(message "Final Map:\n%s"
(substitute-command-keys ,(format "\\{%s}" (symbol-name map-name)))))
- )))
+ (setq new-map (ergoemacs-flatten-composed-keymap
(make-composed-keymap new-map ,map-name)))
+ ;; Try to modify in place, without any
+ ;; copying of keymaps.
+ (ergoemacs-flatten-composed-keymap--define-key
new-map ,map-name))))
(funcall (if remove-p #'remove-hook #'add-hook) hook
- fn-name)))
+ fn-name)
+ (when (and first (not remove-p)
+ (ergoemacs-is-first-p obj hook map-name))
+ (let (found)
+ (setq ergoemacs-first-keymaps
+ (mapcar
+ (lambda(x)
+ (if (not (eq (car x) hook)) x
+ (setq found t)
+ (append (list hook fn-name) (cdr x))))
+ ergoemacs-first-keymaps))
+ (unless found
+ (push (list hook fn-name) ergoemacs-first-keymaps))))))
((and modify-map (not (boundp map-name)))
(pushnew (list map-name full-map map deferred-keys)
ergoemacs-deferred-maps))
((and modify-map (boundp map-name))
@@ -1361,7 +1445,19 @@ The actual keymap changes are included in
`ergoemacs-emulation-mode-map-alist'."
(set-default emulation-var nil)
(push map tmp))
(funcall (if remove-p #'remove-hook #'add-hook) hook
- emulation-var)))))
+ emulation-var)
+ (when (and first (not remove-p))
+ (let (found)
+ (setq ergoemacs-first-keymaps
+ (mapcar
+ (lambda(x)
+ (if (not (eq (car x) hook)) x
+ (setq found t)
+ (append (list hook emulation-var) (cdr x))))
+ ergoemacs-first-keymaps))
+ (unless found
+ (push (list hook emulation-var)
+ ergoemacs-first-keymaps))))))))
(unless (equal tmp '())
(unless (eq defer '())
(push (cons i defer) ergoemacs-deferred-keys))
@@ -1548,8 +1644,9 @@ The actual keymap changes are included in
`ergoemacs-emulation-mode-map-alist'."
new-hook
new-full-map
new-always
+ new-first
new-deferred-keys
- (first t))
+ (curr-first t))
(dolist (map-obj fixed-maps)
(when (ergoemacs-fixed-map-p map-obj)
(with-slots (global-map-p
@@ -1567,6 +1664,7 @@ The actual keymap changes are included in
`ergoemacs-emulation-mode-map-alist'."
modify-map
full-map
always
+ first
deferred-keys) map-obj
(unless (equal read-map '(keymap))
(push read-map new-read-map))
@@ -1580,7 +1678,7 @@ The actual keymap changes are included in
`ergoemacs-emulation-mode-map-alist'."
(push unbind-map new-unbind-map))
(when (slot-boundp map-obj 'hook)
(setq new-hook (oref map-obj hook)))
- (if first
+ (if curr-first
(setq new-shortcut-list shortcut-list
new-shortcut-movement shortcut-movement
new-shortcut-shifted-movement
shortcut-shifted-movement
@@ -1592,10 +1690,11 @@ The actual keymap changes are included in
`ergoemacs-emulation-mode-map-alist'."
new-modify-map modify-map
new-full-map full-map
new-always always
- first nil)
+ curr-first nil)
(setq new-global-map-p (or new-global-map-p global-map-p)
new-modify-map (or new-modify-map modify-map)
new-full-map (or new-full-map full-map)
+ new-first (or new-first first)
new-always (or new-always always)
new-read-list (append new-read-list read-list)
new-shortcut-list (append new-shortcut-list
shortcut-list)
@@ -1624,6 +1723,7 @@ The actual keymap changes are included in
`ergoemacs-emulation-mode-map-alist'."
:modify-map new-modify-map
:full-map new-full-map
:always new-always
+ :first new-first
:deferred-keys new-deferred-keys))
(when new-hook
(oset ret hook new-hook))
@@ -1700,7 +1800,9 @@ The actual keymap changes are included in
`ergoemacs-emulation-mode-map-alist'."
(plist-get plist ':full-map)
(plist-get plist ':full-keymap)))
(ergoemacs-theme-component-maps--always
- (plist-get plist ':always)))
+ (plist-get plist ':always))
+ (ergoemacs-theme-component-maps--first
+ (plist-get plist ':first)))
(funcall body)))
;;;###autoload
@@ -1708,6 +1810,7 @@ The actual keymap changes are included in
`ergoemacs-emulation-mode-map-alist'."
;; Reset variables.
(let* ((ergoemacs-theme-component-maps--versions '())
(ergoemacs-theme-component-maps--always nil)
+ (ergoemacs-theme-component-maps--first nil)
(ergoemacs-theme-component-maps--full-map nil)
(ergoemacs-theme-component-maps--modify-map nil)
(ergoemacs-theme-component-maps--global-map nil)
diff --git a/ergoemacs-themes.el b/ergoemacs-themes.el
index d69c505..7223333 100644
--- a/ergoemacs-themes.el
+++ b/ergoemacs-themes.el
@@ -451,12 +451,14 @@
(define-key eshell-mode-map (kbd "<M-f12>")
'eshell-next-matching-input-from-input)
(when minibuffer-setup-hook
+ :first t
(define-key minibuffer-local-map (kbd "<f11>") 'previous-history-element)
(define-key minibuffer-local-map (kbd "<f12>") 'next-history-element)
(define-key minibuffer-local-map (kbd "<M-f11>")
'previous-matching-history-element)
(define-key minibuffer-local-map (kbd "S-<f11>")
'previous-matching-history-element)
(define-key minibuffer-local-map (kbd "<M-f12>")
'next-matching-history-element)
(define-key minibuffer-local-map (kbd "S-<f12>")
'next-matching-history-element))
+
(when isearch-mode-hook
:modify-map t
:full-shortcut-map t
@@ -812,6 +814,7 @@
:modify-map t
(define-key minibuffer-local-map (kbd "<escape>")
'minibuffer-keyboard-quit))
(when minibuffer-setup-hook
+ :first t
(define-key minibuffer-local-map (kbd "<escape>")
'minibuffer-keyboard-quit))
:version 5.3.7
(global-set-key (kbd "M-n") 'keyboard-quit))
- [elpa] 43/117: Setup local overrides outside of minibuffers and overriding keymaps, (continued)
- [elpa] 43/117: Setup local overrides outside of minibuffers and overriding keymaps, Matthew Fidler, 2014/07/25
- [elpa] 52/117: Take out org-italic, Matthew Fidler, 2014/07/25
- [elpa] 51/117: Fix F8 map, Matthew Fidler, 2014/07/25
- [elpa] 50/117: Add lookup of C-g to ergoemacs-keyboard-quit, Matthew Fidler, 2014/07/25
- [elpa] 55/117: Bug fix for ergoemacs-keyboard-quit, Matthew Fidler, 2014/07/25
- [elpa] 56/117: Add ability to "flatten" a composed keymap; Flatten maps that are always modified, Matthew Fidler, 2014/07/25
- [elpa] 58/117: Remove ergoemacs-read-modal-keymap function, Matthew Fidler, 2014/07/25
- [elpa] 53/117: Don't error on invalid menu., Matthew Fidler, 2014/07/25
- [elpa] 46/117: Install ergoemacs-read-default for every major mode, Matthew Fidler, 2014/07/25
- [elpa] 54/117: Fix menu keybinding preprocessing, Matthew Fidler, 2014/07/25
- [elpa] 57/117: Add first keyword, and use in minibuffer-setup-hook,
Matthew Fidler <=
- [elpa] 60/117: Fix byte-compile warning, Matthew Fidler, 2014/07/25
- [elpa] 62/117: Update ergoemacs-mode-line custom description, Matthew Fidler, 2014/07/25
- [elpa] 61/117: Set ergoemacs-mode-line default to t, Matthew Fidler, 2014/07/25
- [elpa] 63/117: Attempt to fix Issue #278, Matthew Fidler, 2014/07/25
- [elpa] 67/117: Fix Issue #278, Matthew Fidler, 2014/07/25
- [elpa] 59/117: Add ergoemacs-mode-line option, Matthew Fidler, 2014/07/25
- [elpa] 64/117: Add run-hook property, Matthew Fidler, 2014/07/25
- [elpa] 66/117: Allow keymaps to be copied before modifying them, Matthew Fidler, 2014/07/25
- [elpa] 69/117: Fix Issue #279, Matthew Fidler, 2014/07/25
- [elpa] 70/117: Fix unbound keys test, Matthew Fidler, 2014/07/25