Subject: Re: bug#20732: in-string-p fails

From: Andreas Röhler <[email-masked]>
Date: Fri, 05 Jun 2015 13:53:13 +0200

Am 05.06.2015 um 12:34 schrieb Andreas Röhler:
>
> Am 05.06.2015 um 08:01 schrieb Andreas Röhler:
>>
> Meanwhile think calling "widen" here is a mistake. Rather accept 
> narrowing might change the buffers state WRT in-string-p
>
> Here the corrected forms:
>
> (defun ar-in-string-p ()
>   "Return position, if inside or at opening delimiter.
>
> Otherwise return nil. "
>   (interactive)
>   (let* ((pps (parse-partial-sexp (point-min) (point)))
>      (erg (and (nth 3 pps) (nth 8 pps)))
>      (la (unless erg (when (eq (char-syntax (char-after)) 34)
>                (point)))))
>     (setq erg (or erg la))
>     (when (interactive-p) (message "%s" erg))
>     erg))
>
> (defun ar-in-string-p-fast ()
>   "Returns start position if inside, nil otherwise. "
>   (ignore-errors (nth 8 (parse-partial-sexp (point-min) (point)))))
>
>
>

Sorry, nth 8 would be not enough:

(defun ar-in-string-p-fast ()
   "Returns start position if inside, nil otherwise. "
   (ignore-errors (nth 3 (parse-partial-sexp (point-min) (point)))))