所有文章阅读量
UP | HOME

emacs-我的配件

emacs-init1.png

1. 我的全部配置自文件

2. 配置文件目录,及调用相关.

2.1. 1.配置文件加载调用.

  1. 加载文件,在默认的配置文件中加载的文件
    1: (add-to-list 'load-path "~/.emacs.d/loadfile/")
    2: (require '***-***)
    
  2. 想要被加载,插件的.el文件最后一定要proide
    1: (provide '***-***)
    
  3. 关于这些加载项目的差别可以在这个网站查看

2.2. 2.配置文件立即测试,不用重启emacs.

命令 功能
C-x C-e (eval-last-sexp) 光标前面的运行一条语句,立即生效.
M-x eval-buffer 执行当前buffer内的Elisp代码.
M-x eval-region 执行region内的代码
  1. 都是立即生效,可以马上试验一条语句的效果
    1: (setq frame-title-format "emacs@%b") 
    

3. 我的配置文件init.el,主要是引导其他配置文件.

  1: ;; -*- coding: utf-8; lexical-binding: t -*-
  2: ;;pengshao's ~/.emacs.d/init.el
  3: ;;<2025-02-09/Sunday 19:23:31>
  4: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6: 
  7: (defun open-init-file()
  8:   (interactive)
  9:   (find-file "~/.emacs.d/init.el"))
 10: 
 11: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 12: 
 13: 
 14: (require 'package)
 15: (add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/")t)
 16: (add-to-list 'package-archives '("nongnu" . "https://elpa.nongnu.org/nongnu/") t)
 17: (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
 18: (package-initialize)
 19: 
 20: 
 21: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 22: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 23: 
 24: ;;自己的一些小的配置
 25: (add-to-list 'load-path "~/.emacs.d/loadfile/")
 26: 
 27: 
 28: ;;mobileorg配置文件
 29: ;;(require 'pengshao-mobileorg)
 30: 
 31: 
 32: 
 33: ;自动插入天气的配置
 34: (require 'pengshao-openweather)
 35: 
 36: ;;orgmode的全局设置
 37: ;;第一项是链接,第二项是待办事项,第三项是总结
 38: (require 'pengshao-org-mode)
 39: (global-set-key "\C-cl" 'org-store-link)
 40: (global-set-key "\C-cc" 'org-capture)
 41: (global-set-key "\C-ca" 'org-agenda)
 42: ;;这一项好像不用了已经彻底结束了
 43: ;;(global-set-key "\C-cb" 'org-iswitchb)
 44: 
 45: (require 'pengshao-org-publish)
 46: ;;在pengshao-org-publish.el文件当中设置了
 47: ;;(define-key global-map "\C-cp" 'org-publish)
 48: 
 49: 
 50: (require 'pengshao-calendar)
 51: 
 52: 
 53: 
 54: (require 'pengshao-default)
 55: 
 56: (require 'pengshao-backup)
 57: 
 58: (require 'pengshao-insert-date)
 59: 
 60: (require 'pengshao-copy-cut-paste-killring)
 61: 
 62: 
 63: 
 64: 
 65: 
 66: 
 67: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 68: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 69: ;;加载下载的插件
 70: 
 71: 
 72: (add-to-list 'load-path "~/.emacs.d/lisp/")
 73: 
 74: ;;主题插件的配置文件
 75: (require 'color-theme)
 76: (color-theme-initialize)
 77: (color-theme-snow)
 78: 
 79: (require 'iimage)
 80: 
 81: ;;cuamode的cua-rectangle-mark-mode的快捷键
 82: ;;由于与orgmode有冲突,我把C-return改为
 83: (global-set-key (kbd "C-c n") 'cua-rectangle-mark-mode)
 84: 
 85: ;;日历显示农历
 86: (require 'cal-china-x)
 87: (setq calendar-mark-holidays-flag t)
 88: ;; (setq mark-holidays-in-calendar t) ; before emacs-25
 89: (setq cal-china-x-important-holidays cal-china-x-chinese-holidays)
 90: (setq cal-china-x-general-holidays '((holiday-lunar 1 15 "元宵节")))
 91: (setq calendar-holidays
 92:       (append cal-china-x-important-holidays
 93: 	      cal-china-x-general-holidays
 94: 	      ;;other-holidays
 95: 	      ))
 96: 
 97: ;;小小的tabbar-mode
 98: (require 'tabbar)
 99: (tabbar-mode)
100: ;;切换buffer
101: ;;prior就是上翻页pg up,next就是pg dn键盘
102: (global-set-key [C-prior] 'previous-buffer)
103: (global-set-key [C-next] 'next-buffer)
104: ;;Win更换tabbar不错吧,前两个是在不同的分组切换,后面的是在同组切换
105: ;;不知道为什么冲突了
106: ;;(global-set-key [s-up] 'tabbar-backward-group)
107: ;;(global-set-key [s-down] 'tabbar-backward-group)
108: ;;(global-set-key [s-left] 'tabbar-backward-tab)
109: ;;(global-set-key [s-right] 'tabbar-forward-tab)
110: 
111: 
112: 
113: (require 'browse-kill-ring)
114: (global-set-key (kbd "C-c k") 'browse-kill-ring)
115: 
116: 
117: (require 'auto-complete)
118: (require 'auto-complete-config)
119: (add-to-list 'ac-dictionary-directories "~/.emacs.d/lisp/ac-dict/")
120: (ac-config-default)
121: (define-key ac-mode-map (kbd "C-c q") 'auto-complete)
122: 
123: 
124: (require 'sr-speedbar)
125: ;;左侧显示
126: (setq sr-speedbar-right-side nil)     
127: ;;宽度
128: (setq sr-speedbar-width 25)          
129: ;;显示.的头文件
130: (setq speedbar-directory-unshown-regexp "^\(\.\.*$\)\'")
131: ;;窗口跳转跳过sr-speedbar
132: (setq sr-speedbar-skip-other-window-p t)
133: ;;设置快捷键
134: ;(global-set-key [f5] 'sr-speedbar-select-window)
135: (global-set-key [f5] 'sr-speedbar-open)
136: (global-set-key (kbd "C-c s") 'sr-speedbar-open)
137: (global-set-key (kbd "C-c x") 'sr-speedbar-close)
138: ;;开机默认启动speedbar,不用了,现在用sr-speedbar了
139: ;;(speedbar 1)
140: ;;自动打开sr-speedbar
141: ;;不知道为什么太不好用了,每次都多打开一个窗格,所以忽略了,
142: ;;(sr-speedbar-open)
143: 
144: 
145: 
146: 
147: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
148: ;;键盘配置放在最后,只要是配置了F1-F10,和Home/End键
149: ;;所有自己配置的都在init.el了,方便查找
150: 
151: (require 'pengshao-key-building)
152: (custom-set-variables
153:  ;; custom-set-variables was added by Custom.
154:  ;; If you edit it by hand, you could mess it up, so be careful.
155:  ;; Your init file should contain only one such instance.
156:  ;; If there is more than one, they won't work right.
157:  '(org-agenda-files nil)
158:  '(org-safe-remote-resources
159:    '("\\`https://fniessen\\.github\\.io/org-html-themes/setup/theme-readtheorg\\.setup\\'"))
160:  '(package-selected-packages '(json-mode request)))
161: (custom-set-faces
162:  ;; custom-set-faces was added by Custom.
163:  ;; If you edit it by hand, you could mess it up, so be careful.
164:  ;; Your init file should contain only one such instance.
165:  ;; If there is more than one, they won't work right.
166:  )
167: 
168: 
169: 
170: ;; 在 Emacs 启动时清空 *scratch* 缓冲区并插入特定函数代码
171: (setq initial-scratch-message "") ; 清空初始的 *scratch* 消息
172: (with-current-buffer "*scratch*"
173: ;   (let ((result1 (insert-weather)))
174: ;   (insert (format " %s\n" result1)))
175:   (call-interactively 'insert-nongli)
176:   (call-interactively 'insert-weather)
177:   (call-interactively 'insert-pyphoon)
178: 
179:    )

4. 自己自定义的一些配置,啥都有.

 1: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 2: ;; -*- coding: utf-8; lexical-binding: t -*-
 3: ;;pengshao-default.el---默认一小些配置
 4: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 5: 
 6: 
 7: ;; 时间戳使用英文星期
 8: (setq system-time-locale "C")
 9: 
10: ; 东八区(北京时间)
11: (setq calendar-time-zone 8)  
12: 
13: ;; 编码选用 UTF-8
14: (prefer-coding-system 'utf-8)
15: (set-default-coding-systems 'utf-8)
16: (setq default-buffer-file-coding-system 'utf-8)
17: 
18: 
19: ;;关闭起动时的那个“开机画面” 
20: (setq inhibit-startup-message t)
21: 
22: ;;自动显示图片
23: (setq org-startup-with-inline-images t)
24: 
25: 
26: ;;(split-window-below)   ;; 横向分屏
27: ;;(split-window-right)   ;; 纵向分屏
28: 
29: 
30: ;;设置启动时候窗口大小
31: (setq default-frame-alist
32: '((height . 30) (width . 100) (menu-bar-lines . 10) (tool-bar-lines . 10)))
33: 
34: 
35: ;在标题栏提示你目前在什么位置
36: ;(setq frame-title-format "pengshao@%n%b")
37: 
38: 
39: 
40: ;; buffer name (if the buffer isn't visiting a file)
41: (setq frame-title-format
42:       '("" "上古大椿,八千春秋,知途知径,浑然天成."
43: 	(:eval (if (buffer-file-name)
44: 		   (abbreviate-file-name (buffer-file-name)) "%b"))))
45: 
46: ;语法高亮
47: (global-font-lock-mode t)
48: 
49: ;打开图片显示功能
50: (auto-image-file-mode t)
51: 
52: 
53: ;显示列号
54: (column-number-mode t)
55: ;显示行号
56: (global-display-line-numbers-mode t)
57: (setq display-line-numbers-type 'absolute) 
58: 
59: 
60: 
61: ;显示括号匹配
62: (show-paren-mode t)
63: (setq show-paren-style 'parentheses)
64: 
65: ;自动添加括号
66: (electric-pair-mode t)
67: 
68: 
69: ;显示时间,格式如下
70: (display-time-mode 1)
71: (setq display-time-24hr-format t)
72: (setq display-time-day-and-date t)
73: 
74: ;去掉那个大大的工具栏
75: ;;(tool-bar-mode nil)
76: 
77: ;去掉滚动条
78: ;;(scroll-bar-mode nil)
79: 
80: ;支持emacs和外部程序的粘贴
81: (setq x-select-enable-clipboard t)
82: 
83: ;默认显示 80列就换行
84: (setq default-fill-column 80)
85: 
86: ;一打开就起用 text 模式。
87: ;(setq default-major-mode 'text-mode)
88: 
89: ;;eshell增加自动补全
90: ; 忽略大小写进行补全
91: (setq eshell-cmpl-ignore-case t)
92: ; 允许循环补全
93: (setq eshell-cmpl-cycle-completions t)
94: ; 让 pcomplete 支持循环补全
95: (setq pcomplete-cycle-completions t) 
96: 
97: 
98: 
99: (provide 'pengshao-default)

5. org-mode相关的两个配置,第二个是导出静态网站项目配置.

 1: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 2: ;; -*- coding: utf-8; lexical-binding: t -*-
 3: ;;pengshao-org-mode.el---orgmode相关的配置
 4: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 5: 
 6: ;;我的编码设置
 7: (prefer-coding-system 'utf-8)
 8: (set-default-coding-systems 'utf-8)
 9: (set-terminal-coding-system 'utf-8)
10: (set-keyboard-coding-system 'utf-8)
11: (setq default-buffer-file-coding-system 'utf-8)
12: 
13: 
14: ;;org-mode语法高亮
15: (setq org-src-fontify-natively t)
16: 
17: 
18: ;;保证后缀为'.org'的文件会使用Org mode
19: (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
20: 
21: 
22: ;;(global-set-key "\C-cl" 'org-store-link)
23: ;;orgmode的链接
24: 
25: 
26: ;;设置默认的agenda文件,的todo的全局文件可以添加在这里
27: ;;(global-set-key "\C-ca" 'org-agenda)
28: (setq org-agenda-files
29:       (list "~/public_note/idear/list-list.org"
30: 	))
31: 
32: 
33: ;;(global-set-key "\C-cc" 'org-capture)
34: ;;默认的org-notesfile,这里就是org-capture的默认文件
35: (setq org-default-notes-file "~/public_note/idear/todo-list.org")
36: 
37: 
38: ;;每次新建todo和做完都要添加时间
39: ;(setq org-log-todo 'time)
40: ;(setq org-log-done 'time)
41: 
42: 
43: ;;如果不想在全局范围使用font-lock,可以用下面一句配置来只在Org-mode下打开font-lock选项
44: ;;(add-hook 'org-mode-hook 'turn-on-font-lock) 
45: 
46: 
47: 
48: ;;设置org-mode的启动显示选项,#+STARTUP: overview : content : showall : showeverything :
49: (setq org-startup-folded 'content)
50: 
51: ;; prevent editing an invisible part of the buffer防止编辑缓冲区不可见部分
52: (setq org-catch-invisible-edits nil) 
53: 
54: 
55: ;;为org-mode添加自动换行功能
56: (add-hook 'org-mode-hook (lambda () (setq truncate-lines nil)))
57: 
58: ;;为org-mode的(setq org-startup-indented t)缩进星号
59: (setq org-startup-indented t)
60: 
61: ;; 设置 bullet list
62: ;;(setq org-bullets-bullet-list '("☰" "☷" "☯" "☭"))
63: 
64: ;定义多组状态序列,每个“#+SEQ_TODO”行定义一组
65: (setq org-todo-keywords
66:  '((sequence "TODO(T!)" "DOING(H!)"  "|" "DONE(D!)" "CANCELED(C@/!)")
67: 
68:    ))
69: 
70: 
71: ;; org-todo-keyword-faces
72: (setq org-todo-keyword-faces
73:       '(
74: 	("TODO"      . (:foreground "#FF0033" :background "#FFFF33"  :weight bold))
75: 	("CANCELED"  . (:foreground "yellow" :background "#2E8B57"  :weight bold))
76: 	("DOING"     . (:foreground "#990066" :background "#00FF00"  :weight bold))
77: 	))
78: 
79: 
80: ;;'org-tag-faces'
81: (setf org-tag-faces
82:       '(
83: 	("上班" . (:foreground "black" :background "#95A5A6"   :weight bold))
84: 	("休班" . (:foreground "red" :background "#2E8B57"  :weight bold))
85: 	("加班" . (:foreground "white" :background "#3498DB" :weight bold))
86: 	))
87: 
88: 
89: 
90: ;; 折叠时不再显示「...」, 换个你喜欢的符号
91: (setq org-ellipsis "▼")
92: 
93: 
94: 
95: (provide 'pengshao-org-mode)
 1: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 2: ;; -*- coding: utf-8; lexical-binding: t -*-
 3: ;;pengshao-org-publish.el---org-publish相关的配置
 4: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 5: 
 6: (require 'ox-publish)
 7: (setq org-publish-project-alist
 8:       '(
 9: 	 ("psnote-org"
10: 	     :base-directory "~/public_note/"
11: 	     :base-extension "org"
12: 	     :publishing-directory "~/public_site/"
13: 	     :recursive t     ;是否递归
14: 	     :publishing-function org-html-publish-to-html  ;使用哪个函数来进行publish(注:org 7与8在这个地方有区别)
15: 	     :headline-levels 2   ;由于大纲结构也用于列表和任务,因此只有前4个级别用作标题更深的级别会被看作项目列表,我设置的2
16: 	     :auto-preamble t     ;自动前言
17: 	     :section-numbers t ;章节数字是否显示
18: 	     :author "pengshao"   ;作者
19: 	     :email "pengshao58@gmail.com"   ;邮箱
20: 	     :auto-sitemap t                  ; 自动生成 sitemap.org 文件
21: 	     :sitemap-filename "sitemap.org"  ; ... call it sitemap.org (it's the default)...
22: 	     :sitemap-title "PengShao's BLOG!"         ; ... with title
23: 	     ;;:sitemap-file-entry-format "%d %t"   ;这里采用时间+标题的方式生成sitemap 
24: 	     :style-include-default nil  ;禁用默认 css 样式,使用自定义css
25: 
26: 	     ;作为一个字符串给予 html-head 变量并插入到生成的 html 文件的head部
27: 	     ;因此里面的某些字符必须避免转义,比如双引号必须加上反斜杠
28: 	     ;href 的赋值不会做如何转换,因此必须确保是在生成的 html 文件能够访问的绝对路径。
29: 	     ;html-home/up-format"<div id=\"org-div-home-and-up\"> <a accesskey=\"h\" href=\"/home/index.html\"> UP </a> | <a accesskey=\"H\" href=\"/home/index.html\"> HOME </a></div>"
30: 	     ;html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"/home/css/org.css\"/>"
31: 	     ;html-postamble "<script async src=\"https://www.googletagmanager.com/gtag/js?id=UA-164487790-1\"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-164487790-1'); </script>"
32: 	     ;HTML_EXPORT_POSTamble: "<script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"> </script>
33: 
34: 	 )
35: 
36: 
37: 
38: 	 ("psnote-static"
39: 	     :base-directory "~/public_note/"
40: 	     :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf\\|sh\\|el\\|jpeg\\|html"
41: 	     :publishing-directory "~/public_site/"
42: 	     :recursive t
43: 	     :publishing-function org-publish-attachment
44: 	  )
45: 
46: 
47: 	 ("psnote" :components ("psnote-org" "psnote-static"))
48: 
49: 
50: 	))
51: 
52: 
53: (define-key global-map "\C-cp" 'org-publish)
54: 
55: 
56: 
57: 
58: (provide 'pengshao-org-publish)

6. 我比较喜欢在写日记时候加入月相和当地天气

 1: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 2: ;; -*- coding: utf-8; lexical-binding: t -*-
 3: ;;pengshao-einsrt-date.el---插入时间格式相关的配置
 4: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 5: 
 6: 
 7: (defun my-insert-time ()
 8:   (interactive)
 9:   (insert (format-time-string "<%Y-%m-%d/%A %H:%M:%S>" (current-time))))
10: 
11: (global-set-key (kbd "C-c m t") 'my-insert-time)
12: 
13: 
14: 
15: (defun my-insert-date ()
16:   (interactive)
17:   (insert (format-time-string "<%Y-%m-%d-%j/%A>" (current-time))))
18: 
19: (global-set-key (kbd "C-c m d") 'my-insert-date)
20: 
21: 
22: 
23: (defun my-insert-month ()
24:   (interactive)
25:   (insert (format-time-string "<%Y-%B>" (current-time))))
26: 
27: (global-set-key (kbd "C-c m m") 'my-insert-month)
28: 
29: 
30: ;;插入今年的时间进度条
31: (defun make-progress (width percent has-number?)
32:   (let* ((done (/ percent 100.0))
33: 	 (done-width (floor (* width done))))
34:     (concat
35:      "["
36:      (make-string done-width ?/)
37:      (make-string (- width done-width) ? )
38:      "]"
39:      (if has-number? (concat " " (number-to-string percent) "%"))
40:      )))
41: 
42: (defun insert-day-progress ()
43:   (interactive)
44:   (let* ((today (time-to-day-in-year (current-time)))
45: 	 (percent (floor (* 100 (/ today 365.0)))))
46:     (insert (make-progress 30 percent t))
47:     ))
48: 
49: (global-set-key (kbd "C-c m y") 'insert-day-progress)
50: 
51: (add-to-list 'org-src-lang-modes '("plantuml" . plantuml))
52: 
53: 
54: 
55: (provide 'pengshao-insert-date)
 1: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 2: ;; -*- coding: utf-8; lexical-binding: t -*-
 3: ;;pengshao-openweather.el---自动插入天气的教程
 4: ;;<2025-02-08/Saturday 19:32:10>
 5: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 6: 
 7: ;;添加济南天气的操作
 8: (defun insert-weather ()
 9:   (interactive)
10:   (insert (shell-command-to-string "curl wttr.in/jinan?format=4 2> /dev/null")))
11: 
12: 
13: (global-set-key (kbd "C-c m w") #'insert-weather)
14: 
15: 
16: ;;添加月相的操作
17: (defun insert-pyphoon ()
18:   (interactive)
19:   (insert (shell-command-to-string "source ~/mypython/bin/activate && pyphoon")))
20: 
21: 
22: (global-set-key (kbd "C-c m o") #'insert-pyphoon)
23: 
24: 
25: (defun insert-nongli ()
26:   (interactive)
27:   (insert (shell-command-to-string "~/.emacs.d/loadfile/nongli.sh")))
28: 
29: (global-set-key (kbd "C-c m n") #'insert-nongli)
30: 
31: (defun insert-nonglijian ()
32:   (interactive)
33:   (insert (shell-command-to-string "~/.emacs.d/loadfile/nonglijian.sh")))
34: 
35: (global-set-key (kbd "C-c m j") #'insert-nonglijian)
36: 
37: 
38: 
39: (provide 'pengshao-openweather)

6.1. calendar的配置我不太用.

  1: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2: ;; -*- coding: utf-8; lexical-binding: t -*-
  3: ;;pengshao-calendar.el---calendar相关配置(一直没有调试)
  4: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5: 
  6: ;;;;;;;;;;;;;;;;;;;;;;;;;;;; 设置日历 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7: ;;设置日历的一些颜色
  8: (setq calendar-load-hook
  9: '(lambda ()
 10: (set-face-foreground 'diary-face "skyblue")
 11: (set-face-background 'holiday-face "slate blue")
 12: (set-face-foreground 'holiday-face "white")))
 13: 
 14: ;;设置我所在地方的经纬度,calendar里有个功能是日月食的预测,和你的经纬度相联系的。
 15: ;; 让emacs能计算日出日落的时间,在 calendar 上用 S 即可看到
 16: (setq calendar-latitude +36.125)
 17: (setq calendar-longitude +117.786)
 18: (setq calendar-location-name "Laiwu")
 19: 
 20: ;; 设置阴历显示,在 calendar 上用 pC 显示阴历
 21: (setq chinese-calendar-celestial-stem
 22: ["甲" "乙" "丙" "丁" "戊" "己" "庚" "辛" "壬" "癸"])
 23: (setq chinese-calendar-terrestrial-branch
 24: ["子" "丑" "寅" "卯" "辰" "巳" "戊" "未" "申" "酉" "戌" "亥"])
 25: 
 26: ;; 设置 calendar 的显示
 27: (setq calendar-remove-frame-by-deleting t)
 28: ;(setq calendar-week-start-day 1) ; 设置星期一为每周的第一天
 29: (setq mark-diary-entries-in-calendar t) ; 标记calendar上有diary的日期
 30: (setq mark-holidays-in-calendar nil) ; 为了突出有diary的日期,calendar上不标记节日
 31: (setq view-calendar-holidays-initially nil) ; 打开calendar的时候不显示一堆节日
 32: 
 33: ;; 去掉不关心的节日,设定自己在意的节日,在 calendar 上用 h 显示节日
 34: (setq christian-holidays nil)
 35: (setq hebrew-holidays nil)
 36: (setq islamic-holidays nil)
 37: (setq solar-holidays nil)
 38: (setq general-holidays '((holiday-fixed 1 1 "元旦")
 39: (holiday-fixed 2 14 "情人节")
 40: (holiday-fixed 3 14 "白色情人节")
 41: (holiday-fixed 4 1 "愚人节")
 42: (holiday-fixed 5 1 "劳动节")
 43: (holiday-float 5 0 2 "母亲节")
 44: (holiday-fixed 6 1 "儿童节")
 45: (holiday-float 6 0 3 "父亲节")
 46: (holiday-fixed 7 1 "建党节")
 47: (holiday-fixed 8 1 "建军节")
 48: (holiday-fixed 9 10 "教师节")
 49: (holiday-fixed 10 1 "国庆节")
 50: (holiday-fixed 12 25 "圣诞节")))
 51: 
 52: ;;Calendar模式支持各种方式来更改当前日期
 53: ;;(这里的“前”是指还没有到来的那一天,“后”是指已经过去的日子)
 54: ;; q 退出calendar模式
 55: ;; C-f 让当前日期向前一天
 56: ;; C-b 让当前日期向后一天
 57: ;; C-n 让当前日期向前一周
 58: ;; C-p 让当前日期向后一周
 59: ;; M-} 让当前日期向前一个月
 60: ;; M-{ 让当前日期向后一个月
 61: ;; C-x ] 让当前日期向前一年
 62: ;; C-x [ 让当前日期向后一年
 63: ;; C-a 移动到当前周的第一天
 64: ;; C-e 移动到当前周的最后一天
 65: ;; M-a 移动到当前月的第一天
 66: ;; M-e 多动到当前月的最后一天
 67: ;; M-< 移动到当前年的第一天
 68: ;; M-> 移动到当前年的最后一天
 69: 
 70: ;;Calendar模式支持移动多种移动到特珠日期的方式
 71: ;; g d 移动到一个特别的日期
 72: ;; o 使某个特殊的月分作为中间的月分
 73: ;; . 移动到当天的日期
 74: ;; p d 显示某一天在一年中的位置,也显示本年度还有多少天。
 75: ;; C-c C-l 刷新Calendar窗口
 76: 
 77: ;; Calendar支持生成LATEX代码。
 78: ;; t m 按月生成日历
 79: ;; t M 按月生成一个美化的日历
 80: ;; t d 按当天日期生成一个当天日历
 81: ;; t w 1 在一页上生成这个周的日历
 82: ;; t w 2 在两页上生成这个周的日历
 83: ;; t w 3 生成一个ISO-SYTLE风格的当前周日历
 84: ;; t w 4 生成一个从周一开始的当前周日历
 85: ;; t y 生成当前年的日历
 86: 
 87: ;;EMACS Calendar支持配置节日:
 88: ;; h 显示当前的节日
 89: ;; x 定义当天为某个节日
 90: ;; u 取消当天已被定义的节日
 91: ;; e 显示所有这前后共三个月的节日。
 92: ;; M-x holiday 在另外的窗口的显示这前后三个月的节日。
 93: 
 94: 
 95: ;; 另外,还有一些特殊的,有意思的命令:
 96: ;; S 显示当天的日出日落时间(是大写的S)
 97: ;; p C 显示农历可以使用
 98: ;; g C 使用农历移动日期可以使用
 99: 
100: 
101: (provide 'pengshao-calendar)

7. 关于复制粘帖的一些设置

 1: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 2: ;; -*- coding: utf-8; lexical-binding: t -*-
 3: ;;pengshao-copy-cut-paste-killring.el---复制粘帖相关配置
 4: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 5: 
 6: ;不向kill-ring中加入重复内容
 7: (setq kill-do-not-save-duplicates t)
 8: 
 9: ;支持中键粘贴
10: (setq mouse-yank-at-point t)
11: 
12: ;;增大kill-ring-max
13: (setq kill-ring-max 200)
14: 
15: 
16: ;;; 关于没有选中区域,则默认为选中整行的advice
17: ;;;;默认情况下M-w复制一个区域,但是如果没有区域被选中,则复制当前行
18: (defadvice kill-ring-save (before slickcopy activate compile)
19:   "When called interactively with no active region, copy a single line instead."
20:   (interactive
21:    (if mark-active (list (region-beginning) (region-end))
22:      (message "welldone,copy this line")
23:      (list (line-beginning-position)
24: 	   (line-beginning-position 2)))))
25: 
26: 
27: 
28: 
29: (provide 'pengshao-copy-cut-paste-killring)

8. 我的键配置(主要是f1-f10)

 1: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 2: ;; -*- coding: utf-8; lexical-binding: t -*-
 3: ;; pengshao-key-building.el --- 全局键盘绑定设置
 4: ;; 最好放在加载文件的最后,防止被覆盖
 5: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 6: 
 7: 
 8: 
 9: ;;习惯设置,Home键设定光标到文件开头
10: (global-set-key [(home)] 'beginning-of-buffer)
11: ;;习惯设置,End键设定光标到文件结尾
12: (global-set-key [(end)] 'end-of-buffer)
13: 
14: 
15: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16: ;;F1到F10
17: 
18: ;;F1,打开帮助,常用帮助有info和woman(就是在emacs中看man)
19: (global-set-key [f1] 'info)
20: 
21: ;;F2,恢复,
22: (global-set-key [f2] 'undo)
23: 
24: ;;F3,反恢复,
25: ;(global-set-key [f3] 'redo)
26: 
27: ;;F3,快速打开配置文件
28: (global-set-key [f3] 'open-init-file)
29: 
30: 
31: ;;F4,kill当前buffer
32: (global-set-key [f4] 'kill-this-buffer)
33: 
34: ;;F5,speedbar,在init.el设置了
35: ;;(global-set-key [f5] 'sr-speedbar-select-window)
36: ;;(global-set-key (kbd "C-c s") 'sr-speedbar-open)
37: ;;(global-set-key (kbd "C-c x") 'sr-speedbar-close)
38: 
39: ;;F6,dired
40: (global-set-key [f6] 'dired)
41: 
42: ;;F7,eshell,shell,terminal-emulator
43: (global-set-key [f7] 'shell)
44: 
45: ;;;F8,list-bookmarks
46: (global-set-key [f8] 'list-bookmarks)
47: 
48: ;;;F9,bookmark-set
49: (global-set-key [f9] 'bookmark-set)
50: 
51: ;;看新闻组,常用的很,不过更多时间现在sir里
52: ;;(global-set-key [f9] 'gnus)
53: 
54: ;;F10,打开/关闭菜单
55: (global-set-key [f10] 'menu-bar-mode)
56: 
57: ;;编译等,暂时还不常用的设置
58: ;;(global-set-key [f11] 'compile)
59: ;;(global-set-key [f12] 'todo-show)
60: ;;(global-set-key [f12] 'gdb)
61: 
62: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
63: 
64: 
65: 
66: 
67: 
68: 
69: (provide 'pengshao-key-building)

9. 自动备份相关的设置

 1: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 2: ;; -*- coding: utf-8; lexical-binding: t -*-
 3: ;;pengshao-backup.el--备份相关设置
 4: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 5: 
 6: 
 7: (setq
 8:  backup-by-copying t    ;自动备份
 9:  delete-old-versions t ; 自动删除旧的备份文件
10:  kept-new-versions 10   ; 保留最近的50个备份文件
11:  kept-old-versions 2   ; 保留最早的2个备份文件
12:  version-control t    ; 多次备份
13:  ;; 把生成的备份文件放到统一的一个目录,而不在在文件当前目录生成好多 ~ #的文件
14:  ;; 如果你编辑某个文件时 后悔了想恢复成以前的一个版本 你可以到这个目录下找到备份的版本
15: 
16: 
17:  backup-directory-alist `((".*" . "~/emacs.backup/cache/backup_files/")) ;
18:  auto-save-file-name-transforms `((".*" "~/emacs.backup/cache/backup_files/" t))
19:  auto-save-list-file-prefix   "~/emacs.backup/cache/backup_files/saves-")
20: 
21: 
22: 
23: (provide 'pengshao-backup)

10. 一些关于启动的个性化设定,*scratch*和frame-title-format的设置.

10.1. 启动页面*scratch*显示特定内容

将以下代码添加到你的 Emacs 配置文件中:

1: ;; 在 Emacs 启动时清空 *scratch* 缓冲区并插入特定函数代码
2:   (setq initial-scratch-message "") ; 清空初始的 *scratch* 消息
3:   (with-current-buffer "*scratch*"
4:   ;(let ((result1 (insert-weather)))
5:   ;(insert (format " %s\n" result1)))
6:     (call-interactively 'insert-nongli)
7:     (call-interactively 'insert-weather)
8:     (call-interactively 'insert-pyphoon)
9:      )

10.2. frame-title-format设置相关.

  1. 我的设置
    1: ;; buffer name (if the buffer isn't visiting a file)
    2: (setq frame-title-format
    3:       '("" "上古大椿,八千春秋,知途知径,浑然天成."
    4: 	(:eval (if (buffer-file-name)
    5: 		   (abbreviate-file-name (buffer-file-name)) "%b"))))
    
  2. frame-title-format选项相关
    A string is printed verbatim in the mode line except for %-constructs:
    (%-constructs are allowed when the string is the entire mode-line-format
    or when it is found in a cons-cell or a list)
    %b -- print buffer name.      %f -- print visited file name.
    %F -- print frame name.
    %* -- print %, * or hyphen.   %+ -- print *, % or hyphen.
    %& -- is like %*, but ignore read-only-ness.
    %  -- means buffer is read-only and * means it is modified.For a modified read-only buffer, %* gives % and %+ gives *.
    %s -- print process status.
    %p -- print percent of buffer above top of window, or Top, Bot or All.
    %P -- print percent of buffer above bottom of window, perhaps plus Top,or print Bottom or All.
    %m -- print the mode name.
    %n -- print Narrow if appropriate.
    %z -- print mnemonics of buffer, terminal, and keyboard coding systems.
    %Z -- like %z, but including the end-of-line format.
    %[ -- print one [ for each recursive editing level.  %] similar.
    %% -- print %.   %- -- print infinitely many dashes.
    Decimal digits after the % specify field width to which to pad.
    

日期: <2025-02-09/Sunday 18:49:55>

作者: pengshao

Created: 2025-02-17 Mon 23:20

Validate