all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Bozhidar Batsov <bozhidar@batsov.com>
To: Dmitry Gutov <dgutov@yandex.ru>, emacs-devel@gnu.org
Subject: Re: master e8acfc7: Add a command for string quotes toggling to ruby-mode
Date: Wed, 10 Dec 2014 00:07:55 +0200	[thread overview]
Message-ID: <etPan.548772bb.440badfc.2c10@bozhidar-mini.local> (raw)
In-Reply-To: <86k320v6kp.fsf@yandex.ru>

[-- Attachment #1: Type: text/plain, Size: 1224 bytes --]

The thought about using syntax-ppss crossed my mind, but I’m not particularly knowledgable there so I took a familiar route.
I’ll update the code.

P.S. Got to love cryptic code like (nth 8 state). This definitely needs a more digestible API.

-- 
Bozhidar Batsov
On December 9, 2014 at 23:47:37, Dmitry Gutov (dgutov@yandex.ru) wrote:

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

?  

[-- Attachment #2: Type: text/html, Size: 2643 bytes --]

  parent reply	other threads:[~2014-12-09 22:07 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   ` master e8acfc7: Add a command for string quotes toggling to ruby-mode Dmitry Gutov
2014-12-09 21:50     ` Bozhidar Batsov
2014-12-09 22:10       ` Dmitry Gutov
2014-12-09 22:07     ` Bozhidar Batsov [this message]
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=etPan.548772bb.440badfc.2c10@bozhidar-mini.local \
    --to=bozhidar@batsov.com \
    --cc=dgutov@yandex.ru \
    --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.