;; F1 - emacs help
;; F2 - save buffer
;; F3 - undo
;; F4 - redo
;; F5 - comment
;; F6 - line to top of window
;; F7 - compile
;; F8 - other window
;; F9 - find file
;; F10 - toggle line number
;; F11 - remove all visible ^M's
;; F12 - indent region
(modify-frame-parameters nil '((wait-for-wm . nil)))
(add-to-list 'load-path "/usr/share/emacs/misc")
(set-default-font "-adobe-courier-medium-r-normal--18-180-75-75-m-110-iso8859-1")
;(set-frame-height (selected-frame) 58)
;(set-frame-width (selected-frame) 142)
(setq visible-bell t)
(fset 'yes-or-no-p 'y-or-n-p)
(setq lazy-lock-defer-on-scrolling t)
(setq font-lock-support-mod 'lazy-lock-mode)
(setq font-lock-maximum-decoration t)
(setq enable-recursive-minibuffers t)
(setq inhibit-startup-message t)
(tool-bar-mode -1)
(setq text-mode-hook '(lambda() (auto-fill-mode 1)))
(global-font-lock-mode t)
(custom-set-variables
;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
'(auto-compression-mode t nil (jka-compr))
'(case-fold-search t)
'(current-language-environment "Chinese-GB")
'(default-input-method "chinese-py-punct")
'(global-font-lock-mode t nil (font-lock))
'(save-place t nil (saveplace))
'(show-paren-mode t nil (paren))
'(transient-mark-mode t))
(custom-set-faces
;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
'(default ((t (:foreground "white" :background "black")))))
(add-hook 'emacs-lisp-mode-hook 'turn-on-font-lock)
(add-hook 'c-mode-hook 'turn-on-font-lock)
(add-hook 'c-mode-hook
'(lambda()
(c-set-style "k&r")
(setq c-basic-offset 8)))
;; (add-hook 'c++-mode-hook
;; '(lambda()
;; (c-set-style "stroustrup")))
(add-hook 'c++-mode-hook
'(lambda()
(c-set-style "k&r")))
(add-hook 'c-mode-hook
'(lambda()
(c-toggle-auto-hungry-state)))
(add-hook 'c++-mode-hook
'(lambda()
(c-toggle-auto-hungry-state)))
(transient-mark-mode t)
(define-key ctl-x-map "n" 'goto-line)
(define-key ctl-x-map "\\" 'indent-region)
(put 'upcase-region 'disabled nil)
(show-paren-mode t)
(setq show-paren-style 'parentheses)
(setq line-number-mode t)
(setq column-number-mode t)
(setq default-tab-with 8)
;;(global-set-key [(control tab)] 'senator-complete-symbol);
;;(global-set-key [(control tab)] 'senator-completion-menu-popup)
;;(global-set-key [(meat ?/)] 'semantic-ia-complete-symbol-menu)
;; (setq semanticdb-project-roots
;; (list
;; (expand-file-name "/")))
;; (load-file "/usr/share/emacs/cedet/common/cedet.el")
;;(setq-default abbrev-mode t)
(setq scroll-step 1
scroll-margin 3
scroll-conservatively 10000)
;;(setq scroll-conservatively 1)
;;set make-backup-files nil stops emacs from making backups of files
;; (setq make-backup-files nil)
;; (setq-default fill-column 72)
(set-cursor-color "red")
(set-mouse-color "goldenrod")
(set-face-background 'region "blue")
(set-background-color "black")
(menu-bar-mode nil)
(setq require-final-newline t)
;;===== Funtion to delete a line =====
;; (defvar previous-column nil "Save the column position")
;; (defun delete-current-line()
;; "Kill an entire line, including the trailing newline character"
;; (interactive)
;; (setq previous-column (current-column))
;; (end-of-line)
;; (if (= (current-column) 0)
;; (delete-char 1)
;; (progn
;; (beginning-of-line)
;; (kill-line)
;; (delete-char 1)
;; (move-to-column previous-column))))
;; (define-key ctl-x-map "k" 'delete-current-line)
;;the buffer should not be auto-saved.
;;(setq buffer-auto-save-file-name t)
;;emacs deletes auto-save files when a true save is done.
;;(setq delete-auto-save-files t)
;;Esc-G runs the goto-line function.
(global-set-key "\M-g" 'goto-line)
;;(setq auto-save-default nil)
;;(setq auto-save-directory "/tmp/USERNAME")
;;put auto save files (ie #foo#) in one place, *not*
;;scattered all over the file system!
(defvar autosave-dir
(concat "/tmp/emacs_autosaves/" (user-login-name) "/"))
(make-directory autosave-dir t)
(defun auto-save-file-name-p (filename)
(string-match "^#.*#$" (file-name-nondirectory filename)))
(defun make-auto-save-file-name ()
(concat autosave-dir
(if buffer-file-name
(concat "#" (file-name-nondirectory buffer-file-name) "#")
(expand-file-name
(concat "#%" (buffer-name) "#")))))
;;put backup files (ie foo~) in one place too. (The backup-directory-alist
;;list contains regexp>=directory mappings; filenames matching a regexp are
;;backed up in the corresponding directory. Emacs will mkdir it if necessary.)
(defvar backup-dir (concat "/tmp/emacs_backups/" (user-login-name) "/"))
(setq version-control t)
(setq kept-old-versions 2)
(setq kept-new-versions 5)
(setq delete-old-versions t)
(setq backup-directory-alist (list (cons "." backup-dir)))
(setq backup-by-coping t)
(setq tags-file-name "/mnt/hda6/TAGS/TAGS")
;;Line to top of window
;;replace three keystroke sequence C-u 0 C-1
(defun line-to-top-of-window ()
"Move the line point is on to top of window."
(interactive)
(recenter 0))
(defun remove-ctl-m ()
(interactive)
(beginning-of-buffer)
(while (search-forward "\r" nil t)
(replace-match "" nil t))
)
(global-set-key [f1] 'help-command)
(global-set-key [f2] 'save-buffer)
(global-set-key [f3] 'undo)
(global-set-key [f4] 'replace-string)
(global-set-key [f5] 'kdab-insert-header)
(global-set-key [f6] 'kdab-insert-forward-decl)
(global-set-key [f7] 'compile)
(global-set-key [f8] 'other-window)
(global-set-key [f9] 'find-file)
(global-set-key [f10] 'wb-line-number-toggle)
(global-set-key [f11] 'remove-ctl-m)
(global-set-key [f12] 'indent-region)
(require 'wb-line-number)
(set-scroll-bar-mode nil)
;;(wb-line-number-toggle)
(require 'klaralv)
(defun beginning-of-line-or-non-whitespace ()
(interactive)
(if (bolp)
(back-to-indentation)
(beginning-of-line)))
(global-set-key [home] 'beginning-of-line-or-non-whitespace)
(setq kill-whole-line t)
(defun kill-current-line ()
(interactive)
(beginning-of-line)
(kill-line)
)
(define-key ctl-x-map "k" 'kill-current-line)
(display-time-mode t)
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(setq display-time-interval 10)
(display-time)
(setq next-line-add-newlines nil)
(setq kill-ring-max 200)
;; (load "desktop")
;; (desktop-load-default)
;; (desktop-read)
;; (load-library "saveplace")
;; (make-directory "/tmp/saveplace" t)
;; (make-directory "/tmp/shadowtodo" t)
;; (setq save-place-file "/tmp/saveplace/file")
;; (setq shadow-todo-file "/shadowtodo/file")
;; (setq mas-file-history-menu-path nil)
;; (setq mas-file-history-menu-title "History")
;; (with-temp-buffer)
(require 'saveplace)
(setq save-place-file "/tmp/saveplace/files")
(setq-default save-place t)
(defun linux-c-mode ()
"C mode with adjusted defaults for use with the Linux kernel."
(interactive)
(c-mode)
(setq c-indent-level 8)
(setq c-brace-imaginary-offset 0)
(setq c-brace-offset -8)
(setq c-argdecl-indent 8)
(setq c-label-offset -8)
(setq c-continued-statement-offset 8)
(c-set-style "K&R")
(setq tab-width 8)
(setq indent-tabs-mode t)
(setq c-basic-offset 8))
(setq auto-mode-alist (cons '("/usr/src/linux.*/.*\\.[ch]$". linux-c-mode)
auto-mode-alist))
(global-set-key "\C-x\C-x" 'kill-this-buffer)
(setq track-eol t)
(require 'hl-line)
;(global-hl-line-mode t)
(defface hl-line '((t (:foreground "Black" :background "SlateGray3")))
"Face to use for `hl-line-face'." :group 'hl-line)
(setq hl-line-face 'hl-line)
;(global-hl-line-mode t)
;(when (locate-library 'CC-mode)
; (setq c-font-lock-keywords-3
; (append '("signals" "\\(public\\|protected\\|private\\) slots")
; c-font-lock-keywords-3)))
;(require 'font-lock)
;; (setq c-C++access-key "\\<\\(slots\\|signals\\|private\\|protected\\|public\\)\\>[ \t]*[(slots\\|signals)]*[ \t]*:")
;; (font-lock-add-keywords 'c++-mode '(("\\<\\(Q_OBJECT\\|public slots\\|public signals\\|private slots\\|private signals\\|protected slots\\|protected signals\\)\\>" . font-lock-constant-face)))
;(c-add-style "qt-gnu" '("gnu"
; (c-access-key .
; "\\<\\(slots\\|signals\\|private\\|protected\\|public\\)\\>[ \t]*[(slots\\|signals)]*[ \t]*:")
; (c-basic-offset .4)))
;; (c-add-style "qt-gnu" '("gnu"
;; (c-access-key .
;; "\\<\\(signals\\|public\\|protected\\|private\\|public slots\\|protected slots\\|private slots\\):")
;; (c-basic-offset . 4)))
;; ;; syntax-highlighting for Qt
;; ;; (based on work by Arndt Gulbrandsen, Troll Tech)
;; (defun jk/c-mode-common-hook ()
;; "Set up c-mode and related modes.
;; Includes support for Qt code (signal, slots and alikes)."
;; ;; base-style
;; (c-set-style "stroustrup")
;; ;; set auto cr mode
;; (c-toggle-auto-hungry-state 1)
;; ;; qt keywords and stuff ...
;; ;; set up indenting correctly for new qt kewords
;; (setq c-protection-key (concat "\\<\\(public\\|public slot\\|protected"
;; "\\|protected slot\\|private\\|private slot"
;; "\\)\\>")
;; c-C++-access-key (concat "\\<\\(signals\\|public\\|protected\\|private"
;; "\\|public slots\\|protected slots\\|private slots"
;; "\\)\\>[ \t]*:"))
;; (progn
;; ;; modify the colour of slots to match public, private, etc ...
;; (font-lock-add-keywords 'c++-mode
;; '(("\\<\\(slots\\|signals\\)\\>" . font-lock-type-face)))
;; ;; make new font for rest of qt keywords
;; (make-face 'qt-keywords-face)
;; (set-face-foreground 'qt-keywords-face "BlueViolet")
;; ;; qt keywords
;; (font-lock-add-keywords 'c++-mode
;; '(("\\" . 'qt-keywords-face)))
;; (font-lock-add-keywords 'c++-mode
;; '(("\\" . 'qt-keywords-face)))
;; (font-lock-add-keywords 'c++-mode
;; '(("\\
;; ))
;; (add-hook 'c-mode-common-hook 'jk/c-mode-common-hook)
;; ;; Other things I like are, for example,
;; ;; cc-mode
;; (require 'cc-mode)
;; ;; automatic indent on return in cc-mode
;; (define-key c-mode-base-map [RET] 'newline-and-indent)
;; ;; Do not check for old-style (K&R) function declarations;
;; ;; this speeds up indenting a lot.
;; (setq c-recognize-knr-p nil)
;; ;; Switch fromm *. to *. and vice versa
;; (defun switch-cc-to-h ()
;; (interactive)
;; (when (string-match "^\\(.*\\)\\.\\([^.]*\\)$" buffer-file-name)
;; (let ((name (match-string 1 buffer-file-name))
;; (suffix (match-string 2 buffer-file-name)))
;; (cond ((string-match suffix "c\\|cc\\|C\\|cpp")
;; (cond ((file-exists-p (concat name ".h"))
;; (find-file (concat name ".h"))
;; )
;; ((file-exists-p (concat name ".hh"))
;; (find-file (concat name ".hh"))
;; )
;; ))
;; ((string-match suffix "h\\|hh")
;; (cond ((file-exists-p (concat name ".cc"))
;; (find-file (concat name ".cc"))
;; )
;; ((file-exists-p (concat name ".C"))
;; (find-file (concat name ".C"))
;; )
;; ((file-exists-p (concat name ".cpp"))
;; (find-file (concat name ".cpp"))
;; )
;; ((file-exists-p (concat name ".c"))
;; (find-file (concat name ".c"))
;; )))))))
;; (require 'cc-mode)
;; (setq c-C++-access-key "\\<\\(slots\\|signals\\|private\\|protected\\|public\\)\\>[ \t]*[(slots\\|signals)]*[ \t]*:")
;; (font-lock-add-keywords 'c++-mode '(("\\<\\(Q_OBJECT\\|public slots\\|public signals\\|private slots\\|private signals\\|protected slots\\|protected signals\\)\\>" . font-lock-constant-face)))
下面是个截图:
把用到文件misc.tar.bz2解压到/usr/share/emacs下面
|
文件: | misc.tar.bz2 |
大小: | 10KB |
下载: | 下载 |
|
|
文件: | emacs.rar |
大小: | 3KB |
下载: | 下载 |
|