ããã.emacs
この動画ã®äººã®.emacs.
ããè¦ãæãã, ããããªã, ã©ããª.emacsãªãã ããã¨æ°ã«ãªã£ã¦ããã ãã©, å
¬éãã¦ãããã¿ãã.
ここã.
注ææ¸ãã§ã¯, ä¿®æ£ããªãã¨ãã®ã¾ã¾ã§ã¯åããªãã ããã£ã¦ãã¨ããã.
ã§ããã¦ã¾ã 軽ãããè¦ãªããã ãã©, Rubyé¢ä¿ã§ããã¯ãããã¨æã£ãã®ã3ã¤(ã¾ã ã¾ã ããããã ãã©, ç解ã追ãä»ããªã).
(add-to-list 'align-rules-list '(ruby-comma-delimiter (regexp . ",\\(\\s-*\\)[^# \t\n]") (repeat . t) (modes . '(ruby-mode)))) (add-to-list 'align-rules-list '(ruby-hash-literal (regexp . "\\(\\s-*\\)=>\\s-*[^# \t\n]") (repeat . t) (modes . '(ruby-mode))))
è¦ã¦ã®éã, ããã¤ã¯, alignã®è¨å®.
ã«ã³ãã¨ããã·ã¥ã«ã¤ãã¦ã¿ãã.
ããã¾ã試ãã¦ãªã.
å
ã«(require 'align)ãã¦ããå¿
è¦ããã.
ããã¤ãä¸çªããã£ã.
ruby-electric.elããã¼ããã¹ã®ããå ´æã«é
ç½®ã, å
ã«(require 'ruby-electric)ãã¦ããå¿
è¦ããã.
;; Hide-show (require 'hideshow) (add-to-list 'hs-special-modes-alist (list 'ruby-mode (concat "\\(^\\s-*" ruby-electric-simple-keywords-re "\\|{\\|\\[\\)") "end\\|\\]\\|}" "#" 'ruby-forward-sexp nil))
ããã¦, ãã®ãã¤ãã¼ã¢ã¼ãruby-electric-modeãèµ·åããã¨, 次ã®ãããªè£å®å
¥åãã§ããããã«ãªã.
forã¨ã¾ã§å
¥åãã¦, ã¹ãã¼ã¹ãå
¥ããã¨endãè£å®ãã¦ããã.
ãã¡ãã, whileã§ãclassã§ãunlessã§ãOK.
ruby-electric-modeã¯, brackets.elã¿ããã«æ¬å¼§ã¨ãã®è£å®ãããã¢ã¼ãã¿ããã ã(éå§æ¬å¼§ãå
¥åããã¨éæ¬å¼§ãæ¿å
¥ãã¦ãããã¢ã¼ã).
ã ãã, brackets.elã¨ã¯ã¡ãã£ã¨ç¸æ§ãè¯ããªã.
追è¨(0104)
åéãç¸è£.
whileã¨ãã§endãè£å®ãã¦ãããã®ã¯, åç´ã«ruby-electric-modeã®æ©è½.
ãã®è¨å®ã¯, hideshow. ã¤ã¾ã, ruby-modeã§hs-minor-modeã使ããããã«ãããã®.
hs-minor-modeããªã³ã®ç¶æ
ã§, classã¨ãã®ã¨ããã«ã«ã¼ã½ã«ãç½®ãã¦, C-c @ C-hã¨ãããã¨å¯¾å¿ããendã¾ã§ãé ããããã.
ããã¯ããã§ããªã便å©ãã.
ããã¦æå¾.
ããã¤ã¯ãã¹ãç¨ã®é¢æ°ã®è£å®å ¥åãªã®ããªã. 詳細ã¯åãããªã.
;; Snippets (snippet-with-abbrev-table 'ruby-mode-abbrev-table ("inj" . "$>inject($${[]}) do |$${memo}, $${item}|\n$>$.\nend$>") ("def" . "$>def $${method}($${*args})\n$>$.\nend$>") ("dt" . "$>def test_$${method}\n$>$.\nend$>"))
injã¾ã§å
¥åãã¦ã¿ããæ¼ãã¨, inject([]) do |memo, item| ...ã¨è£å®ãã¦ããã.
ä¸ã®def, dtãåæ§.
ã©ããã ãã, ruby-modeã§ã¯, brackets.elããã£ã¦ruby-electric-modeãæåããèµ·åããããã«ãã¨ãã.
ã¡ãã£ã¨ä»ã®è¨å®ãæ··ã£ã¦ã¦ç¶ºéºãããªããã©, ãããªã®æ¸ãã¨ãã°, OK.
;; æ¬å¼§ã¨ãã®èªåæ¿å ¥ (add-hook 'ruby-mode-hook '(lambda() (progn ;; comment-columnã®è¨å® (setq comment-column 39) ;; camelCase-mode (camelCase-mode t) ;; ruby-electric-mode (ruby-electric-mode t) ;; ri-emacsã®è¨å® (define-key ruby-mode-map [f1] 'ri) (define-key ruby-mode-map "\M-\C-i" 'ri-ruby-complete-symbol) (define-key ruby-mode-map [f4] 'ri-ruby-show-args) ;; C-m 㧠æ¹è¡ + ã¤ã³ãã³ã (define-key ruby-mode-map "\C-m" 'ruby-reindent-then-newline-and-indent) )))
è¦ã人ãè¦ãã°, ãã£ã¨é¢ç½ãè¨å®ããã£ã±ãããã¨æãã.
èªåã§ã¯ã¾ã ã¾ã ç解ã§ãã¾ãã.
ã¨, ãããã¨ã§ä¸åº¦ãã¦ã³ãã¼ããã¦ã¿ã¦ä¸ãè¦ã¦ã¿ããã¨ããªã¹ã¹ã¡ããã.
è¨å®ã¯, è¤æ°ãã¡ã¤ã«ã«åå²ããã¦ã¦è¦ãããã.