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

ruby-changes:28764

From: knu <ko1@a...>
Date: Sun, 19 May 2013 02:38:13 +0900 (JST)
Subject: [ruby-changes:28764] knu:r40816 (trunk): * misc/ruby-electric.el (ruby-electric-matching-char): Make

knu	2013-05-19 02:38:02 +0900 (Sun, 19 May 2013)

  New Revision: 40816

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

  Log:
    * misc/ruby-electric.el (ruby-electric-matching-char): Make
      electric quotes work again at the end of buffer.

  Modified files:
    trunk/ChangeLog
    trunk/misc/ruby-electric.el

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40815)
+++ ChangeLog	(revision 40816)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun May 19 02:27:21 2013  Akinori MUSHA  <knu@i...>
+
+	* misc/ruby-electric.el (ruby-electric-matching-char): Make
+	  electric quotes work again at the end of buffer.
+
 Sun May 19 01:39:50 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* configure.in (setjmp-type): check if setjmpex() is really available.
Index: misc/ruby-electric.el
===================================================================
--- misc/ruby-electric.el	(revision 40815)
+++ misc/ruby-electric.el	(revision 40816)
@@ -248,6 +248,17 @@ strings. Note that you must have Font Lo https://github.com/ruby/ruby/blob/trunk/misc/ruby-electric.el#L248
               (insert "{}")
               (backward-char 1))))))
 
+(defmacro ruby-electric-avoid-eob(&rest body)
+  `(if (eobp)
+       (save-excursion
+         (insert "\n")
+         (backward-char)
+         ,@body
+         (prog1
+             (ruby-electric-string-at-point-p)
+           (delete-char 1)))
+     ,@body))
+
 (defun ruby-electric-matching-char(arg)
   (interactive "P")
   (ruby-electric-insert
@@ -257,7 +268,9 @@ strings. Note that you must have Font Lo https://github.com/ruby/ruby/blob/trunk/misc/ruby-electric.el#L268
      (cond
       ((char-equal closing last-command-event)
        (if (and (not (ruby-electric-string-at-point-p))
-                (progn (redisplay) (ruby-electric-string-at-point-p)))
+                (ruby-electric-avoid-eob
+                 (redisplay)
+                 (ruby-electric-string-at-point-p)))
            (save-excursion (insert closing))
          (and (eq last-command 'ruby-electric-matching-char)
               (char-equal (following-char) closing) ;; repeated ' or "

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

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