From: "Andreas Röhler" <andreas.roehler@easy-emacs.de>
To: Dmitry Gutov <dgutov@yandex.ru>, 20732-done@debbugs.gnu.org
Subject: bug#20732: in-string-p fails
Date: Fri, 05 Jun 2015 08:01:11 +0200 [thread overview]
Message-ID: <55713B27.3040407@easy-emacs.de> (raw)
In-Reply-To: <5570BDC8.1010800@yandex.ru>
Am 04.06.2015 um 23:06 schrieb Dmitry Gutov:
> 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.
>
>
Why not have two functions dealing with different circumstances.
- in-string-p-maybe, which might guess first and fast, re-fine afterwards.
- a precise in-string-p running parse-partial-sexp on widened buffer.
(defun in-string-p-precise ()
"Returns the character which delimits the string if inside, nil
otherwise. "
(save-restriction
(widen)
(ignore-errors (nth 3 (parse-partial-sexp (point-min) (point))))))
Maybe also return t if at string-start pos already:
(eq (char-syntax (char-after)) 34)
When not called from complex environment (also precise):
(defun ar-in-string-p ()
"Return position, if inside or at opening delimiter.
Otherwise return nil. "
(interactive)
(save-restriction
(widen)
(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)))
next prev parent reply other threads:[~2015-06-05 6:01 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-04 9:27 bug#20732: in-string-p fails Andreas Röhler
2015-06-04 9:58 ` Dmitry Gutov
2015-06-04 11:50 ` Andreas Röhler
2015-06-04 21:06 ` Dmitry Gutov
2015-06-05 5:41 ` Andreas Röhler
2015-06-05 6:01 ` Andreas Röhler [this message]
2015-06-05 8:36 ` Dmitry Gutov
2015-06-05 8:58 ` Andreas Röhler
2015-06-05 11:17 ` Dmitry Gutov
2015-06-05 10:34 ` Andreas Röhler
2015-06-05 11:53 ` Andreas Röhler
2015-06-05 12:52 ` Andreas Röhler
2015-06-05 15:18 ` Stefan Monnier
2015-06-05 20:06 ` Dmitry Gutov
2015-06-04 16:00 ` Stefan Monnier
2015-06-04 20:59 ` Dmitry Gutov
2015-06-04 22:29 ` Stefan Monnier
2015-06-05 12:17 ` Dmitry Gutov
2015-06-05 15:19 ` Stefan Monnier
2015-06-06 9:59 ` Dmitry Gutov
2015-06-06 18:37 ` Drew Adams
2015-06-06 18:41 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55713B27.3040407@easy-emacs.de \
--to=andreas.roehler@easy-emacs.de \
--cc=20732-done@debbugs.gnu.org \
--cc=dgutov@yandex.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.