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
Subject: Re: General delimited literals in ruby-mode patch
Date: Fri, 10 Feb 2012 09:03:17 +0400	[thread overview]
Message-ID: <87ehu3mga2.fsf@yandex.ru> (raw)
In-Reply-To: 87k43vecyt.fsf@yandex.ru

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

>> The bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6286.

And here's a tentative patch for the last example (regexp as a first
parameter in a paren-less method invocation).

It adds a check whether the regexp is followed by a comma or a
block, though, so the full example should look like this:

Given /A user is logged in/ do
  # whatever
end

AFAIK, all Cucumber step definitions need a block (that's where the
definition goes), so it shouldn't be a problem.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: regexp in paren-less call patch --]
[-- Type: text/x-patch, Size: 1888 bytes --]

diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index e93f8b3..a0a6509 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -1130,9 +1130,8 @@ See `add-log-current-defun-function'."
                         (nth 3 (syntax-ppss (match-beginning 0))))
                 (string-to-syntax "\\"))))
           ;; regexps
-          ("\\(^\\|[[=(,~?:;<>]\\|\\(^\\|\\s \\)\\(if\\|elsif\\|unless\\|while\\|until\\|when\\|and\\|or\\|&&\\|||\\)\\|g?sub!?\\|scan\\|split!?\\)\\s *\\(/\\)[^/\n\\\\]*\\(\\\\.[^/\n\\\\]*\\)*\\(/\\)"
-           (4 "\"/")
-           (6 "\"/"))
+          ("\\(^\\|[[=(,~?:;<>]\\|\\(?:^\\|\\s \\)\\(?:if\\|elsif\\|unless\\|while\\|until\\|when\\|and\\|or\\|&&\\|||\\)\\|g?sub!?\\|scan\\|split!?\\)?\\s *\\(/\\)[^/\n\\\\]*\\(?:\\\\.[^/\n\\\\]*\\)*\\(/\\)"
+           (2 (ruby-syntax-propertize-regexp)))
           ("^=en\\(d\\)\\_>" (1 "!"))
           ("^\\(=\\)begin\\_>" (1 "!"))
           ;; Handle here documents.
@@ -1143,6 +1142,21 @@ See `add-log-current-defun-function'."
            (1 (prog1 "|" (ruby-syntax-propertize-general-delimiters end)))))
          (point) end))
 
+      (defun ruby-syntax-propertize-regexp ()
+        (let ((syn (string-to-syntax "\"/")))
+          (goto-char (match-end 3))
+          (if (or
+               ;; after paren, comma, operator, control flow keyword,
+               ;; or a method from hardcoded list
+               (match-beginning 1)
+               ;; followed by comma or block
+               (looking-at "[imxo]*\\s *\\(?:,\\|\\<do\\>\\)"))
+              (progn
+                (put-text-property (1- (point)) (point)
+                                   'syntax-table syn)
+                syn)
+            (goto-char (match-end 2)))))
+
       (defun ruby-syntax-propertize-heredoc (limit)
         (let ((ppss (syntax-ppss))
               (res '()))

  reply	other threads:[~2012-02-10  5:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-07 23:32 General delimited literals in ruby-mode patch Dmitry Gutov
2012-02-10  0:42 ` Dmitry Gutov
2012-02-10  5:03   ` Dmitry Gutov [this message]
2012-04-24 17:09     ` bug#6286: " Stefan Monnier
2012-04-25  3:03       ` Dmitry Gutov
2012-04-24 15:43   ` Stefan Monnier
2012-04-24 23:46     ` Dmitry Gutov
2012-04-25 14:15       ` Stefan Monnier
     [not found]         ` <4F981DEA.6060700@yandex.ru>
     [not found]           ` <jwv4ns7iubj.fsf-monnier+emacs@gnu.org>
2012-04-28 20:20             ` Dmitry Gutov
2012-05-03  5:39             ` Dmitry Gutov
2012-08-14  3:56               ` Dmitry Gutov
2012-08-14 12:40                 ` Stefan Monnier
2012-08-14 17:46                   ` Dmitry Gutov
2012-08-15  2:33                     ` Stefan Monnier

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=87ehu3mga2.fsf@yandex.ru \
    --to=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.