emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/objed 043ec68 198/216: Adjust some bindings (q should q


From: Stefan Monnier
Subject: [elpa] externals/objed 043ec68 198/216: Adjust some bindings (q should quit window for convenience)
Date: Tue, 8 Jan 2019 12:29:39 -0500 (EST)

branch: externals/objed
commit 043ec68ffb1acf5b62ab48d79ad1596837cb86e4
Author: Clemera <address@hidden>
Commit: Clemera <address@hidden>

    Adjust some bindings (q should quit window for convenience)
---
 README.asc | 13 ++++++++-----
 objed.el   | 26 ++++++++++++++++++--------
 2 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/README.asc b/README.asc
index d57f835..a94631e 100644
--- a/README.asc
+++ b/README.asc
@@ -238,7 +238,7 @@ determining the context:
 |kbd:[u]
 |Move to end of the inner object at point and activate the text moved over. On 
repeat toggle between beginning/end inside the object.
 
-|kbd:[q]
+|kbd:[j]
 |Move point to the other side of the current object.
 
 |kbd:[i]
@@ -319,9 +319,6 @@ commands" below):
 |kbd:[;]
 |Un/comment object(s).
 
-|kbd:[:]
-|Comment and duplicate object.
-
 |kbd:[%]
 |Query replace narrowed to current object.
 
@@ -340,6 +337,9 @@ commands" below):
 |kbd:[M - RET]
 |Insert new (empty) instance of current object type. This inserts the current 
object without the inner content.
 
+|kbd:[S - RET]
+|Comment and duplicate object.
+
 |kbd:[$]
 |Spell check textual content of object using `flyspell`.
 
@@ -363,10 +363,13 @@ Misc commands:
 |===
 |Shortcut |Purpose
 
+|kbd:[q]
+|Quit window if not the only one.
+
 |kbd:[,]
 |Pop to last state, which restores the last position and any object data.
 
-|kbd:[j]
+|kbd:[M-o]
 |Choose an instance of current object type with completion, using the contents 
of the first line for completion.
 
 |kbd:[z]
diff --git a/objed.el b/objed.el
index 8229d65..a0f8edb 100644
--- a/objed.el
+++ b/objed.el
@@ -1,4 +1,4 @@
-;;; objed.el --- Navigate and edit text objects. -*- lexical-binding: t -*-
+;;; objed.el --- Navigate and edit text objects. -*- lexical-bindng: t -*-
 ;; Copyright (C) 2018  Clemens Radermacher
 
 ;; Author: Clemens Radermacher <address@hidden>
@@ -577,6 +577,16 @@ BEFORE and AFTER are forms to execute before/after calling 
the command."
       (objed-exchange-point-and-mark)
     (call-interactively 'backward-word)))
 
+(defun objed-quit-window (&optional kill window)
+  (interactive "P")
+  (unless (one-window-p)
+    (let* ((overriding-terminal-local-map nil)
+           (nc (key-binding "q")))
+      (objed--reset)
+      (if (eq nc 'quit-window)
+          (quit-window kill window)
+        (delete-window))
+      (objed-activate 'line))))
 
 (defvar objed-map
   (let ((map (make-sparse-keymap)))
@@ -594,11 +604,12 @@ BEFORE and AFTER are forms to execute before/after 
calling the command."
     (define-key map (kbd "C-g") 'objed-quit)
     ;; TODO: switch with q, so quit window is qq?
     (define-key map "g" 'objed-quit)
+    (define-key map "q" 'objed-quit-window)
     (define-key map (kbd "?") 'objed-show-top-level)
     ;; TODO: support repeated invokation
     (define-key map (kbd "C-u") 'universal-argument)
-
     (define-key map "0" 'universal-argument)
+
     (define-key map (kbd "C-SPC") 'set-mark-command)
     (define-key map (kbd "C-x C-x") 'objed-exchange-point-and-mark)
     ;; TODO: birdview mode/scroll mode
@@ -664,12 +675,11 @@ BEFORE and AFTER are forms to execute before/after 
calling the command."
     (define-key map "T" 'objed-move-object-backward)
     (define-key map "H" 'objed-move-object-forward)
 
-
     (define-key map "o" 'objed-expand-context)
     (define-key map "u" 'objed-upto-context)
 
     (define-key map "i" 'objed-toggle-state)
-    (define-key map "q" 'objed-toggle-side)
+    (define-key map "j" 'objed-toggle-side)
 
     ;; marking/unmarking
     (define-key map "m" 'objed-mark)
@@ -698,7 +708,7 @@ BEFORE and AFTER are forms to execute before/after calling 
the command."
       (objed-define-op nil objed-indent ignore))
     (define-key map ";"
       (objed-define-op nil objed-comment-or-uncomment-region))
-    (define-key map ":"
+    (define-key map (kbd "<S-return>")
       (objed-define-op nil objed-comment-duplicate))
 
     (define-key map "$"
@@ -721,7 +731,7 @@ BEFORE and AFTER are forms to execute before/after calling 
the command."
     ;; jump to objects with avy
     (define-key map "z" 'objed-ace)
     ;; swiper like object search
-    (define-key map "j" 'objed-occur)
+    (define-key map (kbd "M-o") 'objed-occur)
     ;; TODO: start query replace in current object,
     ;; or for all
     (define-key map "%"
@@ -1674,12 +1684,12 @@ Object is choosen based on context."
          (goto-char (objed--beg))))))
 
 
-(defun objed-activate ()
+(defun objed-activate (&optional obj)
   "Activate objed.
 
 Uses `objed-initial-object' for initialization."
   (interactive)
-  (objed--init objed-initial-object))
+  (objed--init (or obj objed-initial-object)))
 
 
 (defun objed-toggle-side ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]