Last active
November 13, 2015 04:58
-
-
Save uchidev/daa020be40b11529a156 to your computer and use it in GitHub Desktop.
emacs settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(custom-set-variables | |
;; custom-set-variables was added by Custom. | |
;; If you edit it by hand, you could mess it up, so be careful. | |
;; Your init file should contain only one such instance. | |
;; If there is more than one, they won't work right. | |
'(indent-tabs-mode nil) | |
'(mweb-submode-indent-offset 2) | |
'(mweb-tags | |
(quote | |
((php-mode "<\\?php\\|<\\? \\|<\\?=" "[ \\t]\\?>\\|^\\?>") | |
(js-mode "<script[^>]*>" "</script>") | |
(css-mode "<style +type=\"text/css\"[^>]*>" "</style>")))) | |
'(nxml-child-indent 4) | |
'(safe-local-variable-values (quote ((encoding . utf-8))))) | |
(custom-set-faces | |
;; custom-set-faces was added by Custom. | |
;; If you edit it by hand, you could mess it up, so be careful. | |
;; Your init file should contain only one such instance. | |
;; If there is more than one, they won't work right. | |
'(default ((t (:inherit nil :stipple nil :background "#f0f0f0" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 105 :width normal :foundry "outline" :family "MeiryoKe_Gothic")))) | |
'(bold ((t (:weight bold :family "MeiryoKe_Console")))) | |
'(buffer-menu-buffer ((t nil))) | |
'(comint-highlight-input ((t (:foreground "#3030C0")))) | |
'(comint-highlight-prompt ((t (:foreground "#707070" :weight bold)))) | |
'(dired-dir-face ((t (:foreground "#2020C0" :weight bold))) t) | |
'(dired-directory ((t (:inherit nil :foreground "#2020C0" :weight bold)))) | |
'(dired-marked ((t (:inherit error)))) | |
'(dired-warning ((t (:inherit error)))) | |
'(erb-delim-face ((t nil))) | |
'(erb-exec-delim-face ((t (:inherit erb-delim-face)))) | |
'(erb-face ((t nil))) | |
'(erb-out-delim-face ((t (:inherit erb-delim-face)))) | |
'(error ((t (:inherit bold :foreground "#c00" :weight bold)))) | |
'(escape-glyph ((t (:inherit bold :foreground "Grey" :weight bold)))) | |
'(eshell-ls-archive ((t nil))) | |
'(eshell-ls-backup ((t (:inherit dired-ignored)))) | |
'(eshell-ls-directory ((t (:inherit bold :foreground "#2020c0")))) | |
'(eshell-ls-executable ((t nil))) | |
'(eshell-prompt ((t (:inherit nil :foreground "#009000" :weight bold)))) | |
'(eww-form-submit ((t (:background "#808080" :foreground "white" :box (:line-width 2 :style released-button) :weight normal)))) | |
'(eww-form-text ((t (:background "#e0e0e0" :box 1)))) | |
'(fixed-pitch ((t (:inherit default)))) | |
'(font-lock-builtin-face ((t nil))) | |
'(font-lock-comment-delimiter-face ((t (:inherit font-lock-comment-face)))) | |
'(font-lock-comment-face ((t (:foreground "#4040c0")))) | |
'(font-lock-constant-face ((t nil))) | |
'(font-lock-doc-face ((t (:inherit font-lock-comment-face)))) | |
'(font-lock-function-name-face ((t (:inherit bold :foreground "#009000")))) | |
'(font-lock-keyword-face ((t (:inherit bold :foreground "#000080")))) | |
'(font-lock-regexp-grouping-backslash ((t (:foreground "chocolate3")))) | |
'(font-lock-regexp-grouping-construct ((t (:inherit font-lock-regexp-grouping-backslash)))) | |
'(font-lock-string-face ((t nil))) | |
'(font-lock-type-face ((t (:inherit bold :foreground "#000080")))) | |
'(font-lock-variable-name-face ((t (:foreground "black")))) | |
'(font-lock-warning-face ((t (:inherit bold :foreground "#c00000" :weight normal)))) | |
'(fringe ((t (:background "#f0f0f0")))) | |
'(lazy-highlight ((t (:background "LightSteelBlue1")))) | |
'(match ((t (:background "grey80")))) | |
'(mode-line-buffer-id ((t nil))) | |
'(mode-line-emphasis ((t nil))) | |
'(mode-line-inactive ((t (:inherit mode-line :background "grey85" :foreground "grey20" :box (:line-width -1 :color "grey85") :weight light)))) | |
'(nxml-attribute-local-name ((t (:inherit font-lock-function-name-face)))) | |
'(nxml-attribute-prefix ((t (:inherit nxml-attribute-local-name)))) | |
'(nxml-attribute-value ((t (:inherit font-lock-string-face)))) | |
'(nxml-cdata-section-content ((t (:inherit nxml-text)))) | |
'(nxml-comment-content ((t (:inherit font-lock-comment-face)))) | |
'(nxml-delimiter ((t (:foreground "#a0a0a0"))) t) | |
'(nxml-element-local-name ((t (:inherit font-lock-function-name-face)))) | |
'(nxml-name ((t (:inherit font-lock-function-name-face)))) | |
'(nxml-processing-instruction-target ((t (:inherit nxml-attribute-local-name)))) | |
'(nxml-prolog-keyword ((t (:inherit font-lock-keyword-face)))) | |
'(nxml-ref ((t (:inherit ##)))) | |
'(nxml-text ((t nil)) t) | |
'(region ((t (:background "SystemMenuHilight" :foreground "white")))) | |
'(sh-escaped-newline ((t (:inherit font-lock-string-face)))) | |
'(sh-quoted-exec ((t (:inherit bold :foreground "#960096")))) | |
'(show-paren-match ((t (:underline t)))) | |
'(slime-repl-input-face ((t (:foreground "#707070" :weight bold)))) | |
'(slime-repl-output-face ((t nil))) | |
'(slime-repl-prompt-face ((t (:inherit slime-repl-input-face :weight bold)))) | |
'(trailing-whitespace ((t (:foreground "#4a4" :inverse-video t))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; -*- mode: emacs-lisp; coding: utf-8 -*- | |
(global-set-key "\^\\" 'help-command) | |
(global-set-key "\^\\\^\\" 'help-for-help) | |
(global-set-key "\^z" 'scroll-down) | |
(global-set-key "\^u" 'undo) | |
(global-set-key "\^xq" 'what-line) | |
(global-set-key "\^xg" 'goto-line) | |
(global-set-key "\^xz" 'suspend-emacs) | |
(keyboard-translate ?\177 ?\^h) | |
(keyboard-translate ?\^h ?\177) | |
;; ファイルのコンプリートをタブだけでなくスペースでも可能にする。 | |
(when (boundp 'minibuffer-local-filename-completion-map) | |
(define-key minibuffer-local-filename-completion-map " " 'minibuffer-complete-word) | |
(define-key minibuffer-local-must-match-filename-map " " 'minibuffer-complete-word)) | |
;; リージョンをハイライトしない。 | |
(when (boundp 'transient-mark-mode) (setq transient-mark-mode nil)) | |
;; バッファの最後尾での下移動で改行を挿入。 | |
(when (boundp 'next-line-add-newlines) (setq next-line-add-newlines t)) | |
(setq cursor-type 'box) | |
(line-number-mode -1) | |
(blink-cursor-mode -1) | |
(cond (window-system (scroll-bar-mode -1) | |
(tooltip-mode -1) | |
(tool-bar-mode -1)) | |
((not window-system) (menu-bar-mode -1))) | |
;; ---- Windows関連判定関数 | |
(defun windows-ime-p () | |
(and (eq system-type 'windows-nt)(eq window-system 'w32)(featurep 'w32-ime))) | |
(defun windows-gnupack-p () | |
(and (eq system-type 'windows-nt)(equal (car (split-string system-configuration "-")) "i386"))) | |
(defun windows-nt64build-p () | |
(and (eq system-type 'windows-nt)(equal (car (split-string system-configuration "-")) "x86_64"))) | |
;; ---- NTEmacs IME設定 | |
(when (windows-ime-p) | |
(setq default-input-method "W32-IME") | |
(setq-default w32-ime-mode-line-state-indicator "[Aa]") | |
(setq w32-ime-mode-line-state-indicator-list '("[Aa]" "[あ]" "[Aa]")) | |
;;(setq w32-ime-buffer-switch-p nil) | |
(w32-ime-initialize)) | |
;; ---- load-path拡張 | |
(mapc | |
#'(lambda (path) (when (file-directory-p (expand-file-name path)) | |
(add-to-list 'load-path (expand-file-name path)))) | |
'("~/.emacs.d/github/rhtml" | |
"~/.emacs.d/github/scss-mode" | |
"~/.emacs.d/misc")) | |
(load "~/.emacs.d/setup-japanese-coding.el") | |
;; 個人的文字コード関連設定 | |
(setq default-buffer-file-coding-system 'utf-8-unix) | |
;;(add-to-list 'file-coding-system-alist '("\\.txt\\'" utf-8-dos . utf-8-dos)) | |
(add-to-list 'file-coding-system-alist '("\\.el\\'" utf-8-unix . utf-8-unix)) | |
(add-to-list 'file-coding-system-alist '("\\.clj\\'" utf-8-unix . utf-8-unix)) | |
;; (set-face-attribute 'variable-pitch nil :family "*") | |
;; (setq w32-enable-synthesized-fonts t) | |
;; (create-fontset-from-ascii-font | |
;; "-outline-MeiryoKe_Gothic-normal-r-normal-normal-13-*-*-*-*-*-iso8859-1" nil "myfont") | |
;; (set-fontset-font "fontset-myfont" 'japanese-jisx0208 '("MeiryoKe_Gothic" . "jisx0208-sjis")) | |
;; (set-fontset-font "fontset-myfont" 'katakana-jisx0201 '("MeiryoKe_Gothic" . "jisx0201-katakana")) | |
;; (setcdr (assoc 'font default-frame-alist) "fontset-myfont") | |
(setq default-frame-alist | |
(append (list ;;'(font . "fontset-myfont") | |
'(foreground-color . "black") | |
'(background-color . "#f0f0f0") | |
;;'(alpha . 100) | |
'(top . 100) | |
'(left . 100) | |
'(width . 90) | |
'(height . 30)) | |
default-frame-alist)) | |
(setq default-truncate-lines t) | |
(global-set-key "\^[t" 'toggle-tab-width) | |
(global-set-key "\^[l" 'toggle-truncate-lines) | |
(require 'uniquify) | |
(setq uniquify-buffer-name-style 'post-forward-angle-brackets) | |
(setq uniquify-ignore-buffers-re "*[^*]+*") | |
(defun toggle-truncate-lines () | |
(interactive) | |
(cond | |
((eq truncate-lines t) (message "Not Truncate line") (setq truncate-lines nil)) | |
((eq truncate-lines nil) (message "Truncate line") (setq truncate-lines t)) ) | |
(redraw-display)) | |
(defun toggle-tab-width () | |
(interactive) | |
(cond | |
((eq tab-width 8) (message "Tab width is 4")(setq tab-width 4)) | |
((eq tab-width 4) (message "Tab width is 8")(setq tab-width 8)) | |
(t (message "Tab width is 8")(setq tab-width 8))) | |
(redraw-display)) | |
(defun tab-width-32 () | |
(interactive) | |
(message "Tab width is 32") | |
(setq tab-width 32) | |
(redraw-display)) | |
;; C-x m / C-x l / C-x n に個人的なもの設定。 | |
(global-set-key "\^xm" 'personal-transform-region) | |
(global-set-key "\^xl" 'special-set-mark) | |
(global-set-key "\^xn" 'personal-format-region) | |
;; personal-format | |
(defvar personal-format-history | |
(list "percentage-2" "percentage") | |
"The history of personal-format-region") | |
(defun personal-format-region (arg-str beg end) | |
"Personal format command" | |
(interactive | |
(let ((str (read-string | |
(format "Format command[%s]: " (car personal-format-history)) | |
nil 'personal-format-history))) | |
(list (if (string= str "") (car personal-format-history) str) | |
(region-beginning) (region-end)))) | |
(cond | |
((string-match "^percentage$" arg-str) | |
(personal-format-percentage-region beg end)) | |
((string-match "^percentage-2$" arg-str) | |
(personal-format-percentage-region-2 beg end)) | |
(t nil))) | |
(defun personal-format-percentage-region (beg end) | |
"Calculate percentages" | |
(save-excursion | |
(save-restriction | |
(narrow-to-region beg end) | |
(goto-char beg) | |
(let ((prev 0.0)) | |
(while (re-search-forward | |
"\\([0-9\\.]+\\|---\\)/\\([0-9\\.]+\\)[\t ]+\\([0-9\\.]+\\)%" | |
nil t) | |
(let* ((now (cond ((string-equal (match-string 1) "---") prev) | |
(t (setq prev (float (string-to-int (match-string 1))))))) | |
(total (float (string-to-int (match-string 2)))) | |
(percentage-str (format "%.3f" (* (/ now total) 100))) | |
(replace-beg (match-beginning 3)) | |
(replace-end (match-end 3))) | |
(delete-region replace-beg replace-end) | |
(goto-char replace-beg) | |
(insert-string percentage-str))))))) | |
(defun personal-format-percentage-region-2 (beg end) | |
(personal-format-percentage-region beg end) | |
(personal-format-tool-with-arg2 beg end | |
"Builder" "Connector" | |
#'(lambda (arg1 arg2) | |
(/ (- 100000 arg1) (- 25000 arg2)))) | |
(personal-format-tool-with-arg2 beg end | |
"Illuminator" "MController" | |
#'(lambda (arg1 arg2) | |
(/ (- 1000000 arg1) (- 10000 arg2))))) | |
;; tool for personal-format | |
(defun personal-format-tool-with-arg2 (beg end arg1-name arg2-name fn) | |
"tool for personal-format with 2 arg" | |
(save-excursion | |
(save-restriction | |
(narrow-to-region beg end) | |
(let* ((arg-get-fn #'(lambda (beg name) | |
(goto-char beg) | |
(when (re-search-forward (format "^%s[\t ]+\\([0-9\\.]+\\)" name) nil t) | |
(float (string-to-int (match-string 1)))))) | |
(arg1 (funcall arg-get-fn beg arg1-name)) | |
(arg2 (funcall arg-get-fn beg arg2-name)) | |
(value (and (numberp arg1) (numberp arg2) (funcall fn arg1 arg2)))) | |
(when value | |
(goto-char beg) | |
(when (re-search-forward (format "%s:%s=\\([0-9\\.]+\\)" arg1-name arg2-name) nil t) | |
(delete-region (match-beginning 1) (match-end 1)) | |
(goto-char (match-beginning 1)) | |
(insert-string (format "%.3f" value)))))))) | |
;; personal-transform | |
(defvar personal-transform-history | |
(list "codeblock" "pre,code" "hconv <>" "div id=\"\" class=\"\"" "hexstr") | |
"The history of personal-transform-region") | |
(defun personal-transform-region (arg-str beg end) | |
"Sets of the personal tools to transform specified the region" | |
(interactive | |
(let ((str (read-string | |
(format "Command[%s]: " (car personal-transform-history)) | |
nil 'personal-transform-history))) | |
(list (if (string= str "") (car personal-transform-history) str) | |
(region-beginning) (region-end)))) | |
(cond | |
;; hconv <> | |
((string-match "^hconv \s*\\([^\s]+\\)\s*$" arg-str) | |
(let ((s (match-string 1 arg-str))) | |
(personal-transform-region-html-special-char s beg end))) | |
;; hexstr | |
((string-match "^hexstr$" arg-str) | |
(personal-transform-region-to-hex-esc-str beg end)) | |
;; utfcode | |
((string-match "^utfcode$" arg-str) | |
(personal-transform-region-to-code beg end 'utf-8)) | |
;; ucscode | |
((string-match "^ucscode$" arg-str) | |
(personal-transform-region-to-code beg end 'utf-16be)) | |
;; codeblock | |
((string-match "^codeblock\s*$" arg-str) | |
(personal-transform-region-to-cblock-1 beg end)) | |
;; codeblock (java|js|c) | |
((string-match "^codeblock \s*\\([0-9A-Za-z_\-\+\/]+\\)\s*$" arg-str) | |
(let ((s (match-string 1 arg-str))) | |
(personal-transform-region-to-cblock-2 beg end s))) | |
;; pre,conv | |
;; div id="xxx" | |
;; h3 | |
;; ...... | |
(t (personal-transform-region-html-markup arg-str beg end)))) | |
(defun personal-transform-region-html-markup (tag-str beg end) | |
"Insert html markup tag." | |
;; (interactive "MTag: \nr") | |
;;(interactive | |
;; (let ((str (read-string | |
;; (format "Tag[%s]: " (car htmlmarkup-history)) nil 'htmlmarkup-history))) | |
;; (list (if (string= str "") (car htmlmarkup-history) str) | |
;; (region-beginning) (region-end)))) | |
(let ((tagstr-cons | |
(cond | |
;; pre,code <pre><code>...</code></pre> | |
((string-match "^\\([0-9A-Za-z]+\\),\\([0-9A-Za-z]+\\)$" tag-str) | |
(let ((s1 (match-string 1 tag-str)) | |
(s2 (match-string 2 tag-str))) | |
(cons (format "<%s><%s>" s1 s2)(format "</%s></%s>" s2 s1)))) | |
;; div id="xxxx" <div id="xxxx">...</div> | |
((string-match "^\\([0-9A-Za-z]+\\) .+$" tag-str) | |
(let ((s0 (match-string 0 tag-str)) | |
(s1 (match-string 1 tag-str))) | |
(cons (format "<%s>" s0)(format "</%s>" s1)))) | |
;; li <li>...</li> | |
((string-match "^\\([0-9A-Za-z]+\\)$" tag-str) | |
(let ((s1 (match-string 1 tag-str))) | |
(cons (format "<%s>" s1)(format "</%s>" s1)))) | |
;; %= <%= ... %> | |
;; % <% ... %> | |
((string-match "^%\\(.*\\)$" tag-str) | |
(let ((s1 (match-string 1 tag-str))) | |
(cons (format "<%%%s " s1) " %>"))) | |
;; no insert | |
(t (message (format "Unknown syntax: %s: %d %d" tag-str beg end)) | |
(cons "" ""))))) | |
(save-excursion | |
(goto-char end) | |
(insert-before-markers (cdr tagstr-cons)) | |
(goto-char beg) | |
(insert (car tagstr-cons))))) | |
(defun personal-transform-region-replace-tool (reg fn beg end) | |
"regは\\\\(..\\\\)による選択が一つかもしくは存在しない正規表現。 | |
存在しない場合は全体が、ある場合はその選択部分だけが、置き換え対象になる。 | |
fnは置き換え対象文字列を受け取り置き換え文字列を返す関数。 | |
nilを返した場合には置き換え無し。" | |
(save-excursion | |
(goto-char beg) | |
(while (re-search-forward reg end t) | |
(let* ((tgt-str (or (match-string 1) (match-string 0))) | |
(tgt-end (point)) | |
(tgt-len (length tgt-str)) | |
(rep-str (funcall fn tgt-str))) | |
(when rep-str | |
(backward-char tgt-len) | |
(insert rep-str) | |
(delete-char tgt-len) | |
(setq end (+ end (- (point) tgt-end)))))))) | |
(defun personal-transform-region-to-hex-esc-str (beg end) | |
"Transform from \\322 to \\xD2 on buffer" | |
(personal-transform-region-replace-tool | |
"\\\\\\([0-3][0-7][0-7]\\)" | |
#'(lambda (s) | |
(format "x%02X" (string-to-int s 8))) | |
beg end)) | |
(defun personal-transform-region-to-code (beg end cod) | |
"Transform from あ to あ(E3_81_82) or あ(30_42)" | |
(let* ((ustr (encode-coding-region beg end cod t)) | |
(outstr (mapconcat #'(lambda (x) (format "%02X" x)) ustr "_"))) | |
(save-excursion | |
(goto-char end) | |
(insert "(" outstr ")")))) | |
(defun personal-transform-region-to-cblock-1 (beg end) | |
"~~~~~~で囲む" | |
(personal-transform-region-to-cblock beg end "~~~~~~" "~~~~~~")) | |
(defun personal-transform-region-to-cblock-2 (beg end lang) | |
"```langで囲む" | |
(personal-transform-region-to-cblock beg end (concat "```" lang) "```")) | |
(defun personal-transform-region-to-cblock (beg end pre post) | |
"preとpostで囲む" | |
(save-excursion | |
(goto-char end) | |
(insert-before-markers | |
(concat | |
(if (not (bolp)) "\n") | |
post | |
(cond ((eobp) "\n") | |
((eolp) (save-excursion | |
(forward-char 1) | |
(when (not (or (eobp)(eolp))) "\n"))) | |
(t "\n\n")))) | |
(goto-char beg) | |
(insert | |
(concat | |
(cond ((bobp) nil) | |
((bolp) (save-excursion | |
(backward-char 1) | |
(when (not (or (bobp)(bolp))) "\n"))) | |
(t "\n\n")) | |
pre | |
"\n")))) | |
(defun personal-transform-region-html-special-char (strarg beg end) | |
"Transform some HTML special characteres." | |
(personal-transform-region-replace-tool | |
(regexp-opt (mapcar #'char-to-string strarg)) | |
#'(lambda (s) | |
(let ((t-db '(("&" . "&") | |
("<" . "<") | |
(">" . ">") | |
("\"" . """) | |
;;(" " . " ") | |
("'" . "'") | |
("\\" . "\") | |
("¥" . "¥")))) | |
(cond ((assoc s t-db) | |
(cdr (assoc s t-db))) | |
(t nil)))) | |
beg end)) | |
(defun special-set-mark () | |
(interactive) | |
(let ((beg-end-mes (or (save-excursion (special-set-mark-tag)) | |
(save-excursion (special-set-mark-notspace))))) | |
(if beg-end-mes | |
(progn | |
(goto-char (cadr beg-end-mes)) | |
(set-mark (point)) | |
(goto-char (car beg-end-mes)) | |
(message (cadr (cdr beg-end-mes))))))) | |
(defun special-set-mark-tag () | |
(let ((cur (point))) | |
(let ((beg | |
(or (if (string= | |
"<" (buffer-substring-no-properties (point) (+ 1 (point)))) | |
(point)) | |
(let ((beg-limit (save-excursion (beginning-of-line) (point)))) | |
(if (re-search-backward "<" beg-limit t) | |
(match-beginning 0)))))) | |
(if beg | |
(let ((end-limit (save-excursion (end-of-line) (point)))) | |
(let ((end (if (re-search-forward ">" end-limit t) | |
(match-end 0)))) | |
(if (and end (<= beg cur) (< cur end)) | |
(list beg end "mark tag")))))))) | |
(defun special-set-mark-notspace () | |
(beginning-of-line) | |
(let ((beg (progn | |
(re-search-forward "^[ \t]*" nil t) | |
(match-end 0))) | |
(end (progn | |
(re-search-forward "[ \t]*$" nil t) | |
(match-beginning 0)))) | |
(list beg end "mark region of space character"))) | |
(defun colorf-tx (s) | |
"\"#ffffff\" -> \"255,255,255\"" | |
(combine-and-quote-strings | |
(mapcar | |
#'(lambda (byte-str) (format "%d" (string-to-number byte-str 16))) | |
(let ((f3 #'(lambda (fx s n1 n2) | |
(cons (substring s 0 n1)(funcall fx n2 (substring s n1))))) | |
(f2 #'(lambda (n s) | |
(cond ((zerop (length s)) nil) | |
((<= (length s) n) (list s)) | |
(t (funcall f3 f2 s n n))))) | |
(f1 #'(lambda (n s) | |
(let ((v (mod (length s) n))) | |
(if (zerop v) (funcall f2 n s) (funcall f3 f2 s v n)))))) | |
(when (string-match "^#\\([0-9A-Fa-f]+\\)$" s) | |
(let ((ts (match-string 1 s))) | |
(if (> (length ts) 6) nil | |
(funcall f1 2 (match-string 1 s))))))) | |
",")) | |
(when (>= emacs-major-version 23) | |
(defvar phonetic-sign-acc-history | |
(mapcar #'(lambda (x) (decode-coding-string x 'utf-8)) | |
(list "\313\220" "\303\246" "\312\214" "\311\224" "\311\232" | |
"\311\231" "\312\222" "\312\203" "\303\260" "\311\265")) | |
"history of phonetic-sign-(n)acc.") | |
(defun phonetic-sign-i () | |
(let ((str (read-string | |
(format "char[%s]: " (car phonetic-sign-acc-history)) | |
nil 'phonetic-sign-acc-history))) | |
(list (if (string= str "") (car phonetic-sign-acc-history) str)))) | |
(defun phonetic-sign-acc (x) | |
(interactive (phonetic-sign-i)) | |
(insert (decode-coding-string (concat x "\314\201") 'utf-8))) | |
(defun phonetic-sign-nacc (x) | |
(interactive (phonetic-sign-i)) | |
(insert x))) | |
;; tramp | |
(setq tramp-persistency-file-name nil) | |
(setq tramp-default-method "sshx") | |
(require 'tramp) | |
;; eshellのプロンプト | |
(setq eshell-prompt-function | |
#'(lambda () | |
(concat "[" (car (last (split-string (abbreviate-file-name (eshell/pwd)) "/"))) "] " | |
(if (= (user-uid) 0) "# " "$ ")))) | |
;; ---- 拡張関係の設定をここに | |
(when (<= emacs-major-version 23) (load "~/.emacs.d/package.el")) | |
(when (>= emacs-major-version 24) (require 'package)) | |
(setq package-enable-at-startup nil) | |
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/") | |
("marmalade" . "http://marmalade-repo.org/packages/") | |
("melpa" . "http://melpa.milkbox.net/packages/"))) | |
(package-initialize) | |
(load "~/.emacs.d/setup-langmode.el") | |
(load "~/.emacs.d/setup-menu.el") | |
(when (memq t (mapcar #'(lambda (x) (eq (car x) 'slime)) package-alist)) | |
(load "~/.emacs.d/setup-slime-clojure.el")) | |
(when (eq system-type 'windows-nt) | |
(load "~/.emacs.d/setup-win.el")) | |
(cond ((eq system-type 'windows-nt) | |
(if (<= emacs-major-version 23) | |
(setq custom-file "~/.emacs.d/emacs-custom-23-nt.el") | |
(setq custom-file "~/.emacs.d/emacs-custom-24-nt.el"))) | |
(t (setq custom-file "~/.emacs.d/emacs-custom-23-unix.el"))) | |
(load custom-file) | |
(put 'narrow-to-region 'disabled nil) | |
;; VCモード無効化 | |
(setq vc-handled-backends ()) | |
(remove-hook 'find-file-hook 'vc-find-file-hook) | |
(remove-hook 'kill-buffer-hook 'vc-kill-buffer-hook) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; -*- mode: emacs-lisp -*- | |
(cond ((windows-gnupack-p)(require 'cp5022x)) | |
(t (load "~/.emacs.d/cp5022x.el"))) | |
(define-coding-system-alias 'euc-jp 'cp51932) | |
(coding-system-put 'euc-jp :decode-translation-table (get 'japanese-ucs-jis-to-cp932-map 'translation-table)) | |
(coding-system-put 'iso-2022-jp :decode-translation-table (get 'japanese-ucs-jis-to-cp932-map 'translation-table)) | |
(coding-system-put 'utf-8 :decode-translation-table (get 'japanese-ucs-jis-to-cp932-map 'translation-table)) | |
(coding-system-put 'euc-jp :encode-translation-table (get 'japanese-ucs-cp932-to-jis-map 'translation-table)) | |
(coding-system-put 'iso-2022-jp :encode-translation-table (get 'japanese-ucs-cp932-to-jis-map 'translation-table)) | |
(coding-system-put 'cp932 :encode-translation-table (get 'japanese-ucs-jis-to-cp932-map 'translation-table)) | |
(coding-system-put 'utf-8 :encode-translation-table (get 'japanese-ucs-jis-to-cp932-map 'translation-table)) | |
(set-charset-priority 'ascii 'japanese-jisx0208 'latin-jisx0201 'katakana-jisx0201 'iso-8859-1 'cp1252 'unicode) | |
(set-coding-system-priority 'utf-8 'euc-jp 'iso-2022-jp 'cp932) | |
;; East Asian Ambiguous | |
(defun set-east-asian-ambiguous-width (width) | |
(while (char-table-parent char-width-table) | |
(setq char-width-table (char-table-parent char-width-table))) | |
(let ((table (make-char-table nil))) | |
(dolist (range | |
'(#x00A1 #x00A4 (#x00A7 . #x00A8) #x00AA (#x00AD . #x00AE) | |
(#x00B0 . #x00B4) (#x00B6 . #x00BA) (#x00BC . #x00BF) | |
#x00C6 #x00D0 (#x00D7 . #x00D8) (#x00DE . #x00E1) #x00E6 | |
(#x00E8 . #x00EA) (#x00EC . #x00ED) #x00F0 | |
(#x00F2 . #x00F3) (#x00F7 . #x00FA) #x00FC #x00FE | |
#x0101 #x0111 #x0113 #x011B (#x0126 . #x0127) #x012B | |
(#x0131 . #x0133) #x0138 (#x013F . #x0142) #x0144 | |
(#x0148 . #x014B) #x014D (#x0152 . #x0153) | |
(#x0166 . #x0167) #x016B #x01CE #x01D0 #x01D2 #x01D4 | |
#x01D6 #x01D8 #x01DA #x01DC #x0251 #x0261 #x02C4 #x02C7 | |
(#x02C9 . #x02CB) #x02CD #x02D0 (#x02D8 . #x02DB) #x02DD | |
#x02DF (#x0300 . #x036F) (#x0391 . #x03A9) | |
(#x03B1 . #x03C1) (#x03C3 . #x03C9) #x0401 | |
(#x0410 . #x044F) #x0451 #x2010 (#x2013 . #x2016) | |
(#x2018 . #x2019) (#x201C . #x201D) (#x2020 . #x2022) | |
(#x2024 . #x2027) #x2030 (#x2032 . #x2033) #x2035 #x203B | |
#x203E #x2074 #x207F (#x2081 . #x2084) #x20AC #x2103 | |
#x2105 #x2109 #x2113 #x2116 (#x2121 . #x2122) #x2126 | |
#x212B (#x2153 . #x2154) (#x215B . #x215E) | |
(#x2160 . #x216B) (#x2170 . #x2179) (#x2190 . #x2199) | |
(#x21B8 . #x21B9) #x21D2 #x21D4 #x21E7 #x2200 | |
(#x2202 . #x2203) (#x2207 . #x2208) #x220B #x220F #x2211 | |
#x2215 #x221A (#x221D . #x2220) #x2223 #x2225 | |
(#x2227 . #x222C) #x222E (#x2234 . #x2237) | |
(#x223C . #x223D) #x2248 #x224C #x2252 (#x2260 . #x2261) | |
(#x2264 . #x2267) (#x226A . #x226B) (#x226E . #x226F) | |
(#x2282 . #x2283) (#x2286 . #x2287) #x2295 #x2299 #x22A5 | |
#x22BF #x2312 (#x2460 . #x24E9) (#x24EB . #x254B) | |
(#x2550 . #x2573) (#x2580 . #x258F) (#x2592 . #x2595) | |
(#x25A0 . #x25A1) (#x25A3 . #x25A9) (#x25B2 . #x25B3) | |
(#x25B6 . #x25B7) (#x25BC . #x25BD) (#x25C0 . #x25C1) | |
(#x25C6 . #x25C8) #x25CB (#x25CE . #x25D1) | |
(#x25E2 . #x25E5) #x25EF (#x2605 . #x2606) #x2609 | |
(#x260E . #x260F) (#x2614 . #x2615) #x261C #x261E #x2640 | |
#x2642 (#x2660 . #x2661) (#x2663 . #x2665) | |
(#x2667 . #x266A) (#x266C . #x266D) #x266F #x273D | |
(#x2776 . #x277F) (#xE000 . #xF8FF) (#xFE00 . #xFE0F) | |
#xFFFD | |
)) | |
(set-char-table-range table range width)) | |
(optimize-char-table table) | |
(set-char-table-parent table char-width-table) | |
(setq char-width-table table))) | |
(set-east-asian-ambiguous-width 2) | |
;; チルダ波線関連 | |
(let ((table (make-translation-table-from-alist '((#x301c . #xff5e))) )) | |
(mapc | |
(lambda (coding-system) | |
(coding-system-put coding-system :decode-translation-table table) | |
(coding-system-put coding-system :encode-translation-table table) | |
) | |
'(utf-8 cp932 utf-16le))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; -*- mode: emacs-lisp -*- | |
;; プログラム言語関係のメインモードの設定 | |
;; C モード | |
(setq c-auto-newline nil) | |
;; (load "cc-mode") | |
;; (load "cc-styles") | |
;; (add-hook | |
;; 'c-initialization-hook | |
;; '(lambda () | |
;; (setq c-style-alist | |
;; (cons | |
;; '("bsd-kai" | |
;; (c-basic-offset . 4) | |
;; (c-offsets-alist | |
;; (statement-block-intro . +) | |
;; (knr-argdecl-intro . 1) | |
;; (substatement-open . 0) | |
;; (label . 0) | |
;; (statement-cont . +)) | |
;; (c-comment-only-line-offset . 0)) | |
;; c-style-alist)))) | |
(add-hook 'c-mode-hook | |
'(lambda () | |
(setq tab-width 4) | |
(setq indent-tabs-mode nil))) | |
;;(setq c-file-style "bsd-kai"))) | |
(add-hook 'c++-mode-hook | |
'(lambda () | |
(setq tab-width 4) | |
(setq indent-tabs-mode nil))) | |
;;(setq c-file-style "bsd-kai"))) | |
;; (setq c-indent-level 4) | |
;; (setq c-argdecl-indent 1) | |
;; (setq c-brace-offset -4) | |
;; (setq c-continued-brace-offset -4) | |
;; (setq c-label-offset -4) | |
;; (setq c-continued-statement-offset 4) | |
;; Perl モード | |
;;( load "perl-mode.el" ) | |
;;(autoload 'perl-mode "perl-mode") | |
;;(setq auto-mode-alist (append (list (cons "\\.pl$" 'perl-mode)) | |
;; auto-mode-alist)) | |
(add-hook 'perl-mode-hook | |
'(lambda () | |
(setq indent-tabs-mode nil) | |
(setq tab-width 4))) | |
(setq perl-indent-level 2) | |
(setq perl-continued-statement-offset 2) | |
(setq perl-continued-brace-offset 0) | |
(setq perl-brace-offset -2) | |
(setq perl-imaginary-offset 0) | |
(setq perl-label-offset -2) | |
(add-hook 'javascript-mode-hook | |
'(lambda () | |
(setq tab-width 4) | |
(setq indent-tabs-mode nil))) | |
(add-hook 'emacs-lisp-mode-hook | |
'(lambda () | |
(setq tab-width 8) | |
(setq indent-tabs-mode nil))) | |
(setq css-indent-offset 2) | |
(add-hook 'css-mode-hook | |
'(lambda () | |
(setq tab-width 4) | |
(setq indent-tabs-mode nil))) | |
;; ruby-mode | |
(autoload 'ruby-mode "ruby-mode" "Mode for editing ruby source files" t) | |
;;(setq auto-mode-alist (append '(("\\.rb$" . ruby-mode)) auto-mode-alist)) | |
;;(setq interpreter-mode-alist (append '(("ruby" . ruby-mode)) interpreter-mode-alist)) | |
(autoload 'run-ruby "inf-ruby" "Run an inferior Ruby process") | |
(autoload 'inf-ruby-keys "inf-ruby" "Set local key defs for inf-ruby in ruby-mode") | |
(add-hook 'ruby-mode-hook | |
'(lambda () | |
;; ruby-deep-indent-paren-styleをnilにすることで、 | |
;; 括弧の中身が複数行にまたがる場合に、 | |
;; 次行を開き括弧のある行の開始位置を基準にインデントする。 | |
;; 括弧の中身が複数行に渡る場合に、開き括弧直後に改行するスタイルに向く。 | |
;; デフォルトは 'space で、開括弧直後に改行した場合は開き括弧のカラムに、 | |
;; 開き括弧直後に中身が続く場合にはその中身の開始カラムに、 | |
;; 次行の括弧の中身がインデントされる。 | |
(setq ruby-deep-indent-paren-style nil) | |
;; 以下のadviceは行頭に丸閉じ括弧が有る場合のインデントを補正する。 | |
;; 補正無しの場合、丸閉じ括弧は括弧の中身の開始カラムまでインデントする。 | |
;; 補正により、対応する開き括弧の存在する行の開始カラムまでのインデントになる。 | |
;; 角括弧はなぜか補正の必要が無い。 | |
(defadvice ruby-indent-line (after unindent-closing-paren activate) | |
(let ((column (current-column)) | |
indent offset) | |
(save-excursion | |
(back-to-indentation) | |
(let ((state (syntax-ppss))) | |
;; offsetはインデントを動かしたあとのカーソル位置を補正するために保存する。 | |
(setq offset (- column (current-column))) | |
(when (and (eq (char-after) ?\)) | |
(not (zerop (car state)))) | |
(goto-char (cadr state)) | |
(setq indent (current-indentation))))) | |
(when indent | |
(indent-line-to indent) | |
(when (> offset 0) (forward-char offset))))) | |
(require 'smart-compile) | |
(define-key ruby-mode-map (kbd "C-c c") 'smart-compile) | |
(define-key ruby-mode-map (kbd "C-c C-c") (kbd "C-c c C-m")) | |
(require 'rcodetools) | |
;; rcodetools.el ;; gem install rcodetools ;; ~/.gem/..../rcodetools-0.8.5.0/rcodetools.el | |
(define-key ruby-mode-map (kbd "C-c C-d") 'xmp) | |
(inf-ruby-keys))) | |
(setq ruby-program-name "ruby /usr/local/bin/irb --inf-ruby-mode") | |
;; ×ruby-debug19パッケージ | |
;; ○debuggerパッケージ | |
;; shell-modeでturn-on-rdebug-track-modeしてから、 | |
;; ruby xxx.rb とか rails server --debug する。 | |
;; スクリプトにはあらかじめ require 'ruby-debug'と debugger 呼び出しを追加しておく。 | |
;; Railsの場合には Gemfile に gem 'debugger' が必要で、require 'ruby-debug'は不要。 | |
(autoload 'turn-on-rdebug-track-mode "rdebug" "ruby-debugger-1.2.0 emacs interface" t) | |
;; ruby標準デバッガ | |
;; rubyがcygwinバージョンなので、f_rubyを利用する。M-x rubydbでデバッグするスクリプトを指定。 | |
(autoload 'rubydb "rubydb3x" "ruby debugger" t) | |
(setq rubydb-command-name "f_ruby") | |
;; Sinatra関連 | |
(add-to-list 'auto-mode-alist '("\\.ru$" . ruby-mode)) | |
;; ERBはRHTMLモード | |
(autoload 'rhtml-mode "rhtml-mode" "Mode for editing rhtml" t) | |
(add-to-list 'auto-mode-alist '("\\.erb$" . rhtml-mode)) | |
;; Python関連 | |
(when (eq system-type 'windows-nt) | |
(setq python-python-command "python2.6.exe") | |
(defadvice run-python (around run-python-fix-data-directory activate) | |
(let ((data-directory | |
(if (string-match "\\(^[a-zA-Z]\\):\\(.*\\)$" data-directory) | |
(concat "/" (match-string 1 data-directory) (match-string 2 data-directory)) | |
data-directory))) | |
ad-do-it))) | |
;; SCSS-mode | |
(autoload 'scss-mode "scss-mode") | |
(add-to-list 'auto-mode-alist '("\\.scss\\'" . scss-mode)) | |
(setq scss-compile-at-save nil) | |
(setq scss-sass-options '("--cache-location" "'/tmp/.sass-cache'")) | |
(setq scss-output-directory "/tmp/.sass-output") | |
(when (eq system-type 'windows-nt) | |
(defadvice scss-compile (around scss-compile-fix-buffer-file-name activate) | |
(let ((buffer-file-name (if (string-match "^d:\\(/home/.*\\)$" buffer-file-name) | |
(match-string 1 buffer-file-name) | |
buffer-file-name))) | |
ad-do-it))) | |
;; HTMLモード | |
(add-hook 'html-mode-hook | |
'(lambda () | |
(setq tab-width 4) | |
(setq indent-tabs-mode nil))) | |
;; PHPモード(multi-web-modeを介して使用する) | |
(autoload 'php-mode "php-mode" "Major mode for editing php code." t) | |
(add-to-list 'auto-mode-alist '("\\.php$" . php-mode)) | |
(add-to-list 'auto-mode-alist '("\\.inc$" . php-mode)) | |
;; マルチWEBモード | |
(require 'multi-web-mode) | |
(setq mweb-default-major-mode 'html-mode) | |
(setq mweb-tags '(;; (php-mode "<\\?php\\|<\\? \\|<\\?=""\\?>") | |
(php-mode "<\\?php\\|<\\? \\|<\\?=" "[ \\t]\\?>\\|^\\?>") | |
(js-mode "<script +\\(type=\"text/javascript\"\\|language=\"javascript\"\\)[^>]*>" "</script>") | |
(css-mode "<style +type=\"text/css\"[^>]*>" "</style>"))) | |
(setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5")) | |
(multi-web-global-mode 1) | |
;; Haskellモードのタブ操作の指定 | |
(add-hook 'haskell-mode-hook 'turn-on-haskell-simple-indent) | |
;; Javaモード | |
(add-hook 'java-mode-hook | |
'(lambda () | |
(setq tab-width 4) | |
(setq indent-tabs-mode nil))) | |
;; Gradle | |
(add-to-list 'auto-mode-alist '("\\.gradle$" . groovy-mode)) | |
(add-hook 'groovy-mode-hook | |
'(lambda () | |
(setq tab-width 4) | |
(setq c-basic-offset 4) | |
(setq indent-tabs-mode nil))) | |
;; elisp-slime-nav | |
(dolist (hook '(emacs-lisp-mode-hook ielm-mode-hook)) | |
(add-hook hook 'turn-on-elisp-slime-nav-mode)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; gnupack用。環境変数cdを解除する。 | |
(setenv "cd" nil) | |
;; gnupack添付のcygwin-mountを使用する。 | |
(when (windows-gnupack-p) | |
(require 'cygwin-mount) | |
(cygwin-mount-activate)) | |
;; gnupack画像ライブラリ関連 | |
(when (windows-gnupack-p) | |
(setq image-library-alist | |
'((xpm "libxpm.dll") | |
(png "libpng14-14.dll") | |
(jpeg "libjpeg.dll") | |
(tiff "libtiff3.dll") | |
(gif "giflib4.dll") | |
(svg "librsvg-2-2.dll") | |
(gdk-pixbuf "libgdk_pixbuf-2.0-0.dll") | |
(glib "libglib-2.0-0.dll") | |
(gobject "libgobject-2.0-0.dll")))) | |
(require 'shell) | |
;;(setq explicit-shell-file-name "bash.exe") | |
(setq explicit-shell-file-name "f_bash.exe") | |
(setq shell-command-switch "-c") | |
(setq shell-file-name "bash.exe") | |
(modify-coding-system-alist 'process ".*sh\\.exe" 'utf-8) | |
;;(modify-coding-system-alist 'process ".*sh\\.exe" 'cp932) | |
;; ^M をとる | |
(add-hook 'comint-output-filter-functions 'shell-strip-ctrl-m nil t) | |
;; shell-modeでの補完 (for drive letter) | |
(setq shell-file-name-chars "~/A-Za-z0-9_^$!#%&{}@'`.,;()-") | |
;; エスケープシーケンス処理の設定 | |
(autoload 'ansi-color-for-comint-mode-on "ansi-color" "Set `ansi-color-for-comint-mode' to t." t) | |
(setq shell-mode-hook | |
(lambda () | |
(set-buffer-process-coding-system 'utf-8-dos 'utf-8-unix) | |
(set-buffer-file-coding-system 'utf-8-unix) | |
;;(define-key shell-mode-map "\^a" 'comint-bol-or-process-mark) | |
;;(define-key shell-mode-map "\^c\^a" 'beginning-of-line) | |
(define-key shell-mode-map "\^c\^c" (lambda () | |
(interactive) | |
(process-send-string nil "\C-c"))) | |
(define-key shell-mode-map "\^c\^z" (lambda () | |
(interactive) | |
(process-send-string nil "\C-z"))))) | |
(setq w32-quote-process-args ?\") | |
(require 'arc-mode) | |
(defun archive-zip-extract (archive name) | |
(archive-extract-by-stdout | |
(shell-quote-argument archive) ;;archive | |
(shell-quote-argument name) ;;name | |
archive-zip-extract)) | |
;; プロセスの引数をprocess-coding-systemに関係なくcp932へ固定する。 | |
;;(defadvice call-process-region (before ad-call-process-region activate) | |
;; (when (ad-get-args 6) | |
;; (ad-set-args 6 (mapcar | |
;; (lambda (arg) | |
;; (if (multibyte-string-p arg) | |
;; (encode-coding-string arg 'cp932) | |
;; arg)) | |
;; (ad-get-args 6))))) | |
(defmacro encode-process-args-cp932 (func args-number) | |
`(defadvice ,func (before | |
,(intern (concat "ad-" (symbol-name func) "-args-encode-setup")) | |
activate) | |
(when (ad-get-args ,args-number) | |
(ad-set-args ,args-number | |
(mapcar (lambda (arg) | |
(if (multibyte-string-p arg) | |
(encode-coding-string arg 'cp932) | |
arg)) | |
(ad-get-args ,args-number)))))) | |
(encode-process-args-cp932 call-process-region 6) | |
(encode-process-args-cp932 call-process 4) | |
(encode-process-args-cp932 start-process 3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment