[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/objed 0d506fa 074/166: Allow specifying a fallback obje
From: |
Clemens Radermacher |
Subject: |
[elpa] externals/objed 0d506fa 074/166: Allow specifying a fallback object for init |
Date: |
Sun, 29 Dec 2019 08:21:03 -0500 (EST) |
branch: externals/objed
commit 0d506fae17b80bbea1d59844ae4046c319a32516
Author: Clemens Radermacher <address@hidden>
Commit: Clemens Radermacher <address@hidden>
Allow specifying a fallback object for init
---
objed.el | 36 +++++++++++++++++++++++++++++-------
1 file changed, 29 insertions(+), 7 deletions(-)
diff --git a/objed.el b/objed.el
index 0cb6219..afd15d6 100644
--- a/objed.el
+++ b/objed.el
@@ -1258,23 +1258,39 @@ See `objed-cmd-alist'."
(or (memq major-mode '(messages-buffer-mode help-mode))
(not (derived-mode-p 'comint-mode 'special-mode 'dired-mode)))))
-(defun objed-init (&optional obj)
- "Function for activating objed by hooks or advices.
+(defun objed-init (&optional obj fallback)
+ "Function for activating objed by hooks.
Initialize with OBJ which defaults to `objed--object' which falls
-back to char if unset."
+back to char if unset. For meaning of FALLBACK see
+`objed--init'."
(when (funcall objed-init-p-function)
- (objed--init (or obj objed--object 'char))))
+ (objed--init (or obj objed--object 'char)
+ fallback)))
(defun objed--init-later (&rest _)
"Init after command loop returned to top level."
(run-at-time 0 nil #'objed-init))
-(defun objed--init (&optional sym)
+(defun objed--init-later-with (obj fallback)
+ "Return a closure for later init.
+
+The returned function can be used for command advices.
+For the meaning of OBJ and FALLBACK see `objed-init'."
+ (lambda (&rest _)
+ (run-at-time 0 nil #'objed-init obj fallback)))
+
+(defun objed--init (&optional sym fallback)
"Initialize `objed'.
SYM is a symbol (command or object symbol) used to initialize
-or object position data."
+or object position data.
+
+FALLBACK if given is a symbol defining the fallback object which
+will be used if object is not found at current position.
+
+By default if the object isn't found at point any next and after
+that any previous instance of this object is used."
;; if anything went wrong make sure to start with clean state
(when objed--buffer
(objed--reset))
@@ -1319,9 +1335,15 @@ or object position data."
;; init object
(prog1 (cond ((commandp sym)
+ ;; TODO: fallback here, too
(objed--switch-to-object-for-cmd sym))
((symbolp sym)
- (objed--switch-to sym))
+ (if fallback
+ (let ((obatp (objed--inside-object-p sym)))
+ (if obatp
+ (objed--update-current-object obatp)
+ (objed--switch-to fallback)))
+ (objed--switch-to sym)))
(t
(unless objed--object
(setq objed--object 'char))
- [elpa] externals/objed 58669ec 049/166: Fix backward/forward until context, (continued)
- [elpa] externals/objed 58669ec 049/166: Fix backward/forward until context, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 6eb0fd5 052/166: Adjust objed-append-mode, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 1846dd8 053/166: Deactivate append mode on yank, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed b978583 055/166: add (require 'hl-line), Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 6c34f45 059/166: Change binding for objed-occur, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 6096696 063/166: Add alternate bindings for barf/slurp, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 7e25c50 061/166: Add forward slurp/barf sexp commands, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 4d0503c 067/166: Allow using rx for regex objects, too, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed e6bed2e 065/166: Further improve regex object, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed c666cea 076/166: Fix some sexp issues, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 0d506fa 074/166: Allow specifying a fallback object for init,
Clemens Radermacher <=
- [elpa] externals/objed 9fbd47f 084/166: Fix org field object, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 8861388 082/166: Auto switch from sexp object only for interactive state toggle, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 1cad7c2 086/166: Start with line object if not current for block expansion, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 13e7829 093/166: Fix word object navigation with objed-next/prev for inner subwords, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 213f672 094/166: Use prefixed word of symbol for inner ident object, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed c02f3c1 071/166: Add description for uppercase kill/delete, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed f01a171 072/166: Make objed-init suitable for advices, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed db8850a 064/166: Improve regex object, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 870d125 068/166: Update docstrings for regex objects, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 5aa473d 078/166: Reset before quit window when objed is active, Clemens Radermacher, 2019/12/29