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

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

bug#20732: in-string-p fails


From: Andreas Röhler
Subject: bug#20732: in-string-p fails
Date: Fri, 05 Jun 2015 14:52:34 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.4.0


Am 05.06.2015 um 13:53 schrieb Andreas Röhler:

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)))))





and correct the doc-string

(defun ar-in-string-p-fast ()
  "If inside, return character which delimits the string, nil otherwise. "
  (ignore-errors (nth 3 (parse-partial-sexp (point-min) (point)))))






reply via email to

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