[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/objed 8a74424 125/216: Optimize init/reset procedure, a
From: |
Stefan Monnier |
Subject: |
[elpa] externals/objed 8a74424 125/216: Optimize init/reset procedure, avoid unnecessary re-initialization |
Date: |
Tue, 8 Jan 2019 12:29:24 -0500 (EST) |
branch: externals/objed
commit 8a7442463f3201770e529e012e6613ec513fbd28
Author: Clemera <address@hidden>
Commit: Clemera <address@hidden>
Optimize init/reset procedure, avoid unnecessary re-initialization
---
objed.el | 42 ++++++++++++++++++++++--------------------
test/tests.el | 5 +++++
2 files changed, 27 insertions(+), 20 deletions(-)
diff --git a/objed.el b/objed.el
index b73f43d..09a0734 100644
--- a/objed.el
+++ b/objed.el
@@ -297,21 +297,24 @@ See also `objed-disabled-p'"
(backward-paragraph . paragraph)
(forward-paragraph . paragraph)
(fill-paragraph . textblock)
- (down-list string symbol word)
- (forward-sexp sexp defun bracket string symbol word)
- (backward-sexp sexp defun bracket string symbol word)
- (indent-pp-sexp bracket sexp)
+ ;; TODO: add list object
+ ;; or recognize sexp type
+ ;; improve sexp nav...
+ (down-list . sexp)
+ (backward-up-list . sexp)
+ (up-list . sexp)
+ (forward-sexp . sexp)
+ (backward-sexp . sexp)
+ (indent-pp-sexp . bracket)
;; just use inner line?
;; TODO: on second press check all these:
;;section defun bracket string line)
- (back-to-indentation . (line . inner))
+ (back-to-indentation . line)
(org-beginning-of-line . line)
(org-end-of-line . line)
(backward-sentence . sentence)
(org-backward-sentence . sentence)
(org-backward-element . paragraph)
- (backward-up-list bracket string)
- (up-list bracket string)
(beginning-of-defun . defun)
(end-of-defun . defun)
(outline-previous-visible-heading . section)
@@ -332,16 +335,9 @@ See also `objed-disabled-p'"
(yank . region)
(yank-pop . region)
;; misc
- ;; TODO: find a way that doesnt need to reinit each time
(which-key-C-h-dispatch . char)
)
- "Entry commands and associated objects.
-
-If the `cdr' of an entry is a list, each of the objects in this
-list is tried and the first that matches (:atp returns non-nil)
-will be used for initialization. If the `cdr' is a cons cell use
-the `cdr' of it as initial object state which defaults to `whole'
-otherwise."
+ "Entry commands and associated objects."
:group 'objed
:type '(alist :key-type sexp
:value-type (choice sexp
@@ -1104,6 +1100,8 @@ See `objed-cmd-alist'."
(not objed--block-p)
(eq real-this-command cmd)
(not objed-disabled-p)
+ (not (eq (cadr overriding-terminal-local-map)
+ objed-map))
;; (memq (key-binding "q")
;; '(self-insert-command
;; outshine-self-insert-command
@@ -1225,11 +1223,15 @@ mode line hint is removed again."
Reinitializes the current object in case the current command is
one of `objed-keeper-commands'."
- (or (commandp (lookup-key objed-map (this-command-keys-vector)))
- (and (memq (key-binding (this-command-keys-vector))
- objed-keeper-commands)
- (prog1 #'ignore
- (add-hook 'post-command-hook 'objed--reinit-object-one-time nil
t)))))
+ (let ((ocmd (lookup-key objed-map (this-command-keys-vector)))
+ (o nil))
+ (or (commandp ocmd)
+ (and (or (memq this-command objed-keeper-commands)
+ (and (setq o (cdr (assq this-command objed-cmd-alist)))
+ (symbolp o)
+ (setq objed--object o)))
+ (prog1 #'ignore
+ (add-hook 'post-command-hook 'objed--reinit-object-one-time nil
t))))))
(defun objed--reinit-object-one-time ()
diff --git a/test/tests.el b/test/tests.el
index 3b9b1cb..e21cbb0 100644
--- a/test/tests.el
+++ b/test/tests.el
@@ -13,7 +13,12 @@
(setq this-command cmd)
;; pre command hook...
(funcall #'objed--push-state)
+ (objed--keep-transient-p)
(call-interactively cmd)
+ ;; post command hook
+ (when (memq 'objed--reinit-object-one-time
+ post-command-hook)
+ (objed--reinit-object-one-time))
(setq last-command cmd)))
(defun objed-decode-keysequence (str)
- [elpa] externals/objed fe5548c 138/216: Install advices for :commands after objed is loaded, fixes #21, (continued)
- [elpa] externals/objed fe5548c 138/216: Install advices for :commands after objed is loaded, fixes #21, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 5b4bf3f 128/216: Get region command positions according to objed rules, Stefan Monnier, 2019/01/08
- [elpa] externals/objed a246088 144/216: Merge pull request #23 from gergelypolonkai/defcustom-fixes, Stefan Monnier, 2019/01/08
- [elpa] externals/objed c846b15 141/216: Init only where C-n is bound to something other than next-line, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 50c2367 155/216: Mention move objects functionality, Stefan Monnier, 2019/01/08
- [elpa] externals/objed f8af251 080/216: General cleanup, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 72053b7 109/216: Simplify macro usage again, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 9558b39 098/216: Add ace char object, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 49082c7 167/216: Accept 1 as universal arg, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 185fe41 111/216: Remove unused lexical var, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 8a74424 125/216: Optimize init/reset procedure, avoid unnecessary re-initialization,
Stefan Monnier <=
- [elpa] externals/objed 9c1b350 067/216: Update link, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 7abf5b3 091/216: Fixes #3, switch to remote object with '#', Stefan Monnier, 2019/01/08
- [elpa] externals/objed 7ba5cb2 088/216: New until beg/end of buffer behavior, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 22392cf 099/216: Add whitepsace objects, fixes #2, Stefan Monnier, 2019/01/08
- [elpa] externals/objed f3efa0e 121/216: Don't let sentence object jump over to next comments/string, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 192217a 066/216: Add no-skip option and block object, Stefan Monnier, 2019/01/08
- [elpa] externals/objed a2df7ab 075/216: Stay active when using describe key in modal state, Stefan Monnier, 2019/01/08
- [elpa] externals/objed b7fbf71 106/216: Fixes #12, collect no-skipping objects correctly, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 29bccb0 042/216: Whitespace cleanup, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 2e1e5c1 110/216: Run compilation as part of make test, Stefan Monnier, 2019/01/08