--- Begin Message ---
Subject: |
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
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#20732: in-string-p fails |
Date: |
Fri, 5 Jun 2015 00:06:16 +0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0 |
On 06/04/2015 02:50 PM, Andreas Röhler wrote:
In question slow is better than false.
Then (setq open-paren-in-column-0-is-defun-start nil) in your Emacs config.
There is no way to know reliably if inside a string than scanning the
whole buffer. All other is woodoo.
There's a whole package dedicated to doing is faster and in easier
fashion: lisp/emacs-lisp/syntax.el.
You're welcome to suggest improvements that don't sacrifice performance
to this extent.
In result, it needs to consider these requests with care, re-use the
result rather then salting la code with in-string-p calls. :)
What is "it"?
--- End Message ---