Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

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