我的init.el和各种启动配置

1. 我的全部配置自文件
2. 配置文件目录,及调用相关.
2.1. 1.配置文件加载调用.
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: (setq package-archives 16: '(("gnu" . "https://elpa.gnu.org/packages/") 17: ("melpa" . "https://melpa.org/packages/"))) 18: (package-initialize) 19: 20: 21: ;;允许升级内建包 22: (setq package-install-upgrade-built-in t) 23: 24: 25: 26: 27: 28: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 29: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 30: 31: ;;自己的一些小的配置 32: (add-to-list 'load-path "~/.emacs.d/loadfile/") 33: 34: 35: ;;mobileorg配置文件 36: ;;(require 'pengshao-mobileorg) 37: 38: 39: ;默认的配置文件 40: (require 'pengshao-default) 41: 42: ;字符串处理库 43: (require 's) 44: 45: ;自动插入天气的配置,月相,农历两个shellscript的,el文件 46: (require 'pengshao-openweather) 47: 48: ;自动插入名人名言 49: (require 'pengshao-insert-think-deep) 50: 51: 52: ;调用翻译 53: (require 'pengshao-translate) 54: 55: 56: ;;orgmode的全局设置 57: ;;第一项是链接,第二项是待办事项,第三项是总结 58: (require 'pengshao-org-mode) 59: (global-set-key "\C-cl" 'org-store-link) 60: (global-set-key "\C-cc" 'org-capture) 61: (global-set-key "\C-ca" 'org-agenda) 62: ;;这一项好像不用了已经彻底结束了 63: ;;(global-set-key "\C-cb" 'org-iswitchb) 64: 65: (require 'pengshao-org-publish) 66: ;;在pengshao-org-publish.el文件当中设置了 67: ;;(define-key global-map "\C-cp" 'org-publish) 68: 69: 70: (require 'pengshao-calendar) 71: 72: (require 'pengshao-backup) 73: 74: (require 'pengshao-insert-date) 75: 76: (require 'pengshao-copy-cut-paste-killring) 77: 78: 79: 80: 81: 82: 83: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 84: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 85: ;;加载下载的插件 86: 87: 88: (add-to-list 'load-path "~/.emacs.d/lisp/") 89: 90: 91: (require 'magit) 92: (global-set-key (kbd "C-c m g") 'magit-status) ; 绑定快捷键 93: (setq magit-git-executable "/usr/bin/git") ; 指定Git路径 94: 95: ;;主题插件的配置文件 96: (require 'color-theme) 97: (color-theme-initialize) 98: (color-theme-snow) 99: 100: (require 'iimage) 101: 102: ;;cuamode的cua-rectangle-mark-mode的快捷键 103: ;;由于与orgmode有冲突,我把C-return改为 104: (global-set-key (kbd "C-c n") 'cua-rectangle-mark-mode) 105: 106: ;;日历显示农历 107: (require 'cal-china-x) 108: (setq calendar-mark-holidays-flag t) 109: ;; (setq mark-holidays-in-calendar t) ; before emacs-25 110: (setq cal-china-x-important-holidays cal-china-x-chinese-holidays) 111: (setq cal-china-x-general-holidays '((holiday-lunar 1 15 "元宵节"))) 112: (setq calendar-holidays 113: (append cal-china-x-important-holidays 114: cal-china-x-general-holidays 115: ;;other-holidays 116: )) 117: 118: ;;小小的tabbar-mode 119: (require 'tabbar) 120: (tabbar-mode) 121: ;;切换buffer 122: ;;prior就是上翻页pg up,next就是pg dn键盘 123: (global-set-key [C-prior] 'previous-buffer) 124: (global-set-key [C-next] 'next-buffer) 125: ;;Win更换tabbar不错吧,前两个是在不同的分组切换,后面的是在同组切换 126: ;;不知道为什么冲突了 127: ;;(global-set-key [s-up] 'tabbar-backward-group) 128: ;;(global-set-key [s-down] 'tabbar-backward-group) 129: ;;(global-set-key [s-left] 'tabbar-backward-tab) 130: ;;(global-set-key [s-right] 'tabbar-forward-tab) 131: 132: 133: 134: (require 'browse-kill-ring) 135: (global-set-key (kbd "C-c k") 'browse-kill-ring) 136: 137: 138: (require 'auto-complete) 139: (require 'auto-complete-config) 140: (add-to-list 'ac-dictionary-directories "~/.emacs.d/lisp/ac-dict/") 141: (ac-config-default) 142: (define-key ac-mode-map (kbd "C-c q") 'auto-complete) 143: 144: (require 'org-tempo) 145: 146: (require 'sr-speedbar) 147: ;;左侧显示 148: (setq sr-speedbar-right-side nil) 149: ;;宽度 150: (setq sr-speedbar-width 25) 151: ;;显示.的头文件 152: (setq speedbar-directory-unshown-regexp "^\(\.\.*$\)\'") 153: ;;窗口跳转跳过sr-speedbar 154: (setq sr-speedbar-skip-other-window-p t) 155: ;;设置快捷键 156: ;(global-set-key [f5] 'sr-speedbar-select-window) 157: (global-set-key [f5] 'sr-speedbar-open) 158: (global-set-key (kbd "C-c s") 'sr-speedbar-open) 159: (global-set-key (kbd "C-c x") 'sr-speedbar-close) 160: ;;开机默认启动speedbar,不用了,现在用sr-speedbar了 161: ;;(speedbar 1) 162: ;;自动打开sr-speedbar 163: ;;不知道为什么太不好用了,每次都多打开一个窗格,所以忽略了, 164: ;;(sr-speedbar-open) 165: 166: 167: 168: 169: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 170: ;;键盘配置放在最后,只要是配置了F1-F10,和Home/End键 171: ;;所有自己配置的都在init.el了,方便查找 172: 173: (require 'pengshao-key-building) 174: (custom-set-variables 175: ;; custom-set-variables was added by Custom. 176: ;; If you edit it by hand, you could mess it up, so be careful. 177: ;; Your init file should contain only one such instance. 178: ;; If there is more than one, they won't work right. 179: '(org-agenda-files nil) 180: '(org-safe-remote-resources 181: '("\\`https://fniessen\\.github\\.io/org-html-themes/setup/theme-readtheorg\\.setup\\'")) 182: '(package-selected-packages '(magit seq json-mode request))) 183: (custom-set-faces 184: ;; custom-set-faces was added by Custom. 185: ;; If you edit it by hand, you could mess it up, so be careful. 186: ;; Your init file should contain only one such instance. 187: ;; If there is more than one, they won't work right. 188: ) 189: 190: 191: 192: ;; 在 Emacs 启动时清空 *scratch* 缓冲区并插入特定函数代码 193: (setq initial-scratch-message "") ; 清空初始的 *scratch* 消息 194: (with-current-buffer "*scratch*" 195: ; (let ((result1 (insert-weather))) 196: ; (insert (format " %s\n" result1))) 197: (call-interactively 'insert-nongli) 198: (call-interactively 'insert-weather) 199: (call-interactively 'insert-pyphoon) 200: (call-interactively 'insert-think-deep) 201: )
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: (set-terminal-coding-system 'utf-8) 17: (set-keyboard-coding-system 'utf-8) 18: (setq default-buffer-file-coding-system 'utf-8) 19: 20: ;;关闭起动时的那个“开机画面” 21: (setq inhibit-startup-message t) 22: 23: ;;开始启动历史文件记录 24: (recentf-mode 1) 25: (global-set-key (kbd "C-c m h") 'recentf-open-files) 26: 27: ;;自动显示图片 28: (setq org-startup-with-inline-images t) 29: 30: 31: ;;(split-window-below) ;; 横向分屏 32: ;;(split-window-right) ;; 纵向分屏 33: 34: 35: ;;设置启动时候窗口大小 36: (setq default-frame-alist 37: '((height . 30) (width . 100) (menu-bar-lines . 10) (tool-bar-lines . 10))) 38: 39: 40: ;在标题栏提示你目前在什么位置 41: ;(setq frame-title-format "pengshao@%n%b") 42: 43: 44: 45: ;; buffer name (if the buffer isn't visiting a file) 46: (setq frame-title-format 47: '("" "上古大椿,八千春秋,知途知径,浑然天成." 48: (:eval (if (buffer-file-name) 49: (abbreviate-file-name (buffer-file-name)) "%b")))) 50: 51: ;语法高亮 52: (global-font-lock-mode t) 53: 54: ;打开图片显示功能 55: (auto-image-file-mode t) 56: 57: 58: ;显示列号 59: (column-number-mode t) 60: ;显示行号 61: (global-display-line-numbers-mode t) 62: (setq display-line-numbers-type 'absolute) 63: 64: 65: 66: ;显示括号匹配 67: (show-paren-mode t) 68: (setq show-paren-style 'parentheses) 69: 70: ;自动添加括号 71: (electric-pair-mode t) 72: 73: 74: ;显示时间,格式如下 75: (display-time-mode 1) 76: (setq display-time-24hr-format t) 77: (setq display-time-day-and-date t) 78: 79: ;去掉那个大大的工具栏 80: ;;(tool-bar-mode nil) 81: 82: ;去掉滚动条 83: ;;(scroll-bar-mode nil) 84: 85: ;支持emacs和外部程序的粘贴 86: (setq x-select-enable-clipboard t) 87: 88: ;默认显示 80列就换行 89: (setq default-fill-column 80) 90: 91: ;一打开就起用 text 模式。 92: ;(setq default-major-mode 'text-mode) 93: 94: ;;eshell增加自动补全 95: ; 忽略大小写进行补全 96: (setq eshell-cmpl-ignore-case t) 97: ; 允许循环补全 98: (setq eshell-cmpl-cycle-completions t) 99: ; 让 pcomplete 支持循环补全 100: (setq pcomplete-cycle-completions t) 101: 102: 103: 104: (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: ;;这个设置在init.el文件中. 35: ;;默认的org-notesfile,这里就是org-capture的默认文件 36: (setq org-default-notes-file "~/personal_note/todo-list.org") 37: (setq org-capture-templates 38: '(("t" "Todo item" entry 39: (file+headline "~/personal_note/todo-list.org" "Tasks") 40: "* TODO %?\n SCHEDULED: %T\n %i\n %a\n Created: %U") 41: 42: ("w" "Web link" entry 43: (file+headline "~/public_note/share/mybookmarks.org" "bookmarks-temp") 44: "* %? :WEB:\n [[https://%^{URL}][%^{Description}]]\n:PROPERTIES:\n:Description: %^{Description}\n:END:") 45: 46: ("a" "Article excerpt" entry 47: (file "~/personal_note/article-excerpt.org") ; 直接插入文件根层级 48: "* %^{输入标题} :ARTICLE:\n:PROPERTIES:\n:描述: %^{描述}\n:来源: %^{来源}\n:插入时间: %U\n:END:" 49: :empty-lines 1) 50: 51: ("s" "Personal statement" entry 52: (file+headline "~/personal_note/personal-statement.org" "think-temp") 53: "* %? :STATEMENT:\n:PROPERTIES:\n:Thought: %^{Thought}\n:END:")) 54: ) 55: 56: ;;每次新建todo和做完都要添加时间 57: ;(setq org-log-todo 'time) 58: ;(setq org-log-done 'time) 59: 60: 61: ;;如果不想在全局范围使用font-lock,可以用下面一句配置来只在Org-mode下打开font-lock选项 62: ;;(add-hook 'org-mode-hook 'turn-on-font-lock) 63: 64: 65: 66: ;;设置org-mode的启动显示选项,#+STARTUP: overview : content : showall : showeverything : 67: (setq org-startup-folded 'content) 68: 69: ;; prevent editing an invisible part of the buffer防止编辑缓冲区不可见部分 70: (setq org-catch-invisible-edits nil) 71: 72: 73: ;;为org-mode添加自动换行功能 74: (add-hook 'org-mode-hook (lambda () (setq truncate-lines nil))) 75: 76: ;;为org-mode的(setq org-startup-indented t)缩进星号 77: (setq org-startup-indented t) 78: 79: ;; 设置 bullet list 80: ;;(setq org-bullets-bullet-list '("☰" "☷" "☯" "☭")) 81: 82: ;定义多组状态序列,每个“#+SEQ_TODO”行定义一组 83: (setq org-todo-keywords 84: '((sequence "TODO(T!)" "DOING(H!)" "|" "DONE(D!)" "CANCELED(C@/!)") 85: 86: )) 87: 88: 89: ;; org-todo-keyword-faces 90: (setq org-todo-keyword-faces 91: '( 92: ("TODO" . (:foreground "#FF0033" :background "#FFFF33" :weight bold)) 93: ("CANCELED" . (:foreground "yellow" :background "#2E8B57" :weight bold)) 94: ("DOING" . (:foreground "#990066" :background "#00FF00" :weight bold)) 95: )) 96: 97: 98: ;;'org-tag-faces' 99: (setf org-tag-faces 100: '( 101: ("上班" . (:foreground "black" :background "#95A5A6" :weight bold)) 102: ("休班" . (:foreground "red" :background "#2E8B57" :weight bold)) 103: ("加班" . (:foreground "white" :background "#3498DB" :weight bold)) 104: )) 105: 106: 107: 108: ;; 折叠时不再显示「...」, 换个你喜欢的符号 109: (setq org-ellipsis "▼") 110: 111: 112: 113: (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: (global-set-key (kbd "C-c m o") #'insert-pyphoon) 22: 23: 24: (defun insert-nongli () 25: (interactive) 26: (insert (shell-command-to-string "~/.emacs.d/loadfile/nongli.sh"))) 27: 28: (global-set-key (kbd "C-c m n") #'insert-nongli) 29: 30: (defun insert-nonglijian () 31: (interactive) 32: (insert (shell-command-to-string "~/.emacs.d/loadfile/nonglijian.sh"))) 33: 34: (global-set-key (kbd "C-c m j") #'insert-nonglijian) 35: 36: 37: ;; 定义一个函数来插入 MOON-TODAY drawer 并调用 insert-pyphoon 函数 38: (defun insert-moon-today-drawer-with-pyphoon () 39: "Insert a MOON-TODAY drawer at the current line and call insert-pyphoon inside it." 40: (interactive) 41: (insert ":MOON-TODAY:\n") 42: (call-interactively 'insert-pyphoon) 43: (insert ":END:\n")) 44: 45: ;; 绑定快捷键 C-c m c 到 insert-moon-today-drawer-with-pyphoon 函数 46: (add-hook 'org-mode-hook 47: (lambda () 48: (local-set-key (kbd "C-c m c") 'insert-moon-today-drawer-with-pyphoon))) 49: 50: (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: ;; 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"))))
- 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.