1 Star 0 Fork 2

zhengchen/emacs

forked from latpaw/emacs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
init-editing-utils.el 5.68 KB
一键复制 编辑 原始数据 按行查看 历史
chen bin 提交于 2013-04-03 10:06 . configure smartparens
;; Use evil-mode (strongly recommended) will make this file much smaller!
;;----------------------------------------------------------------------------
;; Some basic preferences
;;----------------------------------------------------------------------------
(setq-default
blink-cursor-delay 0
blink-cursor-interval 0.4
bookmark-default-file "~/.emacs.d/.bookmarks.el"
buffers-menu-max-size 30
case-fold-search t
compilation-scroll-output t
ediff-split-window-function 'split-window-horizontally
ediff-window-setup-function 'ediff-setup-windows-plain
grep-highlight-matches t
grep-scroll-output t
indent-tabs-mode nil
line-spacing 0.2
mouse-yank-at-point t
set-mark-command-repeat-pop t
tooltip-delay 1.5
truncate-lines nil
truncate-partial-width-windows nil
;; no annoying beep on errors
visible-bell t)
(global-auto-revert-mode)
(setq global-auto-revert-non-file-buffers t
auto-revert-verbose nil)
;; But don't show trailing whitespace in SQLi, inf-ruby etc.
(add-hook 'comint-mode-hook
(lambda () (setq show-trailing-whitespace nil)))
(transient-mark-mode t)
(define-key global-map (kbd "RET") 'newline-and-indent)
;;----------------------------------------------------------------------------
;; Zap *up* to char is a more sensible default
;;----------------------------------------------------------------------------
(autoload 'zap-up-to-char "misc" "Kill up to, but not including ARGth occurrence of CHAR.")
(global-set-key (kbd "M-z") 'zap-up-to-char)
(global-set-key (kbd "M-Z") 'zap-to-char)
;;----------------------------------------------------------------------------
;; Don't disable narrowing commands
;;----------------------------------------------------------------------------
(put 'narrow-to-region 'disabled nil)
(put 'narrow-to-page 'disabled nil)
(put 'narrow-to-defun 'disabled nil)
;;----------------------------------------------------------------------------
;; Show matching parens
;;----------------------------------------------------------------------------
(paren-activate) ; activating mic-paren
;;----------------------------------------------------------------------------
;; Fix per-window memory of buffer point positions
;;----------------------------------------------------------------------------
(global-pointback-mode)
;;----------------------------------------------------------------------------
;; Handy key bindings
;;----------------------------------------------------------------------------
;; To be able to M-x without meta
(global-set-key (kbd "C-x C-m") 'execute-extended-command)
(global-set-key (kbd "C-.") 'set-mark-command)
(global-set-key (kbd "C-x C-.") 'pop-global-mark)
;;----------------------------------------------------------------------------
;; Page break lines
;;----------------------------------------------------------------------------
(global-page-break-lines-mode)
;;----------------------------------------------------------------------------
;; Shift lines up and down with M-up and M-down
;;----------------------------------------------------------------------------
(move-text-default-bindings)
;;----------------------------------------------------------------------------
;; Cut/copy the current line if no region is active
;;----------------------------------------------------------------------------
(whole-line-or-region-mode t)
(diminish 'whole-line-or-region-mode)
(make-variable-buffer-local 'whole-line-or-region-mode)
(defun suspend-mode-during-cua-rect-selection (mode-name)
"Add an advice to suspend `MODE-NAME' while selecting a CUA rectangle."
(let ((flagvar (intern (format "%s-was-active-before-cua-rectangle" mode-name)))
(advice-name (intern (format "suspend-%s" mode-name))))
(eval-after-load 'cua-rect
`(progn
(defvar ,flagvar nil)
(make-variable-buffer-local ',flagvar)
(defadvice cua--activate-rectangle (after ,advice-name activate)
(setq ,flagvar (and (boundp ',mode-name) ,mode-name))
(when ,flagvar
(,mode-name 0)))
(defadvice cua--deactivate-rectangle (after ,advice-name activate)
(when ,flagvar
(,mode-name 1)))))))
(suspend-mode-during-cua-rect-selection 'whole-line-or-region-mode)
;;----------------------------------------------------------------------------
;; Random line sorting
;;----------------------------------------------------------------------------
(defun sort-lines-random (beg end)
"Sort lines in region randomly."
(interactive "r")
(save-excursion
(save-restriction
(narrow-to-region beg end)
(goto-char (point-min))
(let ;; To make `end-of-line' and etc. to ignore fields.
((inhibit-field-text-motion t))
(sort-subr nil 'forward-line 'end-of-line nil nil
(lambda (s1 s2) (eq (random 2) 0)))))))
;need install browse-kill-ring
(browse-kill-ring-default-keybindings)
;; show trailing spaces in a programming mod
(add-hook 'prog-mode-hook (lambda () (setq show-trailing-whitespace t)))
;; turns on auto-fill-mode, don't use text-mode-hook becasue for some
;; mode (org-mode for example), this will make the exported document
;; ugly!
(add-hook 'markdown-mode-hook 'turn-on-auto-fill)
(add-hook 'change-log-mode-hook 'turn-on-auto-fill)
(add-hook 'cc-mode-hook 'turn-on-auto-fill)
(global-set-key (kbd "C-c q") 'auto-fill-mode)
;; some project prefer tab, so be it
;; @see http://stackoverflow.com/questions/69934/set-4-space-indent-in-emacs-in-text-mode
(setq-default tab-width 4)
(defun toggle-indent-tab ()
(interactive)
(if indent-tabs-mode
(progn
(setq indent-tabs-mode nil)
)
(progn
(setq indent-tabs-mode t)
(setq indent-line-function 'insert-tab)
)
)
)
(provide 'init-editing-utils)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cowboy13/emacs.git
git@gitee.com:cowboy13/emacs.git
cowboy13
emacs
emacs
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385