You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 12 години
преди 13 години
преди 12 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 12 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 12 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
преди 13 години
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054
  1. ;; 外部ファイル読み込み
  2. ;; (load-file "~/filepath")
  3. ;; (thing-at-point 'word)
  4. ;; (define-generic-mode)
  5. (unless (file-directory-p (expand-file-name "~/.emacs.d"))
  6. (make-directory (expand-file-name "~/.emacs.d")))
  7. (unless (file-directory-p (expand-file-name "~/.emacs.d/lisp"))
  8. (make-directory (expand-file-name "~/.emacs.d/lisp")))
  9. (add-to-list 'load-path "~/.emacs.d/lisp")
  10. (require 'cl)
  11. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  12. ;; start and quit
  13. (setq inhibit-startup-message t)
  14. (setq frame-title-format (list '(:eval (my-format-time-string))
  15. " | %b "
  16. '(:eval (number-to-string (length (buffer-list-not-start-with-space))))
  17. " buffers ["
  18. invocation-name
  19. " "
  20. emacs-version
  21. " "
  22. (symbol-name system-type)
  23. "] "
  24. '(:eval (symbol-name last-command))))
  25. (defun buffer-list-not-start-with-space ()
  26. (let ((bl (buffer-list))
  27. b nbl)
  28. (while bl
  29. (setq b (pop bl))
  30. (unless (string-equal " "
  31. (substring (buffer-name b)
  32. 0
  33. 1))
  34. (add-to-list 'nbl b)))
  35. nbl))
  36. (setq confirm-kill-emacs 'y-or-n-p)
  37. (setq gc-cons-threshold (* 1024 1024 4))
  38. (when window-system
  39. (add-to-list 'default-frame-alist '(cursor-type . box))
  40. (add-to-list 'default-frame-alist '(background-color . "white"))
  41. (add-to-list 'default-frame-alist '(foreground-color . "gray10"))
  42. ;; (add-to-list 'default-frame-alist '(alpha . (80 100 100 100))) ;聞いてないみたい
  43. )
  44. (if window-system (menu-bar-mode 1) (menu-bar-mode 0))
  45. (tool-bar-mode 0)
  46. (set-scroll-bar-mode nil)
  47. (add-hook 'kill-emacs-hook ; 終了時に読み込んで壊れてないか調べる
  48. (lambda ()
  49. (when (file-readable-p "~/.emacs")
  50. (load-file "~/.emacs"))))
  51. (add-hook 'after-init-hook
  52. (lambda ()
  53. ;; (message "init time: %d msec"
  54. ;; (+ (* (- (nth 1 after-init-time) (nth 1 before-init-time)) 1000)
  55. ;; (/ (- (nth 2 after-init-time) (nth 2 before-init-time)) 1000)))
  56. (message (emacs-init-time))
  57. (switch-to-buffer "*Messages*")
  58. ))
  59. (cd ".") ; when using windows use / instead of \ in `default-directory'
  60. ;; locale
  61. (set-language-environment "Japanese")
  62. (set-default-coding-systems 'utf-8-unix)
  63. (prefer-coding-system 'utf-8-unix)
  64. (setq system-time-locale "C")
  65. (defvar my-prefix-map
  66. (make-sparse-keymap))
  67. (add-hook 'after-init-hook
  68. (lambda ()
  69. (define-key ctl-x-map (kbd "C-x") my-prefix-map)))
  70. (define-key my-prefix-map (kbd "C-q") 'quoted-insert)
  71. (define-key my-prefix-map (kbd "C-z") 'suspend-frame)
  72. ;; display
  73. (setq redisplay-dont-pause t)
  74. (setq visible-bell t)
  75. (setq ring-bell-function 'ignore)
  76. ;; (comint-show-maximum-output)
  77. ;; kill scratch
  78. (add-hook 'after-init-hook
  79. (lambda ()
  80. (kill-buffer "*scratch*")))
  81. (defun my-delete-frame-or-kill-emacs ()
  82. "delete frame when opening multiple frame, kill emacs when only one."
  83. (interactive)
  84. (if (eq 1
  85. (length (frame-list)))
  86. (save-buffers-kill-emacs)
  87. (delete-frame)))
  88. (global-set-key (kbd "C-x C-c") 'my-delete-frame-or-kill-emacs)
  89. (define-key my-prefix-map (kbd "C-x C-c") 'save-buffers-kill-emacs)
  90. ;; modifier keys
  91. (setq mac-option-modifier 'control)
  92. (setq w32-apps-modifier 'meta)
  93. ;; http://www.emacswiki.org/emacs/ChangingCursorDynamically
  94. ;; bufferの保存はなんで必要なんだろう?
  95. ;; Change cursor color according to mode
  96. (defvar hcz-set-cursor-color-color "")
  97. (defvar hcz-set-cursor-color-buffer "")
  98. (defun hcz-set-cursor-color-according-to-mode ()
  99. "change cursor color according to some minor modes."
  100. ;; set-cursor-color is somewhat costly, so we only call it when needed:
  101. (let ((color
  102. (if buffer-read-only "blue"
  103. (if overwrite-mode "yellow"
  104. "black"))))
  105. (unless (and
  106. (string= color hcz-set-cursor-color-color)
  107. (string= (buffer-name) hcz-set-cursor-color-buffer))
  108. (set-cursor-color (setq hcz-set-cursor-color-color color))
  109. (setq hcz-set-cursor-color-buffer (buffer-name)))))
  110. (add-hook 'post-command-hook 'hcz-set-cursor-color-according-to-mode)
  111. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  112. ;; minibuffer
  113. (setq insert-default-directory t)
  114. (setq completion-ignore-case t
  115. read-file-name-completion-ignore-case t
  116. read-buffer-completion-ignore-case t)
  117. (setq resize-mini-window t)
  118. (temp-buffer-resize-mode 1)
  119. (fset 'yes-or-no-p 'y-or-n-p)
  120. (define-key read-expression-map (kbd "TAB") 'lisp-complete-symbol) ; complete symbol when `eval'
  121. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  122. ;; editting
  123. (setq require-final-newline t)
  124. (setq kill-whole-line t)
  125. (setq scroll-conservatively 35
  126. scroll-margin 2
  127. scroll-step 0) ;4行ずつスクロール?
  128. (setq default-major-mode 'text-mode)
  129. (setq next-line-add-newlines nil)
  130. (setq kill-read-only-ok t)
  131. (setq truncate-partial-width-windows nil) ; when splitted horizontally
  132. ;; (setq-default line-spacing 0.2)
  133. (setq-default indicate-empty-lines t) ; なんだろうこれ
  134. (setq-default tab-width 4)
  135. (setq-default indent-tabs-mode nil)
  136. (pc-selection-mode 1)
  137. (delete-selection-mode 1)
  138. (cua-mode 0)
  139. ;; key bindings
  140. ;; moving around
  141. ;; (global-set-key (kbd "M-j") 'next-line)
  142. ;; (global-set-key (kbd "M-k") 'previous-line)
  143. ;; (global-set-key (kbd "M-h") 'backward-char)
  144. ;; (global-set-key (kbd "M-l") 'forward-char)
  145. ;;(keyboard-translate ?\M-j ?\C-j)
  146. (global-set-key (kbd "M-p") 'backward-paragraph)
  147. (global-set-key (kbd "M-n") 'forward-paragraph)
  148. (global-set-key (kbd "C-<up>") (lambda () (interactive)(scroll-down 1)))
  149. (global-set-key (kbd "C-<down>") (lambda () (interactive)(scroll-up 1)))
  150. (global-set-key (kbd "C-<left>") 'scroll-down)
  151. (global-set-key (kbd "C-<right>") 'scroll-up)
  152. (global-set-key (kbd "<select>") 'previous-line-mark)
  153. (define-key ctl-x-map (kbd "M-x") 'execute-extended-command)
  154. (define-key ctl-x-map (kbd "M-:") 'eval-expression)
  155. ;; C-h and DEL
  156. (global-set-key (kbd "C-h") (kbd "DEL"))
  157. ;; (global-set-key (kbd "C-h") 'backward-delete-char-untabify)
  158. ;; (global-set-key (kbd "DEL") help-map)
  159. ;; (global-set-key (kbd "C-h") (lambda ()
  160. ;; (interactive)
  161. ;; (call-interactively (key-binding (kbd "DEL")))))
  162. ;; (keyboard-translate ?\^h ?\^?) ; scimにはC-hを送りたい
  163. ;; (keyboard-translate ?\b ?\^h) ; dont translate backspace
  164. (global-set-key (kbd "C-m") 'reindent-then-newline-and-indent)
  165. (global-set-key (kbd "C-o")
  166. ;; (lambda ()
  167. ;; (interactive)
  168. ;; (move-end-of-line nil)
  169. ;; (newline-and-indent))
  170. (kbd "C-e C-m")
  171. )
  172. (global-set-key (kbd "C-k") 'kill-whole-line)
  173. (global-set-key (kbd "M-k") 'my-copy-whole-line)
  174. ;; (global-set-key "\C-z" 'undo) ; undo is C-/
  175. ;; (global-set-key (kbd "C-<return>") (lambda () (interactive) (insert "\f\n")))
  176. (global-set-key (kbd "M-u") 'undo)
  177. (global-set-key (kbd "C-r") 'query-replace-regexp)
  178. (global-set-key (kbd "C-s") 'isearch-forward-regexp)
  179. (global-set-key (kbd "M-i")
  180. (lambda ()
  181. (interactive)
  182. (call-interactively (key-binding (kbd "M-TAB"))))
  183. ;; (kbd "M-TAB")
  184. )
  185. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  186. ;; letters, font-lock mode and fonts
  187. ;; change color for border
  188. ;; (set-face-foreground (make-face 'vertical-border-face) "white")
  189. ;; (set-face-background 'vertical-border-face "black")
  190. ;; (defface vertical-border-face
  191. ;; `((((background dark))
  192. ;; (:background "white"))
  193. ;; (((background light))
  194. ;; (:background "black")))
  195. ;; "vertical border")
  196. ;; (set-display-table-slot standard-display-table 'vertical-border
  197. ;; (make-glyph-code #x3a 'vertical-border-face))
  198. ;; (set-face-foreground 'vertical-border "default")
  199. ;; (set-face-background 'vertical-border "white")
  200. (when (eq system-type 'Darwin)
  201. (mac-set-input-method-parameter 'japanese 'cursor-color "red")
  202. (mac-set-input-method-parameter 'roman 'cursor-color "black"))
  203. (when (and (boundp 'input-method-activate-hook) ;ちょっと正しいかわかんない
  204. (boundp 'input-method-inactivate-hook))
  205. (add-hook 'input-method-activate-hook
  206. (lambda () (set-cursor-color "red")))
  207. (add-hook 'input-method-inactivate-hook
  208. (lambda () (set-cursor-color "black"))))
  209. (show-paren-mode 1)
  210. (setq show-paren-style 'mixed)
  211. (transient-mark-mode 1)
  212. (global-font-lock-mode 1)
  213. (setq font-lock-global-modes
  214. '(not
  215. help-mode
  216. eshell-mode
  217. term-mode
  218. Man-mode))
  219. (standard-display-ascii ?\n "$\n")
  220. (copy-face 'default 'my-eol-face)
  221. (set-face-foreground 'my-eol-face "green")
  222. ;; (defface my-eol-face
  223. ;; '((t (:foreground "green")))
  224. ;; "eol.")
  225. (standard-display-ascii ?\f "---------------------------------------------------------------------------------------^L")
  226. (defface my-pagebreak-face
  227. '((t (:foreground "gray")))
  228. "pagebreak.")
  229. (defvar my-eol-face
  230. '(("\n" . (0 my-eol-face t nil)))
  231. )
  232. (defvar my-pagebreak-face
  233. '(("\f" . 'my-pagebreak-face)))
  234. (defvar my-highlight-face
  235. '(("\t" . '(0 highlight t nil))
  236. (" " . '(0 highlight t nil))))
  237. ;; (defvar my-face
  238. ;; '(("\t" . 'highlight)
  239. ;; (" " . 'highlight)
  240. ;; ("\n" . '(0 my-eol-face t nil))
  241. ;; ("\f" . 'my-pagebreak-face)))
  242. ;; 現在行をハイライト
  243. ;; http://wiki.riywo.com/index.php?Meadow
  244. (defface hlline-face
  245. '((((type x w32)
  246. (class color)
  247. (background dark))
  248. (:background "midnightblue")) ; :foreground "white")) ;; ハイライトの文字色は変えない方がいいかも
  249. (((type x w32)
  250. (class color)
  251. (background light))
  252. (:background "gainsboro"))
  253. (t
  254. (:underline "black")))
  255. "*Face used by hl-line.")
  256. ;; (defface hlline-ul-face
  257. ;; '((t (:underline "yellow")))
  258. ;; "underline yellow")
  259. (setq hl-line-face 'hlline-face) ;; (setq hl-line-face nil)
  260. (global-hl-line-mode 1) ;; (hl-line-mode 1)
  261. (setq hl-line-global-modes
  262. '(not
  263. term-mode))
  264. (add-hook 'font-lock-mode-hook
  265. (lambda ()
  266. ;; (font-lock-add-keywords nil my-eol-face)
  267. ;; (font-lock-add-keywords nil my-highlight-face)
  268. ))
  269. (set-face-foreground 'font-lock-regexp-grouping-backslash "#666")
  270. (set-face-foreground 'font-lock-regexp-grouping-construct "#f60")
  271. ;; fonts
  272. (defun my-set-ascii-and-jp-font-with-size (list)
  273. ""
  274. (set-face-attribute 'default nil
  275. :family (nth 0 list)
  276. :height (nth 1 list))
  277. (set-fontset-font "fontset-default"
  278. 'japanese-jisx0208
  279. (font-spec :family (nth 2 list) :size (nth 3 list)))
  280. (set-fontset-font "fontset-default"
  281. 'katakana-jisx0201
  282. (font-spec :family (nth 2 list) :size (nth 3 list)))) ; font spec is available in emacs23 and later, cannot used in emacs22
  283. ;; (my-set-ascii-and-jp-font-with-size '("dejavu sans mono" 90 "takaogothic" 13))
  284. ;; (my-set-ascii-and-jp-font-with-size '("dejavu sans mono" 100 "takaogothic" 14))
  285. ;; (my-set-ascii-and-jp-font-with-size '("dejavu sans mono" 100 "ms gothic" 14))
  286. ;; (my-set-ascii-and-jp-font-with-size '("monaco" 75 "takaogothic" 11))
  287. ;; (my-set-ascii-and-jp-font-with-size '("monaco" 90 "takaogothic" 13))
  288. ;; (my-set-ascii-and-jp-font-with-size '("ProggyCleanTTSZ" 120 "takaogothic" 11))
  289. ;; あ a
  290. emacs-major-version
  291. (defun my-22-set-ascii-and-jp-font-with-size (list)
  292. ""
  293. (set-face-attribute 'default nil
  294. :family (nth 0 list)
  295. :height (nth 1 list))
  296. (set-fontset-font "fontset-default"
  297. 'japanese-jisx0208
  298. (cons (nth 2 list) "jisx0208.*"))
  299. (set-fontset-font "fontset-default"
  300. 'katakana-jisx0201
  301. (cons (nth 2 list) "jisx0201.*")))
  302. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  303. ;; mode-line
  304. (setq eol-mnemonic-dos "crlf")
  305. (setq eol-mnemonic-mac "cr")
  306. (setq eol-mnemonic-unix "lf")
  307. (which-function-mode 0)
  308. (line-number-mode 0)
  309. (column-number-mode 0)
  310. (size-indication-mode 0)
  311. (setq mode-line-position
  312. '(:eval (format "L%%l/%d,C%%c"
  313. (count-lines (point-max)
  314. (point-min)))))
  315. ;; http://www.geocities.jp/simizu_daisuke/bunkei-meadow.html#frame-title
  316. ;; display date
  317. (add-hook 'after-init-hook
  318. (lambda ()
  319. (setq display-time-string-forms
  320. '(dayname ", " day " " monthname " " year " " 24-hours ":"minutes ":" seconds))
  321. (setq display-time-string-forms
  322. '((my-format-time-string)))
  323. (when display-time-mode
  324. (display-time-update))
  325. ))
  326. (setq display-time-interval 29)
  327. (setq display-time-day-and-date t)
  328. (if window-system
  329. (display-time-mode 0)
  330. (display-time-mode 1))
  331. ;; ;; current directory
  332. ;; (let ((ls (member 'mode-line-buffer-identification
  333. ;; mode-line-format)))
  334. ;; (setcdr ls
  335. ;; (cons '(:eval (concat " ("
  336. ;; (abbreviate-file-name default-directory)
  337. ;; ")"))
  338. ;; (cdr ls))))
  339. ;; ;; display last modified time
  340. ;; (let ((ls (member 'mode-line-buffer-identification
  341. ;; mode-line-format)))
  342. ;; (setcdr ls
  343. ;; (cons '(:eval (concat " "
  344. ;; my-buffer-file-last-modified-time))
  345. ;; (cdr ls))))
  346. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  347. ;; file handling
  348. ;; カーソルの場所を保存する
  349. (when (require 'saveplace nil t)
  350. (setq-default save-place t))
  351. ;; http://www.bookshelf.jp/soft/meadow_24.html#SEC260
  352. (setq make-backup-files t)
  353. ;; (make-directory (expand-file-name "~/.emacsbackup"))
  354. (setq backup-directory-alist
  355. (cons (cons "\\.*$" (expand-file-name "~/.emacs.d/backup"))
  356. backup-directory-alist))
  357. (setq version-control 'never)
  358. (setq delete-old-versions t)
  359. (setq auto-save-list-file-prefix (expand-file-name "~/.emacs.d/autosave/"))
  360. (setq delete-auto-save-files t)
  361. (add-to-list 'completion-ignored-extensions ".bak")
  362. ;; (setq delete-by-moving-to-trash t
  363. ;; trash-directory "~/.emacs.d/trash")
  364. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  365. ;; gmail
  366. (setq mail-interactive t
  367. send-mail-function 'smtpmail-send-it
  368. ;; message-send-mail-function 'smtpmail-send-it
  369. smtpmail-smtp-server "smtp.gmail.com"
  370. smtpmail-smtp-service 587
  371. smtpmail-starttls-credentials '(("smtp.gmail.com" 587 "8.slashes@gmail.com" nil))
  372. smtpmail-auth-credentials '(("smtp.gmail.com" 587 "8.slashes@gmail.com" nil))
  373. user-mail-address "8.slashes@gmail.com")
  374. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  375. ;; buffer killing
  376. (defun kill-buffer-by-major-mode (mode &optional exclude-current-buffer-p) ;mapcarとかつかって全部書き換える
  377. "kill buffers.
  378. if EXCLUDE-CURRENT-BUFFER-P is non-nil, never kill current buffer"
  379. (interactive "xmajor mode of buffer to kill: ")
  380. (save-excursion
  381. (let ((bflist (buffer-list))
  382. (cbf (current-buffer))
  383. bf)
  384. (while bflist
  385. (setq bf (pop bflist))
  386. (set-buffer bf)
  387. (if (and (eq mode major-mode) ;メジャーモードが一致し、かつ
  388. (not (and exclude-current-buffer-p ;今のバッファを除外、今のバッファと一致 がともには満たされない
  389. (eq bf cbf))))
  390. (kill-buffer bf))))))
  391. (defun my-kill-this-buffer-when-hide (&optional buffer all-frames)
  392. ""
  393. (interactive)
  394. (let ((bf (or buffer
  395. (current-buffer))))
  396. (if (or (not buffer) (get-buffer-window bf all-frames))
  397. (run-with-timer 3 nil 'my-kill-this-buffer-when-hide bf all-frames)
  398. (kill-buffer bf))))
  399. ;; (add-hook 'dired-mode-hook
  400. ;; 'my-kill-this-buffer-when-hide)
  401. (defvar my-kill-previous-buffer nil)
  402. (defun my-kill-previous-buffer ()
  403. ""
  404. (when my-kill-previous-buffer
  405. (kill-buffer my-kill-previous-buffer))
  406. (setq my-kill-previous-buffer (current-buffer)))
  407. ;; (add-hook 'dired-mode-hook
  408. ;; 'my-kill-previous-buffer)
  409. (defun my-query-kill-this-buffer ()
  410. ""
  411. (interactive)
  412. (if (y-or-n-p (concat "kill this buffer? :"))
  413. (kill-buffer (current-buffer))))
  414. (substitute-key-definition 'kill-buffer 'my-query-kill-this-buffer global-map)
  415. ;;(global-set-key "\C-xk" 'my-query-kill-this-buffer)
  416. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  417. ;; for emacsclient
  418. ;; (if window-system (server-start))
  419. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  420. ;; global keys
  421. (define-key my-prefix-map (kbd "C-f") 'make-frame-command)
  422. (define-key my-prefix-map (kbd "C-o") 'occur)
  423. (define-key my-prefix-map (kbd "C-s") 'my-execute-terminal)
  424. ;; (define-key my-prefix-map (kbd "C-h") help-map)
  425. (global-set-key (kbd "C-\\") help-map)
  426. (define-key ctl-x-map (kbd "DEL") help-map)
  427. (define-key ctl-x-map (kbd "C-h") help-map)
  428. (define-key help-map "a" 'apropos)
  429. ;; compose window
  430. (global-set-key [?\C--] 'other-window)
  431. (global-set-key [?\C-0] 'delete-window)
  432. (global-set-key [?\C-1] 'delete-other-windows)
  433. (global-set-key [?\C-2] 'split-window-vertically)
  434. (global-set-key [?\C-3] 'split-window-horizontally)
  435. ;; disable annoying keys
  436. (global-set-key [prior] 'ignore)
  437. (global-set-key (kbd "<next>") 'ignore)
  438. (global-set-key [menu] 'ignore)
  439. (global-set-key [down-mouse-1] 'ignore)
  440. (global-set-key [down-mouse-2] 'ignore)
  441. (global-set-key [down-mouse-3] 'ignore)
  442. (global-set-key [mouse-1] 'ignore)
  443. (global-set-key [mouse-2] 'ignore)
  444. (global-set-key [mouse-3] 'ignore)
  445. (global-set-key (kbd "<eisu-toggle>") 'ignore)
  446. (global-set-key (kbd "C-<eisu-toggle>") 'ignore)
  447. (mouse-avoidance-mode 'banish)
  448. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  449. ;; download library from web
  450. ;; (require 'url)
  451. ;; (defun dllib-if-needed (lib url &optional callback bite-compile-p force-download-p) ; dont use it
  452. ;; "if LIB does not exist, download it from URL and rename to \"~/emacs.d/lisp/LIB.el\".
  453. ;; after download LIB successfully call CALLBACK. if LIB already exist, call CALLBACK immediately."
  454. ;; (let* ((dir (expand-file-name "~/.emacs.d/lisp/"))
  455. ;; (lpath (concat dir lib ".el")))
  456. ;; (and (if (or force-download-p (not (locate-library lib)))
  457. ;; (condition-case nil
  458. ;; (progn (url-copy-file url
  459. ;; lpath
  460. ;; t)
  461. ;; (and bite-compile-p
  462. ;; (byte-compile-file lpath)
  463. ;; t))
  464. ;; (error (message "downloading %s...something wrong happened!" url)
  465. ;; nil))
  466. ;; t)
  467. ;; callback
  468. ;; (funcall callback))))
  469. (defun dllib-if-unfound (lib url &optional bite-compile-p force-download-p) ; new version
  470. "if LIB does not exist, download it from URL and locate it to \"~/emacs.d/lisp/LIB.el\".
  471. return nil if LIB unfound and downloading failed, otherwise the path of LIB."
  472. (let* ((dir (expand-file-name "~/.emacs.d/lisp/"))
  473. (lpath (concat dir lib ".el"))
  474. (locate-p (locate-library lib)))
  475. (if (or force-download-p (not locate-p))
  476. (progn (condition-case nil
  477. (progn (message "downloading %s..." url)
  478. (url-copy-file url
  479. lpath
  480. t)
  481. (when bite-compile-p
  482. (byte-compile-file lpath)))
  483. (error (message "downloading %s...something wrong happened!" url)
  484. nil))
  485. (locate-library lib))
  486. locate-p)))
  487. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  488. ;;requireが必要なelispおよびhook
  489. (require 'simple nil t)
  490. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  491. ;; share clipboard with x
  492. (when (and window-system
  493. ;; (getenv "DESKTOP_SESSION")
  494. (not (eq window-system 'mac))
  495. )
  496. (setq x-select-enable-clipboard t ; these settings seems to be useless when using emacs in terminal
  497. x-select-enable-primary nil)
  498. (global-set-key "\C-y" 'x-clipboard-yank))
  499. ;; urlに細かい説明あり。でも設定は上記だけでよさそう
  500. ;; http://garin.jp/doc/Linux/xwindow_clipboard
  501. (and (not x-select-enable-clipboard)
  502. (executable-find "xclip")
  503. (dllib-if-unfound "xclip" "http://www.emacswiki.org/emacs/download/xclip.el" t)
  504. (require 'xclip nil t)
  505. (turn-on-xclip))
  506. ;; その他のhook
  507. (add-hook 'after-save-hook
  508. 'executable-make-buffer-file-executable-if-script-p)
  509. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  510. ;; mode関連
  511. (add-hook 'verilog-mode-hook
  512. (lambda ()
  513. (define-key verilog-mode-map ";" 'self-insert-command)))
  514. (setq diff-switches "-u")
  515. (add-hook 'diff-mode-hook
  516. (lambda ()
  517. (view-mode 1)
  518. (set-face-foreground 'diff-index-face "blue")
  519. (set-face-foreground 'diff-hunk-header-face "magenda")
  520. (set-face-foreground 'diff-removed-face "red")
  521. (set-face-foreground 'diff-added-face "blue")
  522. (set-face-foreground 'diff-changed-face "syan")
  523. ))
  524. ;; (ffap-bindings)
  525. (add-hook 'sh-mode-hook
  526. (lambda ()
  527. (define-key sh-mode-map (kbd "C-x C-e") 'my-execute-shell-command-current-line)))
  528. (defun my-execute-shell-command-current-line ()
  529. ""
  530. (interactive)
  531. (shell-command (buffer-substring-no-properties (point-at-bol)
  532. (point))))
  533. (add-hook 'inferior-python-mode-hook
  534. (lambda ()
  535. (define-key inferior-python-mode-map (kbd "<up>") 'comint-previous-input)
  536. (define-key inferior-python-mode-map (kbd "<down>") 'comint-next-input)))
  537. (add-to-list 'Info-default-directory-list (expand-file-name "~/.info/emacs-ja"))
  538. (setq bookmark-default-file "~/.emacs.d/bmk")
  539. (add-hook 'apropos-mode-hook
  540. (lambda ()
  541. (define-key apropos-mode-map "j" 'next-line)
  542. (define-key apropos-mode-map "k" 'previous-line)))
  543. (define-key minibuffer-local-map (kbd "C-u") (lambda () (interactive) (delete-region (point-at-bol) (point-at-eol))))
  544. (add-hook 'isearch-mode-hook
  545. (lambda ()
  546. ;; (define-key isearch-mode-map (kbd "C-j") 'isearch-other-control-char)
  547. ;; (define-key isearch-mode-map (kbd "C-k") 'isearch-other-control-char)
  548. ;; (define-key isearch-mode-map (kbd "C-h") 'isearch-other-control-char)
  549. (define-key isearch-mode-map (kbd "C-h") 'isearch-delete-char)
  550. (define-key isearch-mode-map (kbd "M-r") 'isearch-query-replace-regexp)))
  551. (add-hook 'outline-mode-hook
  552. (lambda ()
  553. (if (string-match "\\.md$" buffer-file-name)
  554. (set (make-local-variable 'outline-regexp) "#+ "))))
  555. (add-to-list 'auto-mode-alist (cons "\\.ol$" 'outline-mode))
  556. (add-to-list 'auto-mode-alist (cons "\\.md$" 'outline-mode))
  557. (when (dllib-if-unfound "markdown-mode"
  558. "http://jblevins.org/projects/markdown-mode/markdown-mode.el"
  559. t)
  560. (add-to-list 'auto-mode-alist (cons "\\.md$" 'markdown-mode))
  561. (autoload 'markdown-mode "markdown-mode" "Major mode for editing Markdown files." nil)
  562. (add-hook 'markdown-mode-hook
  563. (lambda ()
  564. (outline-minor-mode 1)
  565. (set (make-local-variable 'comment-start) ";"))))
  566. ;; (add-hook 'c-mode-hook
  567. ;; (lambda ()
  568. ;; (set (make-local-variable 'comment-start) "//")
  569. ;; (set (make-local-variable 'comment-end) "")))
  570. ;; http://d.hatena.ne.jp/emergent/20070203/1170512717
  571. ;; c-mode
  572. ;; (setq c-default-style "bsd")
  573. ;; BackSpace キーを「賢く」し,インデント幅は2桁,タブはスペースに展開
  574. (add-hook 'c-mode-common-hook
  575. (lambda ()
  576. (setq c-basic-offset 2
  577. indent-tabs-mode nil)
  578. ;; (set-face-foreground 'font-lock-keyword-face "blue")
  579. (c-toggle-hungry-state 1)
  580. ))
  581. (defun my-compile-c-this-file ()
  582. ""
  583. (interactive)
  584. (compile (format "gcc -Wall -g -o %s %s"
  585. (file-name-sans-extension buffer-file-name)
  586. buffer-file-name)))
  587. ;; (when (require 'c nil t)(c-toggle-hungry-state t)
  588. (when (dllib-if-unfound "js2-mode"
  589. "https://github.com/mooz/js2-mode/raw/master/js2-mode.el"
  590. t)
  591. (autoload 'js2-mode "js2-mode" nil t)
  592. (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode)))
  593. ;; (add-hook 'js2-mode-hook
  594. ;; (lambda ()
  595. ;; (add-hook 'before-save-hook
  596. ;; 'my-indent-buffer
  597. ;; nil
  598. ;; t)))
  599. (add-hook 'js2-mode-hook
  600. (lambda ()
  601. (define-key js2-mode-map (kbd "C-m") (lambda ()
  602. (interactive)
  603. (js2-enter-key)
  604. (indent-for-tab-command)))
  605. (add-hook (kill-local-variable 'before-save-hook)
  606. 'js2-before-save)))
  607. (and nil
  608. (require 'zone nil t)
  609. (not (eq system-type 'windows-nt))
  610. ;; (zone-when-idle 180)
  611. (run-with-idle-timer 180 t (lambda ()
  612. (unless (memq major-mode
  613. '(term-mode))
  614. (zone)))))
  615. (when (require 'uniquify nil t)
  616. (setq uniquify-buffer-name-style 'post-forward-angle-brackets)
  617. (setq uniquify-ignore-buffers-re "*[^*]+*")
  618. (setq uniquify-min-dir-content 1))
  619. (add-hook 'view-mode-hook
  620. (lambda()
  621. (define-key view-mode-map "j" (lambda() (interactive) (scroll-up 1)))
  622. (define-key view-mode-map "k" (lambda() (interactive) (scroll-down 1)))
  623. (define-key view-mode-map "/" 'isearch-forward)
  624. (define-key view-mode-map "v" 'toggle-read-only)
  625. (define-key view-mode-map "q" 'bury-buffer)))
  626. (global-set-key "\M-r" 'view-mode)
  627. (setq view-read-only t)
  628. ;; (add-hook 'find-file-hook
  629. ;; (lambda ()
  630. ;; (when buffer-read-only
  631. ;; (view-mode 1))))
  632. (add-hook 'Man-mode-hook
  633. (lambda ()
  634. (view-mode 1)
  635. (setq truncate-lines nil)))
  636. (setq Man-notify-method (if window-system
  637. 'newframe
  638. 'pushy))
  639. ;; (when (and (executable-find "git")
  640. ;; (require 'sgit-mode nil t))
  641. ;; (add-hook 'find-file-hook
  642. ;; 'sgit-load))
  643. (require 'session nil t)
  644. (when (require 'gtkbm nil t)
  645. (global-set-key (kbd "C-x C-d") 'gtkbm))
  646. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  647. ;; frame buffer
  648. ;; (add-hook 'after-make-frame-functions
  649. ;; (lambda (frame)
  650. ;; (recentf-open-files)))
  651. ;; (defvar aaa nil)
  652. ;; (plist-get aaa 'abc)
  653. ;; (setq aaa (plist-put aaa 'abc 'efg))
  654. (defvar my-frame-buffer-plist nil)
  655. ;; (setplist my-frame-buffer-plist nil)
  656. (defun my-frame-buffer-add ()
  657. ""
  658. (setq my-frame-buffer-plist
  659. (plist-put my-frame-buffer-plist
  660. (selected-frame)
  661. (let ((lst (my-frame-buffer-get)))
  662. (if lst
  663. (add-to-list 'lst
  664. (current-buffer))
  665. (list (current-buffer)))))))
  666. (defun my-frame-buffer-remove ()
  667. ""
  668. (setq my-frame-buffer-plist
  669. (plist-put my-frame-buffer-plist
  670. (selected-frame)
  671. (delq (current-buffer)
  672. (my-frame-buffer-get)))))
  673. (defun my-frame-buffer-get (&optional frame)
  674. ""
  675. (plist-get my-frame-buffer-plist
  676. (or frame
  677. (selected-frame))))
  678. (defun my-frame-buffer-get2 (&optional frame)
  679. ""
  680. (delq nil (mapcar (lambda (buf)
  681. (if (or t (buffer-file-name buf))
  682. buf
  683. nil))
  684. (cdr (assq 'buffer-list
  685. (frame-parameters (or frame
  686. (selected-frame))))))))
  687. (my-frame-buffer-get2)
  688. (defun my-frame-buffer-kill-all-buffer (frame)
  689. ""
  690. (mapcar 'kill-buffer
  691. (my-frame-buffer-get frame)))
  692. (add-hook 'find-file-hook
  693. 'my-frame-buffer-add)
  694. ;; (add-hook 'dired-mode-hook
  695. ;; 'my-frame-buffer-add)
  696. (add-hook 'kill-buffer-hook
  697. 'my-frame-buffer-remove)
  698. (add-hook 'delete-frame-functions
  699. 'my-frame-buffer-kill-all-buffer)
  700. (frame-parameters (selected-frame))
  701. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  702. ;; term mode
  703. ;; (setq multi-term-program shell-file-name)
  704. (and (dllib-if-unfound "multi-term"
  705. "http://www.emacswiki.org/emacs/download/multi-term.el"
  706. t)
  707. (require 'multi-term nil t)
  708. (setq multi-term-switch-after-close nil))
  709. ;; http://d.hatena.ne.jp/goinger/20100416/1271399150
  710. ;; (setq term-ansi-default-program shell-file-name)
  711. (add-hook 'term-setup-hook (lambda ()
  712. (setq term-display-table (make-display-table))))
  713. (add-hook 'term-mode-hook (lambda ()
  714. (unless (memq (current-buffer) (and (featurep 'multi-term) ; current buffer is not multi-term buffer
  715. (multi-term-list)))
  716. ;; (define-key term-raw-map "\C-q" 'move-beginning-of-line)
  717. ;; (define-key term-raw-map "\C-r" 'term-send-raw)
  718. ;; (define-key term-raw-map "\C-s" 'term-send-raw)
  719. ;; (define-key term-raw-map "\C-f" 'forward-char)
  720. ;; (define-key term-raw-map "\C-b" 'backward-char)
  721. ;; (define-key term-raw-map "\C-t" 'set-mark-command)
  722. (define-key term-raw-map "\C-x" (lookup-key (current-global-map) "\C-x"))
  723. (define-key term-raw-map "\C-z" (lookup-key (current-global-map) "\C-z")))
  724. (define-key term-raw-map (kbd "ESC") 'term-send-raw)
  725. (define-key term-raw-map [delete] 'term-send-raw)
  726. (define-key term-raw-map "\C-h" 'term-send-backspace)
  727. (define-key term-raw-map "\C-y" 'term-paste)
  728. (define-key term-raw-map "\C-c" 'term-send-raw) ;; 'term-interrupt-subjob)
  729. ;; (dolist (key '("<up>" "<down>" "<right>" "<left>"))
  730. ;; (define-key term-raw-map (kbd key) 'term-send-raw))
  731. ;; (define-key term-raw-map "\C-d" 'delete-char)
  732. (set (make-variable-buffer-local 'scroll-margin) 0)
  733. ;; (set (make-variable-buffer-local 'cua-enable-cua-keys) nil)
  734. ;; (cua-mode 0)
  735. ;; (and cua-mode
  736. ;; (local-unset-key (kbd "C-c")))
  737. ;; (define-key cua--prefix-override-keymap "\C-c" 'term-interrupt-subjob)
  738. ))
  739. ;; (add-hook 'term-exec-hook 'forward-char)
  740. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  741. ;; buffer switching
  742. (when (require 'bs nil t)
  743. ;; (global-set-key "\C-x\C-b" 'bs-show)
  744. (defalias 'list-buffers 'bs-show))
  745. ;; (add-to-list 'bs-configurations '("processes" nil get-buffer-process ".*" nil nil))
  746. (add-to-list 'bs-configurations '("same-dir" nil buffer-same-dir-p ".*" nil nil))
  747. (add-to-list 'bs-configurations '("this-frame" nil (lambda (buf) (memq buf (my-frame-buffer-get))) ".*" nil nil))
  748. (add-to-list 'bs-configurations '("this-frame2" nil (lambda (buf) (memq buf (my-frame-buffer-get2))) ".*" nil nil))
  749. ;; (setq bs-configurations (list '("processes" nil get-buffer-process ".*" nil nil)
  750. ;; '("files-and-scratch" "^\\*scratch\\*$" nil nil bs-visits-non-file bs-sort-buffer-interns-are-last)))
  751. (setq bs-default-configuration "this-frame")
  752. (setq bs-default-sort-name "by name")
  753. (add-hook 'bs-mode-hook
  754. (lambda ()
  755. (setq bs-default-configuration "this-frame")
  756. (set (make-variable-buffer-local 'scroll-margin) 0)
  757. ))
  758. (defun buffer-same-dir-p (bf)
  759. "return t if BF's dir is same as current dir, otherwise nil."
  760. (let ((cdir (expand-file-name default-directory)))
  761. (with-current-buffer bf
  762. (equal (expand-file-name default-directory) cdir))))
  763. (defun echo-buffer-list (&optional blist)
  764. "echo buffer list as string. BLIST is list with buffer objects as elements.
  765. if arg is omitted use value of `buffer-list'."
  766. (interactive)
  767. (message (or (mapconcat (lambda (bf)
  768. (concat (buffer-name bf)
  769. "\t"
  770. (with-current-buffer bf
  771. (symbol-name major-mode))
  772. "\t"
  773. (abbreviate-file-name (buffer-file-name bf))))
  774. (or blist
  775. (buffer-list))
  776. "\n")
  777. "")))
  778. (defun my-buffer-list ()
  779. "return buffer list."
  780. (delq nil
  781. (mapcar (lambda (bf)
  782. (with-current-buffer bf
  783. (and buffer-file-name
  784. bf)))
  785. (buffer-list (selected-frame)))))
  786. (defvar buffer-switch-list-function 'my-buffer-list)
  787. (defun switch-to-previous-buffer-cycle (&optional silent-p)
  788. ""
  789. (interactive)
  790. (let ((bl (funcall buffer-switch-list-function)))
  791. (when bl
  792. (bury-buffer (car bl))
  793. (switch-to-buffer (or (nth 1 bl)
  794. (car bl)))
  795. (or silent-p
  796. (echo-buffer-list (funcall buffer-switch-list-function))))))
  797. (defun switch-to-next-buffer-cycle (&optional silent-p)
  798. ""
  799. (interactive)
  800. (let* ((bl (funcall buffer-switch-list-function))
  801. (bf (nth (- (length bl)
  802. 1)
  803. bl)))
  804. (when bl
  805. (switch-to-buffer bf)
  806. (or silent-p
  807. (echo-buffer-list (funcall buffer-switch-list-function))))))
  808. (iswitchb-mode 1)
  809. (defun iswitchb-buffer-display-other-window ()
  810. ""
  811. (interactive)
  812. (let ((iswitchb-default-method 'display))
  813. (call-interactively 'iswitchb-buffer)))
  814. (defun switch-to-other-buffer ()
  815. ""
  816. (interactive)
  817. (let ((buffer-switch-list-function 'buffer-list))
  818. (switch-to-previous-buffer-cycle t)))
  819. (global-set-key (kbd "C-.") 'switch-to-previous-buffer-cycle)
  820. (global-set-key (kbd "C-,") 'switch-to-next-buffer-cycle)
  821. ;; (global-set-key (kbd "C-\\") 'switch-to-other-buffer)
  822. ;; (global-set-key (kbd "C-\\") 'bury-buffer)
  823. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  824. ;; sdic
  825. (defun sdic-describe-word-at-point-echo ()
  826. ""
  827. (interactive)
  828. (save-window-excursion
  829. (sdic-describe-word-at-point))
  830. (save-excursion
  831. (set-buffer sdic-buffer-name)
  832. (message (buffer-substring (point-min)
  833. (progn (goto-char (point-min))
  834. (or (and (re-search-forward "^\\w" nil t 4)
  835. (progn (previous-line) t)
  836. (point-at-eol))
  837. (point-max)))))))
  838. (setq sdic-eiwa-dictionary-list '((sdicf-client "/usr/share/dict/gene.sdic")))
  839. (setq sdic-waei-dictionary-list '((sdicf-client "/usr/share/dict/jedict.sdic" (add-keys-to-headword t))))
  840. (setq sdic-disable-select-window t)
  841. (setq sdic-window-height 7)
  842. (when (require 'sdic nil t)
  843. ;; (define-key my-prefix-map "\C-w" 'sdic-describe-word)
  844. (define-key my-prefix-map "\C-t" 'sdic-describe-word-at-point-echo))
  845. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  846. ;; vc
  847. ;; (require 'vc)
  848. (setq vc-handled-backends nil)
  849. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  850. ;; gauche-mode
  851. (setq scheme-program-name "gosh")
  852. (defun run-gauche-other-window ()
  853. "Run gauche on other window"
  854. (interactive)
  855. (switch-to-buffer-other-window
  856. (get-buffer-create "*scheme*"))
  857. (run-gauche))
  858. (defun run-gauche ()
  859. "run gauche"
  860. (run-scheme "gosh"))
  861. (defun scheme-send-buffer ()
  862. ""
  863. (interactive)
  864. (scheme-send-region (point-min) (point-max)))
  865. (add-hook 'scheme-mode-hook
  866. (lambda ()
  867. (define-key scheme-mode-map "\C-c\C-b" 'scheme-send-buffer)))
  868. ;; http://d.hatena.ne.jp/kobapan/20090305/1236261804
  869. ;; http://www.katch.ne.jp/~leque/software/repos/gauche-mode/gauche-mode.el
  870. (when (dllib-if-unfound "gauche-mode"
  871. "http://www.katch.ne.jp/~leque/software/repos/gauche-mode/gauche-mode.el"
  872. t)
  873. (setq auto-mode-alist
  874. (cons '("\.scm$" . gauche-mode) auto-mode-alist))
  875. (autoload 'gauche-mode "gauche-mode" "Major mode for Scheme." t)
  876. (autoload 'run-scheme "gauche-mode" "Run an inferior Scheme process." t)
  877. (add-hook 'gauche-mode-hook
  878. (lambda ()
  879. (define-key scheme-mode-map "\C-c\C-z" 'run-gauche-other-window))))
  880. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  881. ;; recentf-mode
  882. (add-hook 'recentf-dialog-mode-hook
  883. 'my-recentf-abbrev-list)
  884. (defun my-recentf-delete-entry ()
  885. ""
  886. (interactive)
  887. (let ((p (point)))
  888. (setq recentf-list
  889. (delete (my-recentf-get-filename) recentf-list))
  890. (recentf-open-files)
  891. (goto-char p)))
  892. (defun my-recentf-abbrev-list ()
  893. ""
  894. (setq recentf-list
  895. (mapcar 'abbreviate-file-name
  896. recentf-list)))
  897. (defun my-recentf-view-file ()
  898. ""
  899. (interactive)
  900. (view-file (my-recentf-get-filename)))
  901. (defun my-recentf-dired ()
  902. ""
  903. (interactive)
  904. (let ((file (my-recentf-get-filename)))
  905. (if (file-directory-p file)
  906. (dired file)
  907. (dired (or (file-name-directory file)
  908. ".")))))
  909. (defun my-recentf-x-open ()
  910. ""
  911. (interactive)
  912. (my-x-open (my-recentf-get-filename)))
  913. (defun my-recentf-cd-and-find-file ()
  914. ""
  915. (interactive)
  916. (cd (file-name-directory (my-recentf-get-filename)))
  917. (call-interactively 'find-file))
  918. (defun my-recentf-get-filename ()
  919. "get file name in recentf-mode"
  920. (replace-regexp-in-string " \\(\\[.+?\\] \\)?" ; " " or " [\\d] "
  921. ""
  922. (buffer-substring-no-properties (point-at-bol)
  923. (point-at-eol))))
  924. (setq recentf-save-file (expand-file-name "~/.emacs.d/.recentf")
  925. recentf-max-menu-items 20
  926. recentf-max-saved-items 30
  927. recentf-show-file-shortcuts-flag nil)
  928. (when (require 'recentf nil t)
  929. (global-set-key "\C-x\C-r" 'recentf-open-files)
  930. ;; (add-hook 'find-file-hook
  931. ;; (lambda ()
  932. ;; (recentf-add-file default-directory)))
  933. (recentf-mode 1)
  934. (add-to-list 'recentf-filename-handlers 'abbreviate-file-name)
  935. (add-to-list 'recentf-exclude "\\.emacs\\.d/\\.recentf"))
  936. (add-hook 'recentf-dialog-mode-hook
  937. (lambda ()
  938. (recentf-save-list)
  939. ;; (define-key recentf-dialog-mode-map (kbd "C-x C-f") 'my-recentf-cd-and-find-file)
  940. (define-key recentf-dialog-mode-map (kbd "<up>") 'previous-line)
  941. (define-key recentf-dialog-mode-map (kbd "<down>") 'next-line)
  942. (define-key recentf-dialog-mode-map "o" 'my-recentf-x-open)
  943. (define-key recentf-dialog-mode-map "d" 'my-recentf-delete-entry)
  944. (define-key recentf-dialog-mode-map "@" 'my-recentf-dired)
  945. (define-key recentf-dialog-mode-map "v" 'my-recentf-view-file)
  946. (cd "~/")))
  947. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  948. ;; dired
  949. (require 'dired)
  950. (defun my-dired-diff ()
  951. ""
  952. (interactive)
  953. (let ((files (dired-get-marked-files nil nil nil t)))
  954. (if (eq (car files)
  955. t)
  956. (diff (cadr files) (dired-get-filename))
  957. (message "One files must be marked!"))))
  958. (require 'dired-aux) ;; needed to use dired-dwim-target-directory
  959. (defun my-dired-do-pack-or-unpack ()
  960. "pack or unpack files.
  961. if targetting one file and that is archive file defined in `pack-program-alist', unpack that.
  962. otherwise, pack marked files. prompt user to decide filename for archive."
  963. (interactive)
  964. (let* ((infiles (dired-get-marked-files t))
  965. (onefile (and (eq 1 ; filename if only one file targeted, otherwise nil.
  966. (length infiles))
  967. (car infiles))))
  968. (if (and onefile
  969. (my-pack-file-name-association onefile))
  970. (when (y-or-n-p (format "unpack %s? " onefile))
  971. (my-unpack onefile))
  972. (let* ((dir-default (dired-dwim-target-directory))
  973. (archive-default (my-pack-file-extension (file-name-nondirectory (car infiles))))
  974. (archive ;; (if (interactive-p)
  975. (read-file-name "Output file to pack : "
  976. dir-default
  977. nil
  978. nil
  979. archive-default)
  980. ;; (concat dir-default archive-default)
  981. ))
  982. (apply 'my-pack
  983. archive
  984. infiles))))
  985. (revert-buffer)
  986. ;; (dired-unmark-all-marks)
  987. )
  988. (defun my-file-name-extension-with-tar (filename)
  989. "if FILENAME has extension with tar, like \"tar.gz\", return that.
  990. otherwise, return extension normally."
  991. (if (string-equal "tar" (file-name-extension (file-name-sans-extension filename)))
  992. (concat "tar."
  993. (file-name-extension filename))
  994. (file-name-extension filename)))
  995. (defun my-pack-file-extension (filename)
  996. "if FILENAME has extension and it can be used for pack, return FILENAME.
  997. otherwise, return FILENAME with `my-pack-default-extension'"
  998. (if (my-pack-file-name-association filename)
  999. filename
  1000. (concat filename "." my-pack-default-extension)))
  1001. (defvar my-7z-program-name
  1002. (or (executable-find "7z")
  1003. (executable-find "7za")
  1004. (executable-find "7zr"))
  1005. "7z program.")
  1006. (defvar my-pack-default-extension
  1007. "7z"
  1008. "default suffix for packing. filename with this suffix must matches one of `pack-program-alist'")
  1009. (defun my-pack-file-name-association (filename)
  1010. "if the pattern matching FILENAME is found at car of the list in `pack-program-alist', return cdr of that list.
  1011. otherwise, return nil."
  1012. (let ((case-fold-search nil))
  1013. (assoc-default filename
  1014. my-pack-program-alist
  1015. 'string-match-p
  1016. nil)))
  1017. (defvar my-pack-program-alist
  1018. `(
  1019. ("\\.7z\\'" ,(concat my-7z-program-name " a") ,(concat my-7z-program-name " x"))
  1020. ("\\.zip\\'" "zip -r" "unzip")
  1021. ("\\.tar\\'" "tar cf" "tar xf")
  1022. ("\\.tgz\\'" "tar czf" "tar xzf")
  1023. ("\\.tar\\.gz\\'" "tar czf" "tar xzf")
  1024. )
  1025. "Alist of filename patterns, command for pack and unpack.
  1026. Each element looks like (REGEXP PACKING-COMMAND UNPACKING-COMMAND).
  1027. PACKING-COMMAND and UNPACKING-COMMAND can be nil if the command is not available.
  1028. alist is searched from the beginning so pattern for \".tar.gz\" should be ahead of pattern for \".gz\"")
  1029. ;; (string-match-p "\\.gz\\'" "aaa.gz") ; \' matches string end, $ also matches the point before newline.
  1030. (defun my-unpack (archive)
  1031. "unpack ARCHIVE. command for unpacking is defined in `pack-program-alist'"
  1032. (interactive "fArchive to extract: ")
  1033. (let* ((earchive (expand-file-name archive))
  1034. (cmd (nth 1
  1035. (my-pack-file-name-association earchive)))
  1036. )
  1037. (if cmd
  1038. (shell-command (concat cmd
  1039. " "
  1040. (shell-quote-argument earchive)))
  1041. (message "this is not archive file defined in `pack-program-alist'!"))))
  1042. (defun my-pack (archive &rest files)
  1043. "pack FILES into ARCHIVE.
  1044. if ARCHIVE have extension defined in `pack-program-alist', use that command.
  1045. otherwise, use `pack-default-extension' for pack."
  1046. (let* ((archive-ext (my-pack-file-extension (expand-file-name archive)))
  1047. (cmd (car (my-pack-file-name-association archive-ext)))
  1048. )
  1049. (if cmd
  1050. (shell-command (concat cmd
  1051. " "
  1052. (shell-quote-argument archive-ext)
  1053. " "
  1054. (mapconcat 'shell-quote-argument
  1055. files
  1056. " ")))
  1057. (message "invalid extension for packing!"))))
  1058. (defun my-pop-to-buffer-erase-noselect (buffer-or-name)
  1059. "pop up buffer using `display-buffer' and return that buffer."
  1060. (let ((bf (get-buffer-create buffer-or-name)))
  1061. (with-current-buffer bf
  1062. (cd ".")
  1063. (erase-buffer))
  1064. (display-buffer bf)
  1065. bf))
  1066. (defun my-replace-nasi-none ()
  1067. ""
  1068. (save-excursion
  1069. (let ((buffer-read-only nil))
  1070. (goto-char (point-min))
  1071. (while (search-forward "なし" nil t)
  1072. (replace-match "none")))))
  1073. (defun dired-get-du () ;em-unix.el使えるかも
  1074. "dired get disk usage"
  1075. (interactive)
  1076. (message "calculating du...")
  1077. (dired-do-shell-command "du -hs * " nil (dired-get-marked-files)))
  1078. (defun my-dired-scroll-up ()
  1079. ""
  1080. (interactive)
  1081. (my-dired-previous-line (- (window-height) 1)))
  1082. (defun my-dired-scroll-down ()
  1083. ""
  1084. (interactive)
  1085. (my-dired-next-line (- (window-height) 1)))
  1086. (defun my-dired-previous-line (&optional arg)
  1087. ""
  1088. (interactive)
  1089. (dired-previous-line (or arg 1))
  1090. (my-dired-print-current-dir-and-file))
  1091. (defun my-dired-next-line (&optional arg)
  1092. ""
  1093. (interactive)
  1094. (dired-next-line (or arg 1))
  1095. (my-dired-print-current-dir-and-file))
  1096. (defun my-dired-print-current-dir-and-file ()
  1097. (message "%s %s"
  1098. default-directory
  1099. (buffer-substring-no-properties (point-at-bol)
  1100. (point-at-eol))))
  1101. (defun dired-do-execute-as-command ()
  1102. ""
  1103. (interactive)
  1104. (let ((file (dired-get-filename t)))
  1105. (if (file-executable-p file)
  1106. (start-process file nil file)
  1107. (when (y-or-n-p "this file cant be executed. mark as executable and go? : ")
  1108. (set-file-modes file (file-modes-symbolic-to-number "u+x" (file-modes file)))
  1109. (start-process file nil file)))))
  1110. ;;http://bach.istc.kobe-u.ac.jp/lect/tamlab/ubuntu/emacs.html
  1111. (defun my-dired-x-open ()
  1112. ""
  1113. (interactive)
  1114. (my-x-open (dired-get-filename t t)))
  1115. (defun my-dired-up-directory ()
  1116. ""
  1117. (interactive)
  1118. (my-dired-find-file ".."))
  1119. (defun my-dired-find-file (&optional filename)
  1120. "if the file to open is a directory, kill current buffer after opening that file."
  1121. (interactive)
  1122. (let ((f (expand-file-name (or filename
  1123. (dired-get-filename))))
  1124. (bf (current-buffer)))
  1125. (find-file f)
  1126. (when (and (file-directory-p f)
  1127. (not (get-buffer-window bf)))
  1128. (kill-buffer bf))))
  1129. (if (eq window-system 'mac)
  1130. (setq dired-listing-switches "-lhFG")
  1131. (setq dired-listing-switches "-lhFG --time-style=long-iso")
  1132. )
  1133. (define-minor-mode my-dired-display-all-mode
  1134. ""
  1135. :init-value nil
  1136. :global t
  1137. (my-dired-display-all-set)
  1138. (when (eq major-mode 'dired-mode)
  1139. (revert-buffer)))
  1140. (defun my-dired-display-all-set ()
  1141. ""
  1142. (if my-dired-display-all-mode
  1143. (setq dired-actual-switches
  1144. (concat "-A "
  1145. dired-actual-switches))
  1146. (setq dired-actual-switches
  1147. (replace-regexp-in-string "-A " "" dired-actual-switches))))
  1148. (add-hook 'dired-mode-hook
  1149. 'my-dired-display-all-set)
  1150. (put 'dired-find-alternate-file 'disabled nil)
  1151. (require 'ls-lisp)
  1152. ;; (setq ls-lisp-use-insert-directory-program nil)
  1153. (setq ls-lisp-dirs-first t)
  1154. (setq dired-ls-F-marks-symlinks t)
  1155. (setq dired-dwim-target t)
  1156. ;; (add-hook 'dired-after-readin-hook
  1157. ;; 'my-replace-nasi-none)
  1158. ;; (add-hook 'after-init-hook
  1159. ;; (lambda ()
  1160. ;; (dired ".")))
  1161. (add-hook 'dired-mode-hook
  1162. (lambda ()
  1163. (define-key dired-mode-map "o" 'my-dired-x-open)
  1164. (define-key dired-mode-map "i" 'dired-get-du)
  1165. (define-key dired-mode-map "!" 'shell-command)
  1166. (define-key dired-mode-map "&" 'async-shell-command)
  1167. (define-key dired-mode-map "X" 'dired-do-async-shell-command)
  1168. (define-key dired-mode-map "=" 'my-dired-diff)
  1169. (define-key dired-mode-map "B" 'gtkbm-add-current-dir)
  1170. (define-key dired-mode-map "b" 'gtkbm)
  1171. (define-key dired-mode-map "@" (lambda () (interactive) (my-x-open ".")))
  1172. (define-key dired-mode-map (kbd "TAB") 'other-window)
  1173. (define-key dired-mode-map "P" 'my-dired-do-pack-or-unpack)
  1174. (define-key dired-mode-map "a" 'my-dired-display-all-mode)
  1175. (define-key dired-mode-map "h" 'my-dired-display-all-mode)
  1176. (define-key dired-mode-map "/" 'dired-isearch-filenames)
  1177. (substitute-key-definition 'dired-advertised-find-file 'my-dired-find-file dired-mode-map)
  1178. (substitute-key-definition 'dired-up-directory 'my-dired-up-directory dired-mode-map)
  1179. (define-key dired-mode-map (kbd "DEL") 'my-dired-up-directory)
  1180. (substitute-key-definition 'dired-next-line 'my-dired-next-line dired-mode-map)
  1181. (substitute-key-definition 'dired-previous-line 'my-dired-previous-line dired-mode-map)
  1182. (define-key dired-mode-map (kbd "<left>") 'my-dired-scroll-up)
  1183. (define-key dired-mode-map (kbd "<right>") 'my-dired-scroll-down)
  1184. (let ((file "._Icon\015"))
  1185. (when (file-readable-p file)
  1186. (delete-file file)))))
  1187. ;; http://homepage1.nifty.com/blankspace/emacs/dired.html
  1188. ;; (add-hook 'dired-load-hook
  1189. ;; (lambda ()
  1190. ;; (load-library "ls-lisp")
  1191. ;; (setq ls-lisp-dirs-first t)
  1192. ;; (setq dired-listing-switches "-alhF"))) ;これ書く場所間違えてね?
  1193. ;; (defadvice dired-next-line (after dired-next-line-print-directory activate)
  1194. ;; "print current directory when go down line"
  1195. ;; (dired-print-current-dir-and-file))
  1196. ;; (defadvice dired-previous-line (after dired-previous-line-print-directory activate)
  1197. ;; "print current directory when go up line"
  1198. ;; (dired-print-current-dir-and-file))
  1199. ;; http://blog.livedoor.jp/tek_nishi/archives/4693204.html
  1200. (defun my-dired-toggle-mark()
  1201. (let ((cur (cond ((eq (following-char) dired-marker-char) ?\040)
  1202. (t dired-marker-char))))
  1203. (delete-char 1)
  1204. (insert cur)))
  1205. (defun my-dired-mark (arg)
  1206. "toggle mark the current (or next ARG) files.
  1207. If on a subdir headerline, mark all its files except `.' and `..'.
  1208. Use \\[dired-unmark-all-files] to remove all marks
  1209. and \\[dired-unmark] on a subdir to remove the marks in
  1210. this subdir."
  1211. (interactive "P")
  1212. (if (dired-get-subdir)
  1213. (save-excursion (dired-mark-subdir-files))
  1214. (let ((inhibit-read-only t))
  1215. (dired-repeat-over-lines
  1216. (prefix-numeric-value arg)
  1217. 'my-dired-toggle-mark))))
  1218. (defun my-dired-mark-backward (arg)
  1219. "In Dired, move up lines and toggle mark there.
  1220. Optional prefix ARG says how many lines to unflag; default is one line."
  1221. (interactive "p")
  1222. (my-dired-mark (- arg)))
  1223. (defun dired-mode-hooks()
  1224. (local-set-key (kbd "SPC") 'my-dired-mark)
  1225. (local-set-key (kbd "S-SPC") 'my-dired-mark-backward))
  1226. (add-hook 'dired-mode-hook 'dired-mode-hooks)
  1227. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1228. ;; eshell
  1229. (defun my-eshell-backward-delete-char ()
  1230. (interactive)
  1231. (when (< (save-excursion
  1232. (eshell-bol)
  1233. (point))
  1234. (point))
  1235. (backward-delete-char 1)))
  1236. (defvar my-eshell-frame-buffer-alist nil)
  1237. (defun my-eshell-frame-buffer (frame)
  1238. "get buffer associated with FRAME. if buffer doesnt exist or killed, return nil."
  1239. (let ((bf (cdr (assq frame my-eshell-frame-buffer-alist))))
  1240. (and bf ;関連付けられたバッファが存在し
  1241. (buffer-name bf) ;かつkillされてない
  1242. bf)))
  1243. (add-hook 'eshell-mode-hook
  1244. (lambda ()
  1245. (add-to-list 'my-eshell-frame-buffer-alist
  1246. (cons (selected-frame) (current-buffer)))))
  1247. (defun my-file-owner-p (file)
  1248. "t if FILE is owned by me."
  1249. (eq (user-uid) (nth 2 (file-attributes file))))
  1250. ;; ;; http://www.bookshelf.jp/pukiwiki/pukiwiki.php?Eshell%A4%F2%BB%C8%A4%A4%A4%B3%A4%CA%A4%B9
  1251. ;; ;; written by Stefan Reichoer <reichoer@web.de>
  1252. ;; (defun eshell/less (&rest args)
  1253. ;; "Invoke `view-file' on the file.
  1254. ;; \"less +42 foo\" also goes to line 42 in the buffer."
  1255. ;; (if args
  1256. ;; (while args
  1257. ;; (if (string-match "\\`\\+\\([0-9]+\\)\\'" (car args))
  1258. ;; (let* ((line (string-to-number (match-string 1 (pop args))))
  1259. ;; (file (pop args)))
  1260. ;; (view-file file)
  1261. ;; (goto-line line))
  1262. ;; (view-file (pop args))))))
  1263. ;; (defun eshell/git (&rest args)
  1264. ;; ""
  1265. ;; (eshell-parse-arguments (point-at-bol) (point-at-eol)))
  1266. (defun eshell/o (&optional file)
  1267. (my-x-open (or file ".")))
  1268. ;; (defun eshell/vi (&rest args)
  1269. ;; "Invoke `find-file' on the file.
  1270. ;; \"vi +42 foo\" also goes to line 42 in the buffer."
  1271. ;; (while args
  1272. ;; (if (string-match "\\`\\+\\([0-9]+\\)\\'" (car args))
  1273. ;; (let* ((line (string-to-number (match-string 1 (pop args))))
  1274. ;; (file (pop args)))
  1275. ;; (find-file file)
  1276. ;; (goto-line line))
  1277. ;; (find-file (pop args)))))
  1278. (defun eshell/clear ()
  1279. "Clear the current buffer, leaving one prompt at the top."
  1280. (let ((inhibit-read-only t))
  1281. (erase-buffer)))
  1282. (defun eshell/d (&optional dirname switches)
  1283. "if first arg is omitted open current directory."
  1284. (dired (or dirname ".") switches))
  1285. (defun eshell/v ()
  1286. (view-mode 1))
  1287. (defalias 'eshell/: 'ignore)
  1288. (defalias 'eshell/type 'eshell/which)
  1289. ;; (defalias 'eshell/vim 'eshell/vi)
  1290. (defalias 'eshell/ff 'find-file)
  1291. (defalias 'eshell/q 'eshell/exit)
  1292. (defun eshell-goto-prompt ()
  1293. ""
  1294. (interactive)
  1295. (goto-char (point-max)))
  1296. (defun eshell-cd-default-directory (&optional eshell-buffer-or-name)
  1297. "open eshell and change wd
  1298. if arg given, use that eshell buffer, otherwise make new eshell buffer."
  1299. (interactive)
  1300. (let ((dir (expand-file-name default-directory)))
  1301. (switch-to-buffer (or eshell-buffer-or-name
  1302. (eshell t)))
  1303. (unless (equal dir (expand-file-name default-directory))
  1304. ;; (cd dir)
  1305. ;; (eshell-interactive-print (concat "cd " dir "\n"))
  1306. ;; (eshell-emit-prompt)
  1307. (goto-char (point-max))
  1308. (eshell-kill-input)
  1309. (insert "cd " dir)
  1310. (eshell-send-input))))
  1311. (setq eshell-directory-name "~/.emacs.d/eshell/")
  1312. (setq eshell-scroll-to-bottom-on-input t)
  1313. (setq eshell-cmpl-ignore-case t)
  1314. (setq eshell-cmpl-cycle-completions nil)
  1315. (setq eshell-highlight-prompt nil)
  1316. (setq eshell-ls-initial-args "-FG") ; "-hF")
  1317. (setq eshell-prompt-function
  1318. (lambda ()
  1319. (with-temp-buffer
  1320. (let (p1 p2 p3 p4)
  1321. (insert " [")
  1322. (setq p1 (point))
  1323. (insert (abbreviate-file-name default-directory))
  1324. (setq p2 (point))
  1325. (insert "]"
  1326. "\n")
  1327. (setq p3 (point))
  1328. (insert user-login-name
  1329. "@"
  1330. (or (getenv "HOSTNAME")
  1331. (substring (shell-command-to-string (or (executable-find "hostname")
  1332. "echo ''"))
  1333. 0
  1334. -1)))
  1335. (setq p4 (point))
  1336. (insert " "
  1337. (format-time-string "%a, %d %b %Y %T %z")
  1338. " eshell\n"
  1339. "last:"
  1340. (number-to-string eshell-last-command-status)
  1341. (if (= (user-uid)
  1342. 0)
  1343. " # "
  1344. " $ "))
  1345. (add-text-properties p1
  1346. p2
  1347. '(face ((foreground-color . "yellow"))))
  1348. (add-text-properties p3
  1349. p4
  1350. '(face ((foreground-color . "cyan"))))
  1351. (buffer-substring (point-min)
  1352. (point-max))))))
  1353. (add-hook 'eshell-mode-hook
  1354. (lambda ()
  1355. ;; (define-key eshell-mode-map (kbd "C-x C-x") (lambda ()
  1356. ;; (interactive)
  1357. ;; (switch-to-buffer (other-buffer))))
  1358. (define-key eshell-mode-map (kbd "C-u") (lambda ()
  1359. (interactive)
  1360. (eshell-goto-prompt)
  1361. (eshell-kill-input)))
  1362. (define-key eshell-mode-map (kbd "C-g") (lambda ()
  1363. (interactive)
  1364. (eshell-goto-prompt)
  1365. (my-keyboard-quit)))
  1366. (define-key eshell-mode-map (kbd "DEL") 'my-eshell-backward-delete-char)
  1367. (define-key eshell-mode-map (kbd "C-p") 'eshell-previous-matching-input-from-input)
  1368. (define-key eshell-mode-map (kbd "C-n") 'eshell-next-matching-input-from-input)
  1369. (mapcar (lambda (alias)
  1370. (add-to-list 'eshell-command-aliases-list
  1371. alias))
  1372. '(("ll" "ls -l")
  1373. ("la" "ls -a")
  1374. ("lla" "ls -al")
  1375. ("ut" "slogin 03110414@un001.ecc.u-tokyo.ac.jp")
  1376. ("aptin" "sudo apt-get install")
  1377. ("u" "uname")
  1378. ("eless" "cat >>> (with-current-buffer (get-buffer-create \"*eshell output\") (erase-buffer) (setq buffer-read-only nil) (current-buffer)); (view-buffer (get-buffer \"*eshell output*\"))")
  1379. ("g" "git")))
  1380. (add-to-list 'eshell-output-filter-functions 'eshell-truncate-buffer)
  1381. (apply 'eshell/addpath exec-path)
  1382. (set (make-variable-buffer-local 'scroll-margin) 0)
  1383. (eshell/export "GIT_PAGER=")
  1384. (eshell/export "GIT_EDITOR=")
  1385. (eshell/export "LC_MESSAGES=C")
  1386. (eshell/export "TERM=xterm")
  1387. ))
  1388. ;; (eval-after-load "em-alias"
  1389. ;; '(progn ;; (eshell/alias "ll" "ls -l")
  1390. ;; ;; (eshell/alias "la" "ls -a")
  1391. ;; ;; (eshell/alias "lla" "ls -al")
  1392. ;; (eshell/alias "sgcc" (if (eq system-type 'windows-nt)
  1393. ;; "gcc -o win.$1.exe $1"
  1394. ;; "gcc -o ${uname}.$1.out $1"))
  1395. ;; (eshell/alias "slmgcc" (if (eq system-type 'windows-nt)
  1396. ;; "gcc -lm -o win.$1.exe $1"
  1397. ;; "gcc -lm -o ${uname}.$1.out $1"))
  1398. ;; ;; (eshell/alias "ut" "ssh g841105@un001.ecc.u-tokyo.ac.jp")
  1399. ;; (add-to-list 'recentf-exclude (concat eshell-directory-name "alias"))))
  1400. ;; (define-key my-prefix-map (kbd "C-s") (lambda ()
  1401. ;; (interactive)
  1402. ;; (eshell-cd-default-directory (buffer-name (or (my-eshell-frame-buffer (selected-frame))
  1403. ;; (eshell t))))))
  1404. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1405. ;; 最終更新日時を得る
  1406. (defvar my-buffer-file-last-modified-time nil "")
  1407. (make-variable-buffer-local 'my-buffer-file-last-modified-time)
  1408. (defun my-get-file-last-modified-time (file)
  1409. ""
  1410. (nth 5
  1411. (file-attributes file)))
  1412. (defun my-set-buffer-file-last-modified-time ()
  1413. ""
  1414. (make-local-variable 'my-buffer-file-last-modified-time)
  1415. (setq my-buffer-file-last-modified-time
  1416. (format-time-string "%Y/%m/%d %H:%M" (my-get-file-last-modified-time buffer-file-name))))
  1417. (add-hook 'find-file-hook
  1418. 'my-set-buffer-file-last-modified-time)
  1419. (add-hook 'after-save-hook
  1420. 'my-set-buffer-file-last-modified-time)
  1421. (add-hook 'after-revert-hook
  1422. 'my-set-buffer-file-last-modified-time)
  1423. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1424. ;; auto saving
  1425. (defun my-save-this-buffer (silent-p)
  1426. "save current buffer if can without asking"
  1427. (let ((cm (if (current-message)
  1428. (format "%s\n" (current-message))
  1429. ""))
  1430. (fun (symbol-function (if silent-p
  1431. 'ignore
  1432. 'message))))
  1433. (cond ((active-minibuffer-window) nil)
  1434. ((not buffer-file-name) (funcall fun "%ssaving... this buffer doesn't visit any file." cm) nil)
  1435. ((not (file-exists-p buffer-file-name)) (funcall fun "%ssaving... file not exist. save manually first." com) nil)
  1436. (buffer-read-only (funcall fun "%ssaving... this buffer is read-only." cm) nil)
  1437. ((not (buffer-modified-p)) (funcal fun "%ssaving... not modified yet." cm) nil)
  1438. ((not (file-writable-p buffer-file-name)) (funcall fun "%ssaving... you cannot change this file." cm) nil)
  1439. (t (funcall fun "%ssaving..." cm)
  1440. (save-buffer)
  1441. (funcall fun "%ssaving... done." cm)))))
  1442. ;; (if (and buffer-file-name
  1443. ;; (not buffer-read-only)
  1444. ;; (buffer-modified-p)
  1445. ;; (file-writable-p buffer-file-name))
  1446. ;; (save-buffer))) ; 静かな方
  1447. (defvar my-auto-save-this-buffer nil "auto save timer object")
  1448. (defun my-auto-save-this-buffer (secs &optional silent-p)
  1449. "auto save current buffer if idle for SEC.
  1450. when SEC is nil, stop auto save if enabled."
  1451. (if secs
  1452. (progn (when my-auto-save-this-buffer
  1453. (cancel-timer my-auto-save-this-buffer)
  1454. (setq my-auto-save-this-buffer nil))
  1455. (setq my-auto-save-this-buffer (run-with-idle-timer secs t 'my-save-this-buffer silent-p)))
  1456. (when my-auto-save-this-buffer
  1457. (cancel-timer my-auto-save-this-buffer)
  1458. (setq my-auto-save-this-buffer nil))))
  1459. (my-auto-save-this-buffer 2 t)
  1460. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1461. ;; misc funcs
  1462. (defvar my-desktop-terminal "roxterm")
  1463. (defun my-execute-terminal ()
  1464. ""
  1465. (interactive)
  1466. (if (and (or (eq system-type 'windows-nt)
  1467. window-system)
  1468. my-desktop-terminal
  1469. )
  1470. (let ((process-environment (cons "TERM=xterm" process-environment)))
  1471. (start-process "terminal"
  1472. nil
  1473. my-desktop-terminal))
  1474. (my-execute-or-find-term)))
  1475. (defun my-term ()
  1476. "open terminal buffer and return that buffer."
  1477. (interactive)
  1478. (if (eq system-type 'windows-nt)
  1479. (eshell t)
  1480. (if (featurep 'multi-term)
  1481. (multi-term)
  1482. (ansi-term "/bin/bash"))))
  1483. (defvar my-frame-term-plist nil)
  1484. ;; (setplist my-frame-term-plist nil)
  1485. (defun my-execute-or-find-term ()
  1486. ""
  1487. (interactive)
  1488. (let* ((buf (plist-get my-frame-term-plist (selected-frame))))
  1489. (if (and buf
  1490. (buffer-name buf))
  1491. (switch-to-buffer buf)
  1492. (setq my-frame-term-plist
  1493. (plist-put my-frame-term-plist
  1494. (selected-frame)
  1495. (my-term))))))
  1496. (defun my-format-time-string (&optional time)
  1497. ""
  1498. (let ((system-time-locale "C"))
  1499. (format-time-string "%a, %d %b %Y %T" time)))
  1500. (defvar my-filer nil)
  1501. (setq my-filer (or (executable-find "pcmanfm")
  1502. (executable-find "nautilus")))
  1503. (defun my-x-open (file)
  1504. "open file."
  1505. (interactive "FOpen File: ")
  1506. (setq file (expand-file-name file))
  1507. (message "Opening %s..." file)
  1508. (cond ((eq system-type 'windows-nt)
  1509. (call-process "cmd.exe" nil 0 nil "/c" "start" "" (convert-standard-filename file)))
  1510. ((eq system-type 'darwin)
  1511. (call-process "open" nil 0 nil file))
  1512. ((not (getenv "DESKTOP_SESSION"))
  1513. (find-file file))
  1514. (t
  1515. (if (file-directory-p file)
  1516. (call-process my-filer nil 0 nil file)
  1517. (call-process "xdg-open" nil 0 nil file))))
  1518. (recentf-add-file file)
  1519. (message "Opening %s...done" file))
  1520. (defvar my-auto-indent-buffer-mode-list
  1521. '(emacs-lisp-mode
  1522. sh-mode
  1523. js-mode
  1524. sgml-mode
  1525. c-mode
  1526. c++-mode))
  1527. (setq my-auto-indent-buffer-mode-list nil)
  1528. (defun my-indent-buffer ()
  1529. "indent whole buffer."
  1530. (interactive)
  1531. (indent-region (point-min)
  1532. (point-max)))
  1533. (defun my-auto-indent-buffer ()
  1534. ""
  1535. (when (memq major-mode my-auto-indent-buffer-mode-list)
  1536. (my-indent-buffer)))
  1537. (add-hook 'before-save-hook
  1538. 'my-auto-indent-buffer)
  1539. (defun my-keyboard-quit ()
  1540. ""
  1541. (interactive)
  1542. (run-hooks 'before-keyboard-quit-hook)
  1543. ;; (redisplay t)
  1544. (redraw-display)
  1545. ;; (run-hooks 'window-configuration-change-hook)
  1546. (my-revert-buffer-if-needed)
  1547. ;; (revert-buffer t t)
  1548. (keyboard-quit)
  1549. (insert "insert me")
  1550. (run-hooks 'after-keyboard-quit-hook))
  1551. (substitute-key-definition 'keyboard-quit 'my-keyboard-quit global-map)
  1552. ;; (global-set-key (kbd "C-g") 'my-keyboard-quit)
  1553. (defun my-convmv-sjis2utf8-test ()
  1554. "run `convmv -r -f sjis -t utf8 *'
  1555. this is test, does not rename files"
  1556. (interactive)
  1557. (shell-command "convmv -r -f sjis -t utf8 *"))
  1558. (defun my-convmv-sjis2utf8-notest ()
  1559. "run `convmv -r -f sjis -t utf8 * --notest'"
  1560. (interactive)
  1561. (shell-command "convmv -r -f sjis -t utf8 * --notest"))
  1562. (defun my-copy-whole-line ()
  1563. ""
  1564. (interactive)
  1565. (kill-new (concat (buffer-substring (point-at-bol)
  1566. (point-at-eol))
  1567. "\n")))
  1568. (defun kill-ring-save-buffer-file-name ()
  1569. "get current filename"
  1570. (interactive)
  1571. (let ((file buffer-file-name))
  1572. (if file
  1573. (progn (kill-new file)
  1574. (message file))
  1575. (message "not visiting file."))))
  1576. ;; ;; コマンド的な
  1577. ;; (defvar my-execute-func-list nil "func list")
  1578. ;; (defvar my-execute-func-hist-list nil "func hist list")
  1579. ;; (setq my-execute-func-list '("(call-interactively 'my-francaiscd-b)"
  1580. ;; "(call-interactively 'my-francaiscd-a)"
  1581. ;; "parsec47"
  1582. ;; "chromium-browser"
  1583. ;; "inkscape"
  1584. ;; "audacious"
  1585. ;; "gnome-terminal"
  1586. ;; "zkaicd.py"
  1587. ;; "glchess"))
  1588. ;; (defun my-execute-start-process-or-eval-sexp ()
  1589. ;; "execute something"
  1590. ;; (interactive)
  1591. ;; (let ((func (completing-read "command?: " my-execute-func-list nil nil "" my-execute-func-hist-list)))
  1592. ;; (if (string= "(" (substring func 0 1))
  1593. ;; (with-temp-buffer (insert func)
  1594. ;; (eval-buffer))
  1595. ;; (start-process "ps"
  1596. ;; nil
  1597. ;; func))))
  1598. ;; delete-trailing-whitespace
  1599. ;; (defun my-delete-blanks-on-eol ()
  1600. ;; ""
  1601. ;; (interactive)
  1602. ;; (save-excursion
  1603. ;; (goto-char (point-min))
  1604. ;; (while (re-search-forward "[ \t]+$" nil t)
  1605. ;; (replace-match "" nil nil))))
  1606. (defun my-revert-buffer-if-needed ()
  1607. ""
  1608. (interactive)
  1609. (unless (verify-visited-file-modtime (current-buffer))
  1610. (revert-buffer t t)))
  1611. (add-hook 'window-configuration-change-hook
  1612. (lambda ()
  1613. (run-with-timer 0.5
  1614. nil
  1615. 'my-revert-buffer-if-needed)))
  1616. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1617. ;; forked from http://d.hatena.ne.jp/khiker/20100119/window_resize
  1618. (define-key my-prefix-map (kbd "C-w") 'my-window-organizer)
  1619. (defun my-window-organizer ()
  1620. "Control window size and position."
  1621. (interactive)
  1622. (save-selected-window
  1623. (select-window (window-at 0 0))
  1624. (let ( ;; (window-obj (selected-window))
  1625. ;; (current-width (window-width))
  1626. ;; (current-height (window-height))
  1627. action
  1628. c)
  1629. (catch 'end-flag
  1630. (while t
  1631. (setq action
  1632. (read-key-sequence-vector (format "size[%dx%d] 1: maximize; 2, 3: split; 0: delete; o: select other; j, l: enlarge; h, k: shrink; q: quit."
  1633. (window-width)
  1634. (window-height))))
  1635. (setq c (aref action 0))
  1636. (cond ((= c ?l)
  1637. (unless (eq (window-width) (frame-width))
  1638. (enlarge-window-horizontally 1)))
  1639. ((= c ?h)
  1640. (unless (eq (window-width) (frame-width))
  1641. (shrink-window-horizontally 1)))
  1642. ((= c ?j)
  1643. (enlarge-window 1))
  1644. ((= c ?k)
  1645. (shrink-window 1))
  1646. ((= c ?o)
  1647. (other-window 1))
  1648. ((memq c '(?d ?0))
  1649. (unless (eq (selected-window) (next-window (selected-window) 0 1))
  1650. (delete-window (selected-window))))
  1651. ((= c ?1)
  1652. (delete-other-windows))
  1653. ((= c ?2)
  1654. (split-window-vertically))
  1655. ((= c ?3)
  1656. (split-window-horizontally))
  1657. ((memq c '(?q ?\C-g))
  1658. (message "Quit")
  1659. (throw 'end-flag t))
  1660. (t
  1661. (beep))))))))
  1662. ;; (aref (read-key-sequence-vector "aa") 0)
  1663. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1664. ;; save and restore frame size
  1665. ;;http://www.bookshelf.jp/soft/meadow_30.html#SEC416
  1666. (defun my-window-size-save ()
  1667. (let* ((rlist (frame-parameters (selected-frame)))
  1668. (ilist initial-frame-alist)
  1669. (nCHeight (frame-height))
  1670. (nCWidth (frame-width))
  1671. (tMargin (if (integerp (cdr (assoc 'top rlist)))
  1672. (cdr (assoc 'top rlist)) 0))
  1673. (lMargin (if (integerp (cdr (assoc 'left rlist)))
  1674. (cdr (assoc 'left rlist)) 0))
  1675. buf
  1676. (file "~/.emacs.d/.framesize.el")
  1677. (recentf-exclude '("\\.emacs\\.d/\\.framesize\\.el$")))
  1678. (if (get-file-buffer (expand-file-name file))
  1679. (setq buf (get-file-buffer (expand-file-name file)))
  1680. (setq buf (find-file-noselect file)))
  1681. (set-buffer buf)
  1682. (erase-buffer)
  1683. (insert (concat
  1684. ;; 初期値をいじるよりも modify-frame-parameters
  1685. ;; で変えるだけの方がいい?
  1686. "(delete 'width default-frame-alist)\n"
  1687. "(delete 'height default-frame-alist)\n"
  1688. "(delete 'top default-frame-alist)\n"
  1689. "(delete 'left default-frame-alist)\n"
  1690. "(setq default-frame-alist (append (list\n"
  1691. "'(width . " (int-to-string nCWidth) ")\n"
  1692. "'(height . " (int-to-string nCHeight) ")\n"
  1693. "'(top . " (int-to-string tMargin) ")\n"
  1694. "'(left . " (int-to-string lMargin) "))\n"
  1695. "default-frame-alist))\n"
  1696. ;;"(setq default-frame-alist default-frame-alist)"
  1697. ))
  1698. (save-buffer)
  1699. ))
  1700. (defun my-window-size-load ()
  1701. (let* ((file "~/.emacs.d/.framesize.el"))
  1702. (if (file-exists-p file)
  1703. (load file))))
  1704. (when window-system
  1705. (my-window-size-load)
  1706. (add-hook 'after-init-hook ;何かがframeの大きさ勝手に変えやがる
  1707. (lambda ()
  1708. (run-with-timer 1
  1709. nil
  1710. (lambda ()
  1711. (modify-frame-parameters (selected-frame)
  1712. default-frame-alist))))
  1713. t)
  1714. ;; (add-hook 'make-frame-hook
  1715. ;; (lambda ()
  1716. ;; (run-with-timer 1
  1717. ;; nil
  1718. ;; (lambda ()
  1719. ;; (modify-frame-parameters (selected-frame)
  1720. ;; initial-frame-alist))))
  1721. ;; t)
  1722. (add-hook 'kill-emacs-hook
  1723. 'my-window-size-save))
  1724. ;; windowサイズを固定
  1725. ;; setq default-frame-alist
  1726. ;; (append (list '(width . 80)
  1727. ;; '(height . 35)
  1728. ;; )
  1729. ;; default-frame-alist)
  1730. ;; ) ;;デフォルトのフレーム設定
  1731. ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1732. ;; ;; emacsを殺伐とさせる
  1733. ;; ;; 補完させるとき失敗するからなし
  1734. ;; ;; http://e-arrows.sakura.ne.jp/2010/05/emacs-should-be-more-savage.html
  1735. ;; (defadvice message (before message-for-stupid (arg &rest arg2) activate)
  1736. ;; (setq arg
  1737. ;; (concat arg
  1738. ;; (if (eq nil (string-match "\\. *$" arg)) ".")
  1739. ;; " And You are a Coward!")))
  1740. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1741. ;; ubuntu
  1742. (defun my-load-scim ()
  1743. "use scim-bridge.el as japanese im."
  1744. ;; Load scim-bridge.
  1745. (require 'scim-bridge)
  1746. ;; Turn on scim-mode automatically after loading .emacs
  1747. (add-hook 'after-init-hook 'scim-mode-on)
  1748. (setq scim-cursor-color "red")
  1749. (scim-define-preedit-key ?\^h t)
  1750. (scim-define-common-key ?\* nil)
  1751. (scim-define-common-key ?\^/ nil))
  1752. (defun my-load-anthy ()
  1753. "use anthy.el as japanese im."
  1754. ;; anthy
  1755. (require 'anthy)
  1756. (global-set-key [muhenkan] (lambda () (interactive) (anthy-mode-off)))
  1757. (global-set-key [henkan] (lambda () (interactive) (anthy-mode-on)))
  1758. (when (>= emacs-major-version 23)
  1759. (setq anthy-accept-timeout 1)))
  1760. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1761. ;; windows用設定
  1762. ;; (add-to-list 'exec-path "c:/Program Files/Gauche/bin/")
  1763. (defun start-ckw-bash ()
  1764. ""
  1765. (interactive)
  1766. (start-process "ckw_bash"
  1767. nil
  1768. "C:/Documents and Settings/sr/Application Data/dbx/apps/ckw/ckw.exe")) ; cじゃないといけないらしい
  1769. (defun my-w32-add-export-path (&rest args)
  1770. ""
  1771. (mapcar (lambda (path)
  1772. (add-to-list 'exec-path (expand-file-name path)))
  1773. (reverse args))
  1774. (setenv "PATH"
  1775. (mapconcat 'convert-standard-filename
  1776. exec-path
  1777. ";")))
  1778. (when (eq system-type 'windows-nt)
  1779. ;; (setq scheme-program-name "\"c:/Program Files/Gauche/bin/gosh.exe\" -i")
  1780. ;; (setq python-python-command "c:/Python26/python.exe")
  1781. (define-key my-prefix-map (kbd "C-c") 'start-ckw-bash)
  1782. (my-w32-add-export-path "c:/WINDOWS"
  1783. (expand-file-name "~/bin")
  1784. (expand-file-name "~/dbx/apps/bin"))
  1785. (when window-system
  1786. (setq w32-enable-synthesized-fonts t))
  1787. (setq file-name-coding-system 'sjis))