[前][次][番号順一覧][スレッド一覧]

ruby-changes:38304

From: knu <ko1@a...>
Date: Fri, 24 Apr 2015 23:52:41 +0900 (JST)
Subject: [ruby-changes:38304] knu:r50385 (trunk): Import ruby-electric.el version 2.2.3 from upstream

knu	2015-04-24 23:52:31 +0900 (Fri, 24 Apr 2015)

  New Revision: 50385

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50385

  Log:
    Import ruby-electric.el version 2.2.3 from upstream

  Modified files:
    trunk/ChangeLog
    trunk/misc/ruby-electric.el
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50384)
+++ ChangeLog	(revision 50385)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Apr 24 23:48:45 2015  Akinori MUSHA  <knu@i...>
+
+	* misc/ruby-electric.el: Import version 2.2.3 from
+	  https://github.com/knu/ruby-electric.el.
+
 Fri Apr 24 10:40:02 2015  NAKAMURA Usaku  <usa@r...>
 
 	* win32/win32.c (rb_w32_{getc,putc}): removed.  they are needed for old
Index: misc/ruby-electric.el
===================================================================
--- misc/ruby-electric.el	(revision 50384)
+++ misc/ruby-electric.el	(revision 50385)
@@ -10,7 +10,7 @@ https://github.com/ruby/ruby/blob/trunk/misc/ruby-electric.el#L10
 ;; URL: https://github.com/knu/ruby-electric.el
 ;; Keywords: languages ruby
 ;; License: The same license terms as Ruby
-;; Version: 2.2.2
+;; Version: 2.2.3
 
 ;;; Commentary:
 ;;
@@ -33,6 +33,9 @@ https://github.com/ruby/ruby/blob/trunk/misc/ruby-electric.el#L33
 
 (require 'ruby-mode)
 
+(eval-when-compile
+  (require 'cl))
+
 (defgroup ruby-electric nil
   "Minor mode providing electric editing commands for ruby files"
   :group 'ruby)
@@ -279,19 +282,31 @@ enabled." https://github.com/ruby/ruby/blob/trunk/misc/ruby-electric.el#L282
         (t
          (ruby-electric-space/return-fallback))))
 
-(defun ruby-electric-code-at-point-p()
+(defun ruby-electric--get-faces-at-point ()
+  (let* ((point (point))
+         (value (or
+                 (get-text-property point 'read-face-name)
+                 (get-text-property point 'face))))
+    (if (listp value) value (list value))))
+
+(defun ruby-electric--faces-at-point-include-p (&rest faces)
   (and ruby-electric-mode
-       (let* ((properties (text-properties-at (point))))
-         (and (null (memq 'font-lock-string-face properties))
-              (null (memq 'font-lock-comment-face properties))))))
+       (loop for face in faces
+             with pfaces = (ruby-electric--get-faces-at-point)
+             thereis (memq face pfaces))))
+
+(defun ruby-electric-code-at-point-p()
+  (not (ruby-electric--faces-at-point-include-p
+        'font-lock-string-face
+        'font-lock-comment-face)))
 
 (defun ruby-electric-string-at-point-p()
-  (and ruby-electric-mode
-       (consp (memq 'font-lock-string-face (text-properties-at (point))))))
+  (ruby-electric--faces-at-point-include-p
+   'font-lock-string-face))
 
 (defun ruby-electric-comment-at-point-p()
-  (and ruby-electric-mode
-       (consp (memq 'font-lock-comment-face (text-properties-at (point))))))
+  (ruby-electric--faces-at-point-include-p
+   'font-lock-comment-face))
 
 (defun ruby-electric-escaped-p()
   (let ((f nil))

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]