比较愚钝,前两天才知道有spacemacs这个东东,研究了下,发现确实不错,至少我不需要手动配置N多参数了,还有模式兼容比我之前自己管理要好的多。所以将emacs的配置管理升级为使用spacemacs了
我对emacs-lisp几乎属于完全不懂的地步,原来的管理都是在org-mode下配置的,这个不想更改,因为相关的配置说明或者遇到问题做标注还是很方便的。
直接上配置:
私人配置
(org-babel-load-file (expand-file-name “person.org” “~/emacs_config”))
emacs 初始化配置
.emacs 中的配置
- windows上首先设置HOME路径,如果在环境变量中设置了则不用
- 然后设置配置文件所在目录的路径
- 设置org-mode的路径,在第一次初始化配置的时候,会使用系统自带的org版本,完全初始化成功后,变成安装后的
- 加载配置文件
(setenv "HOME" "C:\\work") (setq user-emacs-directory "~/emacs_config") (setq load-path (cons "~/emacs_config/elpa/org-plus-contrib-20161118" load-path)) (org-babel-load-file (expand-file-name "tips.org" user-emacs-directory))
patch
ntemacs 24的bug:调用grep会出现下面的错误
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
注释掉emacs/24.4/lisp/progmodes/grep.el::470的下列代码
(setenv "GREP_OPTIONS" (concat (getenv "GREP_OPTIONS") " --color=" (if (eq grep-highlight-matches 'always) "always" "auto")))
环境变量
我在很多不同的设备和环境中使用emacs,因此,需要将不同设备的环境,配置下相关工具的位置
shell 配置
windows 下没有bash,这真是一个非常痛苦的事情,这个就是在windows上配置bash的相关内容
(cond
((memq initial-window-system ‘(x w32))
(cond
((memq system-type ‘(windows-nt cygwin))
;(
(message “for windows”)
; (setq exec-path (cons “~/Git/usr/bin” exec-path))
(setq shell-file-name “bash”)
(setenv “PS1” “\\[[\\e[32m\\]\\u@\\h \\[\\e[33m\\]\\w\\[\\e[0m\\]]\\$ “)
(setenv “SHELL” shell-file-name)
;(setenv “CYWIN” “nodosfilewaring”)
(setq explicit-shell-file-name shell-file-name)
;使用方法,把光标移动到要粘贴的地方,然后用按住 Alt + 拖拉鼠标, 选择要拷贝的部分, 抬起鼠标,选择的部分就粘贴到了光标所在位置. 也就是说,一个动作完成 copy & paste 的工作,而且不改变 kill ring 的内容, 用 windows 的术语是剪切板. 和上面的方法类似, 如果按住 Alt + Shift + 拖动鼠标,那么就会完成 cut & paste 的功能.
(defun cygwin-shell()
(interactive)
(shell “*cygwin-shell*”)
; (set-buffer-process-coding-system ‘chinese-gbk-unix ‘chinese-gbk-unix)
(delete-other-windows)
)
;; enable cygwin clear, default set it does not work
(add-hook ‘shell-mode-hook ‘n-shell-mode-hook)
(defun n-shell-mode-hook ()
“12Jan2002 – sailor, shell mode customizations.”
(local-set-key ‘[up] ‘comint-previous-input)
(local-set-key ‘[down] ‘comint-next-input)
(local-set-key ‘[(shift tab)] ‘comint-next-matching-input-from-input)
(setq comint-input-sender ‘n-shell-simple-send)
)
(defun n-shell-simple-send (proc command)
“17Jan02 – sailor. Various commands pre-processing before sending to shell.”
(cond
;; Checking for clear command and execute it.
((string-match “^[ \t]*clear[ \t]*$” command)
(comint-send-string proc “\n”)
(erase-buffer)
)
;; Checking for man command and execute it.
((string-match “^[ \t]*man[ \t]*” command)
(comint-send-string proc “\n”)
(setq command (replace-regexp-in-string “^[ \t]*man[ \t]*” “” command))
(setq command (replace-regexp-in-string “[ \t]+$” “” command))
;;(message (format “command %s command” command))
(funcall ‘man command)
)
;; Send other commands to the default handler.
(t (comint-simple-send proc command))
)
)
(make-local-variable ‘comint-completion-addsuffix)
(setq comint-completion-addsuffix ‘(“/” . “”))
;; This variable is local to buffer
(setq comint-prompt-regexp “^[ \n\t]*[$] ?”)
)
((memq system-type ‘(gnu/linux)) (message “for linux”))
)))
其他内容
(setq abbrev-file-name “~/.emacs.d/.abbrev_defs”)
(setq abbreviated-home-dir nil)
(defvar ywb-emacs-lisp-path
(expand-file-name (concat data-directory “../site-lisp/”)))
(global-auto-revert-mode 1)
linux交换按键
win键盘实在难用,即使在spacemacs下,我也不想使用小手指来按ctrl键
clear Mod4 clear Control !! keySym 格式 !! keysym 原按键 = 修改后的按键 keysym Control_L = Super_L keysym Super_L = Control_L !!keysym Control_R = Super_R keysym Super_R = Control_R add Mod4 = Super_L Super_R add Control = Control_L Control_R
密码过期时间
(setq password-cache-expiry nil)
目录设置
(setq diary-file “~/.emacs.d/diary”)
(setq todo-file-do “~/.emacs.d/todo-do”)
(setq todo-file-done “~/.emacs.d/todone-done”)
(setq todo-file-top “~/.emacs.d/todone-top”)
spacemacs 设置
将最近打开的文件保存在默认的.emacs.d下,这样不同设备上就不会产生干扰。
将elpa配置到和配置文件指定的目录,使用同步工具进行同步在不同的设备上都不用重复下载了。
(setq dotspacemacs-configuration-layer-path “~/emacs_config”)
(setq recentf-save-file (expand-file-name “recentf” “.emacs.d”))
(setq dotspacemacs-elpa-https nil)
(setq dotspacemacs-check-for-update nil)
(setq package-user-dir (concat user-emacs-directory “/elpa”))
(setenv “SPACEMACSDIR” user-emacs-directory)
(setq spacemacs-start-directory (concat user-emacs-directory “/spacemacs/”))
(load-file (concat spacemacs-start-directory “init.el”))
快捷键设置
(global-set-key [f2] ‘shell)
(global-set-key [f3] ‘grep-find)
软件
org2blog
我用这个来写blog的
(global-set-key (kbd “
org2blog 使用wordpress的code方式
#+ATTR_WP: :syntaxhl light=true
分页
#+HTML: <span id="more-1842"></span>