branch: externals/objed commit 781f0eeedb8e68862a895e83f1811775eac13983 Author: Clemens Radermacher <clem...@posteo.net> Commit: Clemens Radermacher <clem...@posteo.net>
Make word object behave correctly with superword/subword-mode --- objed-objects.el | 21 ++++++++++----------- objed.el | 36 ++++++++++++++++++++++++++---------- 2 files changed, 36 insertions(+), 21 deletions(-) diff --git a/objed-objects.el b/objed-objects.el index f0bedf5..a4f5940 100644 --- a/objed-objects.el +++ b/objed-objects.el @@ -1518,6 +1518,7 @@ comments." :try-prev (search-backward " " nil t)) + (objed-define-object nil word :atp (looking-at "\\<") @@ -1527,17 +1528,15 @@ comments." 'identifier) :get-obj (objed-make-object - :obounds (if (bound-and-true-p subword-mode) - (let ((find-word-boundary-function-table subword-empty-char-table)) - (bounds-of-thing-at-point 'word)) - (bounds-of-thing-at-point 'word)) - :ibounds (if (and (bound-and-true-p subword-mode) - (eq this-command 'forward-word)) - (save-excursion - (forward-word -1) - (bounds-of-thing-at-point 'word)) - (let ((find-word-boundary-function-table - subword-find-word-boundary-function-table)) + :obounds (bounds-of-thing-at-point 'word) + :ibounds (let* ((subword-mode t) + (superword-mode nil) + (find-word-boundary-function-table + subword-find-word-boundary-function-table)) + (if (eq this-command 'forward-word) + (save-excursion + (forward-word -1) + (bounds-of-thing-at-point 'word)) (bounds-of-thing-at-point 'word)))) :try-next (re-search-forward "\\<." nil t) diff --git a/objed.el b/objed.el index 8510a87..4044be5 100644 --- a/objed.el +++ b/objed.el @@ -661,12 +661,32 @@ selected one." (define-key map "~" 'objed-undo-in-object) ;; general movement - (define-key map "s" (objed--call-and-switch - forward-word - word)) - (define-key map "r" (objed--call-and-switch - backward-word - word)) + (define-key map "s" (defun objed-forward-word () + "Call `forward-word' and switch to object word" + (interactive) + (if (objed--inner-p) + (let* ((subword-mode t) + (superword-mode nil) + (find-word-boundary-function-table + subword-find-word-boundary-function-table)) + (setq this-command 'forward-word) + (call-interactively 'forward-word)) + (setq this-command 'forward-word) + (call-interactively 'forward-word)) + (objed--switch-to 'word objed--obj-state))) + (define-key map "r" (defun objed-backward-word () + "Call `forward-word' and switch to object word" + (interactive) + (if (objed--inner-p) + (let* ((subword-mode t) + (superword-mode nil) + (find-word-boundary-function-table + subword-find-word-boundary-function-table)) + (setq this-command 'backward-word) + (call-interactively 'backward-word)) + (setq this-command 'backward-word) + (call-interactively 'backward-word)) + (objed--switch-to 'word objed--obj-state))) (define-key map "S" 'objed-move-word-forward) (define-key map "R" 'objed-move-word-backward) @@ -1879,10 +1899,6 @@ Default to sexp at point." Switches to inner object or object inside current one." (interactive) - (if (bound-and-true-p subword-mode) - (subword-mode -1) - (unless (objed--inner-p) - (subword-mode 1))) (objed--toggle-state))