æå ã® init.el ãæ·¡ã ã¨ç´¹ä»ãã
Emacs Advent Calendar 2012ã®è¨äºã§ããæ¨æ¥ã¯ @syohex ããã®Emacsでポモドーロテクニック - Qiitaã§ããã
ãã¦ãä»åã¯æå
ã® init.el ã®ãã¿ãæ·¡ã
ã¨ç´¹ä»ãã¦ã¿ã¾ãã
ã¿ããªç¥ã£ã¦ããããã¨ãããã¿ã°ããã ã¨ã¯æãã¾ãããéã«çããã£ãããããã®ããããããããªãã®ã§ããããã§ããå½¹ã«ç«ã¦ãã°å¹¸ãã§ãã
æ§é å
ã¾ããè¨å®ãã¡ã¤ã«ã®æ§é åã§ããããããã試ããçµæ以ä¸ã®ãããªæãã§åãããã¨ã§å®çãã¾ããã
- init.el 以ä¸ã®ãã¡ã¤ã«ãèªã¿è¾¼ã¿
- base å¤é¨ã©ã¤ãã©ãªã«ä¾åããªãæ¨æºEmacsã®è¨å®
- frame GUIãªã©è¦ãç®å¨ãã®è¨å®
- utils 便å©ãã¼ã«ã®èªã¿è¾¼ã¿ãè¨å®
- modes å種modeã®èªã¿è¾¼ã¿ãè¨å®
- keybinds ã°ãã¼ãã«ãã¼ãã¤ã³ãã®è¨å®
- completions, e2wm, howm, org, wl, ... å種æ©è½ãã¨ã®å¤§ã¾ããªè¨å®
ã¡ã¤ã³ã®ç°å¢ãWindowsãLinuxãªã©ãè¡ã£ããæ¥ãããã¦ããã®ã§ã移è¡ã®æéããªãã¹ã楽ã«ãªãããã«ãã¦ãã¾ãã
base ã ãã¯OSããã¼ã¸ã§ã³ã«ãã¾ãä¾åããªãããã«ãã¦ããã¦ãæä½éã®åãã確ä¿ããä¸ã§ãä»ã®ãã¡ã¤ã«ããããã¦ããæãã§ãã
Emacsãåããã®ã¯ã¡ã¤ã³ã®ç°å¢ã ããªã®ã§ãç°å¢ãè¦ã¦åå²ãããã¨ã¯ãããªããªãã¾ããã(ã¡ã¤ã³ä»¥å¤ã¯Vimãå¤ãã§ããWindowsã ã¨sakuraã¨ãã)
ãã¼ãã¤ã³ãã®è¨å®ãä¸ç®æã§è¡ãããã«ãã¦ãã¾ããããã§ããã¼ãã¤ã³ãããã¶ã£ã¦ãã¾ã£ã¦ãã©ãã§è¨å®ãã¦ããã®ãè¿·ããªããªãå¿é ããªããªãã¾ããã
ãã®å½¢ã§å®å ¨ã«ç´å¾ãã¦ããããã§ã¯ãªãããã£ã¨ããæ¹æ³ã¯ãªãããªã¨æ¨¡ç´¢ãã¦ãã¾ãã
便å©ãã¼ã«è²ã
ãã®å ´ã®ãã¡ã¤ã«åãURLãéã ffap
ç´°ããã§ãããå¿ é ã§ãã
èªåç¹°ãè¿ã dmacro
ã©ãèãã¦ããã¼ãã¼ããã¯ãã®æ¹ãæ£ç¢ºã§ç¢ºå®ã ã£ããããã®ã§ããã
ã¡ãã£ã¨ãããã¯ãã¯ãã£ã¨ãã£ã¡ãå¤ç¨ãã¦ãã¾ãã
ãã£ã±ããã¢ã¼ãï¼ç¶æ ï¼ããç¡ãè¨è¨ãããã®ããããã¾ããã
ã¦ã¤ã³ãã¦åãæ¿ã elscreen
ãã®æã®ãã®ã§ããã°ã windows.el ã elscreen ã ã¨æãã¾ãããelscreenã使ã£ã¦ãã¾ãã
æ®éã ã¨ãããã¡ã®ãããã¼è¡ã«ã¿ãã表示ãããã®ã§ããããããã¼è¡ãå é ãã¦ã»ãããªãã®ã§ããã¬ã¼ã ã®ã¿ã¤ãã«ã«ä¸è¦§ã表示ããã¦ãã¾ãã以ä¸ãã®è¨å®ã³ã¼ãã§ãã
(defvar elscreen-my-title-maps '()) ; ã¿ã¤ãã«ã®å¤æããã (defun my-elscreen-truncate-screen-name (screen-name truncate-length &optional padding) (let ((truncate-length (max truncate-length 4))) (cond ((> (string-width screen-name) truncate-length) (concat (truncate-string-to-width screen-name truncate-length nil) "~")) (padding (truncate-string-to-width screen-name truncate-length nil ?\ )) (t screen-name)))) (defun elscreen-frame-title-update () (when (elscreen-screen-modified-p 'elscreen-frame-title-update) (let* ((screen-list (sort (elscreen-get-screen-list) '<)) (screen-to-name-alist (elscreen-get-screen-to-name-alist)) (tab-width (elscreen-e21-tab-width)) (title (mapconcat (lambda (screen) (format "%s" (let ((label (elscreen-e21-tab-escape-% (my-elscreen-truncate-screen-name (reduce (lambda (x f) (funcall f x)) elscreen-my-title-maps :initial-value (get-alist screen screen-to-name-alist)) tab-width t)))) (if (eq screen (elscreen-get-current-screen)) (concat "ã" label "ã") label)))) screen-list " "))) (if (fboundp 'set-frame-name) (set-frame-name title) (setq frame-title-format title))))) (eval-after-load "elscreen" '(add-hook 'elscreen-screen-update-hook 'elscreen-frame-title-update)) ;; elscreen-my-title-maps ã®ä½¿ãæ¹ä¾ (defun skype--elscreen-title-name-map (x) (if (string-match "Skype\\(Chat\\|Message\\):\\[\\(.*\\)\\]$" x) (let* ((title (match-string 2 x)) (buf (get-buffer x)) (missed (if buf (skype--chat-missed-p (buffer-local-value 'skype-chat-handle buf)) nil))) (concat (if missed "â " "â") title)) x)) (add-to-list 'elscreen-my-title-maps 'skype--elscreen-title-name-map)
ããã¾ãè¦ããã¨ãç¡ãã®ã§ããã¾ã«ç¢ºèªããããããªãããã§ååããªã¨ããæãã§ãã
C-w ã§åèªåé¤ã
ã·ã§ã«ã¨åæ§ã®æä½ã¯ããªãå¿«é©ã§ããã¾ãããã¨ãã¨ã®æ©è½ãç¡é§ã«ãªã£ã¦ãã¾ããã
(defun kill-region-or-backward-kill-word () (interactive) (if (region-active-p) (kill-region (point) (mark)) (backward-kill-word 1))) ; (global-set-key (kbd "C-w") 'kill-region-or-backward-kill-word)
ã¯ãªã¼ãã®åãæã
", ', ` ããã°ã«ãã¾ããRubyãJSã§ã¯ãªã¼ãå¤ãããã¨ãããããã®ã§ã
transpose-chars-or-swap-quotes ã C-t ã«å²ãå½ã¦ã¦ãã¾ãã
(defvar swap-quotes-list '((?\" ?\') (?\' ?\`) (?\` ?\"))) (defun transpose-chars-or-swap-quotes (arg) (interactive "p") (or (swap-quotes) (transpose-chars arg))) (defun swap-quotes () (interactive) (catch 'break (dolist (i swap-quotes-list) (let ((target-char (car i)) (replaced-char (cadr i)) (prev-pos (point))) (if (= (char-after (point)) target-char) (save-excursion (forward-char 1) (let ((next-pos (re-search-forward (char-to-string target-char)))) (if next-pos (subst-char-in-region prev-pos next-pos target-char replaced-char) (message "The corresponding quote is not found."))) (throw 'break t))))) nil))
ã¹ãã¼ã¹ãä¸æ°ã«åé¤
ã³ã¼ããã³ãããããè¡ãã¤ãªãããããã¨ãã¹ãã¼ã¹ã大éã«ä½ã¨ãããå¿ è¦ããã£ã¦ããããªæã«ãã使ã£ã¦ã¾ããã«ã¼ã½ã¼ã«ã®å ´æãã¹ãã¼ã¹æåãããã§ãªããã§åããå¤ããã¾ãã
kill-word-or-delete-horizontal-space ã M-d ã«å²ãå½ã¦ã¦ãã¾ãã
(defun kill-word-or-delete-horizontal-space (arg) (interactive "p") (let ((pos (point))) (if (and (not (eobp)) (= (char-syntax (char-after pos)) 32) (= (char-syntax (char-after (1+ pos))) 32)) (prog1 (delete-horizontal-space) (unless (memq (char-after pos) '(?( ?) ?{ ?} ?[ ?])) (insert " "))) (kill-word arg))))
let ã«ã¢ã¹ã¿ã¼ãå¾ã§ä»ãã
ã¢ã¹ã¿ã¼ãªãã¹ãä»ããªãã»ããããã®ããªã¨æã£ã¦ãã¦ãããããã¨å¾ã§å¿ è¦ã«ãªã£ãæã«ã«ã¼ã½ã¼ã«ã移åããã®ãé¢åãªã®ã§ããã使ã£ã¦ã¾ãã
æ¥æ¬èªéå¤æ
ééãã¦ç¢ºå®ãã¦éå¤æããããã¨ããã¾ã«ããã®ã§ãããIMã«ãã£ã¦ã¯ãµãã¼ããã¦ãªãã£ããããã®ã§Emacså ã§éå¤æãå®ç¾ããã¦ã¿ã¾ãããå½¢æ ç´ è§£æãªã©ã使ã£ã¦å¼·å¼ã«æ¼¢åãããã¼ãåã«å¤æãã¦ããã¼å ¥åã¨ãã¥ã¬ã¼ããã¦å¤æããã¾ãã
mozcã¨atokã¨anthyã¨ãã®é£æç¯å¤æãä»®å®ãã¦ãã¾ããMeCabãChaSenãå¿ è¦ã§ãã
ä¸ã¯IIIMECFã§ããããå®é¨ãã¦ãæã®åç»ã§ãããéå¤æã®åããããã¾ãã
js2-mode
moozããã®ã¨ããã®js2ã使ã£ã¦ãã¾ããæé«ã§ãã
JSã«ã¯æ±ºã¾ã£ãã¯ã©ã¹ã®æ¸ãæ¹ããã¾ããªãã¦ãåã¨ãã£ã¿ãæ¯æ´ãã¼ã«ã解æã«è¦å´ãã¦ããã¨ããã§ãã
js2ã§ãããããã¾ãèãã¦è¨è¨ãã¦ãããäºãã¡ã¸ã£ã¼ãªã¯ã©ã¹ã·ã¹ãã ã®ãã¿ã¼ã³ãç»é²ãã¦ããã®ã§ãããASTã®ãã¿ã¼ã³ã使ã£ã¦ç¬èªã®ã¯ã©ã¹ã·ã¹ãã ãç»é²ã§ããããã«ãªã£ã¦ãã¾ãã
ä¾ãã°ã以ä¸ã®ãããªãããã¿ã¤ãæåãªã¯ã©ã¹ã·ã¹ãã ããã£ãæã
// Class1ãã¯ãã¼ã³ãã¦ä¸æ¸ã var Class2 = clone(Class1, { method1: function() { ... }, field1: 123 });
以ä¸ã®ãããªã³ã¼ãã§ãã®ãã¿ã¼ã³ãç»é²ã§ãã¾ãã
(eval-after-load 'js2-mode '(progn (require 'js2-imenu-extras) (push `(:framework object-clone :call-re ,(concat "\\_<clone(" js2-mode-identifier-re "\\s-*,\\s-*") :recorder js2-imenu-record-object-clone-extend) js2-imenu-extension-styles) (js2-imenu-extras-setup))) (defun js2-imenu-record-object-clone-extend () (let* ((node (js2-node-at-point (1- (point))))) (when (js2-call-node-p node) (let* ((args (js2-call-node-args node)) (methods (second args)) (super-class (first args)) (parent (js2-node-parent node))) (when (js2-object-node-p methods) (let ((subject (cond ((js2-var-init-node-p parent) (js2-var-init-node-target parent)) ((js2-assign-node-p parent) (js2-assign-node-left parent))))) (when subject (js2-record-object-literal methods (js2-compute-nested-prop-get subject) (js2-node-abs-pos methods)))))))))
å¤å°èªèã®çãã¨ãããããã®ã§ãããã ããããã¾ããã£ã¦ãã¾ãã
Mochikitã¨ãEXT.jsãªã©ã®ã¯ã©ã¹ã·ã¹ãã ã¨ãã§ãããã¾ãèªèããããã¨ãã§ãããã§ãã
smartchr ã§PHPã®é »åºæåãå ¥å
ãããªã®ãå¤ç¨ããã®ãã©ããã¨ã¯æãã¾ãããããããä»äºãå¤ãã®ã§ã以ä¸ã®ãããªæãã§ä½¿ã£ã¦ãã¾ãã
(eval-after-load "php-mode" '(progn (define-key php-mode-map (kbd "F") (smartchr '("F" "$" "$this->"))) (define-key php-mode-map (kbd ">") (smartchr '(">" " => "))) (define-key php-mode-map (kbd "?") (smartchr '("?" "<?php `!!' ?>" "<?php echo `!!' ?>"))) (define-key php-mode-map (kbd "a") (smartchr '("a" "array(`!!')"))) (define-key php-mode-map (kbd "[") (smartchr '("[" "[`!!']" "[\'`!!'\']"))) )) (eval-after-load "sgml-mode" '(progn (define-key sgml-mode-map (kbd "\"") (smartchr '("\"" "\"`!!'\"" ""`!!'"))) (define-key sgml-mode-map (kbd ">") (smartchr '(">" ">"))) (define-key html-mode-map (kbd "=") (smartchr '("=" "<%= `!!' %>"))) (define-key html-mode-map (kbd "%") (smartchr '("%" "<% `!!' %>"))) ))
smartchr ã«ããã yasnippet ã«ãããã¯ãæ©ã¿ã©ããã§ãã
ãã¼å ¥åæ°ã¨è¨ãããã¯ããªãºã ã¨ãæ°æã¡ããã®åé¡ãªã®ããªã¨æã£ã¦ãã¾ãã
以ä¸ã§ãã
ææ¥ï¼ããã¾ãããä»æ¥ã§ãããããï¼ã¯ id:uhiaha888 ããã§ãããããããé¡ããããã¾ãã