diff --git a/ChangeLog b/ChangeLog index d8bc414359..e74fdecb45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Oct 7 22:52:16 2013 Akinori MUSHA + + * misc/ruby-additional.el: Use preceding-char/following-char + (returning 0 at BOF/EOF) instead of char-before/char-after + (returning nil at BOF/EOF) to avoid error from char-syntax when + at BOF/EOF. + Mon Oct 7 22:45:20 2013 Nobuyoshi Nakada * cont.c (FIBER_USE_NATIVE): split long conditions. diff --git a/misc/ruby-additional.el b/misc/ruby-additional.el index 6ef10944f2..85cfdd8d90 100644 --- a/misc/ruby-additional.el +++ b/misc/ruby-additional.el @@ -7,11 +7,11 @@ (defun ruby-insert-end () (interactive) - (if (eq (char-syntax (char-before)) ?w) + (if (eq (char-syntax (preceding-char)) ?w) (insert " ")) (insert "end") (save-excursion - (if (eq (char-syntax (char-after)) ?w) + (if (eq (char-syntax (following-char)) ?w) (insert " ")) (ruby-indent-line t) (end-of-line))) @@ -19,16 +19,16 @@ (defun ruby-brace-to-do-end () (when (looking-at "{") (let ((orig (point)) (end (progn (ruby-forward-sexp) (point)))) - (when (eq (char-before) ?\}) + (when (eq (preceding-char) ?\}) (delete-char -1) - (if (eq (char-syntax (char-before)) ?w) + (if (eq (char-syntax (preceding-char)) ?w) (insert " ")) (insert "end") - (if (eq (char-syntax (char-after)) ?w) + (if (eq (char-syntax (following-char)) ?w) (insert " ")) (goto-char orig) (delete-char 1) - (if (eq (char-syntax (char-before)) ?w) + (if (eq (char-syntax (preceding-char)) ?w) (insert " ")) (insert "do") (when (looking-at "\\sw\\||") @@ -38,7 +38,7 @@ (defun ruby-do-end-to-brace () (when (and (or (bolp) - (not (memq (char-syntax (char-before)) '(?w ?_)))) + (not (memq (char-syntax (preceding-char)) '(?w ?_)))) (looking-at "\\