Subject: bug#32504: [PATCH] syntax-is-{comment|string}-p

From: Noam Postavsky <[email-masked]>
Date: Thu, 30 Aug 2018 21:21:54 -0400

Alex Branham <[email-masked]> writes:

>>     (cl-defstruct (syntax-state (:constructor nil)
>>                                 (:type list))
>>       depth list-start sexp-end
>>       string-start comment quoted
         ^^^^^^^^^^^^
That should be string-terminator

>>       min-depth comment-style comment-or-string-start
>>       open-parens syntax-sequence)
>
> I'm not a big fan of the docstrings generated by this, is there a way to
> change them to be more helpful?

Hmm, doesn't look like it.  Well, that's just a convenient way of
defining them all quickly for discussion, it wouldn't be that much
harder to write out defuns I guess.

> But it would be a lot better (in my eyes, anyway) if it looked something
> like this, had the -p suffix, and made CL-X default to point:

> Return non-nil if the syntax of CL-X is a comment.

I don't think it should be a -p predicate, because there is meaningful
distinction between non-nil values:

     4. nil if outside a comment, t if inside a non-nestable comment,
        else an integer (the current comment nesting).

> CL-X defaults to point.

And, my intention is to operate on the return value of syntax-ppss, not
give a point to call it with.  So it could be used as:

    (syntax-state-comment (syntax-ppss))

or

    (let ((ppss (syntax-ppss)))
      (and (syntax-state-comment ppss)
           (syntax-state-comment-or-string-start ppss)))

or

    (syntax-state-comment (parse-partial-sexp ...))