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: Small improvements to ruby-mode Date: Sat, 13 Jul 2013 00:31:03 +0400 Message-ID: <51E06787.8020401@yandex.ru> References: <2A6700DEDCA640EF92B326002717596D@gmail.com> <51D31E12.7060002@yandex.ru> <51D4476A.40107@yandex.ru> <51D6A02C.2020207@yandex.ru> <51D6D500.7080306@yandex.ru> <51DB6516.1090708@yandex.ru> <51DC43CE.3090206@yandex.ru> <51DDA366.9020700@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1373662503 32164 80.91.229.3 (12 Jul 2013 20:55:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 12 Jul 2013 20:55:03 +0000 (UTC) Cc: Stefan Monnier , emacs-devel To: Bozhidar Batsov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jul 12 22:55:04 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UxkMo-0007O0-9l for ged-emacs-devel@m.gmane.org; Fri, 12 Jul 2013 22:55:02 +0200 Original-Received: from localhost ([::1]:37172 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxkMn-0003P3-OO for ged-emacs-devel@m.gmane.org; Fri, 12 Jul 2013 16:55:01 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxkMf-0003G4-3F for emacs-devel@gnu.org; Fri, 12 Jul 2013 16:54:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uxjze-0006f3-RN for emacs-devel@gnu.org; Fri, 12 Jul 2013 16:31:49 -0400 Original-Received: from mail-la0-x22e.google.com ([2a00:1450:4010:c03::22e]:64534) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uxjze-0006ds-DI for emacs-devel@gnu.org; Fri, 12 Jul 2013 16:31:06 -0400 Original-Received: by mail-la0-f46.google.com with SMTP id eg20so8006803lab.5 for ; Fri, 12 Jul 2013 13:31:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding :x-antivirus:x-antivirus-status; bh=xRbHOFwuhadwQTSOto6FwHagQqsGMaRT2R0lVTOJ/QM=; b=FbIBzpI1jteB16nZqUzrAzfCDEzhpp4JGIfimIfvO1gzx3k6T04G8R0sno2Ha6Bjg0 ZKdd/4JrqpWLsqqrjKJ+ajf2o5/4coYTdPJ/mvRHTx3lNNmxdEq7yCXQWsYpPjnF/32L vnkgjw7/BWFAc2uxhKeEYK0FAzMvW5rw0IbuYRJTTeJzSst2RWvsSe9a/qEadoUN0JRK jupoeSuKYGjERhd5Vn2htfxiSOGOJzHNzWBOM9xFi1pcEIm5SgjWMmrd0hVxQrahcNBF NoQTSmNebB7SSRI8uqwwmSHfaojpQb7Aq2ibkyBt3HaHiYqOSaIqQR7HOJb/28uWuMkG tDJw== X-Received: by 10.152.88.78 with SMTP id be14mr20402742lab.19.1373661065273; Fri, 12 Jul 2013 13:31:05 -0700 (PDT) Original-Received: from [127.0.0.1] ([178.252.98.87]) by mx.google.com with ESMTPSA id m14sm14522256lbl.1.2013.07.12.13.31.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 12 Jul 2013 13:31:04 -0700 (PDT) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 In-Reply-To: X-Antivirus: avast! (VPS 130712-1, 12.07.2013), Outbound message X-Antivirus-Status: Clean X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::22e 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:161842 Archived-At: On 11.07.2013 15:23, Bozhidar Batsov wrote: > Still, we should consider functions with names like Float. Currently > they are not highlighted correctly - Something(test) is highlighted as a > constant, when obviously it's not. Fixed, among other things, see the patch at the bottom. We don't highlight method calls, so I just disabled highlighting in this case. > I guess classes, constants and > functions like this could be font-locked after the first character > that's not part of the identifier name appears, to avoid the changing of > the face after the initial character. Function calls can be identified by having a paren after the name (no luck with parenless calls). But there's really nothing that would distinguish a Math::E reference from Foo::C. Or from GC, IO, DL, IRB, URI, XML, HTML, etc. === modified file 'lisp/progmodes/ruby-mode.el' --- lisp/progmodes/ruby-mode.el 2013-07-09 01:17:48 +0000 +++ lisp/progmodes/ruby-mode.el 2013-07-12 20:07:57 +0000 @@ -1351,7 +1351,7 @@ (progn (eval-and-compile (defconst ruby-percent-literal-beg-re - "\\(%\\)[qQrswWx]?\\([[:punct:]]\\)" + "\\(%\\)[qQrswWxIi]?\\([[:punct:]]\\)" "Regexp to match the beginning of percent literal.") (defconst ruby-syntax-methods-before-regexp @@ -1387,7 +1387,7 @@ (funcall (syntax-propertize-rules ;; $' $" $` .... are variables. - ;; ?' ?" ?` are ascii codes. + ;; ?' ?" ?` are character literals (one-char strings in 1.9+). ("\\([?$]\\)[#\"'`]" (1 (unless (save-excursion ;; Not within a string. @@ -1518,7 +1518,7 @@ (save-match-data (save-excursion (goto-char (nth 8 parse-state)) - (looking-at "%\\(?:[QWrx]\\|\\W\\)"))))))) + (looking-at "%\\(?:[QWrxI]\\|\\W\\)"))))))) (defun ruby-syntax-propertize-expansions (start end) (save-excursion @@ -1848,8 +1848,11 @@ '("\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+" 0 font-lock-variable-name-face) ;; constants - '("\\(?:\\_<\\|::\\)\\([A-Z]+\\(\\w\\|_\\)*\\)" - 1 font-lock-type-face) + '("\\(?:\\_<\\|::\\)\\([A-Z]+\\(\\w\\|_\\)*\\)\\(?:\\_>[^\(]\\|::\\|\\'\\)" + 1 (progn + (when (eq ?: (char-before)) + (forward-char -2)) + font-lock-type-face)) '("\\(^\\s *\\|[\[\{\(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+\\):[^:]" 2 font-lock-constant-face) ;; expression expansion '(ruby-match-expression-expansion @@ -1857,6 +1860,9 @@ ;; negation char '("[^[:alnum:]_]\\(!\\)[^=]" 1 font-lock-negation-char-face) + ;; character literals + ;; FIXME: Support longer escape sequences. + '("\\?\\\\?\\S " 0 font-lock-string-face) ) "Additional expressions to highlight in Ruby mode.")