all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: emacs-devel@gnu.org
Cc: Bozhidar Batsov <bozhidar@tradeo.com>
Subject: Re: master e8acfc7: Add a command for string quotes toggling to ruby-mode
Date: Tue, 09 Dec 2014 23:47:34 +0200	[thread overview]
Message-ID: <86k320v6kp.fsf@yandex.ru> (raw)
In-Reply-To: <E1XyOqS-0007dA-S5@vcs.savannah.gnu.org> (Bozhidar Batsov's message of "Tue, 09 Dec 2014 17:45:09 +0000")

Hi!

Bozhidar Batsov <bozhidar@batsov.com> writes:

> +(defun ruby--string-region ()
> +  "Return region for string at point."
> +  (let ((orig-point (point)) (regex "'\\(\\(\\\\'\\)\\|[^']\\)*'\\|\"\\(\\(\\\\\"\\)\\|[^\"]\\)*\"") beg end)
> +    (save-excursion
> +      (goto-char (line-beginning-position))
> +      (while (and (re-search-forward regex (line-end-position) t) (not (and beg end)))
> +        (let ((match-beg (match-beginning 0)) (match-end (match-end 0)))
> +          (when (and
> +                 (> orig-point match-beg)
> +                 (< orig-point match-end))
> +            (setq beg match-beg)
> +            (setq end match-end))))
> +      (and beg end (list beg end)))))

Any reason this doesn't do something like

(let ((state (syntax-ppss)))
  (when (memq (nth 3 state) '(?' ?\"))
    (goto-char (nth 8 state))
    (forward-sexp)
    (list (nth 8 state) (point))))

?



       reply	other threads:[~2014-12-09 21:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20141209174508.29184.57986@vcs.savannah.gnu.org>
     [not found] ` <E1XyOqS-0007dA-S5@vcs.savannah.gnu.org>
2014-12-09 21:47   ` Dmitry Gutov [this message]
2014-12-09 21:50     ` master e8acfc7: Add a command for string quotes toggling to ruby-mode Bozhidar Batsov
2014-12-09 22:10       ` Dmitry Gutov
2014-12-09 22:07     ` Bozhidar Batsov
2014-12-09 22:23       ` Dmitry Gutov
2014-12-10  2:11   ` Ted Zlatanov
2014-12-10  8:30     ` Bozhidar Batsov
2014-12-10 13:25       ` Ted Zlatanov
2014-12-22 15:06         ` Bozhidar Batsov

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=86k320v6kp.fsf@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=bozhidar@tradeo.com \
    --cc=emacs-devel@gnu.org \
    /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.