emacs-devel
[Top][All Lists]
Advanced

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

Re: Proposal: make up-list escape strings


From: Stefan Monnier
Subject: Re: Proposal: make up-list escape strings
Date: Tue, 08 Apr 2014 21:11:50 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)

> Here's a small patch that makes backward-up-list and up-list escape
> strings as well as explicit lists. This behavior is active only when
> these functions are called interactively or when lisp explicitly asks
> for this behavior, so the change shouldn't pose a compatibility risk.
> Backing out of strings is generally a useful thing to do when you want
> to operate on the string as a whole.

Thanks, this is long overdue.  See comments below:

> +If ESCAPE-STRINGS is non-nil (as it is interactively), treat
> +encoding strings as sexps."
   ^^^^^^^^
   enclosing, right?  ;-)

Why limit this to strings?  It makes just as much sense to do it for
comments, doesn't it?

>      (while (/= arg 0)
>        (if (null forward-sexp-function)
> -          (goto-char (or (scan-lists (point) inc 1) (buffer-end arg)))
> +          (condition-case err
> +              (goto-char (or (scan-lists (point) inc 1) (buffer-end arg)))
> +            (scan-error
> +             (or (and escape-strings
> +                      (let ((syntax (syntax-ppss)))
> +                        (and (nth 3 syntax)
> +                             (nth 8 syntax))
> +                        (goto-char (nth 8 syntax))
> +                        (when (> arg 0) (forward-sexp))
> +                        t))
> +                 (signal (car err) (cdr err)))))

If @ is point, I think that from

      (a "b (c (d @ e) " "f) g" h)

up-list should move to

      (a "b (c (d e)@ " "f) g" h)

and then to

      (a "b (c (d e) "@ "f) g" h)

whereas I think your code would move to

      (a "b (c (d e) " "f)@ g" h)

> +            (or (and escape-strings
> +                     (let ((syntax (syntax-ppss)))
> +                       (and (nth 3 syntax)
> +                            (nth 8 syntax))
> +                       (goto-char (nth 8 syntax))
> +                       (when (> arg 0) (forward-sexp))
> +                       t))

This should be factored out into a separate function to avoid the
code duplication.


        Stefan



reply via email to

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