ruby-changes:41321
From: nobu <ko1@a...>
Date: Thu, 31 Dec 2015 10:38:37 +0900 (JST)
Subject: [ruby-changes:41321] nobu:r53393 (trunk): ruby-additional.el: escape control code
nobu 2015-12-31 10:38:28 +0900 (Thu, 31 Dec 2015) New Revision: 53393 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53393 Log: ruby-additional.el: escape control code * misc/ruby-additional.el (ruby-encode-unicode): escape control code except for LF. Modified files: trunk/misc/ruby-additional.el Index: misc/ruby-additional.el =================================================================== --- misc/ruby-additional.el (revision 53392) +++ misc/ruby-additional.el (revision 53393) @@ -114,11 +114,23 @@ Emacs to Ruby." https://github.com/ruby/ruby/blob/trunk/misc/ruby-additional.el#L114 (setq end (set-marker (make-marker) end)) (goto-char beg) (while (and (< (point) end) - (re-search-forward "[^\C-@-~]+" end t)) - (let ((u (mapconcat (lambda (c) (format "%x" c)) (match-string-no-properties 0) " "))) + (re-search-forward "\\([\C-@-\C-I\C-K\C-_\C-?]+\\)\\|[^\C-@-\C-?]+" end t)) + (let ((str (match-string-no-properties 0)) sep b e f) + (if (match-beginning 1) + (setq b "" e "" sep "" + f (lambda (c) + (cond ((= c ?\t) "\\t") + ((= c ?\r) "\\r") + ((= c ?\e) "\\e") + ((= c ?\f) "\\f") + ((= c ?\b) "\\b") + ((= c ?\v) "\\v") + ((= c ?\C-?) "\\c?") + ((concat "\\c" (char-to-string (logior c #x40))))))) + (setq b "\\u{" e "}" sep " " f (lambda (c) (format "%x" c)))) + (setq str (mapconcat f str sep)) (delete-region (match-beginning 0) (match-end 0)) - (insert "\\u{" u "}")) - )) + (insert b str e)))) )) ;; monkey-patching ruby-mode.el in Emacs 24, as r49872. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/