branch: externals/objed commit 041f518f359924f70ba1177346b004c08c03efed Author: Clemens Radermacher <clem...@posteo.net> Commit: Clemens Radermacher <clem...@posteo.net>
Fix sexp movement in strings --- objed-objects.el | 8 +++++--- objed.el | 45 +++++++++++++++++++++++++++++---------------- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/objed-objects.el b/objed-objects.el index 54f89ab..8955892 100644 --- a/objed-objects.el +++ b/objed-objects.el @@ -1212,14 +1212,16 @@ position POS, otherwise just return POS." ;; * Object definition helpers -(defun objed--in-string-p (&optional syn) +(defun objed--in-string-p (&optional syn ignore-atp) "Return non-nil if point is inside or at string. If SYN is given use it instead of syntax at point." (let ((syn (or syn (syntax-ppss)))) - (or (and (nth 3 syn) + (if (and (nth 3 syn) (nth 8 syn)) - (objed--at-string-p)))) + (nth 8 syn) + (and (not ignore-atp) + (objed--at-string-p))))) (defun objed--at-string-p () "Return non-nil if point is at string." diff --git a/objed.el b/objed.el index 72a41d3..74b219b 100644 --- a/objed.el +++ b/objed.el @@ -899,26 +899,39 @@ Use `objed-define-dispatch' to define a dispatch command.") (defun objed--forward-sexp () (interactive) - (while (and (not (eobp)) - (or (and (not (bobp)) - (not (memq (char-syntax (char-before)) (list ?\s ?>))) - (eq (char-syntax (char-after)) ?\")) - (not (ignore-errors - (call-interactively 'forward-sexp) - t)))) - (forward-char 1))) + (let ((stringp nil)) + (while (and (not (eobp)) + (or (and (not (bobp)) + (save-excursion + (objed--skip-ws) + (eq (char-syntax (char-after)) ?\")) + (setq stringp (objed--in-string-p nil t))) + (not (ignore-errors + (call-interactively 'forward-sexp) + t)))) + (if stringp + (progn (goto-char stringp) + (forward-sexp 1)) + (forward-char 1)) + (setq stringp nil)))) (defun objed--backward-sexp () (interactive) - (while (and (not (bobp)) - (or (and (not (eobp)) - (eq (char-syntax (char-before)) ?\") - (not (memq (char-syntax (char-after)) (list ?\s ?>)))) - (not (ignore-errors - (call-interactively 'backward-sexp) - t)))) - (forward-char -1))) + (let ((stringp nil)) + (while (and (not (bobp)) + (or (and (not (eobp)) + (save-excursion + (objed--skip-ws t) + (eq (char-syntax (char-before)) ?\")) + (setq stringp (objed--in-string-p nil t))) + (not (ignore-errors + (call-interactively 'backward-sexp) + t)))) + (if stringp + (goto-char stringp) + (forward-char -1)) + (setq stringp nil)))) (defmacro objed--save-state (&rest body)