emacs-pretest-bug
[Top][All Lists]
Advanced

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

Re: up-list gives error inside strings


From: Nikolaj Schumacher
Subject: Re: up-list gives error inside strings
Date: Wed, 25 Apr 2007 15:15:08 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.98 (darwin)

Richard Stallman <address@hidden> writes:

>     Calling `up-list' inside a string gives this error:
>     up-list: Scan error: "Unbalanced parentheses", 14, 19
>
> These commands do not know that they are starting from inside a string.
>
> It may now be possible to make them understand that, using
> syntax-ppss.  If someone wants to start implementing this, please go
> ahead; it could be installed in a later release.

Thank you for pointing that out.
Using this, it was very easy to get the function I wanted.


(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")
  (let ((pos (point)))
    (if (< arg 0)
        ;; backward
        (while (and pos (/= arg 0))
          (setq pos (cadr (syntax-ppss pos)))
          (incf arg))
      ;; forward
      (while (and pos (/= arg 0))
        (when (setq pos (cadr (syntax-ppss pos)))
          (setq pos (scan-sexps pos 1)) ; move to end of sexp
          (decf arg))))
    (if pos
        (goto-char pos)
      (error "Reached top level"))))




reply via email to

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