;;; Created: Fang lungang 2004
;;; Modified: Fang lungang 01/06/2012 19:55>
;;; This configure file is for GNU Emacs 21, 22 and 23 on Windows, Linux and
;;; FreeBSD.
;;; ------ begin Personal ------
(setq user-full-name "Fang lungang" ange-ftp-default-user "name")
;;; viper or not
(setq viper-inhibit-startup-message t)
(setq viper-expert-level '5)
(when nil ; for those who miss vi so bad, change "nil" to "t"
(setq viper-mode t)
(require 'viper))
;;; ------ end Personal ------
;;; ------ begin Site ------
;;; site/host specific config
;; (setq url-proxy-services '(("http" . "cnproxy.cn.xxxxx.com:8080")))
;;; frame: font, position, title & transparence etc.
(setq frame-title-format
(list (replace-regexp-in-string "\\..*$" ""system-name)
":"
'(buffer-file-name "%f"
(dired-directory dired-directory "%b"))))
;;; frame position/size; emacs22 or later supports 'emacs --fullscreen'
;; (setq initial-frame-alist '((top . 1) (left . 1) (width . 80) (height . 30)))
;; transparent frame
;; (add-to-list 'default-frame-alist '(alpha 80 50))
;; ;; change dynamically (set-frame-parameter (selected-frame) 'alpha '(100 50))
;; Fonts in Emacs 22 and earlier uses the X Logical Font Description (XLFD)
;; format. From Emacs 23, prefer the simpler and more flexible fontconfig
;; format.
;; Fontset, the default fontset is good enough now. Recommended English fonts:
;; Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, consolas; Chinese fonts:
;; MS YaHei, WenQuanYi Zen Hei Mono
;; (when (>= emacs-major-version 23)
;; (add-to-list 'default-frame-alist '(font . "Monaco-12")))
;; (create-fontset-from-fontset-spec
;; (concat
;; "-*-dejavu sans mono-medium-r-normal--16-0-0-0-c-0-fontset-lgfang,"
;; "ascii:-*-dejavu sans mono-medium-r-normal-*-*-*-*-*-*-0-iso10646-1,"
;; "chinese-gb2312:-*-WenQuanYi Zen Hei Mono-normal-normal-normal-*-*-*-*-*-*-0-iso10646-1,"
;; "chinese-gb18030:-*-WenQuanYi Zen Hei Mono-normal-normal-normal-*-*-*-*-*-*-0-iso10646-1"))
;; (create-fontset-from-fontset-spec
;; (concat
;; "-apple-Monaco-normal-normal-normal-*-14-*-*-*-*-0-fontset-lgfang,"
;; "ascii:-apple-Monaco-normal-normal-normal-*-*-*-*-*-*-0-iso10646-1,"
;; "chinese-gb2312:-microsoft-Microsoft YaHei-normal-normal-normal-*-*-*-*-*-*-0-iso10646-1,"
;; "chinese-utf8:-microsoft-Microsoft YaHei-normal-normal-normal-*-*-*-*-*-*-0-iso10646-1"))
;;; paths
(setq my-emacs-base (file-name-as-directory "~/.emacs.d")
my-extension-path (file-name-as-directory "~/.emacs.d/extensions")
my-personal-path (file-name-as-directory
"~/mynotes/personal/"))
;;; load path
(add-to-list 'load-path my-extension-path)
(add-to-list 'load-path my-emacs-base)
(when (eq system-type 'windows-nt)
;;; exec path
(setq exec-path (append '("c:/share/MPlayer-1.0rc2")
'("c:/share")
'("c:/cygwin/bin")
'("c:/cygwin/usr/local/bin")
exec-path))
;;; woman path
(setq woman-manpath '("c:/cygwin/usr/local/man"
"c:/cygwin/usr/share/man"
"c:/cygwin/usr/man"
"c:/cygwin/usr/ssl/man"
"c:/cygwin/usr/share/qt3/doc/man"
"c:/cygwin/usr/X11R6/man"
)))
;;; Geo info
(setq cn-weather-city "青岛")
(setq calendar-latitude 36.06
calendar-longitude 120.27
calendar-location-name "QingDao")
;;; world time I care
(setq display-time-world-list
'(("Asia/Shanghai" "China")
("US/Eastern" "Westford")
("US/Central" "IH")
("Europe/Paris" "Paris")))
;;; ------ end Site ------
;;; ------ begin LanguageEnvironment ------
;; (if (eq system-type 'windows-nt)
;; (if (>= emacs-major-version 23) (set-language-environment 'Chinese-GB18030)
;; (set-language-environment 'Chinese-GB)
;; )
;; (set-language-environment 'utf-8))
;;; ------ end LanguageEnvironment ------
;;; ------ begin Keys ------
;; global key bindings
;;; 1~12 Function keys
;; f1: help, maybe useful when c-h not available
(define-key global-map [f2] 'my-recentf-open)
;;(define-key global-map [f2] 'speedbar-get-focus)
;; f3/f4: define keyboard macros
(define-key global-map [f5] 'org-clock-jump-to-current-clock)
(define-key global-map [f6] 'whitespace-cleanup)
(define-key global-map [f7] 'flyspell-mode)
(define-key global-map [f8] 'flyspell-prog-mode)
(define-key global-map [f9] 'ido-goto-symbol)
(define-key global-map [f10] 'org-capture)
;; f11 : leave it blank to seperate F12 from others to reduce mis-touch
;; f12 : reserved for twm/tmux etc.
;;; C-, M-, C-M- ... :(
(define-key global-map (kbd "C-x C-b") 'ibuffer)
(define-key global-map (kbd "C-x c l") 'org-store-link)
(define-key global-map (kbd "C-x c a") 'org-agenda)
(define-key global-map (kbd "M-/") 'hippie-expand)
(define-key global-map (kbd "M-,") 'hs-toggle-hiding)
(define-key global-map (kbd "M-.") 'my-toggle-selective-display)
(define-key global-map (kbd "M-g c") 'move-to-column)
(define-key global-map (kbd "M-g ]") 'my-goto-page)
(define-key global-map (kbd "C-x t") 'sdcv-search-pointer) ;translation
(define-key global-map (kbd "<mouse-9>") 'sdcv-search-pointer)
;;; Windows related operations
;; Split & Resize
(define-key global-map (kbd "C-x |") 'split-window-horizontally)
(define-key global-map (kbd "C-x _") 'split-window-vertically)
(define-key global-map (kbd "C-{") 'shrink-window-horizontally)
(define-key global-map (kbd "C-}") 'enlarge-window-horizontally)
(define-key global-map (kbd "C-^") 'enlarge-window)
;; Navgating: Windmove uses C-<up> etc.
(define-key global-map (kbd "C-<up>" ) 'windmove-up)
(define-key global-map (kbd "C-<down>" ) 'windmove-down)
(define-key global-map (kbd "C-<right>" ) 'windmove-right)
(define-key global-map (kbd "C-<left>") 'windmove-left)
;; Swap buffers: M-<up> etc.
(define-key global-map (kbd "M-<up>" ) 'buf-move-up)
(define-key global-map (kbd "M-<down>" ) 'buf-move-down)
(define-key global-map (kbd "M-<right>") 'buf-move-right)
(define-key global-map (kbd "M-<left>" ) 'buf-move-left)
;; Tile
(define-key global-map (kbd "C-\\") 'tiling-cycle) ; accepts prefix number
(define-key global-map (kbd "C-M-<up>") 'tiling-tile-up)
(define-key global-map (kbd "C-M-<down>") 'tiling-tile-down)
(define-key global-map (kbd "C-M-<right>") 'tiling-tile-right)
(define-key global-map (kbd "C-M-<left>") 'tiling-tile-left)
;; Another type of representation of same keys, in case your terminal doesn't
;; recognize above key-binding. Tip: C-h k C-up etc. to see into what your
;; terminal tranlated the key sequence.
(define-key global-map (kbd "M-[ a" ) 'windmove-up)
(define-key global-map (kbd "M-[ b" ) 'windmove-down)
(define-key global-map (kbd "M-[ c" ) 'windmove-right)
(define-key global-map (kbd "M-[ d" ) 'windmove-left)
(define-key global-map (kbd "ESC <up>" ) 'buf-move-up)
(define-key global-map (kbd "ESC <down>" ) 'buf-move-down)
(define-key global-map (kbd "ESC <right>") 'buf-move-right)
(define-key global-map (kbd "ESC <left>" ) 'buf-move-left)
(define-key global-map (kbd "ESC M-[ a" ) 'tiling-tile-up)
(define-key global-map (kbd "ESC M-[ b" ) 'tiling-tile-down)
(define-key global-map (kbd "ESC M-[ c" ) 'tiling-tile-right)
(define-key global-map (kbd "ESC M-[ d" ) 'tiling-tile-left)
;;; "Super" ("win") & "Hyper" ("Menu") key only works in X :(
(define-key global-map (kbd "s-m") 'bookmark-set)
(define-key global-map (kbd "s-b") 'bookmark-jump)
;;; ------ end keys ------
;;; ------ begin General ------
(require 'ascii nil t)
;; ;;; abbrev - conflict with auto-complete-mode
;; (setq-default abbrev-mode t save-abbrevs nil)
;; (load "lgfang-abbrev" t nil nil)
;;; appointment
(require 'appt nil t)
(setq appt-display-format 'window
appt-audible t
appt-display-mode-line t
appt-display-duration t
appt-message-warning-time 12)
(when (> emacs-major-version 21) (appt-activate 1))
;;; asm mode
(setq-default asm-comment-char 35) ; 35 -> ascii code for '#' in DEC
;;; auctex
(load "auctex.el" t nil nil)
;; (load "preview-latex.el" t nil nil)
(add-hook 'LaTeX-mode-hook
(lambda ()
(setq TeX-auto-untabify t
TeX-engine 'xetex
TeX-show-compilation t
TeX-view-program-list '(("Gsview" "gsview32.exe %o")
("Okular" "okular --unique %o")
("Evince" "evince %o")
("Firefox" "firefox %o"))
TeX-view-program-selection '((output-pdf "Okular")
(output-dvi "Okular"))
TeX-output-view-style '(("^pdf$" "." "okular --unique %o -p %(outpage)"))
)
(TeX-global-PDF-mode t)
(reftex-mode t)
))
;;; auto-complete
(let ((my-path-to-auto-complete
(concat my-extension-path "auto-complete-1.3")))
(when
(and (> emacs-major-version 21)
(file-exists-p my-path-to-auto-complete)
(add-to-list 'load-path my-path-to-auto-complete)
(require 'auto-complete-config nil t))
(add-to-list 'ac-dictionary-directories
(concat my-path-to-auto-complete "/dict"))
(add-to-list 'ac-dictionary-directories
(concat my-extension-path "/my-ac-dict"))
(ac-config-default)
(define-key ac-complete-mode-map "\C-s" 'ac-next)
(define-key ac-complete-mode-map "\C-r" 'ac-previous)
(setq ac-dwim t)
(setq ac-auto-start 2 ; start ac after 3 chars
;; modes that automatically startup auto-complete-mode
ac-modes '(asm-mode c++-mode c-mode cc-mode
emacs-lisp-mode java-mode lisp-interaction-mode
lisp-mode makefile-mode makefile-gmake-mode org-mode
cperl-mode python-mode sh-mode tcl-mode muse-mode
org-mode text-mode shell-script-mode conf-mode ))
(add-to-list 'ac-sources ac-source-yasnippet)
(setq-default ac-sources ac-sources) ; works, though a little bit tricky
;; ;; do not start ac automatically
;; (setq ac-auto-start nil)
;; (global-set-key "\M-/" 'ac-start)
;; ;; common source
;; (setq-default ac-sources '(ac-source-imenu ac-source-abbrev
;; ac-source-words-in-buffer
;; ac-source-files-in-current-dir ac-source-filename
;; ))
(dolist
(hook
'(emacs-lisp-mode-hook
lisp-interaction-mode-hook
shell-mode-hook
tcl-mode-hook))
(add-hook hook (lambda()
(add-to-list 'ac-sources ac-source-filename))))))
;;; auto-fill for text mode
;; (add-hook 'text-mode-hook 'turn-on-auto-fill)
;;; auto insert
(setq auto-insert t
auto-insert-directory (concat my-emacs-base "auto-insert/"))
(add-hook 'find-file-hooks 'auto-insert)
;;; auto mode list
(setq auto-mode-alist
(append
'(("\\.[xX]\\'" . c-mode)
("\\.mak\\'" . makefile-mode)
("\\.make\\'" . makefile-mode)
("\\.gdb\\'" . gdb-script-mode)
("\\.v\\'" . verilog-mode))
auto-mode-alist))
;;; auto-revert when file modified by other
(global-auto-revert-mode t)
;;; backup files ?
(setq make-backup-files t ; yes
version-control 'never) ; but only make a single backup
;;; bbdb & bbdb-vcard-export
(add-to-list 'load-path (concat my-extension-path "bbdb-2.35/lisp"))
(when (require 'bbdb nil t)
(require 'qp)
(bbdb-initialize 'gnus 'message)
(setq bbdb-default-area-code 532
bbdb-default-country "China"
bbdb-file (concat my-personal-path "my-bbdb")
bbdb-north-american-phone-numbers-p nil
bbdb-user-mail-names (regexp-opt '("myname@163.com" "another@smth.org"))
bbdb-complete-name-allow-cycling t
bbdb-use-pop-up nil)
;; (add-hook 'gnus-startup-hook 'bbdb-insinuate-gns)
(and (require 'bbdb-vcard nil t)
(setq bbdb-vcard-export-coding-system 'utf-8-unix))
(defun my-bbdb-to-nokia()
(interactive)
(let ((path "~/tmp/exported-vcards/"))
(bbdb "" nil) ; have to run this first
(bbdb-vcard-export path t t)
(mapc (lambda(file)
(with-temp-buffer
(insert-file-contents-literally file)
(quoted-printable-encode-region (point-min) (point-max))
;; delete useless field
(replace-regexp "^\\(FN\\|NICKNAME\\):.*$" ""
nil (point-min) (point-max))
;; corrections of quoted-printable-encode-region
(replace-regexp "^VERSION:3.0" "VERSION:2.1"
nil (point-min) (point-max))
(replace-string ";TYPE=3D" ";"
nil (point-min) (point-max))
(replace-regexp "^EMAIL:" "EMAIL;INTERNET:"
nil (point-min) (point-max))
(replace-regexp "^\\(ADR[^:]*\\|N\\|ORG\\):"
"\\1;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:"
nil (point-min) (point-max))
(write-region (point-min) (point-max) file nil)))
(file-expand-wildcards (concat path "*.vcf"))))))
;;; eudc
;; NOTE: ldap-host-parameters-alist must set before (require 'eudc)
(setq eudc-strict-return-matches nil
eudc-server-hotlist '(("localhost" . bbdb)
("ldap-ap.post.lucent.com" . ldap))
ldap-ldapsearch-args (quote ("-tt" "-LLL" "-x"))
ldap-host-parameters-alist (quote (("ldap-ap.post.lucent.com"
base "ou=people,o=lucent.com")))
eudc-query-form-attributes '(uid firstname surname email phone)
;;eudc-default-return-attributes nil ; nil for all
eudc-default-return-attributes (quote (cn ; must-have for bbdb
title
phone
mail
alcateluniqueid
lucenthrid
companyname
managername))
eudc-inline-expansion-servers 'hotlist)
(require 'eudc)
(eudc-set-server "ldap-ap.post.lucent.com" 'ldap)
(eudc-protocol-set 'eudc-inline-expansion-format
'("%s %s <%s>" firstname lastname net)
'bbdb)
(eudc-protocol-set 'eudc-inline-query-format
'((name) (firstname) (lastname) (firstname
lastname) (net))
'bbdb)
(eudc-protocol-set 'eudc-inline-expansion-format
'("%s <%s>" displayName email)
'ldap)
(eudc-protocol-set 'eudc-inline-query-format
'((cn) (mail) (cn cn) (cn cn cn) (sn)
(uid) (givenName) (givenName name) (name))
'ldap)
;; (defun enz-eudc-expand-inline()
;; (interactive)
;; (move-end-of-line 1)
;; (insert "*")
;; (unless (condition-case nil
;; (eudc-expand-inline)
;; (error nil))
;; (backward-delete-char-untabify 1)))
;; ;; Adds some hooks
;; (eval-after-load "message"
;; '(define-key message-mode-map (kbd "TAB") 'enz-eudc-expand-inline))
(require 'bookmark+ nil t) ; I 'ln -s my-bookmarks .emacs.bmk'
(when (require 'browse-kill-ring nil t)
(browse-kill-ring-default-keybindings))
(require 'buffer-move nil t)
;;; c mode configuration
(defconst lgfang-c-style
'((c-tab-always-indent . t)
(c-basic-offset . 4)
(c-ignore-auto-fill . nil)
(c-comment-only-line-offset . (0 . 0))
(c-hanging-braces-alist . ((substatement-open after before)
(brace-list-open)))
(c-hanging-colons-alist . ((member-init-intro before)
(inher-intro)
(case-label after)
(label after)
(access-label after)))
(c-cleanup-list . (scope-operator
empty-defun-braces
defun-close-semi))
(c-offsets-alist . ((knr-argdecl-intro . 5)
(arglist-intro . +)
(arglist-close . c-lineup-close-paren)
(inclass . +)
(member-init-intro . +)
(statement-block-intro . +)
(defun-block-intro . +)
(substatement-open . 0)
(label . 0)
(statement-case-open . +)
(statement-case-intro . +)
(case-label . 0)
(statement-cont . c-lineup-math)
(inline-open . 0)
(brace-list-open . +)
(topmost-intro-cont . 0)))
(c-special-indent-hook . c-gnu-impose-minimum)
(c-block-comment-prefix . "")
(c-echo-syntactic-information-p . t))
"lgfang's C Programming Style")
(c-add-style "lgfang" lgfang-c-style nil)
(add-hook 'c-mode-common-hook
(lambda ()
(c-set-style "lgfang")
(c-toggle-hungry-state 1)
(hs-minor-mode 1)
(if (and (>= emacs-major-version 23) (>= emacs-minor-version 2))
(subword-mode t)
(c-subword-mode t))
(hide-ifdef-mode 1)
(turn-on-cwarn-mode)
;; (eldoc-mode 1)
(define-key c-mode-base-map (kbd "M-'")
'my-hif-toggle-block)))
;;; Can't hook imenu-add-menubar-index to c-mode-common-hook since awk mode
;;; don't support it
(add-hook 'c-mode-hook 'imenu-add-menubar-index)
(add-hook 'c++-mode-hook 'imenu-add-menubar-index)
(add-hook 'java-mode-hook 'imenu-add-menubar-index)
;; calendar for Chinese
(when (and (> emacs-major-version 21)
(require 'cal-china-x nil t))
(setq mark-holidays-in-calendar t
;; calendar-chinese-all-holidays-flag t
calendar-holidays
(append cal-china-x-chinese-holidays
holiday-christian-holidays)))
;; Some popular themes: gnome2, calm forest, euphoria, bharadwaj
(when (require 'color-theme nil t)
(defun color-theme-lgfang-nw ()
"Color theme by lgfang, based on calm-forest."
(interactive)
(color-theme-install
'(color-theme-lgfang-nw
((background-color . "gray12")
(background-mode . dark)
(border-color . "black")
(cursor-color . "orange")
(foreground-color . "green")
(mouse-color . "yellow"))
((help-highlight-face . underline)
(list-matching-lines-face . bold)
(senator-eldoc-use-color . t)
(view-highlight-face . highlight)
(widget-mouse-face . highlight))
(default ((t (:stipple nil :background "gray12" :foreground "green" :inverse-video nil :box nil
:strike-through nil :overline nil :underline nil :slant normal :weight normal :height 98 :width
normal :family "outline-courier new"))))
(Info-title-1-face ((t (:bold t :weight bold :family "helv" :height 1.728))))
(Info-title-2-face ((t (:bold t :family "helv" :weight bold :height 1.44))))
(Info-title-3-face ((t (:bold t :weight bold :family "helv" :height 1.2))))
(Info-title-4-face ((t (:bold t :family "helv" :weight bold))))
(bold ((t (:bold t :weight bold))))
(bold-italic ((t (:italic t :bold t :slant italic :weight bold))))
(border ((t (:background "black"))))
(comint-highlight-input ((t (:bold t :weight bold))))
(comint-highlight-prompt ((t (:foreground "cyan"))))
(cparen-around-andor-face ((t (:bold t :foreground "maroon" :weight bold))))
(cparen-around-begin-face ((t (:foreground "maroon"))))
(cparen-around-conditional-face ((t (:bold t :foreground "RoyalBlue" :weight bold))))
(cparen-around-define-face ((t (:bold t :foreground "Blue" :weight bold))))
(cparen-around-lambda-face ((t (:foreground "LightSeaGreen"))))
(cparen-around-letdo-face ((t (:bold t :foreground "LightSeaGreen" :weight bold))))
(cparen-around-quote-face ((t (:foreground "SaddleBrown"))))
(cparen-around-set!-face ((t (:foreground "OrangeRed"))))
(cparen-around-syntax-rules-face ((t (:foreground "Magenta"))))
(cparen-around-vector-face ((t (:foreground "chocolate"))))
(cparen-binding-face ((t (:foreground "ForestGreen"))))
(cparen-binding-list-face ((t (:bold t :foreground "ForestGreen" :weight bold))))
(cparen-conditional-clause-face ((t (:foreground "RoyalBlue"))))
(cparen-normal-paren-face ((t (:foreground "grey50"))))
(cursor ((t (:background "orange"))))
(custom-button-face ((t (:background "lightgrey" :foreground "black" :box (:line-width 2 :style
released-button)))))
(custom-button-pressed-face ((t (:background "lightgrey" :foreground "black" :box (:line-width
2 :style pressed-button)))))
(custom-changed-face ((t (:background "blue" :foreground "white"))))
(custom-comment-face ((t (:background "dim gray"))))
(custom-comment-tag-face ((t (:foreground "gray80"))))
(custom-documentation-face ((t (nil))))
(custom-face-tag-face ((t (:bold t :family "helv" :weight bold :height 1.2))))
(custom-group-tag-face ((t (:bold t :foreground "light blue" :weight bold :height 1.2))))
(custom-group-tag-face-1 ((t (:bold t :family "helv" :foreground "pink" :weight bold :height
1.2))))
(custom-invalid-face ((t (:background "red" :foreground "yellow"))))
(custom-modified-face ((t (:background "blue" :foreground "white"))))
(custom-rogue-face ((t (:background "black" :foreground "pink"))))
(custom-saved-face ((t (:underline t))))
(custom-set-face ((t (:background "white" :foreground "blue"))))
(custom-state-face ((t (:foreground "lime green"))))
(custom-variable-button-face ((t (:bold t :underline t :weight bold))))
(custom-variable-tag-face ((t (:bold t :family "helv" :foreground "light blue" :weight bold
:height 1.2))))
(eieio-custom-slot-tag-face ((t (:foreground "light blue"))))
(extra-whitespace-face ((t (:background "pale green"))))
(fixed-pitch ((t (:family "courier"))))
(font-latex-bold-face ((t (:bold t :foreground "OliveDrab" :weight bold))))
(font-latex-italic-face ((t (:italic t :foreground "OliveDrab" :slant italic))))
(font-latex-math-face ((t (:foreground "burlywood"))))
(font-latex-sedate-face ((t (:foreground "LightGray"))))
(font-latex-string-face ((t (:foreground "RosyBrown"))))
(font-latex-warning-face ((t (:bold t :foreground "Red" :weight bold))))
(font-lock-builtin-face ((t (:foreground "LightSteelBlue"))))
(font-lock-comment-face ((t (:foreground "chocolate1"))))
(font-lock-constant-face ((t (:foreground "Aquamarine"))))
(font-lock-doc-face ((t (:foreground "LightSalmon"))))
(font-lock-function-name-face ((t (:foreground "LightSkyBlue"))))
(font-lock-keyword-face ((t (:foreground "Cyan"))))
(font-lock-string-face ((t (:foreground "LightSalmon"))))
(font-lock-type-face ((t (:foreground "PaleGreen"))))
(font-lock-variable-name-face ((t (:foreground "LightGoldenrod"))))
(font-lock-warning-face ((t (:bold t :foreground "Pink" :weight bold))))
(fringe ((t (:background "grey10"))))
(header-line ((t (:box (:line-width -1 :style released-button) :background "grey20" :foreground
"grey90" :box nil))))
(highlight ((t (:background "green" :foreground "black"))))
(info-header-node ((t (:italic t :bold t :weight bold :slant italic :foreground "white"))))
(info-header-xref ((t (:bold t :weight bold :foreground "cyan"))))
(info-menu-5 ((t (:foreground "red1"))))
(info-menu-header ((t (:bold t :family "helv" :weight bold))))
(info-node ((t (:italic t :bold t :foreground "white" :slant italic :weight bold))))
(info-xref ((t (:bold t :foreground "cyan" :weight bold))))
(isearch ((t (:background "palevioletred2" :foreground "brown4"))))
(isearch-lazy-highlight-face ((t (:background "paleturquoise4"))))
(italic ((t (:italic t :slant italic))))
(jde-bug-breakpoint-cursor ((t (:background "brown" :foreground "cyan"))))
(jde-db-active-breakpoint-face ((t (:background "red" :foreground "black"))))
(jde-db-requested-breakpoint-face ((t (:background "yellow" :foreground "black"))))
(jde-db-spec-breakpoint-face ((t (:background "green" :foreground "black"))))
(jde-java-font-lock-api-face ((t (:foreground "light goldenrod"))))
(jde-java-font-lock-bold-face ((t (:bold t :weight bold))))
(jde-java-font-lock-code-face ((t (nil))))
(jde-java-font-lock-constant-face ((t (:foreground "Aquamarine"))))
(jde-java-font-lock-doc-tag-face ((t (:foreground "light coral"))))
(jde-java-font-lock-italic-face ((t (:italic t :slant italic))))
(jde-java-font-lock-link-face ((t (:foreground "blue" :underline t :slant normal))))
(jde-java-font-lock-modifier-face ((t (:foreground "LightSteelBlue"))))
(jde-java-font-lock-number-face ((t (:foreground "LightSalmon"))))
(jde-java-font-lock-operator-face ((t (:foreground "medium blue"))))
(jde-java-font-lock-package-face ((t (:foreground "steelblue1"))))
(jde-java-font-lock-pre-face ((t (nil))))
(jde-java-font-lock-underline-face ((t (:underline t))))
(menu ((t (nil))))
(mode-line ((t (:background "grey75" :foreground "black" :box (:line-width -1 :style
released-button)))))
(mouse ((t (:background "yellow"))))
(region ((t (:background "blue3" :foreground "black"))))
(scroll-bar ((t (nil))))
(secondary-selection ((t (:background "SkyBlue4"))))
(semantic-dirty-token-face ((t (:background "gray10"))))
(semantic-unmatched-syntax-face ((t (:underline "red"))))
(senator-intangible-face ((t (:foreground "gray75"))))
(senator-momentary-highlight-face ((t (:background "gray30"))))
(senator-read-only-face ((t (:background "#664444"))))
(show-paren-match-face ((t (:background "turquoise"))))
(show-paren-mismatch-face ((t (:background "purple" :foreground "white"))))
(speedbar-button-face ((t (:foreground "green3"))))
(speedbar-directory-face ((t (:foreground "light blue"))))
(speedbar-file-face ((t (:foreground "cyan"))))
(speedbar-highlight-face ((t (:background "sea green"))))
(speedbar-selected-face ((t (:foreground "red" :underline t))))
(speedbar-separator-face ((t (:background "blue" :foreground "white" :overline "gray"))))
(speedbar-tag-face ((t (:foreground "yellow"))))
(tool-bar ((t (:background "grey75" :foreground "black" :box (:line-width 1 :style
released-button)))))
(trailing-whitespace ((t (:background "red"))))
(underline ((t (:underline t))))
(variable-pitch ((t (:family "helv"))))
(widget-button-face ((t (:bold t :weight bold))))
(widget-button-pressed-face ((t (:foreground "red"))))
(widget-documentation-face ((t (:foreground "lime green"))))
(widget-field-face ((t (:foregraund "LightSalmon" :background "gray"))))
(widget-inactive-face ((t (:foreground "light gray"))))
(widget-single-line-field-face ((t (:background "dim gray")))))))
(unless (> emacs-major-version 21) (global-font-lock-mode 1))
(if window-system (color-theme-gnome2)
(color-theme-lgfang-nw)))
(column-number-mode t)
(setq comment-style 'extra-line)
;;; Compilation
(require 'compile)
(setq compile-command "make SWATCA=t"
compilation-scroll-output t)
(define-key compilation-mode-map "n" 'next-error-no-select)
(define-key compilation-mode-map "p" 'previous-error-no-select)
(define-key compilation-mode-map " "
(lambda () (interactive) (save-selected-window (compile-goto-error))))
(define-key compilation-mode-map [return] 'compile-goto-error)
(define-key compilation-mode-map "o"
(lambda () (interactive) (compile-goto-error) (delete-other-windows)))
(define-key compilation-mode-map "q" 'quit-window)
;; Enable auot-encryt using ccrypt
(require 'ps-ccrypt nil t)
;;(setq-default cursor-type 'hbar)
;; ;;; typed text replaces the selection (marked region)
;; (delete-selection-mode 1)
(setq default-major-mode 'text-mode)
(when (> emacs-major-version 21)
(desktop-save-mode -1))
;;; diary
(add-hook 'list-diary-entries-hook 'include-other-diary-files)
(add-hook 'list-diary-entries-hook 'sort-diary-entries)
(setq diary-display-hook 'fancy-diary-display
diary-file (concat my-personal-path "my-diary"))
;;; dired etc.
(setq dired-recursive-copies 'top dired-recursive-deletes 'top)
(require 'dired-x)
(add-hook 'dired-load-hook (lambda () (load "dired-x")))
;; don't show hiden files, bak files etc.
(when (> emacs-major-version 21)
(add-hook 'dired-mode-hook (lambda () (dired-omit-mode 1)))
(setq dired-omit-files (concat dired-omit-files "\\|^\\..+$")))
;;; guess of '!' action
(add-to-list 'dired-guess-shell-alist-user
(list "\\.\\(avi\\|mkv\\|mpg\\|rmvb\\|rm\\)\\'" "mplayer"))
(add-to-list 'dired-guess-shell-alist-user
(list "\\.\\(rar\\)\\'" "7z x"))
(when (require 'dired-details nil t)
(dired-details-install))
;;; ediff
;;don't pop a frame for ediff
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
;; (setq-default ediff-diff-options "-w")
;;; elisp
(add-hook 'emacs-lisp-mode-hook
(lambda()
(imenu-add-menubar-index)
(hs-minor-mode 1)))
;;; emms configure in another file
(when (> emacs-major-version 21) (load "lgfang-emms" t nil nil))
;;; eshell: restore arrows(up/down) to their orginal functions
(add-hook 'eshell-mode-hook
(lambda ()
(define-key eshell-mode-map [up] 'previous-line)
(define-key eshell-mode-map [down] 'next-line)))
;; multi-eshell
(when (require 'multi-eshell nil t)
(setq multi-eshell-name "*eshell*")
(setq multi-eshell-shell-function (quote (eshell))))
;;; face, add our own keywords. ctypes.el is too heavy-weight
(add-hook 'find-file-hooks ; for all modes (except muse-mode?)
(lambda ()
(font-lock-add-keywords
nil '(("\\<\\(lgfang\\|TODO\\|FIXME\\|NOTE\\):"
. (0 font-lock-warning-face t))))))
(font-lock-add-keywords 'c-mode ; for c mode only
'(("\\<\\(TRUE\\|FALSE\\)\\>"
. font-lock-constant-face)))
(require 'ffap)
(ffap-bindings)
;; (setq ffap-c-path (append ffap-c-path sourcepair-header-path))
;;; fill column
(setq-default fill-column 80)
;;; flymake
(when (> emacs-major-version 21)
(require 'flymake)
(setq flymake-no-changes-timeout 2) ; don't grab too much cpu time
(setq flymake-allowed-file-name-masks
(cons '("\\.cc\\'" flymake-simple-make-init) ;C++ source file
flymake-allowed-file-name-masks))
;;; remember add target in makefile
;;; check-syntax:
;;; g++/gcc -o nul -Wall -S $(CHK_SOURCES)
)
;; (setq gdb-many-windows t)
;;; hide-ifdef-mode settings
(require 'hideif)
(setq hide-ifdef-initially nil)
(load "lgfang-hif" t nil nil)
(defvar my-define-alist nil)
(add-hook 'c-mode-hook
(lambda () (my-hide-if-0)
(when my-define-alist
(hide-ifdef-use-define-alist my-define-alist))))
;;; hide-show
(require 'myhideshow nil t) ; or add (forward-line -1) to hideshow.el according
; to http://www.emacswiki.org/cgi-bin/wiki/HideShow
(setq hs-allow-nesting t
hs-isearch-open t)
;; default value of following var can't deal with '{' not in the same
;; line with "if"
(add-to-list 'hs-special-modes-alist
'(c-mode "[\n\t ]*{" "}" "/[*/]" nil
hs-c-like-adjust-block-beginning))
(add-to-list 'hs-special-modes-alist
'(c++-mode "[\n\t ]*{" "}" "/[*/]" nil
hs-c-like-adjust-block-beginning))
;;; hippie expand
(setq hippie-expand-try-functions-list
'(try-expand-dabbrev
try-expand-dabbrev-visible
try-expand-dabbrev-all-buffers
try-expand-dabbrev-from-kill
try-complete-file-name-partially
try-complete-file-name
try-expand-all-abbrevs
try-expand-list
try-expand-line
try-complete-lisp-symbol-partially
try-complete-lisp-symbol))
(require 'htmlize nil t)
;;; ido
(when (> emacs-major-version 21)
;; C-r/C-s for ido-next/previous-match
(ido-mode 'buffer)
(setq ido-enable-flex-matching t))
;;; imenu
(setq imenu-sort-function 'imenu--sort-by-name)
(setq imenu-auto-rescan t)
;; (setq imenu-use-popup-menu t)
(setq inhibit-startup-message t
inhibit-splash-screen t)
(eval-after-load "outline"
'(setq initial-scratch-message
(if (file-exists-p "~/.tod.org")
(with-temp-buffer
(insert-file-contents "~/.tod.org")
;; jump to somewhere randomly, must after first heading
(outline-next-heading)
;; set random seed, otherwise "emacs -nw" always get same tip
(random t)
(goto-char (+ (random (- (point-max) (point))) (point)))
(outline-mark-subtree)
(let* ((beg (point))
(end (mark)))
(buffer-substring beg end)))
"Hello My Buddy,\n
You may want to get a copy of 'Tip Of the Day'.\n
lgfang")))
;;; ispell - aspell instead
(setq ispell-program-name "aspell")
;; regardless locale settings, always use english refer to
;; ispell-dictionary-alist for details
(setq ispell-dictionary "english")
;;; from http://blog.waterlin.org
(defadvice kill-ring-save (before slickcopy activate compile)
"If region not active, copy current line."
(interactive
(if mark-active (list (region-beginning) (region-end))
(list (line-beginning-position)
(line-beginning-position 2)))))
(defadvice kill-region (before slickcut activate compile)
"If region not active, kill current line."
(interactive
(if mark-active (list (region-beginning) (region-end))
(list (line-beginning-position)
(line-beginning-position 2)))))
;;; linum
(when (> emacs-major-version 21)
(require 'linum nil t)
;;(global-linum-mode t)
)
(setq longlines-wrap-follows-window-size t)
(menu-bar-mode -1)
(setq messages-buffer-max-lines 500) ; default value too small
(when (require 'midnight nil t)
(midnight-delay-set 'midnight-delay "1:30am")
(setq clean-buffer-list-delay-general 1))
(require 'motion-and-kill-dwim nil t)
;;; mouse
(setq mouse-yank-at-point t) ; instead of at mouse cursor
(when (not window-system) (xterm-mouse-mode 1)) ;use mouse in xterm
;;; muse configurations were in another file
(load "lgfang-muse" t nil nil)
;;; nXML mode
(when (or (>= emacs-major-version 23) ; nxml is part of emacs 23
(and (add-to-list 'load-path
(concat my-extension-path "nxml-mode-20041004"))
(load "rng-auto" t nil nil)))
(add-to-list 'auto-mode-alist
(cons (concat "\\." (regexp-opt
'("xml" "xsd" "sch"
"rng" "xslt" "svg" "rss") t)
"\\'") 'nxml-mode))
(when (> emacs-major-version 21)
(setq magic-mode-alist
(cons '("<\\?xml " . nxml-mode) magic-mode-alist)))
(fset 'xml-mode 'nxml-mode)
(fset 'html-mode 'nxml-mode)
(require 'rng-loc nil t)
(add-to-list 'rng-schema-locating-files
(concat my-emacs-base "my-schemas.xml")))
;;; occur
(define-key occur-mode-map "n" 'next-error-no-select)
(define-key occur-mode-map "p" 'previous-error-no-select)
(define-key occur-mode-map " " 'occur-mode-display-occurrence)
(define-key occur-mode-map "o" (lambda () (interactive)
(occur-mode-goto-occurrence)
(delete-other-windows)))
;;; org-mode
(add-to-list 'load-path (concat my-extension-path "/org/lisp"))
(add-to-list 'load-path (concat my-extension-path "/org/contrib"))
(when (and (> emacs-major-version 21)
(require 'org nil t))
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
(setq org-hide-leading-stars nil
org-cycle-include-plain-lists t
org-archive-location "%s_archive::"
;; org-log-done 'nil
org-deadline-warning-days 0 ; already seed deadline in week-view agenda
org-agenda-skip-deadline-if-done t
org-agenda-skip-scheduled-if-done t
org-agenda-show-all-dates nil
org-agenda-start-on-weekday nil
org-agenda-include-diary t
org-agenda-files (list
(concat my-personal-path "tasks.org")
(concat my-personal-path "my-readings.org")
(concat my-personal-path "my-anniv.org"))
org-reverse-note-order t
org-default-notes-file "~/income.org" ; not used, see org-remember-templates
org-capture-templates (list
(list "o" "Misc overheads" 'entry
(list 'file+olp
(concat my-personal-path "tasks.org")
"Work" "overheads" "misc")
"* TODO %?" :prepend t)
(list "b" "Bugs" 'entry
(list 'file+olp
(concat my-personal-path "tasks.org")
"Work" "scrum" "bugs")
"* TODO %?" :prepend t)
(list "d" "Document review" 'entry
(list 'file+olp
(concat my-personal-path "tasks.org")
"Work" "support" "review")
"* TODO %?" :prepend t)
(list "l" "Lab support" 'entry
(list 'file+olp
(concat my-personal-path "tasks.org")
"Work" "support" "lab")
"* TODO %?" :prepend t)
(list "q" "Answer queries/emails" 'entry
(list 'file+olp
(concat my-personal-path "tasks.org")
"Work" "support" "query")
"* TODO %?" :prepend t)
(list "s" "Study need" 'entry
(list 'file+olp
(concat my-personal-path "tasks.org")
"Work" "study")
"* NEXT %?" :prepend t)
(list "p" "personal" 'entry
(list 'file+olp
(concat my-personal-path "tasks.org")
"Personal" "Misc")
"* TODO %?" :prepend t)
;; (list "l" "log time" 'entry
;; '(file+datetree "~/timelog.org" )
;; "** %U - %?")
(list "r" "report" 'entry
(list 'file+function
(concat my-personal-path "work-report.org")
(function (lambda()
(let ((heading (format-time-string "week %Y-%W")))
(goto-char (point-min))
(if (re-search-forward
(format org-complex-heading-regexp-format
(regexp-quote heading))
nil t)
(beginning-of-line 2)
(goto-char (point-min))
(or (bolp) (insert "\n"))
(insert "* " heading "\n"))))))
"** %?" :prepend t))
org-todo-keywords '((sequence "TODO(t)"
"NEXT(n)"
"PENDING(p!)"
"HOLD(h@)"
"SOMEDAY(s)"
"|"
"DELEGATED(o@)"
"CANCELED(c@)"
"DONE(d!)"))
org-agenda-custom-commands '(("a" "Agenda and TODO"
( (todo "PENDING")
(agenda)
(todo "TODO")
(todo "NEXT")))
("t" "All Items" alltodo nil nil)
("r" tags "rec"))
;; publish related
org-export-html-style-include-default nil
org-export-htmlize-output-type 'css
org-export-html-style "<link rel=\"stylesheet\" href=\"../lgfang.css\" type=\"text/css\" />"
org-publish-project-alist
'(
("mynotes"
:base-directory "~/mynotes/"
:base-extension "org"
:publishing-directory "~/tmp/exported-notes"
:recursive t
:publishing-function org-publish-org-to-html ; org-publish-org-to-pdf
:exclude "my.org"
)
("mynotes-attachment"
:base-directory "~/mynotes/"
:base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
:publishing-directory "~/tmp/exported-notes/"
:recursive t
:publishing-function org-publish-attachment
)
;; ("homepage" :components ("homepage-notes" "homepage-attachment"))
))
(add-hook 'remember-mode-hook 'org-remember-apply-template)
(add-hook 'org-mode-hook 'imenu-add-menubar-index))
;;; parenthesis highlighting, Use highlight-parentheses instead
;; (show-paren-mode nil)(setq show-paren-style 'expression)
(when (require 'highlight-parentheses nil t)
;; M-x list-colors-display to see named colors
(setq hl-paren-colors '("brown" "orange" "yellow" "forest green" "cyan" "blue"
"violet"))
(dolist (hook '(emacs-lisp-mode-hook
lisp-interaction-mode-hook
c-mode-common-hook))
(add-hook hook (lambda()(highlight-parentheses-mode t)))))
;;; perl: using cperl-mode instead
(defalias 'perl-mode 'cperl-mode)
(add-hook 'cperl-mode-hook 'imenu-add-menubar-index)
;;; Python related
;;; pylint
(load "pylint" t nil nil)
;;; Python mode
(add-hook 'python-mode-hook
(lambda()
(imenu-add-menubar-index)
(if (and (>= emacs-major-version 23) (>= emacs-minor-version 2))
(subword-mode t)
(c-subword-mode t))
(outline-minor-mode 1)))
;;; recently opened file
(require 'recentf)
;; add at the front of list, don't conncect to remote hosts
(when (> emacs-major-version 21)
(add-to-list 'recentf-keep 'file-remote-p))
(setq recentf-max-saved-items 100)
(recentf-mode 1)
;;; remember
(add-to-list 'load-path (concat my-extension-path "remember-2.0"))
(when (require 'remember nil t)
(setq
remember-annotation-functions '(org-remember-annotation)
remember-handler-functions '(org-remember-handler)))
;;; Always end a file with a newline
(setq require-final-newline t)
;;; rfcview & sb-rfcview
(add-to-list 'auto-mode-alist
'("/\\(rfc[0-9]+\\|draft-.+\\)\\.txt\\(\\.gz\\)?\\'"
. rfcview-mode))
(autoload 'rfcview-mode "rfcview")
(eval-after-load "speedbar" '(load "sb-rfcview" t nil nil))
;;; rnc mode - relax-ng compact syntax
(add-to-list 'auto-mode-alist '("\\.rnc\\'" . rnc-mode))
(autoload 'rnc-mode "rnc-mode")
;;; save minibuffer history between sessions
(when (> emacs-major-version 21) (savehist-mode t))
;;; save place of cursor between sessions
(when (> emacs-major-version 21)
(setq-default save-place t) (require 'saveplace))
(setq scroll-margin 0 scroll-conservatively 100) ; scroll-step ?
(when (> emacs-major-version 21) (set-scroll-bar-mode nil))
(require 'sdcv)
;;; sentence end
(setq sentence-end-double-space nil)
;; (setq sentence-end "\\([。!?]\\|……\\|[.?!][]\"')}]*\\($\\|[ \t]\\)\\)[ \t\n]*")
;; (server-start) ; Don't start server, run 'emacs --daemon' instead
;;; sh-mode-hook. Mode for shell script is sh-mode, NOT shell-mode
(add-hook 'sh-mode-hook
(lambda ()
(hs-minor-mode 1)
(setq imenu-generic-expression
my-sh-imenu-generic-expression
outline-regexp "# [*\\f]+")
(imenu-add-menubar-index)))
(setq my-sh-imenu-generic-expression
'((nil "^\\s-*\\(function\\s-+\\)?\\([A-Za-z_][A-Za-z_0-9]+\\)\\s-*()" 2)
(nil "^\\s-*function\\s-+\\([A-Za-z_][A-Za-z_0-9]+\\)" 1)))
;;; skeleton
;; avoid skeleton/abbrev recursion
(setq-default skeleton-further-elements '((abbrev-mode nil)))
(load "lgfang-skeleton" t nil nil)
;; skeleton-pair-insert
(setq skeleton-pair t ; turn on/off skeleton-pair-insert
skeleton-pair-on-word nil) ; inhibit paired insertion
; before/inside a word
(when skeleton-pair ; if turned on
(dolist (hook '(c-mode-common-hook tcl-mode-hook org-mode-hook latex-mode-hook))
(add-hook hook
(lambda ()
(local-set-key (kbd "(") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "[") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "{") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "'") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "`") 'skeleton-pair-insert-maybe)
(local-set-key (kbd "\"") 'skeleton-pair-insert-maybe)))))
;;; speedbar & sr-speedbar
(setq speedbar-show-unknown-files t)
;; (add-hook 'speedbar-timer-hook
;; (lambda ()
;; (save-excursion
;; (set-buffer speedbar-buffer)
;; (speedbar-expand-line))))
(when (require 'sr-speedbar nil t)
(setq sr-speedbar-skip-other-window-p t))
;;; split horizontally if screen wide enough
(when (>= emacs-major-version 23) (setq split-width-threshold 170))
;;; avoid Chinese chars in time stamps even in Chinese locale.
(setq system-time-locale "C")
;;; tab related
(setq-default tab-stop-list
'(4 8 12 16 20 24 28 32 36 40
44 48 52 56 60 64 68 72 76 80)
tab-width 4
;; change tabs to spaces when entering it
indent-tabs-mode nil)
;;; Tabbar
;; (when (and (require 'tabbar nil t) window-system) (tabbar-mode 1))
;;; Tcl & expect
(add-hook 'tcl-mode-hook
(lambda ()
(imenu-add-menubar-index)
(hs-minor-mode 1)
(if (and (>= emacs-major-version 23) (>= emacs-minor-version 2))
(subword-mode t)
(c-subword-mode t))))
(add-to-list 'interpreter-mode-alist '("expect" . tcl-mode))
;;; Tiling
(require 'tiling nil t)
;;; time stamp
(add-hook 'write-file-hooks 'time-stamp)
(setq time-stamp-format "%U %02m/%02d/%:y %02H:%02M"
time-stamp-start "\\(Modified\\|last-edit\\): *\\\\?"
time-stamp-end "\\\\?>")
;;; toggle-window-dedicated.el
(load "toggle-window-dedicated" t nil nil)
(tool-bar-mode -1)
(when (> emacs-major-version 21)
(setq tooltip-use-echo-area t)
(tooltip-mode 1))
;;; tramp
(when (> emacs-major-version 21)
(require 'tramp)
(setq tramp-debug-buffer t)
(when (eq system-type 'windows-nt)
(unless (> emacs-major-version 22) (setq tramp-rsh-end-of-line "\r"))
;; define method plinkt ('plink -telnet') for telnet on windows
(add-to-list 'tramp-methods
'("plinkt"
(tramp-connection-function tramp-open-connection-telnet)
(tramp-login-program "plink")
(tramp-copy-program nil)
(tramp-remote-sh "/bin/sh")
(tramp-login-args (("-telnet") ("%h")))
(tramp-copy-args nil)
(tramp-copy-keep-date-arg nil))))
(let ( ;; uses plink as ssh client on windows
(ssh-program (if (eq system-type 'windows-nt) "plink" "ssh"))
(ftp-program (if (eq system-type 'windows-nt) "plinkt" "ftp")))
(add-to-list 'tramp-default-method-alist '("localhost" nil "su"))
(setq tramp-default-method-alist
(append
(mapcar (lambda (host) (list host nil ftp-program))
'( "192.168.*" ; ftp sites
"135.251.*"
"135.252.*"
"152.148.185.*"
"ihgp.*"
"oak.*"))
tramp-default-method-alist))
(setq tramp-default-method-alist
(append
(mapcar (lambda (host) (list host nil ssh-program))
'("maatca.inse.*")) ; ssh sites
tramp-default-method-alist))))
;;; highlight selected region
(setq-default transient-mark-mode t)
;;; trash
(when (>= emacs-major-version 23)
(setq delete-by-moving-to-trash nil)
;; works for *nix only
(setq trash-directory "~/.trashbin"))
(setq-default truncate-lines nil)
;;; Uniquify buffer name with more meaningful names
(when (require 'uniquify nil t)
(setq uniquify-buffer-name-style 'post-forward
uniquify-strip-common-suffix t
uniquify-separator "@"))
;;; verilog mode
(autoload 'verilog-mode "verilog-mode" "Verilog mode" t )
(load "visws" t nil nil)
;;; w32
(when (eq system-type 'windows-nt)
(load "w32-fontified-region-to-clipboard" t nil nil)
(setq w32-recognize-altgr nil)
(require 'w32-winprint nil t))
;;; w3m
(add-to-list 'load-path (concat my-extension-path "emacs-w3m"))
(if (>= emacs-major-version 23)
(require 'w3m-ems nil t)
(require 'w3m nil t))
(autoload 'w3m-browse-url "w3m" "Ask a WWW browser to show a URL." t)
;;; Weather
(require 'cn-weather nil t)
(which-function-mode t)
;;; whitespace
(if (> emacs-major-version 22)
(progn
(setq whitespace-line-column fill-column
whitespace-style '(trailing
tabs
indentation
;; space-before-tab
;; space-after-tab
lines-tail
empty
))
;;(global-whitespace-mode 1)
)
;; for emacs22 and older
(setq-default indicate-empty-lines t
show-trailing-whitespace nil)
(dolist (hook '(emacs-lisp-mode-hook
c-mode-common-hook
python-mode-hook
nxml-mode-hook
tcl-mode-hook
muse-mode-hook))
(add-hook hook (lambda () (setq show-trailing-whitespace)))))
(require 'windmove nil t)
(when (require 'winner nil t) (winner-mode 1))
;;; woman
(setq woman-use-own-frame nil)
;;; word
(setq-default word-wrap t)
;;; to make the cursor as wide as the character it is over
(setq x-stretch-cursor t)
;;; xcscope for cscope
(when (require 'xcscope nil t)
;; for large code base, set it to t.
(setq cscope-do-not-update-database t)
;; use xcscope for java too.
(add-hook 'java-mode-hook (function cscope:hook))
(add-hook 'eshell-mode-hook (function cscope:hook))
(setq cscope-database-regexps
'(("\\(sandbox/trunk\\)"
(t) ;; local cscope.out first
("/home/lgfang/projects/vsg/sandbox/lcp_lite/")
("/home/lgfang/projects/vsg/sandbox/libsoap-1.1.0/libcsoap/")
("/home/lgfang/projects/vsg/sandbox/libxml2/")
t ;; 't' doesn't work, have to comment out useless database-dir
;;("/remote/srm249/clientstore/b2008.09_icc_us02/syn/icc_sh/cscope.out.bak")
))))
(add-to-list 'load-path (concat my-extension-path "yasnippet"))
(when (require 'yasnippet nil t)
(yas/initialize)
(setq yas/root-directory
(list (concat my-extension-path "yasnippet/snippets")))
(when (file-exists-p "~/.emacs.snippets")
(add-to-list 'yas/root-directory "~/.emacs.snippets"))
(mapc 'yas/load-directory yas/root-directory)
;; Org-mode specific
(defun yas/org-very-safe-expand ()
(let ((yas/fallback-behavior 'return-nil)) (yas/expand)))
(add-hook 'org-mode-hook
(lambda ()
;; yasnippet (using the new org-cycle hooks)
(make-variable-buffer-local 'yas/trigger-key)
(setq yas/trigger-key [tab])
(add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
(define-key yas/keymap [tab] 'yas/next-field))))
;;; y/n instead of yes/no
(fset 'yes-or-no-p 'y-or-n-p)
;;; ------ end General ------
;;; ------ begin MyFunction ------
(defun my-ascii-table ()
"Display basic ASCII table (0 thru 128). From Rick on emacswiki"
(interactive)
(setq buffer-read-only nil) ;; Not need to edit the content, just read mode (added)
(local-set-key "q" 'bury-buffer) ;; Nice to have the option to bury the buffer (added)
(switch-to-buffer "*ASCII*")
(erase-buffer)
(save-excursion (let ((i -1))
(insert "ASCII characters 0 thru 127.\n\n")
(insert " Hex Dec Char| Hex Dec Char| Hex Dec Char| Hex Dec Char\n")
(while (< i 31)
(insert (format "%4x %4d %4s | %4x %4d %4s | %4x %4d %4s | %4x %4d %4s\n"
(setq i (+ 1 i)) i (single-key-description i)
(setq i (+ 32 i)) i (single-key-description i)
(setq i (+ 32 i)) i (single-key-description i)
(setq i (+ 32 i)) i (single-key-description i)))
(setq i (- i 96))))))
(defun my-goto-page (pageNumber)
"RFCs in ascii format use traditional page
delimiter (Ctrl-L). While Emacs Provides functions like
forward-page,backward-page etc., it doesn't provide goto-page or
sth alike. To go to certain page, I used to either go to the
beginning of the buffer at first or calculate how many pages to
be moved from current page at first. For me, that is a little
boring. I think this function may help. P.S. You may want to give
rfcview.el a try."
(interactive
(if (and current-prefix-arg (not (consp current-prefix-arg)))
(list (prefix-numeric-value current-prefix-arg))
;; Look for a default, a number in the buffer at point.
(let* ((default
(save-excursion
(skip-chars-backward "0-9")
(if (looking-at "[0-9]")
(buffer-substring-no-properties
(point)
(progn (skip-chars-forward "0-9") (point)))))))
(list (read-from-minibuffer
(format
(if default "Goto Page (%s): " "Goto Page: ") default)
nil nil t
'minibuffer-history
default)))))
(save-restriction
(widen)
(goto-char (point-min))
(forward-page (1- pageNumber))))
;;; for CVS
(defvar my-vc-tag-history nil "History list for tags")
(defun my-porting (tag)
(interactive
(list
(read-from-minibuffer "'TO' tag: " nil nil nil
'my-vc-tag-history)))
(delete-other-windows)
(vc-diff nil)
(other-window 1)
(find-file
(replace-regexp-in-string "sandbox/[^/]*/" (format "sandbox/%s/" tag)
(buffer-file-name))))
(defun my-cvs-co(tag module)
"(require 'pcvs)"
(interactive
(list (read-from-minibuffer "tag: " nil nil nil 'my-vc-tag-history)
(read-from-minibuffer "module:" nil nil nil 'minibuffer-history)
))
(let* ((sandbox (file-name-as-directory (expand-file-name "~/sandbox")))
(directory (concat sandbox tag)))
(make-directory directory t)
(cvs-cmd-do "checkout" directory (list "-r" tag module) nil 'new :noexist t)))
;;; for hideif
(defun my-hif-toggle-block ()
"toggle hide/show-ifdef-block"
(interactive)
(require 'hideif)
(let* ((top-bottom (hif-find-ifdef-block))
(top (car top-bottom)))
(goto-char top)
(hif-end-of-line)
(setq top (point))
(if (hif-overlay-at top)
(show-ifdef-block)
(hide-ifdef-block))))
(defun hif-overlay-at (position)
"An imitation of the one in hide-show"
(let ((overlays (overlays-at position))
ov found)
(while (and (not found) (setq ov (car overlays)))
(setq found (eq (overlay-get ov 'invisible) 'hide-ifdef)
overlays (cdr overlays)))
found))
(defun my-hide-ifdef-use-define-alist (name)
"A simple wrapper for `hide-ifdef-use-define-alist' -- lgfang"
(interactive
(list (let* ((prompt "Use MACRO define list: ")
(symbol-names (mapcar (lambda (a) (symbol-name (car a)))
hide-ifdef-define-alist)))
(if (require 'ido nil t)
(ido-completing-read prompt symbol-names)
(completing-read prompt symbol-names)))))
(setq hide-ifdef-initially t) ; also apply to buffers not opened yet
(setq my-define-alist name)
(hide-ifdefs) ; for current file
(hide-ifdef-use-define-alist name))
(defun my-hide-if-0()
"hide #if 0 blocks, inspired by internet."
(interactive)
(require 'hideif)
(save-excursion
(goto-char (point-min))
(while (re-search-forward "^[ \t]*#if[ \t]*0" nil t) (hide-ifdef-block))))
(when (> emacs-major-version 21)
(defun ido-goto-symbol ()
"Will update the imenu index and then use ido to select a
symbol to navigate to. From emacswiki, by shjk"
(interactive)
(imenu--make-index-alist)
(let ((name-and-pos '()) (symbol-names '()))
(flet ((addsymbols (symbol-list)
(when (listp symbol-list)
(dolist (symbol symbol-list)
(let ((name nil) (position nil))
(cond
((and (listp symbol) (imenu--subalist-p symbol))
(addsymbols symbol))
((listp symbol)
(setq name (car symbol))
(setq position (cdr symbol)))
((stringp symbol)
(setq name symbol)
(setq position (get-text-property 1 'org-imenu-marker symbol))))
(unless (or (null position) (null name))
(add-to-list 'symbol-names name)
(add-to-list 'name-and-pos (cons name position))))))))
(addsymbols imenu--index-alist))
(let* ((selected-symbol (ido-completing-read "jump to: " symbol-names nil nil
(thing-at-point 'symbol)))
(position (cdr (assoc selected-symbol name-and-pos))))
(push-mark)
(goto-char position))))
) ; end (when (> emacs-major-version 21)
(defun my-insert-date ()
"Insert current date at point. From Tijs van Bakel at
newsgroup: gnu.emacs.help. To customize format of date
string,refer to format-time-string."
(interactive)
(insert (format-time-string "%m/%d/%Y")))
(defun lgfang-log-view-diff (beg end)
"Overwrite the default log-view-diff, make use of
log-view-get-marked"
(interactive
(if (log-view-get-marked) (log-view-get-marked)
(list (log-view-current-tag (point))
(log-view-current-tag (point)))))
(when (string-equal beg end)
(save-excursion
(goto-char (point)) ;not marked
(log-view-msg-next)
(setq beg (log-view-current-tag))))
(vc-version-diff
(if log-view-per-file-logs
(list (log-view-current-file))
log-view-vc-fileset)
beg end))
(eval-after-load "log-view" '(fset 'log-view-diff 'lgfang-log-view-diff))
(defun lgfang-log-view-revision ()
"get marked revision (or revision at point)"
(interactive)
(let ((revision (if (log-view-get-marked) (car (log-view-get-marked))
(log-view-current-tag (point)))))
(switch-to-buffer-other-window
(vc-find-revision (log-view-current-file) revision))))
(eval-after-load "log-view"
'(define-key log-view-mode-map "v" 'lgfang-log-view-revision))
(defun my-mode-line-all () ; long/long/ago
"Sometimes there are too many infomation in mode line to show
it in one line. Using this function to show it in an message
box (or pop-up tool tip)"
(interactive)
(message "%s" (format-mode-line mode-line-format t))
;; (tooltip-show (format-mode-line mode-line-format t))
;; (message-box "%s" (format-mode-line mode-line-format t))
)
(defun my-recentf-open ()
"open recent files. In ido style if applicable"
(interactive)
(let* ((prompt "File Name: ")
(path-table (mapcar
(lambda (x) (cons (file-name-nondirectory
x) x)) recentf-list))
(fname (if (require 'ido nil t)
(ido-completing-read
prompt
(mapcar (lambda(x) (file-name-nondirectory
x)) recentf-list))
(completing-read prompt path-table))))
(find-file (cdr (assoc fname path-table)))))
(defun my-set-frame-title (formatString)
"a short hand to set frame title, ugly but works"
(interactive
(let ((default "---"))
(list (read-from-minibuffer "Set frame title: " nil nil t
'minibuffer-history default))))
(if (string-equal formatString "---")
(setq frame-title-format
(list (replace-regexp-in-string "\\..*$" ""system-name) ":"
'(buffer-file-name "%f"
(dired-directory dired-directory "%b"))))
(setq frame-title-format (message "%s" formatString))))
(defun my-toggle-selective-display()
"set-selective-display to current column or toggle
selective-display"
(interactive)
(let ((arg (progn (back-to-indentation) (1+ (current-column)))))
(set-selective-display (if (eq arg selective-display) nil arg))))
;;; ------ end MyFunction ------
(load "tmp.el" t nil nil)

