-
Notifications
You must be signed in to change notification settings - Fork 5
/
.emacs-1
executable file
·859 lines (724 loc) · 31.9 KB
/
.emacs-1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
;;(load "/usr/share/emacs/site-lisp/site-gentoo")
(add-to-list 'load-path "~/.emacs.d/93free")
(add-to-list 'load-path "~/.emacs.d/lisps")
;;(add-to-list 'load-path "~/.emacs.d/lisps/mumamo")
;; 载入elisp文件
(global-set-key [(f1)] (lambda () (interactive) (manual-entry (current-word))))
;;(global-set-key [f2] 'speedbar) ; 快速浏览
(global-set-key [f2] 'view-mode) ; 只读模式
(global-set-key [f3] 'linum-mode) ; 显示行号
(global-set-key [f4] 'global-highline-mode) ; 高亮光标行
;;(global-set-key [f5] 'revert-buffer) ; 重载文件/刷新
(global-set-key [f6] 'eshell) ; 一个 elisp 写的 shell
(global-set-key [f7] 'calendar) ; Emacs 的日历系统
;;(global-set-key [f10] 'hs-toggle-hiding)
;;(global-set-key [f8] 'plan) ; 计划任务
(global-set-key [f9] 'other-window) ; 跳转到 Emacs 的另一个窗口
;;(global-set-key [f10] ') ; 文件菜单
(global-set-key [f11] 'compile) ; 在 Emacs 中编译
(global-set-key [f12] 'gdb) ; 在 Emacs 中调试
;; 这些功能键有时候还是很有用的。除了直接设置之外,还可以配合 Shift, Ctrl 设置,比如:
;;
;; (global-set-key [(shift f1)] 'goto-line)
;;
;; 实际上 Shift-F1 也可以用 F13 表示。
(require 'grep-edit)
(require 'twittering-mode)
(setq twittering-username "transtone")
(setq twittering-update-status-function
'twittering-update-status-from-pop-up-buffer)
(twittering-icon-mode) ; Show icons (requires wget)
(setq twittering-timer-interval 300)
(eval-after-load "man" '(require 'man-completion))
(global-set-key (kbd "C-SPC") 'nil)
(global-set-key "\C-x\C-b" 'electric-buffer-list)
(global-set-key "\C-c\C-z" 'pop-global-mark)
;; 很多文件的时候,在几个文件中跳转到曾经用过的 mark 地方。
(global-set-key "\C-\\" 'toggle-truncate-lines)
;; 基本不用 Emacs 的输入法,绑定给折行命令吧
(global-set-key "\C-z" 'set-mark-command)
;; 设置标记。
(define-prefix-command 'ctl-x-m-map)
(global-set-key "\C-xm" 'ctl-x-m-map)
;; 定义了一个新的前缀,并且绑定到 C-x m
(define-key ctl-x-m-map "w" 'ibuffer)
;; 管理 Emacs 所打开的 buffer。
(setq inhibit-startup-message t)
;; 不显示 Emacs 的开始画面。
(setq frame-title-format '("" buffer-file-name "@" user-login-name ":" system-name))
;; 设置缓冲标题
(setq default-major-mode 'text-mode)
;; 任意的打开一个新文件时,缺省使用 text-mode。
;;(setq require-final-newline t)
;; 存盘的时候,要求最后一个字符是换行符。
(setq resize-mini-windows nil)
;; mini buffer 的大小保持不变。
;;(mouse-avoidance-mode 'animate)
;; 鼠标指针避开光标
;; 用鼠标快速 copy ,cut , paste
(require 'mouse-copy)
(global-set-key [S-down-mouse-1] 'mouse-drag-secondary-pasting)
(global-set-key [M-S-down-mouse-1] 'mouse-drag-secondary-moving)
(setq track-eol t)
;; 当光标在行尾上下移动的时候,始终保持在行尾。
(setq Man-notify-method 'pushy)
;; 当浏览 man page 时,直接跳转到 man buffer。
(setq uniquify-buffer-name-style 'forward)
;; 当有两个文件名相同的缓冲时,使用前缀的目录名做 buffer 名字,不用原来的
(setq line-number-display-limit 1000000)
;; 当行数超过一定数值,不再显示行号。
(setq kill-ring-max 200)
;; kill-ring 最多的记录个数。
(setq ring-bell-function 'ignore)
;; 彻底的消除 ring-bell 的效果。
(setq apropos-do-all nil)
;; M-x apropos 时多查询些结果,但需要更多的 CPU。
(setq dired-recursive-copies t)
(setq dired-recursive-deletes t)
;; 复制(删除)目录的时,第归的复制(删除)其中的子目录。
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
;;(setq display-time-use-mail-icon t)
(setq display-time-interval 10)
;; 在 mode-line 上显示时间。
(require 'smtpmail)
(setq send-mail-function 'smtpmail-send-it)
(setq message-send-mail-function 'smtpmail-send-it)
(setq user-full-name "transtone")
(setq smtpmail-local-domain "gmail.com")
(setq user-mail-address (concat "zm3345@" smtpmail-local-domain))
;; 缺省的名字和邮件地址,很多地方用得到,比如 VC(version control) 中产生ChangeLog 文件。
(setq appt-issue-message t)
;; 打开约会提醒功能。
(setq x-select-enable-clipboard t)
;; 支持emacs和外部程序的粘贴
(defun qiang-comment-dwim-line (&optional arg)
"Replacement for the comment-dwim command.
If no region is selected and current line is not blank and we are not at the end of the line,
then comment current line.
Replaces default behaviour of comment-dwim, when it inserts comment at the end of the line."
(interactive "*P")
(comment-normalize-vars)
(if (and (not (region-active-p)) (not (looking-at "[ \t]*$")))
(comment-or-uncomment-region (line-beginning-position) (line-end-position))
(comment-dwim arg)))
(global-set-key "\M-;" 'qiang-comment-dwim-line)
;;do what I mean,注释功能
;;###复制一行绑定
(global-set-key (kbd "M-w") 'huangq-save-line-dwim)
;;###autoload
(defun huangq-save-one-line (&optional arg)
"save one line. If ARG, save one line from first non-white."
(interactive "P")
(save-excursion
(if arg
(progn
(back-to-indentation)
(kill-ring-save (point) (line-end-position)))
(kill-ring-save (line-beginning-position) (line-end-position)))))
;;;###autoload
(defun huangq-kill-ring-save (&optional n)
"If region is active, copy region. Otherwise, copy line."
(interactive "p")
(if (and mark-active transient-mark-mode)
(kill-ring-save (region-beginning) (region-end))
(if (> n 0)
(kill-ring-save (line-beginning-position) (line-end-position n))
(kill-ring-save (line-beginning-position n) (line-end-position)))))
;;;###autoload
(defun huangq-save-line-dwim (&optional arg)
"If region is active, copy region.
If ARG is nil, copy line from first non-white.
If ARG is numeric, copy ARG lines.
If ARG is non-numeric, copy line from beginning of the current line."
(interactive "P")
(if (and mark-active transient-mark-mode)
;; mark-active, save region
(kill-ring-save (region-beginning) (region-end))
(if arg
(if (numberp arg)
;; numeric arg, save ARG lines
(huangq-kill-ring-save arg)
;; other ARG, save current line
(huangq-save-one-line))
;; no ARG, save current line from first non-white
(huangq-save-one-line t))))
;;==============================================
(setq time-stamp-active t)
(setq time-stamp-warn-inactive t)
(setq time-stamp-format "%:y-%02m-%02d %3a %02H:%02M:%02S 93free")
;; 设置时间戳,标识出最后一次保存文件的时间。
(setq version-control t)
(setq kept-old-versions 1)
(setq kept-new-versions 2)
(setq delete-old-versions t)
(setq backup-directory-alist '(("." . "~/.emacs.d/tmp")))
(setq backup-by-copying t)
;; Emacs 中,改变文件时,默认都会产生备份文件(以 ~ 结尾的文件)。可以完全去掉
;; (并不可取),也可以制定备份的方式。这里采用的是,把所有的文件备份都放在一
;; 个固定的地方("~/var/tmp")。对于每个备份文件,保留最原始的一个版本和最新的
;; 两个版本。并且备份的时候,备份文件是复本,而不是原件。
(global-font-lock-mode 1)
(setq font-lock-maximum-decoration t)
(setq font-lock-global-modes '(not shell-mode text-mode))
(setq font-lock-verbose t)
(setq font-lock-maximum-size '((t . 1048576) (vm-mode . 5250000)))
;; 语法高亮。除 shell-mode 和 text-mode 之外的模式中使用语法高亮。
(setq git-lock-defer-on-scrolling t)
(setq font-lock-support-mode 'git-lock-mode)
;; 为什么使用语法显示的大文件在移动时如此之慢
(require 'color-theme)
(setq theme-load-from-file t)
;;(color-theme-initialize)
;;(color-theme-sitaramv-nt)
(load-file "~/.emacs.d/lisps/themes/color-theme-tango-light.el")
(load-file "~/.emacs.d/lisps/themes/color-theme-ir-black.el")
(load-file "~/.emacs.d/lisps/themes/color-theme-tango-2.el")
(load-file "~/.emacs.d/lisps/themes/color-theme-subdued.el")
(load-file "~/.emacs.d/lisps/themes/color-theme-irblack-2.el")
(load-file "~/.emacs.d/lisps/themes/zen-and-art.el")
(load-file "~/.emacs.d/lisps/themes/zen-and-art2.el")
;;(if window-system
;; (if (> (caddr (decode-time (current-time))) 18)
;; (color-theme-tango-light) ;白天光线好用黑色系的主题
;; (color-theme-tango-2)) ;晚上光线差用深蓝系的主题
;;(color-theme-tty-dark)
;;)
;;(color-theme-irblack-2)
(color-theme-tango-light)
;;(color-theme-zen-and-art2)
(defun djcb-opacity-modify (&optional dec)
"modify the transparency of the emacs frame; if DEC is t,
decrease the transparency, otherwise increase it in 10%-steps"
(let* ((alpha-or-nil (frame-parameter nil 'alpha)) ; nil before setting
(oldalpha (if alpha-or-nil alpha-or-nil 100))
(newalpha (if dec (- oldalpha 10) (+ oldalpha 10))))
(when (and (>= newalpha frame-alpha-lower-limit) (<= newalpha 100))
(modify-frame-parameters nil (list (cons 'alpha newalpha))))))
;; C-8 will increase opacity (== decrease transparency)
;; C-9 will decrease opacity (== increase transparency
;; C-0 will returns the state to normal
(global-set-key (kbd "C-8") '(lambda()(interactive)(djcb-opacity-modify)))
(global-set-key (kbd "C-9") '(lambda()(interactive)(djcb-opacity-modify t)))
(global-set-key (kbd "C-0") '(lambda()(interactive)
(modify-frame-parameters nil `((alpha . 100)))))
;; shell 和 eshell 相关设置
(setq shell-file-name "/bin/bash")
;; 让 shell mode 可以正常显示颜色
(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
(require 'ansi-color)
;; eshell 的颜色;; 这样可以显示颜色,但是当在文件很多的目录里面显示的时候会很慢
;(add-hook 'eshell-preoutput-filter-functions
; 'ansi-color-apply)
;; 这样直接把颜色滤掉
(add-hook 'eshell-preoutput-filter-functions
'ansi-color-filter-apply)
;; eshell ssh
(defun eshell/ssh (&rest args)
"Secure shell"
(let ((cmd (eshell-flatten-and-stringify
(cons "ssh" args)))
(display-type (framep (selected-frame))))
(cond
((and
(eq display-type 't)
(getenv "STY"))
(send-string-to-terminal (format "\033]83;screen %s\007" cmd)))
((eq display-type 'x)
(eshell-do-eval
(eshell-parse-command
(format "Terminal -e %s &" cmd)))
nil)
(t
(apply 'eshell-exec-visual (cons "ssh" args))))))
(require 'hfyview)
(setq-default kill-whole-line t)
;; 在行首 C-k 时,同时删除该行。
(fset 'yes-or-no-p 'y-or-n-p)
;; 按 y 或空格键表示 yes,n 表示 no。
(auto-compression-mode 1) ; 打开压缩文件时自动解压缩。
(column-number-mode 1) ; 显示列号。
(blink-cursor-mode -1) ; 光标不要闪烁。
(display-time-mode 1) ; 显示时间。
(show-paren-mode 1) ; 高亮显示匹配的括号。
(setq show-paren-style 'parentheses) ; 括号不来回弹跳。
;;(menu-bar-mode -1) ; 不要 menu-bar。
(icomplete-mode 1) ; 给出用 M-x foo-bar-COMMAND 输入命令的提示。
;;(set-scroll-bar-mode 'right) ; scroll-bar 靠右显示。
(scroll-bar-mode -1) ; 不要 scroll-bar
(display-battery-mode 1)
(tool-bar-mode -1) ; 不要 tool-bar。
(global-linum-mode 1) ; 开启行号。
(setq linum-format "%d ")
(autoload 'table-insert "table" "WYGIWYS table editor")
;; 可以识别文本文件里本来就存在的表格,而且可以把表格输出为 HTML 和 TeX。
(autoload 'folding-mode "folding" "Folding mode" t)
(autoload 'turn-off-folding-mode "folding" "Folding mode" t)
(autoload 'turn-on-folding-mode "folding" "Folding mode" t)
;;【folding.el】编辑文本的一部分,将其他部分折叠起来。
;; 设置 sentence-end 可以识别中文标点。不用在 fill 时在句号后插入两个空格。
(setq sentence-end "\\([。!?]\\|……\\|[.?!][]\"')}]*\\($\\|[ \t]\\)\\)[ \t\n]*")
(setq sentence-end-double-space nil)
(load-library "hideshow")
(add-hook 'java-mode-hook 'hs-minor-mode)
(add-hook 'perl-mode-hook 'hs-minor-mode)
(add-hook 'php-mode-hook 'hs-minor-mode)
(add-hook 'emacs-lisp-mode-hook 'hs-minor-mode)
(global-set-key [f5] 'hs-hide-all)
(global-set-key (kbd "M-,") 'hs-toggle-hiding)
;; 代码折叠
(require 'thumbs)
(autoload 'thumbs "thumbs" "Preview images in a directory." t)
(auto-image-file-mode t)
;; 开启图片浏览
(setq tab-width 4 indent-tabs-mode nil)
;; 将tab替换成空格
(setq x-stretch-cursor nil)
;; 如果设置为 t,光标在 TAB 字符上会显示为一个大方块 :)。
;;(require 'un-define) ;;最新版的mule-ucs不自动加载unicode支持,须照此行方法手动载入.
(require 'unicad)
;;(set-language-environment 'utf-8)
(set-keyboard-coding-system 'chinese-gbk)
(modify-coding-system-alist 'file "\\.nfo\\'" 'cp437)
;; 用cp437编码来打开.nfo文件
;;(autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
(setq auto-mode-alist (cons '("\\.asp$" . html-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.phtml$" . html-mode) auto-mode-alist))
;;; cperl-mode is preferred to perl-mode
;;; "Brevity is the soul of wit" <foo at acm.org>
(mapc
(lambda (pair)
(if (eq (cdr pair) 'perl-mode)
(setcdr pair 'cperl-mode)))
(append auto-mode-alist interpreter-mode-alist))
(require 'mmm-mode)
(setq mmm-global-mode 'maybe)
(setq mmm-submode-decoration-level 2)
(set-face-background 'mmm-code-submode-face "#DDEEFF")
(mmm-add-classes
'((php-in-html
:submode php-mode
:face mmm-code-submode-face
:front "<\\?\\(php=?\\)?"
:back "\\?>"
:include-front t
:include-back t)))
(mmm-add-mode-ext-class 'html-mode "\\.php$" 'php-in-html)
(add-hook 'php-mode-user-hook 'turn-on-font-lock)
(add-hook 'html-mode-user-hook 'turn-on-font-lock)
(setq auto-mode-alist
(append '(("\\.py\\'" . python-mode)
("\\.css\\'" . css-mode)
("\\.php\\'" . html-mode)
("\\.tmp\\'" . html-mode)
("\\.html\\'" . html-mode))
auto-mode-alist))
;; 将文件模式和文件后缀关联起来。
(require 'django-html-mode)
(require 'django-mode)
(autoload 'python-mode "python-mode" "Python editing mode." t)
(autoload 'py-shell "python-mode" "Python shell" t)
;;【python-mode.el】www.python.org 上面的 python-mode
;; 显示匹配的括号
(show-paren-mode t)
;; 括号匹配
(global-set-key "%" 'match-paren)
(defun match-paren (arg)
"Go to the matching paren if on a paren; otherwise insert %."
(interactive "p")
(cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
((looking-at "\\s\)") (forward-char 1) (backward-list 1))
(t (self-insert-command (or arg 1)))))
;; 当 % 在括号上按下时,那么匹配括号,否则输入一个 %。
;;(global-set-key "\C-ch" 'highline-mode)
;;(global-set-key "\C-cg" 'global-highline-mode)
;;(global-set-key "\C-cc" 'highline-customize)
;;(global-set-key "\C-cv" 'highline-view-mode)
;;(global-set-key "\C-c2" 'highline-split-window-vertically)
;;(global-set-key "\C-c3" 'highline-split-window-horizontally)
;; 交换两个窗口的内容
;; transpose(interchange) two windows
(defun his-transpose-windows (arg)
"Transpose the buffers shown in two windows."
(interactive "p")
(let ((selector (if (>= arg 0) 'next-window 'previous-window)))
(while (/= arg 0)
(let ((this-win (window-buffer))
(next-win (window-buffer (funcall selector))))
(set-window-buffer (selected-window) next-win)
(set-window-buffer (funcall selector) this-win)
(select-window (funcall selector)))
(setq arg (if (plusp arg) (1- arg) (1+ arg))))))
;; 交换两个窗口内的 buffer
(global-set-key (kbd "C-c l") 'his-transpose-windows)
;; 水木 ilovecpp 给出一个命令,用于切换 mode,很好用。
(global-set-key (kbd "C-c m") 'switch-major-mode)
;; 插入 template
(global-set-key (kbd "C-c t") 'template-expand-template)
;; 这两个命令特别好用,可以根据文件的后缀或者 mode 判断调用的 compile
;; 命令。当目录下有 makefile 自动使用 make 命令。
(global-set-key (kbd "C-c r") 'smart-run)
(global-set-key (kbd "C-c s") 'smart-compile)
;; 最常用的注释命令。
(global-set-key (kbd "C-'") 'comment-dwim)
;; 这个命令配合 comment-dwim 基本上能满足所有的注释命令
(global-set-key (kbd "C-c g") 'comment-or-uncomment-region)
;; imenu 是一个代码跳转的很好用的命令。这个命令在调用 imenu 同时,显示所有补全
(global-set-key (kbd "C-c i") 'his-imenu)
;; 使用外部的浏览器打开光标下的网址
(global-set-key (kbd "C-c o") 'browse-url-at-point)
;; 我写的一个 elisp,树形显示 imenu
(global-set-key (kbd "C-c v") 'my-tr-imenu)
;; Windmove 是在窗口之间移动的很好用的命令。默认是用 Shift+上下左右键移动。
(when (featurep 'windmove)
(global-set-key (kbd "C-c n") 'windmove-down)
(global-set-key (kbd "C-c p") 'windmove-up)
(global-set-key (kbd "C-c ,") 'windmove-left)
(global-set-key (kbd "C-c .") 'windmove-right)
(windmove-default-keybindings))
;;(require 'tex-site)
(require 'compile)
(require 'redo)
(global-set-key ( kbd "C-.") 'redo)
;; 设置Redo的键绑定
(require 'ibuffer)
(global-set-key (kbd "C-x C-b") 'ibuffer)
(require 'browse-kill-ring)
(global-set-key [(control c)(k)] 'browse-kill-ring)
(browse-kill-ring-default-keybindings)
;; 方便的在 kill-ring 里寻找需要的东西。
(require 'ido)
(ido-mode t)
;; 为 view-mode 加入 vim 的按键。
(setq view-mode-hook
(lambda ()
(define-key view-mode-map "h" 'backward-char)
(define-key view-mode-map "l" 'forward-char)
(define-key view-mode-map "j" 'next-line)
(define-key view-mode-map "k" 'previous-line)))
(define-key global-map "\e\e" 'vi-mode) ;quick switch into vi-mode
;;(setq find-file-hook (list
;; (function (lambda ()
;; (if (not (or (eq major-mode 'Info-mode)
;; (eq major-mode 'vi-mode)))
;; (vi-mode))))))
(require 'erc)
;;(require 'erc-list)
;;(require 'erc-nicklist)
(setq erc-encoding-coding-alist (quote (("default" . utf-8))))
;; gnuserv begain
;; -----------------------------------------------
;;(require 'devices)
;;(require 'gnuserv-compat)
;;(require 'gnuserv)
;;(gnuserv-start)
;;(setq gnuserv-frame (selected-frame)) ;在当前frame打开
;;(setenv "GNUSERV_SHOW_EMACS" "1") ;打开后让emacs跳到前面来
;; -----------------------------------------------
;; gnuserv end here
;;(server-start)
(remove-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function)
(global-set-key (kbd "C-x C-k") 'server-edit)
;; tabbar设置
(require 'tabbar)
(require 'tabbar-extension)
(global-set-key (kbd "<S-up>") 'tabbar-backward-group)
(global-set-key (kbd "<S-down>") 'tabbar-forward-group)
(global-set-key (kbd "M-n") 'tabbar-backward)
(global-set-key (kbd "M-p") 'tabbar-forward)
(global-set-key (kbd "<S-left>") 'tabbar-backward)
(global-set-key (kbd "<S-right>") 'tabbar-forward) ; 用 Shift+方向键 切换tab
;;(setq tabbar-buffer-groups-function
;;(lambda ()
;;(list "All Buffers")))
(setq tabbar-buffer-list-function
(lambda ()
(remove-if
(lambda(buffer)
(find (aref (buffer-name buffer) 0) " *"))
(buffer-list))))
(defun tabbar-buffer-groups ()
"Return the list of group names the current buffer belongs to.
Return a list of one element based on major mode."
(list
(cond
((or (get-buffer-process (current-buffer))
;; Check if the major mode derives from `comint-mode' or
;; `compilation-mode'.
(tabbar-buffer-mode-derived-p
major-mode '(comint-mode compilation-mode)))
"Process"
)
((member (buffer-name)
'("*scratch*" "*Messages*"))
"Common"
)
((eq major-mode 'dired-mode)
"Dired"
)
((memq major-mode
'(html-mode php-mode nxml-mode sgml-mode ))
"Webcodes"
)
((memq major-mode
'(python-mode django-mode django-html-mode css-mode javascript-mode js-mode js2-mode))
"Djangocodes"
)
((memq major-mode
'(help-mode apropos-mode Info-mode Man-mode))
"Help"
)
((memq major-mode
'(rmail-mode
rmail-edit-mode vm-summary-mode vm-mode mail-mode
mh-letter-mode mh-show-mode mh-folder-mode
gnus-summary-mode message-mode gnus-group-mode
gnus-article-mode score-mode gnus-browse-killed-mode))
"Mail"
)
(t
;; Return `mode-name' if not blank, `major-mode' otherwise.
(if (and (stringp mode-name)
;; Take care of preserving the match-data because this
;; function is called when updating the header line.
(save-match-data (string-match "[^ ]" mode-name)))
mode-name
(symbol-name major-mode))
))))
(tabbar-mode 1)
;;;; 设置tabbar外观
;; 设置默认主题: 字体, 背景和前景颜色,大小
(set-face-attribute 'tabbar-default nil
;; :family "Vera Sans YuanTi Mono"
:background "gray80"
:foreground "gray30"
:height 0.7
)
;; 设置左边按钮外观:外框框边大小和颜色
(set-face-attribute 'tabbar-button nil
:inherit 'tabbar-default
:box '(:line-width 1 :color "gray30")
)
;; 设置当前tab外观:颜色,字体,外框大小和颜色
(set-face-attribute 'tabbar-selected nil
:inherit 'tabbar-default
:foreground "Black"
:background "#FAD294"
:box '(:line-width 1 :color "#F58400")
;; :overline "black"
;; :underline "black"
:weight 'bold
)
;; 设置非当前tab外观:外框大小和颜色
(set-face-attribute 'tabbar-unselected nil
:inherit 'tabbar-default
:box '(:line-width 1 :color "gray70")
)
;; tabbar end here
(require 'highlight-tail)
(setq highlight-tail-colors
'(("#c1e156" . 0)
("#b8ff07" . 25)
("#00c377" . 60)))
(highlight-tail-mode)
;; 最近打开的文件
;;(setq recentf-max-saved-items nil)
;;(recentf-mode 1)
;;(defvar recentf-open-last-file "" "`recentf-open-files-complete'最近打开的文件")
;;(defun recentf-open-files-complete ()
;; (interactive)
;; (let* ((all-files recentf-list)
;; (default (file-name-nondirectory (directory-file-name recentf-open-last-file)))
;; (collection (mapcar (function (lambda (x) (cons (file-name-nondirectory (directory-file-name x)) x))) all-files))
;; (prompt (if (string= default "") "文件名或目录名: " (format "文件名或目录名(缺省为%s): " default)))
;; (file ""))
;; (while (string= file "")
;; (setq file (completing-read prompt collection nil t nil nil default)))
;; (find-file (setq recentf-open-last-file (cdr (assoc-ignore-representation file collection))))))
;;(global-set-key [(control x)(control r)] 'recentf-open-files-complete-sb)
;;(define-key recentf-dialog-mode-map (kbd "n") 'widget-forward)
;;(define-key recentf-dialog-mode-map (kbd "j") 'widget-forward)
;;(define-key recentf-dialog-mode-map (kbd "p") 'widget-backward)
;;(define-key recentf-dialog-mode-map (kbd "k") 'widget-backward)
;; 记录打开的目录到recentf里面去
;;(defun recentf-add-dir ()
;; "Add directory name to recentf file list."
;; (recentf-add-file dired-directory))
;;(add-hook 'dired-mode-hook 'recentf-add-dir)
;; calendar & planner begain
;; -------------------------------------------
(require 'todo-mode)
(require 'weekly-view)
(require 'cal-china-x)
(setq diary-file "~/.emacs.d/plans/.diary") ;; 默认的日记文件
(add-hook 'diary-display-hook 'fancy-diary-display-week-graph)
(load-library "cal-desk-calendar")
(add-hook 'diary-display-hook 'sort-diary-entries)
(add-hook 'diary-display-hook 'fancy-schedule-display-desk-calendar t)
;; planner
;;(setq muse-project-alist
;; '(("WikiPlanner"
;; ("~/.emacs.d/plans" ;; Or wherever you want your planner files to be
;; :default "index"
;; :major-mode planner-mode
;; :visit-link planner-visit-link))))
;;(require 'planner)
;;(global-set-key (kbd "<f8> p") 'planner-create-task-from-buffer)
;;(setq planner-publishing-directory "~/.emacs.d/plans")
;;;;Start planner together with Calendar
;;(planner-calendar-insinuate)
;;(setq planner-calendar-show-planner-files t)
;; -------------------------------------------
;; calendar & planner end here
(require 'org)
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
;;(define-key global-map "\C-cl" 'org-store-link)
;;(define-key global-map "\C-ca" 'org-agenda)
(setq org-log-done t)
(autoload 'remember "remember" nil t)
(autoload 'remember-region "remember" nil t)
(setq org-reverse-note-order t)
(when (file-exists-p "~/gtd/")
(define-key global-map [(f14)] 'remember)
(setq remember-annotation-functions '(org-remember-annotation))
(setq remember-handler-functions '(org-remember-handler))
(add-hook 'remember-mode-hook 'org-remember-apply-template)
(setq org-directory "~/gtd/")
(setq org-remember-templates
`((?t "* TODO %?\n %i"
,(expand-file-name "todo.org" org-directory) "Tasks")
(?m "* %U\n\n %?%i\n %a"
,(expand-file-name "notes.org" org-directory) "Notes")))
(let ((todo (expand-file-name "todo.org" org-directory)))
(when (file-exists-p todo)
(add-to-list 'org-agenda-files todo))))
;; 自动补全 "hippie-expand"
(global-set-key "\M-/" 'hippie-expand)
(setq hippie-expand-try-functions-list
'(try-expand-dabbrev
try-expand-dabbrev-visible
try-expand-dabbrev-all-buffers
try-expand-dabbrev-from-kill
try-complete-file-name-partially
try-complete-file-name
try-expand-all-abbrevs
try-expand-list
try-expand-line
try-complete-lisp-symbol-partially
try-complete-lisp-symbol))
;; hippie-expand 的补全方式。它是一个优先列表, hippie-expand 会优先使用表最前面的函数来补全。
;; 这个函数是一个 vi 的 "f" 命令的替代品。
(defun wy-go-to-char (n char)
"Move forward to Nth occurence of CHAR.
Typing `wy-go-to-char-key' again will move forwad to the next Nth
occurence of CHAR."
(interactive "p\ncGo to char: ")
(search-forward (string char) nil nil n)
(while (char-equal (read-char)
char)
(search-forward (string char) nil nil n))
(setq unread-command-events (list last-input-event)))
(define-key global-map (kbd "C-c a") 'wy-go-to-char)
;; 有了这段代码之后,当你按 C-c a x (x 是任意一个字符) 时,光标就会到下一个 x 处。
;; 再次按 x,光标就到下一个 x。比如 C-c a w w w w ..., C-c a b b b b b b ...
;; 这两个函数可以分别把一个区域和匹配某个regexp的行都藏起来,就跟不存在一样……
;; hide region
(require 'hide-region)
(global-set-key (kbd "C-c r") 'hide-region-hide)
(global-set-key (kbd "C-c R") 'hide-region-unhide)
;; hide lines
(require 'hide-lines)
;;(global-set-key (kbd "C-c l") 'hide-lines)
(global-set-key (kbd "C-c L") 'show-all-invisible)
;; hide-lines 在操作某些行的时候用起来特别方便。加一个前缀参数可以把不匹配的行都藏起来,只看到匹配的!
;; cedet配置
;;(require 'cedet)
;;(require 'semantic-ia)
;; Enable EDE (Project Management) features
;;(global-ede-mode 1)
;;(semantic-load-enable-excessive-code-helpers)
;;(semantic-load-enable-semantic-debugging-helpers)
;; Enable SRecode (Template management) minor-mode.
;;(global-srecode-minor-mode 1)
;; ecb代码浏览器
;;(require 'ecb-autoloads)
;;(defun ecb ()
;; "启动ecb"
;; (interactive)
;; (ecb-activate)
; (ecb-layout-switch "left9"))
;;(require 'cedet)
;;(require 'ecb)
;;(setq ecb-options-version "2.40")
;;(setq ecb-layout-name "left2")
;;(setq ecb-compile-window-height 10)
;;(add-hook 'ecb-activate-hook
;; (lambda ()
;; (ecb-toggle-compile-window -1)))
;;(setq ecb-vc-enable-support t)
;;(setq ecb-tip-of-the-day nil)
(require 'xcscope)
;; 中国象棋
(require 'chinese-chess-pvc)
;;(require 'ange-ftp)
(require 'tramp)
(setq auto-save-default nil)
(require 'epa) ;;使用EasyPG
;;(require 'zencoding-mode)
;;(add-hook 'html-mode-hook 'zencoding-mode) ;; Auto-start on any markup modes
;; yasnippet
(require 'yasnippet)
(yas/initialize)
(yas/load-directory "~/.emacs.d/lisps/yasnippet/snippets")
(require 'dropdown-list)
(setq yas/prompt-functions '(yas/dropdown-prompt
yas/ido-prompt
yas/completing-prompt))
(require 'auto-complete)
(require 'auto-complete-config)
(require 'ac-anything)
;; dirty fix for having AC everywhere
(define-globalized-minor-mode real-global-auto-complete-mode
auto-complete-mode (lambda ()
(if (not (minibufferp (current-buffer)))
(auto-complete-mode 1))
))
(real-global-auto-complete-mode t)
;;(define-key ac-complete-mode-map "\t" 'ac-expand)
;;(define-key ac-complete-mode-map "\r" 'ac-complete)
(define-key ac-complete-mode-map "\M-n" 'ac-next)
(define-key ac-complete-mode-map "\M-p" 'ac-previous)
(set-default 'ac-sources
'(ac-source-semantic
ac-source-yasnippet
ac-source-abbrev
ac-source-words-in-buffer
ac-source-words-in-all-buffer
ac-source-imenu
ac-source-files-in-current-dir
ac-source-filename))
(defun wl-sudo-find-file (file dir)
(find-file (concat "/sudo:localhost:" (expand-file-name file dir))))
(require 'find-func)
(find-function-setup-keys)
;;session和desktop插件,需要放在最后
;;(require 'session)
;;(add-hook 'after-init-hook 'session-initialize)
;;(desktop-save-mode 1)
;;(setq desktop-save-directory "~/.emacs.d/desktop/")
;;(setq desktop-buffers-not-to-save
;; (concat "\\(" "^nn\\.a[0-9]+\\|\\.log\\|(ftp)\\|^tags\\|^TAGS"
;; "\\|\\.emacs.*\\|\\.diary\\|\\.newsrc-dribble\\|\\.bbdb"
;; "\\)$"))
;;(add-to-list 'desktop-modes-not-to-save 'dired-mode)
;;(add-to-list 'desktop-modes-not-to-save 'Info-mode)
;;(add-to-list 'desktop-modes-not-to-save 'info-lookup-mode)
;;(add-to-list 'desktop-modes-not-to-save 'fundamental-mode)
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(mumamo-background-chunk-major ((((class color) (min-colors 88) (background dark)) nil)))
)