Skip to content

Instantly share code, notes, and snippets.

@TheWaWaR
Last active August 29, 2015 14:18
Show Gist options
  • Save TheWaWaR/2888a2bcf6237dcd5ee6 to your computer and use it in GitHub Desktop.
Save TheWaWaR/2888a2bcf6237dcd5ee6 to your computer and use it in GitHub Desktop.
Simple emacs config file
;;;;;;;;;;;;;;; Install Emacs24.4 ;;;;;;;;;;;;;;
;; wget http://ftp.gnu.org/gnu/emacs/emacs-24.4.tar.xz
;; tar Jxf emacs-24.4.tar.xz
;; cd emacs-24.4
;; ./configure --with-x=no --with-x-toolkit=no --with-xpm=no --with-jpeg=no --with-png=no --with-gif=no --with-tiff=no
;; make
;; sudo make install
(ido-mode)
(winner-mode)
(progn
(global-set-key (kbd "C-c ;") 'delete-other-windows)
(global-set-key (kbd "C-c 8") 'eshell)
(global-set-key (kbd "C-c 7") 'sql-mysql)
(global-set-key (kbd "C-c '") 'winner-undo)
(global-set-key (kbd "C-c \"") 'winner-redo)
(global-set-key (kbd "C-c g") 'my-find-grep)
(global-set-key (kbd "C-c t") 'datetime)
(global-set-key (kbd "C-c j") 'set-mark-command)
(global-set-key (kbd "C-c d") 'dired)
(global-set-key (kbd "C-x <left>") 'windmove-left)
(global-set-key (kbd "C-x <right>") 'windmove-right)
(global-set-key (kbd "C-x <up>") 'windmove-up)
(global-set-key (kbd "C-x <down>") 'windmove-down)
(global-set-key (kbd "C-x m") 'eshell)
)
(defun datetime ()
(interactive)
(insert (format-time-string "[%Y-%m-%d %H:%M]")))
;;; Copy from grep.el.gz -> grep-find function
(defun my-find-grep (command-args)
(interactive
(progn
(grep-compute-defaults)
(setq file-regx (read-string "File regx: "))
(setq str-regx (read-string "String regx: "))
(setq my-grep-find-command
(format "find . -type f \\( -name \"%s\" \\) -exec egrep -nH -e \"%s\" {} +"
file-regx str-regx))
(if my-grep-find-command
(list (read-shell-command "Run find (like this): "
my-grep-find-command 'grep-find-history))
;; No default was set
(read-string
"compile.el: No `grep-find-command' command available. Press RET.")
(list nil))))
(when command-args
(let ((null-device nil)) ; see grep
(grep command-args))))
;;;; Eshell 命令绑定
;; cls 清屏
(defun eshell/cls()
"to clear the eshell buffer."
(interactive)
(let ((inhibit-read-only t))
(erase-buffer)))
;; 打开文件
(defun eshell/em (&rest files)
(let ((the-files (if (listp (car files))
(car files)
files)))
(eshell-printn (format "Edit: %S" the-files))
(while the-files (find-file (pop the-files)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment