branch: externals/objed commit 2ea1ebb58161140dff0d677b0805a43063b8c1ab Author: Clemens Radermacher <clem...@posteo.net> Commit: Clemens Radermacher <clem...@posteo.net>
Adjust default binding scheme --- README.asc | 31 +++++++++++++--------------- objed.el | 31 ++++++++++++---------------- test/tests/emacs-lisp-mode/expansion/block_2 | 2 +- test/tests/emacs-lisp-mode/expansion/block_3 | 2 +- test/tests/emacs-lisp-mode/expansion/block_4 | 2 +- test/tests/emacs-lisp-mode/expansion/block_5 | 2 +- test/tests/emacs-lisp-mode/expansion/block_6 | 2 +- 7 files changed, 32 insertions(+), 40 deletions(-) diff --git a/README.asc b/README.asc index 374eb3e..ffc7e0a 100644 --- a/README.asc +++ b/README.asc @@ -55,11 +55,11 @@ kbd:[M-SPC] by default. It uses the last command and its mapping in `objed-command-alist` to choose the initial object. Objeds modal state provides basic movement commands which move by line, sexp -or word. Those switch automatically to the corresponding object type. Other -commands only activate the part between the initial position and the new -position moved to. By repeating commands you can often expand/proceed to other -objects. This way you can compose movement and editing operations very -efficiently. +word or character. Those switch automatically to the corresponding object +type. Other commands only activate the part between the initial position and +the new position moved to. By repeating commands you can often expand/proceed +to other objects. This way you can compose movement and editing operations +very efficiently. The expansion commands distinguish between block objects (objects built out of lines of text like paragraphs or text blocks with the same level of @@ -155,7 +155,7 @@ If commands allow for numeric arguments you can input them without the use of kbd:[Ctrl] or kbd:[Meta]. kbd:[0] can be used as an alternative for the universal argument (kbd:[C-u]). To add custom commands to the modal state you can use `objed-user-map` which is available under prefix key kbd:['] and -`objed-other-user-map` bound to kbd:[-]. It's recommended to use one of these +`objed-other-user-map` bound to kbd:[?]. It's recommended to use one of these map for custom object bindings and the other one for additional operations. In addition to the commands configured in `objed-cmd-alist` you can use the @@ -195,6 +195,9 @@ Basic movement commands (switch the object type on movement): |=== |Shortcut |Purpose +|kbd:[l/h] +|Move forward/backward one char and activate the char object + |kbd:[f/b] |Move forward/backward one sexp and activate the sexp object @@ -211,7 +214,7 @@ Commands for block objects (objects built out of lines of text): |=== |Shortcut |Purpose -|kbd:[h] +|kbd:[v] |Activate (line based) object at point and move to its start. On repeat proceed to beginning of the indentation block, comment block, paragraph or other block objects. |kbd:[a] @@ -263,12 +266,6 @@ command mark all instances in current defun/buffer): |kbd:[,] |Switch to identifier object and move to previous. -|kbd:[_] -|Switch to symbol object. - -|kbd:[l] -|Switch to line object. - |kbd:[c] |Prefix to switch to other objects, see `objed-object-map` for available objects and `objed-define-object` to add your own (https://with-emacs.com/posts/objed/writing-your-own-text-objects-for-objed/[blog]). |=== @@ -399,7 +396,7 @@ Misc commands: |kbd:[M] |Add/Remove current object to marked objects and move to previous. -|kbd:[v] +|kbd:[@] |Activate region with current object (extend current object). |kbd:[Ctrl - Space] @@ -408,7 +405,7 @@ Misc commands: |kbd:[/] |Undo last edit command. -|kbd:[?] +|kbd:[C-h b] |Get key binding help (uses `which-key` if available). |kbd:[g/Ctrl - g] @@ -438,10 +435,10 @@ You can add your own prefix bindings using `objed-define-dispatch`. |kbd:[ยด] |Activate part from point backward until boundary of some object. -|kbd:[@] +|kbd:[-] |Extend current object by including leading whitespace. -|kbd:[_] +|kbd:[+] |Extend current object by including trailing whitespace. |=== diff --git a/objed.el b/objed.el index da626d8..e8d7f41 100644 --- a/objed.el +++ b/objed.el @@ -627,10 +627,10 @@ selected one." (define-key map (kbd (format "C-%c" n)) 'digit-argument)) ;; common emacs keys (define-key map (kbd "C-g") 'objed-quit) + (define-key map (kbd "C-h b") 'objed-show-top-level) ;; TODO: switch with q, so quit window is qq? (define-key map "g" 'objed-quit) (define-key map "q" 'objed-quit-window-or-reformat) - (define-key map (kbd "?") 'objed-show-top-level) ;; TODO: support repeated invokation (define-key map (kbd "C-u") 'universal-argument) ;; for quick access @@ -654,6 +654,10 @@ selected one." (define-key map "~" 'objed-undo-in-object) ;; general movement + (define-key map "l" (objed--call-and-switch right-char char)) + (define-key map "h" (objed--call-and-switch left-char char)) + (define-key map "L" 'objed-move-char-forward) + (define-key map "H" 'objed-move-char-backward) (define-key map "s" (defun objed-forward-word () "Call `forward-word' and switch to object word" (interactive) @@ -687,7 +691,6 @@ selected one." (define-key map "f" (objed--call-and-switch objed--forward-sexp sexp)) (define-key map "b" (objed--call-and-switch objed--backward-sexp sexp)) - ;; TODO: move sexp (define-key map "F" 'objed-move-object-forward) (define-key map "B" 'objed-move-object-backward) @@ -705,7 +708,6 @@ selected one." (define-key map "N" 'objed-move-line-forward) (define-key map "P" 'objed-move-line-backward) - (define-key map "(" 'objed-backward-until-context) (define-key map ")" 'objed-forward-until-context) (define-key map "[" 'objed-previous) ;; objed-current-or-previous-context @@ -723,10 +725,9 @@ selected one." (define-key map "<" 'objed-top-object) (define-key map ">" 'objed-bottom-object) ;; block expansions - (define-key map "h" 'objed-expand-block) (define-key map "a" 'objed-beg-of-block) (define-key map "e" 'objed-end-of-block) - + (define-key map "v" 'objed-expand-block) ;; context expansions (define-key map "o" 'objed-expand-context) @@ -741,16 +742,10 @@ selected one." ;; mark upwards (define-key map "M" 'objed-toggle-mark-backward) ;; (define-key map "M" 'objed-unmark-all) - ;; Use h block expansion now - ;; TODO: bind l to something else - (define-key map "l" 'objed-line-object) - - ;; "visual" - (define-key map "v" 'objed-extend) - ;; TODO: more general include expansion? - (define-key map "@" 'objed-include-leading-ws) - (define-key map "_" 'objed-include-trailing-ws) + (define-key map "@" 'objed-extend) + (define-key map "-" 'objed-include-leading-ws) + (define-key map "+" 'objed-include-trailing-ws) ;; basic edit ops (define-key map "k" 'objed-kill) @@ -779,15 +774,14 @@ selected one." ;; direct object switches (define-key map "." 'objed-goto-next-identifier) (define-key map "," 'objed-goto-prev-identifier) - ;; (define-key map "_" 'objed-toggle-indentifier-place) - ;;(define-key map "%" 'objed-contents-object) + (define-key map "_" 'objed-toggle-indentifier-place) ;; prefix keys (define-key map "x" 'objed-op-map) (define-key map "c" 'objed-object-map) ;; for custom user object and op commands (define-key map "'" 'objed-user-map) - (define-key map "-" 'objed-other-user-map) + (define-key map "?" 'objed-other-user-map) (define-key map (kbd "M-g o") 'objed-occur) @@ -939,7 +933,7 @@ To define new operations see `objed-define-op'.") "Keymap for custom user bindings.") (defvar objed-other-user-map - (let ((map (objed--define-prefix "-" 'objed-user-map))) + (let ((map (objed--define-prefix "?" 'objed-user-map))) map) "Keymap for custom user bindings.") @@ -970,6 +964,7 @@ To define new operations see `objed-define-op'.") (define-key map "s" 'objed-string-object) (define-key map ";" 'objed-comment-object) (define-key map "=" 'objed-face-object) + (define-key map "%" 'objed-contents-object) (define-key map "t" 'objed-tag-object) (define-key map "f" 'objed-file-object) diff --git a/test/tests/emacs-lisp-mode/expansion/block_2 b/test/tests/emacs-lisp-mode/expansion/block_2 index 48cb69b..adbfb33 100644 --- a/test/tests/emacs-lisp-mode/expansion/block_2 +++ b/test/tests/emacs-lisp-mode/expansion/block_2 @@ -1,4 +1,4 @@ -h +v ;;;; (defun check () diff --git a/test/tests/emacs-lisp-mode/expansion/block_3 b/test/tests/emacs-lisp-mode/expansion/block_3 index 96bc597..283f469 100644 --- a/test/tests/emacs-lisp-mode/expansion/block_3 +++ b/test/tests/emacs-lisp-mode/expansion/block_3 @@ -1,4 +1,4 @@ -hh +vv ;;;; (defun check () diff --git a/test/tests/emacs-lisp-mode/expansion/block_4 b/test/tests/emacs-lisp-mode/expansion/block_4 index 4bd3e1a..0a06608 100644 --- a/test/tests/emacs-lisp-mode/expansion/block_4 +++ b/test/tests/emacs-lisp-mode/expansion/block_4 @@ -1,4 +1,4 @@ -hhh +vvv ;;;; (defun check () diff --git a/test/tests/emacs-lisp-mode/expansion/block_5 b/test/tests/emacs-lisp-mode/expansion/block_5 index f06dd82..57df0ea 100644 --- a/test/tests/emacs-lisp-mode/expansion/block_5 +++ b/test/tests/emacs-lisp-mode/expansion/block_5 @@ -1,4 +1,4 @@ -hhhh +vvvv ;;;; (defun check () diff --git a/test/tests/emacs-lisp-mode/expansion/block_6 b/test/tests/emacs-lisp-mode/expansion/block_6 index dcb6fd7..50e5def 100644 --- a/test/tests/emacs-lisp-mode/expansion/block_6 +++ b/test/tests/emacs-lisp-mode/expansion/block_6 @@ -1,4 +1,4 @@ -hhhhh +vvvvvv ;;;; (defun check ()