> Using this, it was very easy to get the function I wanted.

Calling `syntax-ppss' repeatedly can become costly for deeply nested
positions.  I'd propose something like the below:

(defun up-list-forward (arg)
  "Move forward out of one level of parentheses.
With arg, do this that many times.
A negative argument means move backward but still to a less deep spot."
  (interactive "p")
  (or arg (setq arg 1))
  (unless (zerop arg)
    (let* ((pos (point))
           (abs (abs arg))
           (ppss (syntax-ppss pos))
           (depth (nth 0 ppss))
           (ninth (nth 9 (syntax-ppss pos))))
      (if (< depth abs)
          (error "Reached top level")
        (goto-char (nth (- depth abs) ninth))
        (unless (< arg 0)
          (condition-case nil
              (forward-sexp)
            (scan-error
             ;; Improve as soon as `scan-error' gets documented somewhere.
             (goto-char pos)
             (error "No enclosing list"))))))))



_______________________________________________
emacs-pretest-bug mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug

Reply via email to