summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-31 01:38:28 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-31 01:38:28 +0000
commit3e0f09dbe5c9017900668bb6d1a4715dae36f0c2 (patch)
tree651c33f6dc8e1ea7ad16a331915dbe099d8c07c0 /misc
parent34167345aca4d869b45de9d43a93d8a4956e0313 (diff)
ruby-additional.el: escape control code
* misc/ruby-additional.el (ruby-encode-unicode): escape control code except for LF. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'misc')
-rw-r--r--misc/ruby-additional.el20
1 files changed, 16 insertions, 4 deletions
diff --git a/misc/ruby-additional.el b/misc/ruby-additional.el
index e3f6a02f4d..2aa20cba38 100644
--- a/misc/ruby-additional.el
+++ b/misc/ruby-additional.el
@@ -114,11 +114,23 @@ Emacs to Ruby."
(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.