;;-*- mode: lisp; coding: utf-8 -*-
;; Tested Emacs version: 23.1.1, 23.2, 24.3
;;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;; Convention
;;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;; ; - turn on or off some feature by add or erase it
;; ;; - remark (should not be ereased)
;; ;;o;; - obsolete (used for mark obsolete version)
;; ;;^^^ - region begin
;; ;;{
{-- - group begin
;; ;;[[-- - section begin
;; ;;((-- - subsection begin
;; ;;<<-- - item begin
;; ;;-- - entry
;; ;;-->> - item end
;; ;;--)) - subsection end
;; ;;--]] - section end
;; ;;--}} - group end
;; ;;vvv - region end
;;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;; Prepare Setup
;;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(defgroup myemacs nil
"group myemacs"
:group 'local
:prefix 'myemacs)
;;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;; Subroutines
;;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;;-->>Path Parse
(defun fun-path (path)
"substitute enviroment varibles in path"
(substitute-in-file-name path)
)
(defun fun-path-list (path-list)
"parse path list"
(let (value)
(dolist (elt path-list value)
(setq value (cons (fun-path elt) value))
)
)
)
;;-->>Maximize Frame
(defun fun-x-maximize-frame()
"Maximize the current frame for X"
(interactive)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0)
)
(x-send-client-message
nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0)
)
)
(defun fun-w32-maximize-frame()
"Maximize the current frame for MS-Windows"
(interactive)
(w32-send-sys-command 61488)
)
(defun fun-maximize-frame()
(interactive)
(cond
((eq window-system 'x)
(fun-x-maximize-frame))
((eq window-system 'w32)
(fun-w32-maximize-frame))
((eq window-system 'nil)
())
)
)
;;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;; Env
;;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;;HOME DIRECTORY : set at HKEY_LOCAL_MACHINE\SOFTWARE\GNU\Emacs\HOME or enviroment variable "HOME"
;;when Emacs start, it load .emacs under HOME DIRECTORY or with arguments `--no-init-file --load PATH/.emacs'
(when (eq system-type 'windows-nt)
(setenv "SOFT_DRIVE" "D:")
(setenv "WORK_DRIVE" "E:")
;;use the enviroment variable "HOME" to load .emacs;we can set it to a new directory as the new home
(setenv "SOFTWARE" (fun-path "$SOFT_DRIVE/software"))
(setenv "HOME" (fun-path "$SOFTWARE/home"))
(setenv "WINLINUX" (fun-path "$SOFTWARE/winlinux"))
(setenv "MINGW" (fun-path "$SOFTWARE/MinGW"))
;;use env("PATH") to search program , such as eshell
(setenv "PATH" (concat (fun-path (concat
"$WINLINUX/emacs-23.2/bin;"
"$WINLINUX/cscope;"
"$WINLINUX/shell.w32-ix86;"
"$WINLINUX/win-bash_0_6;"
"$WINLINUX/unzip-5.51-1-bin/bin;"
"$WINLINUX/llvm/bin;"
"$WINLINUX/clang/bin;"
"$WINLINUX/w3m;"
"$WINLINUX/ISpell;"
)) (getenv "PATH")))
)
(defun fun-setup-dir ()
"setup directory based on OS"
(cond
((eq system-type 'gnu/linux)
(progn
(setenv "SRC" "~/src")
(setenv "DOC" "~/doc")
))
((eq system-type 'windows-nt)
(progn
(setenv "SRC" (fun-path "$WORK_DRIVE/src"))
(setenv "DOC" (fun-path "$WORK_DRIVE/doc"))
))
(t (error "not supported os"))
)
(setenv "EMACSD" (directory-file-name (file-name-directory load-file-name)))
(message "env EMACSD : %s" (getenv "EMACSD"))
(setq myemacsd (getenv "EMACSD"))
(setq mylispd (concat myemacsd "/site-lisp"))
(setenv "ISPELL_DICT" (fun-path "$EMACSD/data/ISpell"))
(setenv "KERNEL_SRC" (fun-path"$SRC/linux-2.6.32.60"))
)
(fun-setup-dir)
;;--Include Path List
(defun fun-myemacs-include-dir-list-project ()
"return list of project include directories"
(list
"../include/"
"include/"
))
(defun fun-myemacs-include-dir-list-system ()
"return list of system include directories, which usually are output of `echo "" | gcc -v -x c++ -E -'"
(cond
((eq system-type 'windows-nt) (split-string "
d:/software/mingw/bin/../lib/gcc/mingw32/4.8.1/include/c++
d:/software/mingw/bin/../lib/gcc/mingw32/4.8.1/include/c++/mingw32
d:/software/mingw/bin/../lib/gcc/mingw32/4.8.1/include/c++/backward
d:/software/mingw/bin/../lib/gcc/mingw32/4.8.1/include
d:/software/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../include
d:/software/mingw/bin/../lib/gcc/mingw32/4.8.1/include-fixed
d:/software/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/include
"))
((eq system-type 'gnu/linux) (split-string "
/usr/lib/gcc/i686-redhat-linux/4.4.5/../../../../include/c++/4.4.5
/usr/lib/gcc/i686-redhat-linux/4.4.5/../../../../include/c++/4.4.5/i686-redhat-linux
/usr/lib/gcc/i686-redhat-linux/4.4.5/../../../../include/c++/4.4.5/backward
/usr/local/include
/usr/lib/gcc/i686-redhat-linux/4.4.5/include
/usr/include
"))
)
)
(defun fun-myemacs-include-dir-list-kernel ()
"return list of kernel include directories"
(if (file-exists-p (getenv "KERNEL_SRC"))
(fun-path-list '(
"$KERNEL_SRC/include"
"$KERNEL_SRC/arch/x86/include"
))
nil
)
)
(defcustom myemacs-include-dir-list-system (fun-myemacs-include-dir-list-system)
"system include dirs"
:type '(repeat string)
:group 'myemacs
)
(defcustom myemacs-include-dir-list-project (fun-myemacs-include-dir-list-project)
"system include dirs"
:type '(repeat string)
:group 'myemacs
)
(defcustom myemacs-include-dir-list-kernel (fun-myemacs-include-dir-list-kernel)
"system include dirs"
:type '(repeat string)
:group 'myemacs
)
(defun fun-get-system-include-dir-list ()
(let (
(value)
(dir-list-list '(
myemacs-include-dir-list-system
myemacs-include-dir-list-project
myemacs-include-dir-list-kernel
)))
(dolist (dir-list dir-list-list value)
(when (boundp dir-list)
(setq value (append value (symbol-value dir-list)))
)
)
)
)
(setq system-include-dir-list (fun-get-system-include-dir-list))
;;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;;Common (group based on `GNU Emacs Manual')
;;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;;======================================
;;{
{-- Important General Concepts
;;[[--Entering Emacs
;;You can also force Emacs to display a file or directory at startup by setting the variable `initial-buffer-choice' to a non-`nil' value.(In that case, even if you specify one or more files on the command line, Emacs opens but does not display them.)
;(setq initial-buffer-choice t) ;;The value of `initial-buffer-choice' can be either the name of the desired file or directory, or `t', which means to display the `*scratch*' buffer.
(setq inhibit-startup-screen t) ;;If the variable `inhibit-startup-screen' is non-`nil', Emacs does not display the startup screen.
;;[[-- Exiting Emacs
;;If the value of the variable `confirm-kill-emacs' is non-`nil', `C-x C-c' assumes that its value is a predicate function, and calls that function. If the result of the function call is non-`nil', the session is killed, otherwise Emacs continues to run.
(setq confirm-kill-emacs 'yes-or-no-p)
;;======================================
;;{
{-- Fundamental Editing Commands
;;[[-- Basic
;;--Inserting Text
;;To insert a non-graphic character, or a character that your keyboard does not support, first "quote" it by typing `C-q' (`quoted-insert').
;;`C-q' followed by any non-graphic character (even `C-g') inserts that character. For instance, `C-q <DEL>' inserts a literal `DEL' character.
;;`C-q' followed by a sequence of octal digits inserts the character with the specified octal character code.
(setq read-quoted-char-radix 16) ;;To use decimal or hexadecimal instead of octal, set the variable `read-quoted-char-radix' to 10 or 16.
;;[[-- Minibuffer
(setq resize-mini-windows t) ;;A value of t means resize them to fit the text displayed in them.
(setq completion-auto-help 'lazy) ;;Emacs only shows the completion list buffer on the second attempt to complete
(setq history-delete-duplicates t) ;;adding a new element deletes from the list all other elements that are equal to i
(icomplete-mode t) ;;Icomplete mode presents a constantly-updated display that tells you what completions are available for the text you've entered so far
;;<<-- Minibuffer Edit
(setq enable-recursive-minibuffers t)
;;[[-- Help
;;((-- Misc Help
;;--InfoMode
;; C-u C-h i : open a file in info-mode
(defun fun-reopen-in-info-mode ()
(let ((file-name (buffer-file-name)))
(kill-buffer (current-buffer))
(info file-name)
)
)
(add-to-list 'auto-mode-alist '("\\.info\\'" . fun-reopen-in-info-mode))
;;((-- Help Echo
(setq help-at-pt-display-when-idle t) ;;To display help text automatically whenever it is available on the character after point
;;======================================
;;{
{-- Important Text-Changing Commands
;;[[-- Mark
(delete-selection-mode t) ;;inserting text while the mark is active causes the selected text to be deleted first
;;[[-- Yanking
;;-- Yanking Earlier Kills
(setq kill-ring-max 200) ;;The length of the kill ring is controlled by the variable `kill-ring-max'; no more than that many blocks of killed text are saved.
;;[[-- Display
;;--Horizontal Scrolling
(setq hscroll-margin 8) ;;The variable `hscroll-margin' controls how close point can get to the window's edges before automatic scrolling occurs.
;;--Follow Mode ;;"Follow mode" is a minor mode that makes two windows, both showing the same buffer, scroll as a single tall "virtual window."
;(follow-mode t)
;;Highlight Interactively
;(global-highlight-changes-mode t) ;;Highlight Changes mode is a minor mode that "highlights" the parts of the buffer were changed most r
emacs配置(.emacs.d/init.el)
最新推荐文章于 2024-09-09 08:08:21 发布
本文详细介绍了如何配置Emacs编辑器,重点讨论了.emacs.d/init.el文件的使用,涵盖了快捷键设定、主题应用、插件安装与定制等方面,旨在提升Emacs的使用效率和个性化体验。
摘要由CSDN通过智能技术生成