branch: externals/objed
commit db01e080ec51d66ae0783f31c9a9534fdfe91060
Author: Clemens Radermacher <clem...@posteo.net>
Commit: Clemens Radermacher <clem...@posteo.net>

    Undo last commit
---
 objed.el | 43 ++++++++++++++++++++-----------------------
 1 file changed, 20 insertions(+), 23 deletions(-)

diff --git a/objed.el b/objed.el
index 68d7425..11c8dca 100644
--- a/objed.el
+++ b/objed.el
@@ -1250,26 +1250,22 @@ See `objed-cmd-alist'."
 
 (defun objed-init-p ()
   "Default for `objed-init-p-function'."
-  (when (window-live-p (get-buffer-window))
-    (with-current-buffer (window-buffer (selected-window))
-      (and (eq (key-binding (kbd "C-n"))
-               #'next-line)
-           (eq (key-binding "n")
-               #'self-insert-command)
-           (not (minibufferp))
-           (not (active-minibuffer-window))
-           (not (and (bobp)
-                     (bound-and-true-p git-commit-mode)))
-           (not (derived-mode-p 'comint-mode))
-           (not (and (bobp) (eobp)))
-           ;; only for modes which do not
-           ;; their their own modal setup
-           (or (memq (key-binding "f")
-                     '(self-insert-command
-                       org-self-insert-command
-                       outshine-self-insert-command
-                       outline-self-insert-command
-                       undefined)))))))
+  (and (eq (key-binding (kbd "C-n"))
+           #'next-line)
+       (not (minibufferp))
+       (not (active-minibuffer-window))
+       (not (and (bobp)
+                 (bound-and-true-p git-commit-mode)))
+       (not (derived-mode-p 'comint-mode))
+       (not (and (bobp) (eobp)))
+       ;; only for modes which do not
+       ;; their their own modal setup
+       (or (memq (key-binding "f")
+                 '(self-insert-command
+                   org-self-insert-command
+                   outshine-self-insert-command
+                   outline-self-insert-command
+                   undefined)))))
 
 (defun objed--init (&optional sym)
   "Initialize `objed'.
@@ -3627,9 +3623,10 @@ If region is active deactivate it first."
 Resets objed if appropriate."
   (unless (or objed--with-allow-input
               (not objed--buffer))
-    (when (or (not (eq (current-buffer) objed--buffer))
-              (not (get-buffer-window (current-buffer))))
-      (objed--reset--objed-buffer))))
+    (when (not (eq (current-buffer) objed--buffer))
+      (objed--reset--objed-buffer)
+      (select-window (get-buffer-window (current-buffer)) t)
+      (objed--init (or objed--object 'char)))))
 
 (defun objed--reset--objed-buffer ()
   "Reset `objed--buffer'."

Reply via email to