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: Thu, 04 Jun 2015 11:27:52 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

Cursor at 4th line before sdsd:

"asdf

(defun foo1 (&optional beg end)
  sdsd "

;;;

(in-string-p) returns falsely nil, because it scans from "(defun "

This would do it

(defun ar-in-string-p ()
  "Return delimiters start position, if inside, otherwise return nil. "
  (interactive)
  (save-restriction
    (widen)
    (let* ((erg (nth 8 (parse-partial-sexp (point-min) (point))))
       (la (unless erg (when (looking-at "\\s\"")
                 (match-beginning 0)))))
      (setq erg (or erg la))
      (when (interactive-p) (message "%s" erg))
      erg)))

Introduced "widen" - IMO there is no reliability without.

It also returns t if at the first char of a string-delimiter.

Source:

http://bazaar.launchpad.net/~a-roehler/s-x-emacs-werkstatt/trunk/view/head:/misc-utils.el







reply via email to

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