mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* misc/ruby-additional.el: Properly quote the body. An unquoted
body given to eval-after-load is evaluated immediately! git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43122 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a6ae6a8b17
commit
42b72a08d1
2 changed files with 96 additions and 91 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Thu Oct 3 00:17:15 2013 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
|
* misc/ruby-additional.el: Properly quote the body. An unquoted
|
||||||
|
body given to eval-after-load is evaluated immediately!
|
||||||
|
|
||||||
Wed Oct 2 21:38:30 2013 Yusuke Endoh <mame@tsg.ne.jp>
|
Wed Oct 2 21:38:30 2013 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
* ext/socket/ifaddr.c (rsock_getifaddrs): fix possible memory leak.
|
* ext/socket/ifaddr.c (rsock_getifaddrs): fix possible memory leak.
|
||||||
|
|
|
@ -1,100 +1,100 @@
|
||||||
;; missing functions in Emacs 24.
|
;; missing functions in Emacs 24.
|
||||||
|
|
||||||
(eval-after-load "\\(\\`\\|/\\)ruby-mode\\.elc?\\(\\.gz\\)?\\'"
|
(eval-after-load 'ruby-mode
|
||||||
(progn
|
'(progn
|
||||||
(define-key ruby-mode-map "\C-c\C-e" 'ruby-insert-end)
|
(define-key ruby-mode-map "\C-c\C-e" 'ruby-insert-end)
|
||||||
(define-key ruby-mode-map "\C-c{" 'ruby-toggle-block)
|
(define-key ruby-mode-map "\C-c{" 'ruby-toggle-block)
|
||||||
|
|
||||||
(defun ruby-insert-end ()
|
(defun ruby-insert-end ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(if (eq (char-syntax (char-before)) ?w)
|
(if (eq (char-syntax (char-before)) ?w)
|
||||||
(insert " "))
|
(insert " "))
|
||||||
(insert "end")
|
(insert "end")
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(if (eq (char-syntax (char-after)) ?w)
|
(if (eq (char-syntax (char-after)) ?w)
|
||||||
(insert " "))
|
(insert " "))
|
||||||
(ruby-indent-line t)
|
(ruby-indent-line t)
|
||||||
(end-of-line)))
|
(end-of-line)))
|
||||||
|
|
||||||
(defun ruby-brace-to-do-end ()
|
(defun ruby-brace-to-do-end ()
|
||||||
(when (looking-at "{")
|
(when (looking-at "{")
|
||||||
(let ((orig (point)) (end (progn (ruby-forward-sexp) (point))))
|
(let ((orig (point)) (end (progn (ruby-forward-sexp) (point))))
|
||||||
(when (eq (char-before) ?\})
|
(when (eq (char-before) ?\})
|
||||||
(delete-char -1)
|
(delete-char -1)
|
||||||
(if (eq (char-syntax (char-before)) ?w)
|
(if (eq (char-syntax (char-before)) ?w)
|
||||||
(insert " "))
|
(insert " "))
|
||||||
(insert "end")
|
(insert "end")
|
||||||
(if (eq (char-syntax (char-after)) ?w)
|
(if (eq (char-syntax (char-after)) ?w)
|
||||||
(insert " "))
|
(insert " "))
|
||||||
(goto-char orig)
|
(goto-char orig)
|
||||||
(delete-char 1)
|
(delete-char 1)
|
||||||
(if (eq (char-syntax (char-before)) ?w)
|
(if (eq (char-syntax (char-before)) ?w)
|
||||||
(insert " "))
|
(insert " "))
|
||||||
(insert "do")
|
(insert "do")
|
||||||
(when (looking-at "\\sw\\||")
|
(when (looking-at "\\sw\\||")
|
||||||
(insert " ")
|
(insert " ")
|
||||||
(backward-char))
|
(backward-char))
|
||||||
t))))
|
t))))
|
||||||
|
|
||||||
(defun ruby-do-end-to-brace ()
|
(defun ruby-do-end-to-brace ()
|
||||||
(when (and (or (bolp)
|
(when (and (or (bolp)
|
||||||
(not (memq (char-syntax (char-before)) '(?w ?_))))
|
(not (memq (char-syntax (char-before)) '(?w ?_))))
|
||||||
(looking-at "\\<do\\(\\s \\|$\\)"))
|
(looking-at "\\<do\\(\\s \\|$\\)"))
|
||||||
(let ((orig (point)) (end (progn (ruby-forward-sexp) (point))))
|
(let ((orig (point)) (end (progn (ruby-forward-sexp) (point))))
|
||||||
(backward-char 3)
|
(backward-char 3)
|
||||||
(when (looking-at ruby-block-end-re)
|
(when (looking-at ruby-block-end-re)
|
||||||
(delete-char 3)
|
(delete-char 3)
|
||||||
(insert "}")
|
(insert "}")
|
||||||
(goto-char orig)
|
(goto-char orig)
|
||||||
(delete-char 2)
|
(delete-char 2)
|
||||||
(insert "{")
|
(insert "{")
|
||||||
(if (looking-at "\\s +|")
|
(if (looking-at "\\s +|")
|
||||||
(delete-char (- (match-end 0) (match-beginning 0) 1)))
|
(delete-char (- (match-end 0) (match-beginning 0) 1)))
|
||||||
t))))
|
t))))
|
||||||
|
|
||||||
(defun ruby-toggle-block ()
|
(defun ruby-toggle-block ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(or (ruby-brace-to-do-end)
|
(or (ruby-brace-to-do-end)
|
||||||
(ruby-do-end-to-brace)))
|
(ruby-do-end-to-brace)))
|
||||||
|
|
||||||
(defun ruby-mode-set-encoding ()
|
(defun ruby-mode-set-encoding ()
|
||||||
"Insert a magic comment header with the proper encoding always.
|
"Insert a magic comment header with the proper encoding always.
|
||||||
Now encoding needs to be set always explicitly actually."
|
Now encoding needs to be set always explicitly actually."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(let ((coding-system))
|
(let ((coding-system))
|
||||||
(widen)
|
(widen)
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(if (re-search-forward "[^\0-\177]" nil t)
|
(if (re-search-forward "[^\0-\177]" nil t)
|
||||||
(progn
|
(progn
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(setq coding-system
|
(setq coding-system
|
||||||
(or coding-system-for-write
|
(or coding-system-for-write
|
||||||
buffer-file-coding-system))
|
buffer-file-coding-system))
|
||||||
(if coding-system
|
(if coding-system
|
||||||
(setq coding-system
|
(setq coding-system
|
||||||
(or (coding-system-get coding-system 'mime-charset)
|
(or (coding-system-get coding-system 'mime-charset)
|
||||||
(coding-system-change-eol-conversion coding-system nil))))
|
(coding-system-change-eol-conversion coding-system nil))))
|
||||||
(setq coding-system
|
(setq coding-system
|
||||||
(if coding-system
|
(if coding-system
|
||||||
(symbol-name
|
(symbol-name
|
||||||
(or (and ruby-use-encoding-map
|
(or (and ruby-use-encoding-map
|
||||||
(cdr (assq coding-system ruby-encoding-map)))
|
(cdr (assq coding-system ruby-encoding-map)))
|
||||||
coding-system))
|
coding-system))
|
||||||
"ascii-8bit")))
|
"ascii-8bit")))
|
||||||
(setq coding-system "us-ascii"))
|
(setq coding-system "us-ascii"))
|
||||||
(if (looking-at "^#!") (beginning-of-line 2))
|
(if (looking-at "^#!") (beginning-of-line 2))
|
||||||
(cond ((looking-at "\\s *#.*-\*-\\s *\\(en\\)?coding\\s *:\\s *\\([-a-z0-9_]*\\)\\s *\\(;\\|-\*-\\)")
|
(cond ((looking-at "\\s *#.*-\*-\\s *\\(en\\)?coding\\s *:\\s *\\([-a-z0-9_]*\\)\\s *\\(;\\|-\*-\\)")
|
||||||
(unless (string= (match-string 2) coding-system)
|
(unless (string= (match-string 2) coding-system)
|
||||||
(goto-char (match-beginning 2))
|
(goto-char (match-beginning 2))
|
||||||
(delete-region (point) (match-end 2))
|
(delete-region (point) (match-end 2))
|
||||||
(and (looking-at "-\*-")
|
(and (looking-at "-\*-")
|
||||||
(let ((n (skip-chars-backward " ")))
|
(let ((n (skip-chars-backward " ")))
|
||||||
(cond ((= n 0) (insert " ") (backward-char))
|
(cond ((= n 0) (insert " ") (backward-char))
|
||||||
((= n -1) (insert " "))
|
((= n -1) (insert " "))
|
||||||
((forward-char)))))
|
((forward-char)))))
|
||||||
(insert coding-system)))
|
(insert coding-system)))
|
||||||
((looking-at "\\s *#.*coding\\s *[:=]"))
|
((looking-at "\\s *#.*coding\\s *[:=]"))
|
||||||
(t (when ruby-insert-encoding-magic-comment
|
(t (when ruby-insert-encoding-magic-comment
|
||||||
(insert "# -*- coding: " coding-system " -*-\n")))))))
|
(insert "# -*- coding: " coding-system " -*-\n")))))))
|
||||||
|
|
||||||
))
|
))
|
||||||
|
|
Loading…
Add table
Reference in a new issue