|
10 | 10 | ;; URL: https://github.com/knu/ruby-electric.el
|
11 | 11 | ;; Keywords: languages ruby
|
12 | 12 | ;; License: The same license terms as Ruby
|
13 |
| -;; Version: 2.2.2 |
| 13 | +;; Version: 2.2.3 |
14 | 14 |
|
15 | 15 | ;;; Commentary:
|
16 | 16 | ;;
|
|
33 | 33 |
|
34 | 34 | (require 'ruby-mode)
|
35 | 35 |
|
| 36 | +(eval-when-compile |
| 37 | + (require 'cl)) |
| 38 | + |
36 | 39 | (defgroup ruby-electric nil
|
37 | 40 | "Minor mode providing electric editing commands for ruby files"
|
38 | 41 | :group 'ruby)
|
@@ -279,19 +282,31 @@ enabled."
|
279 | 282 | (t
|
280 | 283 | (ruby-electric-space/return-fallback))))
|
281 | 284 |
|
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) |
283 | 293 | (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))) |
287 | 302 |
|
288 | 303 | (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)) |
291 | 306 |
|
292 | 307 | (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)) |
295 | 310 |
|
296 | 311 | (defun ruby-electric-escaped-p()
|
297 | 312 | (let ((f nil))
|
|
0 commit comments