[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/objed 26cd732 32/59: Exit with exit code or op name
From: |
Clemens Radermacher |
Subject: |
[elpa] externals/objed 26cd732 32/59: Exit with exit code or op name |
Date: |
Sun, 24 Mar 2019 06:06:40 -0400 (EDT) |
branch: externals/objed
commit 26cd7329a69d6085ee4cc0a10ea33d3260e4850a
Author: Clemens Radermacher <address@hidden>
Commit: Clemens Radermacher <address@hidden>
Exit with exit code or op name
---
objed.el | 55 ++++++++++++++++++++++++++++++++-----------------------
1 file changed, 32 insertions(+), 23 deletions(-)
diff --git a/objed.el b/objed.el
index bbd6a07..37969ea 100644
--- a/objed.el
+++ b/objed.el
@@ -3374,16 +3374,23 @@ multiple ones."
(insert text)
(not (= -1 (forward-line -1)))))
-(defun objed-exit-op (op &optional text range)
+(defun objed-exit-op (exit &optional text range)
"Handle exit of an operation.
-OP is the operation (ignored for now). If TEXT is given it
-carries the textual content of the object the operation acted
-on and RANGE hold the object position data."
+EXIT is the operation name or exit code. If TEXT is given it
+carries the textual content of the object the operation acted on
+and RANGE hold the object position data."
;; TODO: improve exit behaviour for default operations
- (let ((exitf (cdr (assq op objed--exit-alist))))
- ;; (objed--update-current-object)
- (cond ((functionp exitf)
+ (let ((exitf (cdr (assq exit objed--exit-alist))))
+ (cond ((eq 'keep exit)
+ (ignore))
+ ((eq 'current exit)
+ (objed--update-current-object
+ (objed-make-object :beg (car range)
+ :end (cadr range))))
+ ((eq 'exit exit)
+ (objed--exit-objed))
+ ((functionp exitf)
(funcall exitf text))
((eq 'current exitf)
(objed--update-current-object
@@ -3393,7 +3400,7 @@ on and RANGE hold the object position data."
(objed--exit-objed))
(exitf
(objed--switch-to exitf))
- ((or (eq op 'ignore)
+ ((or (eq exit 'ignore)
(bound-and-true-p multiple-cursors-mode)))
(t
(if (and text (objed--line-p text))
@@ -3404,10 +3411,13 @@ on and RANGE hold the object position data."
(face-remap-remove-relative objed--extend-cookie)
(setq objed--extend-cookie nil))
(when (and range
- (not (eq exitf 'current)))
+ (not (eq exitf 'current))
+ (not (eq exit 'current))
+ (not (eq exit 'keep)))
(set-marker (car range) nil)
(set-marker (cadr range) nil))))
+
(defun objed-quit ()
"Quit and deactivate.
@@ -3486,21 +3496,20 @@ Resets objed if appropriate."
;; * OP execution
-(defun objed--do (action &optional name)
+(defun objed--do (action &optional exit)
"Execute ACTION on current object(s).
-NAME is the symbol used for current op and defaults to
-`this-command'.
-
-Return number of times ACTION got applied."
- (let ((name (or name this-command)))
+Apply action to current object(s) and exit with EXIT which is the
+symbol used for op exit and defaults to `this-command' (see
+ON got applied."
+ (let ((exit (or exit this-command)))
(cond (objed--marked-ovs
- (objed--do-objects action name))
+ (objed--do-objects action exit))
(t
- (objed--do-object action name)))))
+ (objed--do-object action exit)))))
-(defun objed--do-object (action name)
- "Apply ACTION for op named NAME on current object."
+(defun objed--do-object (action exit)
+ "Apply ACTION on current object and exit with EXIT."
(let ((range (objed--current)))
(when range
(let ((text (apply #'buffer-substring range))
@@ -3508,10 +3517,10 @@ Return number of times ACTION got applied."
(set-marker (make-marker) (cadr range)))))
(prog1 1
(apply action range)
- (objed-exit-op name text range))))))
+ (objed-exit-op exit text range))))))
-(defun objed--do-objects (action name)
- "Apply ACTION for op named NAME on marked objects."
+(defun objed--do-objects (action exit)
+ "Apply ACTION on marked objects and exit with EXIT."
(let ((ovs objed--marked-ovs)
(appendp (memq action '(kill-region copy-region-as-kill)))
(n 0))
@@ -3529,7 +3538,7 @@ Return number of times ACTION got applied."
(prog1 n
;; always ?
(setq objed--marked-ovs nil)
- (objed-exit-op name))))
+ (objed-exit-op exit))))
(defun objed--ov-sequence-p (ovs)
- [elpa] externals/objed 6227a85 43/59: Improve movment with objed extend, (continued)
- [elpa] externals/objed 6227a85 43/59: Improve movment with objed extend, Clemens Radermacher, 2019/03/24
- [elpa] externals/objed c87ea0f 38/59: Change binding for objed-insert, Clemens Radermacher, 2019/03/24
- [elpa] externals/objed b5e68c9 33/59: Add objed insert command, Clemens Radermacher, 2019/03/24
- [elpa] externals/objed 1d116bd 42/59: Improve objed context object, Clemens Radermacher, 2019/03/24
- [elpa] externals/objed fef1621 47/59: Reorder few defuns by topic, Clemens Radermacher, 2019/03/24
- [elpa] externals/objed dc86d31 45/59: Change bindings for duplicate ops, Clemens Radermacher, 2019/03/24
- [elpa] externals/objed a46a1e5 46/59: Add binding for including leading ws, Clemens Radermacher, 2019/03/24
- [elpa] externals/objed 315a622 40/59: Update beg of object at point semantics, Clemens Radermacher, 2019/03/24
- [elpa] externals/objed a09e198 36/59: Improve objed-eval-exp, Clemens Radermacher, 2019/03/24
- [elpa] externals/objed 5af62e2 35/59: Default to char if current buffer has no objed--object set, Clemens Radermacher, 2019/03/24
- [elpa] externals/objed 26cd732 32/59: Exit with exit code or op name,
Clemens Radermacher <=
- [elpa] externals/objed 4c878f8 21/59: Change objed-append-mode activation rules, Clemens Radermacher, 2019/03/24
- [elpa] externals/objed c17de45 48/59: Convert toggle state to shrink context command, Clemens Radermacher, 2019/03/24
- [elpa] externals/objed fe2b5f1 34/59: Improve objed-copy, Clemens Radermacher, 2019/03/24
- [elpa] externals/objed 08cb11c 31/59: Eval op improvements/fixes, Clemens Radermacher, 2019/03/24
- [elpa] externals/objed 951af46 28/59: Convert eval op to eval-context, Clemens Radermacher, 2019/03/24
- [elpa] externals/objed 20d776a 04/59: Improve identifier command, Clemens Radermacher, 2019/03/24
- [elpa] externals/objed 084c9ea 39/59: Adding toggle identifier place command, Clemens Radermacher, 2019/03/24
- [elpa] externals/objed d35abd5 30/59: Improve eval context op for comments and change its binding, Clemens Radermacher, 2019/03/24
- [elpa] externals/objed 26235a7 44/59: Improve duplicate op, Clemens Radermacher, 2019/03/24
- [elpa] externals/objed 5f9a7f6 37/59: Give feedback message on reformat, Clemens Radermacher, 2019/03/24