summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-04-24 14:52:31 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-04-24 14:52:31 +0000
commit9955bb0130c18648e064c97b86b5310e32d164e5 (patch)
tree1a7297c2e3fc328ede6109aa924637ab974ba924 /misc
parent347d44ca415740d295af54b5059fd5030bfb3709 (diff)
Import ruby-electric.el version 2.2.3 from upstream
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'misc')
-rw-r--r--misc/ruby-electric.el33
1 files changed, 24 insertions, 9 deletions
diff --git a/misc/ruby-electric.el b/misc/ruby-electric.el
index 2d84954a77..f54e91ccbc 100644
--- a/misc/ruby-electric.el
+++ b/misc/ruby-electric.el
@@ -10,7 +10,7 @@
;; 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 @@
(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."
(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))