(setq user-full-name "Fang lungang" ange-ftp-default-user "lungangfang")
(setq viper-inhibit-startup-message t)
(setq viper-expert-level '5)
(when nil (setq viper-mode t)
(require 'viper))
(setq zoneinfo-style-world-list
'(("Asia/Shanghai" "China")
("US/Eastern" "Westford")
("US/Central" "IH")))
(setq legacy-style-world-list
'(("CST-8" "China")
("EST5EDT" "Westford")
("CST6CDT" "IH")))
(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
"~/My Documents/homepage/source/personal/"))
(add-to-list 'load-path my-extension-path)
(add-to-list 'load-path my-emacs-base)
(when (eq system-type 'windows-nt)
(setq exec-path (append '("c:/share/MPlayer-1.0rc2")
'("c:/cygwin/bin")
'("c:/cygwin/usr/local/bin")
exec-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"
))
)
(when window-system
(if (eq system-type 'windows-nt)
(create-fontset-from-fontset-spec
(concat
"-outline-Consolas-normal-r-normal-*-18-*-*-*-c-*-fontset-lgfang,"
fang," "chinese-gb2312:-outline-新宋体-normal-r-normal-*-*-*-96-96-c-*-iso10646-1,"
"chinese-gb18030:-outline-新宋体-normal-r-normal-*-*-*-96-96-c-*-iso10646-1"))
(create-fontset-from-fontset-spec
(concat
ng"))) "-unknown-文泉驿等宽正黑-normal-normal-normal-*-18-*-*-*-*-*-fontset-lgfang,"
"chinese-gb2312:-unknown-文泉驿等宽正黑-normal-normal-normal-*-*-*-*-*-*-0-iso10646-1,"
"chinese-gb18030:-unknown-文泉驿等宽正黑-normal-normal-normal-*-*-*-*-*-*-0-iso10646-1")))
(add-to-list 'default-frame-alist '(font . "fontset-lgfang"))
(set-default-font "fontset-lgfang"))
(setq initial-frame-alist '((top . 1) (left . 1) (width . 100) (height . 32)))
(setq calendar-latitude 36.06
calendar-longitude 120.27
calendar-location-name "QingDao")
(if (>= emacs-major-version 23)
(set-language-environment 'Chinese-GB18030)
(set-language-environment 'Chinese-GB))
(define-key global-map (kbd "M-/") 'hippie-expand)
(define-key global-map (kbd "C-x C-b") 'ibuffer)
(define-key global-map (kbd "M-g c") 'move-to-column)
(define-key global-map (kbd "M-g f") 'ffap)
(define-key global-map (kbd "M-g w") 'webjump)
(define-key global-map (kbd "M-g ]") 'my-goto-page)
(define-key global-map (kbd "M-,") 'hs-toggle-hiding)
(define-key global-map (kbd "M-.") 'my-toggle-selective-display)
(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 [f2] 'global-whitespace-mode)
(define-key global-map [f5] 'my-recentf-open)
(define-key global-map [f6] 'my-whitespace-cleanup)
(define-key global-map [f7] 'flyspell-mode)
(define-key global-map [f8] 'flyspell-prog-mode)
(define-key global-map [f9] 'my-mode-line-all)
(define-key global-map [f10] 'ido-goto-symbol)
(define-key global-map [f11] 'org-remember)
(require 'ascii nil t)
(setq-default abbrev-mode t save-abbrevs nil)
(load "abbrev-defs" t nil nil)
(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))
(setq-default asm-comment-char 35)
(when (and (> emacs-major-version 21)
(require 'auto-complete nil t))
(require 'auto-complete-semantic nil t)
(global-auto-complete-mode t)
(define-key ac-complete-mode-map "\C-n" 'ac-next)
(define-key ac-complete-mode-map "\C-p" 'ac-previous)
(setq ac-dwim t)
(setq ac-auto-start 3
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
))
(setq-default ac-sources
'(ac-source-imenu
ac-source-abbrev
ac-source-words-in-buffer
ac-source-files-in-current-dir
ac-source-filename
))
(defconst ac-c++-keywords
(sort
(list "and" "bool" "compl" "do" "export" "goto" "namespace"
"or_eq" "return" "struct" "try" "using" "xor" "and_eq"
"break" "const" "double" "extern" "if" "new" "private"
"short" "switch" "typedef" "virtual" "xor_eq" "asm" "case"
"const_cast" "dynamic_cast" "false" "inline" "not"
"protected" "signed" "template" "typeid" "void" "auto"
"catch" "continue" "else" "float" "int" "not_eq" "public"
"sizeof" "this" "typename" "volatile" "bitand" "char"
"default" "enum" "for" "long" "operator" "register"
"static" "throw" "union" "wchar_t" "bitor" "class" "delete"
"explicit" "friend" "mutable" "or" "reinterpret_cast"
"static_cast" "true" "unsigned" "while" )
#'(lambda (a b) (> (length a) (length b)))))
(defvar ac-source-c++
'((candidates
. (lambda ()
(all-completions ac-target ac-c++-keywords))))
"Source for c++ keywords.")
(add-hook 'c++-mode-hook (lambda ()
(add-to-list 'ac-sources 'ac-source-c++)))
(dolist (mode (list 'emacs-lisp-mode-hook
'lisp-interaction-mode))
(add-hook mode
'(lambda () (add-to-list 'ac-sources 'ac-source-symbols))))
(defconst ac-perl-builtin-functions
'( "abs" "exec" "glob" "order" "seek" "symlink" "accept" "exists"
"gmtime" "our" "seekdir" "syscall" "alarm" "exit" "goto"
"pack" "select" "sysopen" "atan" "exp" "grep" "package"
"semctl" "sysread" "bind" "fcntl" "hex" "pipe" "semget"
"sysseek" "binmode" "fileno" "import" "pop" "semop" "system"
"bless" "flags" "index" "pos" "send" "syswrite" "caller"
"flock" "int" "precision" "setgrent" "tell" "chdir" "fork"
"ioctl" "print" "sethostent" "telldir" "chmod" "format" "join"
"printf" "setnetent" "tie" "chomp" "formline" "keys"
"prototype" "setpgrp" "tied" "chop" "getc" "kill" "push"
"setpriority" "time" "chown" "getgrent" "last" "q"
"setprotoent" "times" "chr" "getgrgid" "lc" "qq" "setpwent"
"tr" "chroot" "getgrnam" "lcfirst" "qr" "setservent"
"truncate" "close" "gethostbyaddr" "length" "quotemeta"
"setsockopt" "uc" "closedir" "gethostbyname" "link" "qw"
"shift" "ucfirst" "connect" "gethostent" "listen" "qx"
"shmctl" "umask" "continue" "getlogin" "local" "rand" "shmget"
"undef" "cos" "getnetbyaddr" "localtime" "read" "shmread"
"unlink" "crypt" "getnetbyname" "lock" "readdir" "shmwrite"
"unpack" "dbmclose" "getnetent" "log" "readline" "shutdown"
"unshift" "dbmopen" "getpeername" "lstat" "readlink" "sin"
"untie" "defined" "getpgrp" "m" "readpipe" "size" "use"
"delete" "getppid" "map" "recv" "sleep" "utime" "die"
"getpriority" "mkdir" "redo" "socket" "values" "do"
"getprotobyname" "msgctl" "ref" "socketpair" "vec" "dump"
"getprotobynumber" "msgget" "rename" "sort" "vector" "each"
"getprotoent" "msgrcv" "require" "splice" "wait" "endgrent"
"getpwent" "msgsnd" "reset" "split" "waitpid" "endhostent"
"getpwnam" "my" "return" "sprintf" "wantarray" "endnetent"
"getpwuid" "next" "reverse" "sqrt" "warn" "endprotoent"
"getservbyname" "no" "rewinddir" "srand" "write" "endpwent"
"getservbyport" "oct" "rindex" "stat" "y" "endservent"
"getservent" "open" "rmdir" "study" "eof" "getsockname"
"opendir" "s" "sub" "eval" "getsockopt" "ord" "scalar"
"substr"))
(defvar ac-source-perl
'((candidates
. (lambda ()
(all-completions ac-target ac-perl-builtin-functions))))
"Source for perl.")
(add-hook 'cperl-mode-hook (lambda ()
(add-to-list 'ac-sources 'ac-source-perl))))
(setq auto-insert t
auto-insert-directory (concat my-emacs-base "auto-insert/"))
(add-hook 'find-file-hooks 'auto-insert)
(setq auto-mode-alist (append '(("\\.[xX]\\'" . c-mode)
("\\.mak\\'" . makefile-mode)
("\\.make\\'" . makefile-mode)
("\\.gdb\\'" . gdb-script-mode)
("\\.v\\'" . verilog-mode)
) auto-mode-alist))
(global-auto-revert-mode t)
(setq make-backup-files t version-control 'never)
(when (< emacs-major-version 23)
(add-to-list 'load-path (concat my-extension-path "bbdb-2.35/lisp")))
(when (require 'bbdb nil t)
(bbdb-initialize)
(setq bbdb-default-area-code 532
bbdb-default-country "China"
bbdb-file (concat my-personal-path "my-bbdb")
bbdb-info-file (concat my-extension-path "bbdb-2.35/texinfo/bbdb.info")
bbdb-north-american-phone-numbers-p nil)
(require 'bbdb-vcard-export nil t))
(when (require 'browse-kill-ring nil t)
(browse-kill-ring-default-keybindings))
(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)
(c-subword-mode t)
(hide-ifdef-mode 1)
(turn-on-cwarn-mode)
(define-key c-mode-base-map (kbd "M-'") 'my-hif-toggle-block)
))
(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)
(when (< emacs-major-version 23) (require 'cal-china-x nil t))
(when (require 'color-theme nil t)
(if window-system (color-theme-gnome2)
(color-theme-calm-forest)))
(column-number-mode t)
(setq comment-style 'extra-line)
(require 'compile)
(setq compile-command "gcc -g -Wall "
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)
(setq default-major-mode 'text-mode)
(when (> emacs-major-version 21) (desktop-save-mode -1))
(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"))
(setq dired-recursive-copies 'top dired-recursive-deletes 'top)
(require 'dired-x)
(add-hook 'dired-load-hook (lambda () (load "dired-x")))
(add-hook 'dired-mode-hook (lambda () (dired-omit-mode 1)))
(setq dired-omit-files (concat dired-omit-files "\\|^\\..+$"))
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
(add-hook 'emacs-lisp-mode-hook
(lambda()
(imenu-add-menubar-index)
(hs-minor-mode 1)))
(add-hook 'eshell-mode-hook
(lambda ()
(define-key eshell-mode-map [up] 'previous-line)
(define-key eshell-mode-map [down] 'next-line)))
(when (require 'multi-eshell nil t)
(setq multi-eshell-name "*eshell*")
(setq multi-eshell-shell-function (quote (eshell))))
(add-hook 'find-file-hooks (lambda ()
(font-lock-add-keywords
nil '(("\\<\\(lgfang\\|TODO\\|FIXME\\|NOTE\\):"
. (0 font-lock-warning-face t))))))
(font-lock-add-keywords 'c-mode '(("\\<\\(TRUE\\|FALSE\\)\\>"
. font-lock-constant-face)))
(setq-default fill-column 80)
(when (> emacs-major-version 21)
(require 'flymake)
(setq flymake-no-changes-timeout 2) (setq flymake-allowed-file-name-masks
(cons '("\\.cc\\'" flymake-simple-make-init) flymake-allowed-file-name-masks))
)
(setq frame-title-format
(list (replace-regexp-in-string "\\..*$" ""system-name) ":"
'(buffer-file-name "%f"
(dired-directory
dired-directory "%b"))))
(require 'hideif)
(setq hide-ifdef-initially nil)
(setq hs-allow-nesting t)
(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))
(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)
(when (> emacs-major-version 21)
(ido-mode 'buffer)
(setq ido-enable-flex-matching t))
(setq imenu-sort-function 'imenu--sort-by-name)
(setq inhibit-startup-message nil)
(setq ispell-program-name "aspell")
(when (> emacs-major-version 21)
(require 'linum nil t)
)
(setq longlines-wrap-follows-window-size t)
(setq messages-buffer-max-lines 500)
(setq mouse-yank-at-point t) (when (not window-system) (xterm-mouse-mode 1))
(when (or (>= emacs-major-version 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")))
(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)))
(when (and (> emacs-major-version 21)
(require 'org nil t))
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
(setq org-hide-leading-stars t
org-cycle-include-plain-lists t
org-archive-location "::* Archived Tasks"
org-log-done 'time
org-deadline-warning-days 14
org-agenda-skip-deadline-if-done t
org-agenda-skip-scheduled-if-done t
org-agenda-show-all-dates t
org-agenda-start-on-weekday nil
org-agenda-include-diary t
org-agenda-files (list
(concat my-personal-path "work-tasks.org")
(concat my-personal-path "my-tasks.org")
(concat my-personal-path "my-readings.org")
(concat my-personal-path "my-anniversaries.org")
)
org-reverse-note-order t
org-default-notes-file "~/income.org" org-remember-templates (list
(list ?p "* TODO %?" (concat my-personal-path "my-tasks.org"))
(list ?w "* TODO %?" (concat my-personal-path "work-tasks.org")))
org-tag-alist '(("@work" . ?w) ("@home" . ?h) ("out" . ?o)
("phone" . ?p) ("read" . ?r) ("video" . ?v)
("computer" . ?c) ("someday" . ?s))
org-todo-keywords '((sequence "TODO(t)" "NEXT(n)" "STARTED(s)" "WAITING(w@/!)"
"|" "HOLD(h@/!)" "DELEGATED(p@/!)" "CANCELED(c@/!)" "DONE(d!)"))
org-agenda-custom-commands '( ("a" "Agenda + TODO" ((todo "TODO")(agenda)(todo "WAITING")))
("n" todo "NEXT" nil)
("h" todo "HOLD" nil)
("s" tags "someday")
)
org-publish-project-alist
'(("org"
:base-directory "~/My Documents/homepage/source/personal/"
:publishing-directory "~/My Documents/tmp"
:section-numbers nil
:table-of-contents nil
:exclude "my.*.org"
:style "<link rel=stylesheet
href=\"../my.css\"
type=\"text/css\">"))
)
(add-hook 'remember-mode-hook 'org-remember-apply-template)
(add-hook 'org-mode-hook 'imenu-add-menubar-index))
(defalias 'perl-mode 'cperl-mode)
(load "pylint" t nil nil)
(add-hook 'python-mode-hook
(lambda()
(imenu-add-menubar-index)
(c-subword-mode t)
(outline-minor-mode 1)
))
(require 'recentf)
(when (> emacs-major-version 21)
(add-to-list 'recentf-keep 'file-remote-p))
(setq recentf-max-saved-items 100)
(recentf-mode 1)
(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)
))
(setq require-final-newline t)
(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))
(add-to-list 'auto-mode-alist '("\\.rnc\\'" . rnc-mode))
(autoload 'rnc-mode "rnc-mode")
(when (> emacs-major-version 21) (savehist-mode t))
(setq scroll-margin 0 scroll-conservatively 100)
(when (> emacs-major-version 21) (server-start))
(add-hook 'sh-mode-hook (lambda ()
(hs-minor-mode 1)
(setq imenu-generic-expression
my-sh-imenu-generic-expression)
(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)))
(show-paren-mode t)
(load "my-skeleton" t nil nil)
(setq skeleton-pair nil skeleton-pair-on-word nil) (when skeleton-pair (global-set-key (kbd "(") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "[") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "{") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "'") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "`") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "\"") 'skeleton-pair-insert-maybe)
(add-hook 'c-mode-hook ys '(lambda ()
(define-key c-mode-base-map "{" 'skeleton-pair-insert-maybe)
(define-key c-mode-base-map "(" 'skeleton-pair-insert-maybe)
))
)
(setq speedbar-show-unknown-files t)
(when (>= emacs-major-version 23) (setq split-width-threshold 120))
(setq system-time-locale "C")
(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
indent-tabs-mode nil)
(when (and (require 'tabbar nil t) window-system) (tabbar-mode 1))
(add-hook 'tcl-mode-hook (lambda ()
(imenu-add-menubar-index)
(hs-minor-mode 1)
(c-subword-mode t)
))
(add-to-list 'interpreter-mode-alist '("expect" . tcl-mode))
(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 "\\\\?>")
(load "toggle-window-dedicated" t nil nil)
(tool-bar-mode -1)
(setq tooltip-use-echo-area t)
(tooltip-mode 1)
(when (> emacs-major-version 21)
(require 'tramp)
(setq tramp-debug-buffer t)
(when (eq system-type 'windows-nt)
(setq tramp-rsh-end-of-line "\r")
(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"))
(tramp-copy-args nil)
(tramp-copy-keep-date-arg nil)
)))
(let ( (ssh-program (if (eq system-type 'windows-nt) "plink" "ssh"))
(ftp-program (if (eq system-type 'windows-nt) "plink" "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.*" "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.*")) tramp-default-method-alist))))
(setq-default transient-mark-mode t)
(when (>= emacs-major-version 23)
(setq delete-by-moving-to-trash t)
(setq trash-directory "~/.trashbin") )
(autoload 'verilog-mode "verilog-mode" "Verilog mode" t )
(setq-default truncate-lines nil)
(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))
(require 'webjump)
(load (concat my-personal-path "my-web-bookmark") t nil nil)
(which-function-mode t)
(if (>= emacs-major-version 23)
(progn
(setq whitespace-line-column fill-column
whitespace-style '(trailing
indentation
space-before-tab
space-after-tab
lines-tail
empty))
(global-whitespace-mode 1))
(setq-default indicate-empty-lines t
show-trailing-whitespace nil)
(mapcar (lambda(hook)
(add-hook hook
(lambda () (setq show-trailing-whitespace t))))
(list 'emacs-lisp-mode-hook
'c-mode-common-hook
'python-mode-hook
'nxml-mode-hook
'tcl-mode-hook
'muse-mode-hook)))
(windmove-default-keybindings)
(setq woman-use-own-frame nil)
(when (require 'xcscope nil t)
(setq cscope-do-not-update-database t)
(add-hook 'java-mode-hook (function cscope:hook))
(add-hook 'eshell-mode-hook (function cscope:hook)))
(fset 'yes-or-no-p 'y-or-n-p)
(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. --lgfang"
(interactive
(if (and current-prefix-arg (not (consp current-prefix-arg)))
(list (prefix-numeric-value current-prefix-arg))
(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)))
)
(defun my-hif-toggle-block ()
"toggle hide/show-ifdef-block --lgfang"
(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 --lgfang"
(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-if-0()
"hide #if 0 blocks, inspired by internet. --lgfang"
(interactive)
(require 'hideif)
(save-excursion
(goto-char (point-min))
(while (re-search-forward "^[ \t]*#if[ \t]*0" nil t) (hide-ifdef-block)) )
)
(add-hook 'c-mode-hook 'my-hide-if-0)
(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. --lgfang"
(interactive)
(insert (format-time-string "%m/%d/%Y")))
(defun my-mode-line-all () "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) --lgfang"
(interactive)
(message "%s" (format-mode-line mode-line-format t))
)
(defun my-recentf-open ()
"open recent files. In ido style if applicable --lgfang"
(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 --lgfang"
(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 --lgfang"
(interactive)
(let ((arg (progn (back-to-indentation) (1+ (current-column)))))
(set-selective-display (if (eq arg selective-display) nil arg))))
(defun my-whitespace-cleanup (beg end)
"Modified standard delete-trailing-whitespace to work regards
region. And add untabify. I don't like the standard
whitespace-cleanup come with emacs22.--lgfang"
(interactive "r")
(if (>= emacs-major-version 23)
(whitespace-cleanup-region beg end)
(save-match-data
(save-excursion
(goto-char beg)
(while (re-search-forward "\\s-$" end t)
(skip-syntax-backward "-" (save-excursion (forward-line 0) (point)))
(save-match-data
(if (looking-at ".*\f")
(goto-char (match-end 0))))
(delete-region (point) (match-end 0))))))
(untabify (region-beginning) (region-end)))
(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))
(position (cdr (assoc selected-symbol name-and-pos))))
(goto-char position))))
)
(custom-set-faces
'(flymake-errline ((((class color)) (:inherit font-lock-warning-face :underline t))))
'(flymake-warnline ((((class color)) (:foreground "Orange" :underline t :weight bold)))))