Skip to content

Commit 9955bb0

Browse files
committed
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
1 parent 347d44c commit 9955bb0

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Fri Apr 24 23:48:45 2015 Akinori MUSHA <[email protected]>
2+
3+
* misc/ruby-electric.el: Import version 2.2.3 from
4+
https://github.com/knu/ruby-electric.el.
5+
16
Fri Apr 24 10:40:02 2015 NAKAMURA Usaku <[email protected]>
27

38
* win32/win32.c (rb_w32_{getc,putc}): removed. they are needed for old

misc/ruby-electric.el

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
;; URL: https://github.com/knu/ruby-electric.el
1111
;; Keywords: languages ruby
1212
;; License: The same license terms as Ruby
13-
;; Version: 2.2.2
13+
;; Version: 2.2.3
1414

1515
;;; Commentary:
1616
;;
@@ -33,6 +33,9 @@
3333

3434
(require 'ruby-mode)
3535

36+
(eval-when-compile
37+
(require 'cl))
38+
3639
(defgroup ruby-electric nil
3740
"Minor mode providing electric editing commands for ruby files"
3841
:group 'ruby)
@@ -279,19 +282,31 @@ enabled."
279282
(t
280283
(ruby-electric-space/return-fallback))))
281284

282-
(defun ruby-electric-code-at-point-p()
285+
(defun ruby-electric--get-faces-at-point ()
286+
(let* ((point (point))
287+
(value (or
288+
(get-text-property point 'read-face-name)
289+
(get-text-property point 'face))))
290+
(if (listp value) value (list value))))
291+
292+
(defun ruby-electric--faces-at-point-include-p (&rest faces)
283293
(and ruby-electric-mode
284-
(let* ((properties (text-properties-at (point))))
285-
(and (null (memq 'font-lock-string-face properties))
286-
(null (memq 'font-lock-comment-face properties))))))
294+
(loop for face in faces
295+
with pfaces = (ruby-electric--get-faces-at-point)
296+
thereis (memq face pfaces))))
297+
298+
(defun ruby-electric-code-at-point-p()
299+
(not (ruby-electric--faces-at-point-include-p
300+
'font-lock-string-face
301+
'font-lock-comment-face)))
287302

288303
(defun ruby-electric-string-at-point-p()
289-
(and ruby-electric-mode
290-
(consp (memq 'font-lock-string-face (text-properties-at (point))))))
304+
(ruby-electric--faces-at-point-include-p
305+
'font-lock-string-face))
291306

292307
(defun ruby-electric-comment-at-point-p()
293-
(and ruby-electric-mode
294-
(consp (memq 'font-lock-comment-face (text-properties-at (point))))))
308+
(ruby-electric--faces-at-point-include-p
309+
'font-lock-comment-face))
295310

296311
(defun ruby-electric-escaped-p()
297312
(let ((f nil))

0 commit comments

Comments
 (0)