From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: General delimited literals in ruby-mode patch Date: Fri, 10 Feb 2012 09:03:17 +0400 Message-ID: <87ehu3mga2.fsf@yandex.ru> References: <8739ammd8l.fsf@yandex.ru> <87k43vecyt.fsf@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1328850217 22856 80.91.229.3 (10 Feb 2012 05:03:37 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 10 Feb 2012 05:03:37 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Feb 10 06:03:37 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rvie0-0004pD-Cr for ged-emacs-devel@m.gmane.org; Fri, 10 Feb 2012 06:03:36 +0100 Original-Received: from localhost ([::1]:35209 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rvidz-0006so-TC for ged-emacs-devel@m.gmane.org; Fri, 10 Feb 2012 00:03:35 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:45589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rvidu-0006hh-68 for emacs-devel@gnu.org; Fri, 10 Feb 2012 00:03:31 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rvids-00045x-2R for emacs-devel@gnu.org; Fri, 10 Feb 2012 00:03:30 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:48018) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rvidr-00045r-TH for emacs-devel@gnu.org; Fri, 10 Feb 2012 00:03:28 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Rvido-0004jx-Kp for emacs-devel@gnu.org; Fri, 10 Feb 2012 06:03:24 +0100 Original-Received: from 178.252.98.87 ([178.252.98.87]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 10 Feb 2012 06:03:24 +0100 Original-Received: from dgutov by 178.252.98.87 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 10 Feb 2012 06:03:24 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 64 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 178.252.98.87 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.93 (windows-nt) Cancel-Lock: sha1:Fhzx/kN26QK73IMevYSgmUaSQnw= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:148421 Archived-At: --=-=-= Content-Type: text/plain >> 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. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=ruby-parenless-regexp.diff Content-Description: regexp in paren-less call patch 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 *\\(?:,\\|\\\\)")) + (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 '())) --=-=-=--