Current directory :
Root directory

Tree directory :
hdh@jabber.cz
  Filter :
  Language :  
 
;;Emacs server
(server-start)
 
;;load-path
(add-to-list 'load-path "~/dots/emacs/" t)
(add-to-list 'load-path "~/e1/path/32/gambc/current/share/emacs/site-lisp/" t)
 
;; Gambit modes
(autoload 'gambit-inferior-mode "gambit" "Hook Gambit mode into cmuscheme.")
(autoload 'gambit-mode "gambit" "Hook Gambit mode into scheme.")
(add-hook 'inferior-scheme-mode-hook (function gambit-inferior-mode))
(add-hook 'scheme-mode-hook (function gambit-mode))
(setq scheme-program-name "gsi -:t")
 
;; Python
(setq python-python-command "ipython") ;; TODO check if we have it first
 
;;I have two Backspace keys, and the World is still not enough
(global-set-key (kbd "C-w") 'backward-kill-word) ;; kill-word is M-d
(global-set-key (kbd "C-y") 'clipboard-yank)
(global-set-key (kbd "C-x C-w") 'kill-region)
(global-set-key (kbd "C-x M-w") 'clipboard-kill-ring-save)
(global-set-key (kbd "C-<return>") 'newline)
(global-set-key (kbd "C-x 4 C-b") 'switch-to-buffer-other-window)
 
;;no beep beep
(setq visible-bell t)
 
;; Backups and Autosaves
(setq
   backup-by-copying t                 ;; don't clobber symlinks
   backup-directory-alist '(("." . "~/.emacs.d/autosaves/")) ;; don't litter
   delete-old-versions t
   kept-new-versions 6
   kept-old-versions 2
   version-control t)                  ;; use versioned backups
 
(setq default-major-mode 'text-mode)
(setq fill-column 79)
 
(setq default-input-method "ucs")
;(toggle-input-method)
(add-to-list 'auto-mode-alist
 '("www.lyricwiki.org.[[:alnum:]]+.txt\\'"  lambda nil (set-input-method "vietnamese-telex")))
(add-to-list 'auto-mode-alist
 '("mail.google.com.[[:alnum:]]+.txt\\'"  lambda nil (set-input-method "vietnamese-telex")))
(add-to-list 'auto-mode-alist
 '("translations.launchpad.net.[[:alnum:]]+.txt\\'" lambda nil (set-input-method "vietnamese-telex")))
(add-to-list 'file-coding-system-alist
  '("mail.google.com.[[:alnum:]]+.txt\\'" . utf-8-unix))
;(set-fontset-font "fontset-default" 'latin '("tahoma" . "unicode-bmp"))
 
;;color-theme
(require 'color-theme)
(color-theme-initialize)
(setq color-theme-is-global t)
(if window-system
    (color-theme-dark-blue2)
    (color-theme-renegade))
 
;;shell-command completion
(require 'shell-command)
(shell-command-completion-mode)
 
;; dirvars.el http://www.emacswiki.org/cgi-bin/emacs/DirVarsPackage
(require 'dirvars)
 
;;load anything.el
;(require 'anything)
 
;; Code Folding
(load "folding")
(folding-mode-add-find-file-hook)
(global-set-key (kbd "C-c f") 'folding-toggle-show-hide)
(global-set-key (kbd "C-c c") 'folding-whole-buffer)
(global-set-key (kbd "C-c o") 'folding-open-buffer)
(folding-add-to-marks-list 'python-mode "#[[["  "#]]]"  nil t)
 
;;hniksic's highlighted HTML
;(require 'htmlize)
 
;;display blank chars and longlines
;(require 'blank-mode)
;(blank-global-mode-on)
(require 'show-wspace)
(toggle-trailing-whitespace-font-lock)
 
;; uniquify with a sensible name
(require 'uniquify)
(setq uniquify-buffer-name-style 'post-forward)
(setq uniquify-trailing-separator-p t)
(defadvice iswitchb-kill-buffer (after rescan-after-kill activate)
  "*Regenerate the list of matching buffer names after a kill.
    Necessary if using `uniquify' with `uniquify-after-kill-buffer-p'
    set to non-nil."
  (setq iswitchb-buflist iswitchb-matches)
  (iswitchb-rescan))
(defun iswitchb-rescan ()
  "*Regenerate the list of matching buffer names."
  (interactive)
  (iswitchb-make-buflist iswitchb-default)
  (setq iswitchb-rescan t))
 
;; css
(setq css-indent-offset 2)
 
;; nxhtml-mode
(load "~/dots/emacs/nxml/autostart.el")
(setq indent-region-mode t)
(setq indent-tabs-mode nil)
(setq nxhtml-global-minor-mode t)
(setq nxhtml-global-validation-header-mode t)
(setq nxhtml-skip-welcome t)
(add-hook 'nxhtml-mode-hook 'nxml-fontify-buffer)
(setq nxhtml-image-completion-pattern "\\.\\(?:png\\|svg\\|jpg\\|jpeg\\|gif\\)$")
(setq nxhtml-validation-headers '(("head-utf-8" . "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
  <head>
")))
(setq nxhtml-default-encoding 'UTF-8)
(eval-after-load 'nxhtml
  '(define-key nxhtml-mode-map [f2] 'nxml-complete))
(setq html-mode-hook
      '(lambda ()
	 (longlines-mode t)))
;(setq nxhtml-mode-hook
;      '(lambda ()
;         (longlines-mode t)))
;; HTML modes for HTML files
(add-to-list 'auto-mode-alist
   '(".html\\'" . (lambda ()
		      (load-library "html-helper-mode")
		      (html-helper-mode))))
(add-to-list 'auto-mode-alist
   '(".xhtml\\'" . nxhtml-mode))
(add-to-list 'magic-mode-alist
   '("<\\?xml \\(?:.\\|
\\)+?>\\(?:\\|
\\)<!DOCTYPE html " . nxhtml-mode)) ;; mở file trông giĝ́ xhtml với nxhtml-mode
;; SVG
(add-to-list 'auto-mode-alist
   '(".svg\\'" . nxml-mode))
(add-to-list 'magic-mode-alist
   '("<\\?xml \\(?:.\\|
\\)+?>\\(?:\\|
\\)<!DOCTYPE svg " . nxml-mode))
;; ui
(add-to-list 'magic-mode-alist
    '("<ui " . nxml-mode))
 
;;dictionary
(autoload 'dictionary-search "dictionary"
  "Ask for a word and search it in all dictionaries" t)
(autoload 'dictionary-match-words "dictionary"
  "Ask for a word and search all matching words in the dictionaries"
t)
(autoload 'dictionary-lookup-definition "dictionary"
  "Unconditionally lookup the word at point." t)
(autoload 'dictionary "dictionary"
  "Create a new dictionary buffer" t)
(autoload 'dictionary-mouse-popup-matching-words "dictionary"
  "Display entries matching the word at the cursor" t)
(autoload 'dictionary-popup-matching-words "dictionary"
  "Display entries matching the word at the point" t)
(autoload 'dictionary-tooltip-mode "dictionary"
  "Display tooltips for the current word" t)
(autoload 'global-dictionary-tooltip-mode "dictionary"
  "Enable/disable dictionary-tooltip-mode for all buffers" t)
 
(autoload 'dictionary-lookup-definition "dictionary"
  "Unconditionally lookup the word at point." t)
(autoload 'dictionary "dictionary"
  "Create a new dictionary buffer" t)
(autoload 'dictionary-mouse-popup-matching-words "dictionary"
  "Display entries matching the word at the cursor" t)
(autoload 'dictionary-popup-matching-words "dictionary"
  "Display entries matching the word at the point" t)
(autoload 'dictionary-tooltip-mode "dictionary"
  "Display tooltips for the current word" t)
(autoload 'global-dictionary-tooltip-mode "dictionary"
  "Enable/disable dictionary-tooltip-mode for all buffers" t)
(global-set-key "\C-cs" 'dictionary-search)
(global-set-key "\C-cm" 'dictionary-match-words)
;; font-lock is messed up by the pronunciation guide of some dicts
;(setq dictionary-mode-hook
;      '(font-lock-mode nil))
(setq dictionary-server "localhost")
 
;; rect-mark
;; Support for marking a rectangle of text with highlighting.
(define-key ctl-x-map "r\C-@" 'rm-set-mark)
(define-key ctl-x-map [?r ?\C-\ ] 'rm-set-mark)
(define-key ctl-x-map "r\C-x" 'rm-exchange-point-and-mark)
(define-key ctl-x-map "r\C-w" 'rm-kill-region)
(define-key ctl-x-map "r\M-w" 'rm-kill-ring-save)
(define-key global-map [S-down-mouse-1] 'rm-mouse-drag-region)
(autoload 'rm-set-mark "rect-mark"
  "Set mark for rectangle." t)
(autoload 'rm-exchange-point-and-mark "rect-mark"
  "Exchange point and mark for rectangle." t)
(autoload 'rm-kill-region "rect-mark"
  "Kill a rectangular region and save it in the kill ring." t)
(autoload 'rm-kill-ring-save "rect-mark"
  "Copy a rectangular region to the kill ring." t)
(autoload 'rm-mouse-drag-region "rect-mark"
  "Drag out a rectangular region with the mouse." t)
;; Use this section in your "~/.emacs" to modify picture mode so that
;; it automatically uses the rect-mark equivalents of many commands.
;; One vision of a better picture mode.
(add-hook 'picture-mode-hook 'rm-example-picture-mode-bindings)
(autoload 'rm-example-picture-mode-bindings "rect-mark"
  "Example rect-mark key and mouse bindings for picture mode.")
 
;;contact info
(setq user-full-name "Hoàng Đức Hiếu")
(setq user-email-address "hieu.d.hoang@gmail.com")
(setq pgg-gpg-user-id (format "%s <%s>" user-full-name user-email-address))
 
;; save minibuffer between session
(savehist-mode t)
;; save editing files between session
(desktop-save-mode 1)
(setq history-length 250)
(add-to-list 'desktop-globals-to-save 'file-name-history)
;; session.el
(require 'session)
(add-hook 'after-init-hook 'session-initialize)
 
;; ANSI color shell
(ansi-color-for-comint-mode-on)
 
(transient-mark-mode t)
;(longlines-mode t)
(setq longlines-auto-wrap t)
(setq longlines-show-hard-newlines t)
(put 'narrow-to-region 'disabled nil)
(put 'upcase-region 'disabled nil)
;; removes gnu startup screen
(setq inhibit-startup-message t)
(setq isearch-allow-scroll t)
(setq query-replace-skip-read-only t)
 
;; inserts a final new line if missing
;; `visit' means add a newline (as an undoable change) if it's needed
;; when visiting the file.
;; `visit-save' means add a newline (as an undoable change) if it's
;; needed when visiting the file, and also add a newline if it's
;; needed
;; when saving the file.
(setq require-final-newline 'visit-save)
 
;; disable menubar when running emacs in a terminal
(if window-system
    (menu-bar-mode 1)
    (menu-bar-mode -1))
 
;;
(setq history-delete-duplicates t)
 
;; replaces all "answer yes or no" prompts with "answer y or n"
(fset 'yes-or-no-p 'y-or-n-p)
 
;; interactive buffer switching (lists buffers, selects while typing)
(iswitchb-mode 1)
 
;; make sure that emacs starts the ispell process in your home
;; directory (otherwise can prevent unmounting of usb drive)
(setq ispell-process-directory (expand-file-name "~/"))
 
;; latex-mode
(setq latex-mode-hook
      '(lambda ()
	 (longlines-mode t)))
 
;; Wikipedia-mode
(autoload 'wikipedia-mode "wikipedia-mode.el"
  "Major mode for editing documents in Wikipedia markup."
  t)
(add-to-list 'auto-mode-alist
   '(".mwiki\\'" . wikipedia-mode))
 
(setq wikipedia-mode-hook
   '(lambda ()
     (progn
       (abbrev-mode)
 
       (defun hdh/wikipedia-insert-audience-sentence (&optional number)
          "insert a mark for an audience sentence, give numeric arg
for the speaker's sequence, give 0 for no number"
          (interactive "p")
	  (insert (if (eq number 0)
                      "'''[Audience member:]'''"
                      (format "'''[Audience member %d:]'''" number))))
       (define-key wikipedia-mode-map (kbd "C-c C-f C-q") 'hdh/wikipedia-insert-audience-sentence)
 
       ;;markup insert
       (defun hdh/wikipedia-insert-all (left-mark right-mark back-move
forth-move)
         (if (or (and (boundp 'zmacs-region-active-p)
zmacs-region-active-p)
                 (and (boundp 'transient-mark-mode) mark-active))
                 (save-excursion
                      (if (< (point) (mark))
                          (exchange-point-and-mark))
                      (goto-char (point))
                      (insert left-mark)
                      (goto-char (mark))
                      (insert right-mark)))
                 (insert left-mark right-mark)
                 (if (< (point) (mark))
                     (backward-char back-move)
                     (forward-char forth-move)))
       ;;foo mark
       (defun hdh/wikipedia-insert-foo ()
         (interactive)
          (hdh/wikipedia-insert-all "foo" "oof" 3 3))
       (define-key wikipedia-mode-map (kbd "C-c C-f C-f") 'hdh/wikipedia-insert-foo)
 
       ;; draft mark
       (defun hdh/wikipedia-insert-draft ()
         (interactive)
         (if (or (and (boundp 'zmacs-region-active-p)
zmacs-region-active-p)
                 (and (boundp 'transient-mark-mode) mark-active))
                 (save-excursion
                      (goto-char (point))
                      (insert "<!--d-->")
                      (goto-char (mark))
                      (insert "<!--d-->"))
                 (insert "<!--d--><!--d-->")
                 (backward-char 8)))
       (define-key wikipedia-mode-map (kbd "C-c C-f C-d") 'hdh/wikipedia-insert-draft)
 
       ;; w:link|here
       (defun hdh/wikipedia-insert-link-wikipedia ()
         (interactive)
         (if (or (and (boundp 'zmacs-region-active-p)
zmacs-region-active-p)
                 (and (boundp 'transient-mark-mode) mark-active))
             (save-excursion
                 (if (< (point) (mark))
                     (exchange-point-and-mark))
                 (goto-char (point))
                 (insert "]]")
                 (goto-char (mark))
                 (insert "[[w:")
                 (forward-char 4))
             (insert "[[w:]]")
             (backward-char 2)))
       (define-key wikipedia-mode-map (kbd "C-c C-f C-w") 'hdh/wikipedia-insert-link-wikipedia)
 
       t)))
 
;; save all buffers then close all buffers
(defun hdh/save-kill-buffers ()
  (interactive)
  (save-some-buffers)
  (kill-some-buffers))
 
;; scrolling without moving the point
(global-set-key (kbd "M-n") (lambda ()
			 (interactive) (scroll-up (/ (window-height)
3))))
(global-set-key (kbd "M-p") (lambda ()
			 (interactive) (scroll-down (/ (window-height)
3))))
 
;; counts all the words in the buffer
(defun hdh/count-words-buffer ()
  (interactive)
  (count-words-region (point-min) (point-max)))
 
 
;;emms
;; (add-to-list 'load-path "~/e1/home/emacs/emms-2.1")
;; (require 'emms-setup)
;; (emms-devel)
;; (emms-default-players)
 
;; (setq emms-source-file-default-directory "/Music")
 
;; (defun emms-osd-cat (string)
;;   (shell-command ("osd_cat -p middle -A center --wait --delay=3"))
;;   nil)
 
;;Erlang mode
;;(add-to-list 'load-path "~/e1/path/32/erlang/lib/erlang/lib/tools-2.5.4/emacs")
;;(setq erlang-root-dir "~/e1/path/32/erlang/lib/erlang")
;;(add-to-list 'exec-path "~/e1/path/32/erlang/lib/erlang/bin")
;;(require 'erlang-start)
 
;;Steve Yegge's HTML highlight
;; (defun syntax-highlight-region (start end)
;;   "Adds <font> tags into the region that correspond to the
;; current color of the text.  Throws the result into a temp
;; buffer, so you don't dork the original."
;;   (interactive "r")
;;   (let ((text (buffer-substring start end)))
;;     (with-output-to-temp-buffer "*html-syntax*"
;;       (set-buffer standard-output)
;;       (insert "<pre>")
;;       (save-excursion (insert text))
;;       (save-excursion (syntax-html-escape-text))
;;       (while (not (eobp))
;; 	(let ((plist (text-properties-at (point)))
;; 	      (next-change
;; 	       (or (next-single-property-change
;; 		    (point) 'face (current-buffer))
;; 		   (point-max))))
;; 	  (syntax-add-font-tags (point) next-change)
;; 	  (goto-char next-change)))
;;       (insert "\n</pre>"))))
 
;; (defun syntax-add-font-tags (start end)
;;   "Puts <font> tag around text between START and END."
;;   (let (face color rgb name r g b)
;;     (and
;;      (setq face (get-text-property start 'face))
;;      (or (if (listp face) (setq face (car face))) t)
;;      (setq color (face-attribute face :foreground))
;;      (setq rgb (assoc (downcase color) color-name-rgb-alist))
;;      (destructuring-bind (name r g b) rgb
;;        (let ((text (buffer-substring-no-properties start end)))
;; 	 (delete-region start end)
;; 	 (insert (format "<font color=#%.2x%.2x%.2x>" r g b))
;; 	 (insert text)
;; 	 (insert "</font>"))))))
 
;; (defun syntax-html-escape-text ()
;;   "HTML-escapes all the text in the current buffer, starting at
;; (point)."
;;   (save-excursion (replace-string "<" "&lt;"))
;;   (save-excursion (replace-string ">" "&gt;")))
 
;;totd from emacswiki.org
(require 'cl)
(defun totd ()
 (interactive)
 (with-output-to-temp-buffer "*Tip of the day*"
   (let* ((commands (loop for s being the symbols
                          when (commandp s) collect s))
          (command (nth (random (length commands)) commands)))
     (princ
      (concat "Your tip for the day is:\n========================\n\n"
              (describe-function command)
              "\n\nInvoke with:\n\n"
              (with-temp-buffer
                (where-is command t)
                (buffer-string)))))))
(random t)
(totd)
 
 
(setq scroll-step 1)                    ; scroll one line at a time
(display-time-mode t)                   ; display time below
(show-paren-mode t)                     ; show parenthesis
(setq column-number-mode t)             ; show column numbers below
(transient-mark-mode t)                 ; show mark visually...
;(setq make-backup-files nil)         ; no nasty back-up files
(setq show-trailing-whitespace t)       ; show whitespaces at the end of the line
(setq frame-title-format "%b (%m)")     ; descriptive frame title "filename (mode)"
;; use ibuffer by default
(global-set-key (kbd "C-x C-b") 'ibuffer)
(autoload 'ibuffer "ibuffer" "List buffers." t)
 
;;Rect select
(global-set-key (kbd "C-x r C-SPC") 'rm-set-mark)
(global-set-key (kbd "C-x r C-x") 'rm-exchange-point-and-mark)
(global-set-key (kbd "C-x r C-w") 'rm-kill-region)
(global-set-key (kbd "C-x r M-w") 'rm-kill-ring-save)
(autoload 'rm-set-mark "rect-mark"
      "Set mark for rectangle." t)
(autoload 'rm-exchange-point-and-mark "rect-mark"
    "Exchange point and mark for rectangle." t)
(autoload 'rm-kill-region "rect-mark"
      "Kill a rectangular region and save it in the kill ring." t)
(autoload 'rm-kill-ring-save "rect-mark"
     "Copy a rectangular region to the kill ring." t)
(rx word)
(defun iswitchb-local-keys ()
  (mapc (lambda (K)
          (let* ((key (car K)) (fun (cdr K)))
            (define-key iswitchb-mode-map (edmacro-parse-keys key) fun)))
        '(("<right>" . iswitchb-next-match)
          ("<left>"  . iswitchb-prev-match)
          ("<up>"    . iswitchb-next-match)
          ("<down>"  . iswitchb-prev-match))))
 
(add-hook 'iswitchb-define-mode-map-hook 'iswitchb-local-keys)
 
(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(describe-char-unidata-list (quote (name general-category canonical-combining-class bidi-class decomposition decimal-digit-value digit-value numeric-value mirrored old-name iso-10646-comment uppercase lowercase titlecase)))
 '(erc-echo-timestamps t)
 '(erc-insert-timestamp-function (quote erc-insert-timestamp-left))
 '(erc-modules (quote (autojoin button completion fill irccontrols match menu netsplit noncommands readonly ring scrolltobottom services smiley sound stamp track unmorse)))
 '(erc-nick "hdh")
 '(erc-nick-uniquifier "_")
 '(erc-server "irc.freenode.net")
 '(erc-stamp-mode t)
 '(erc-timestamp-format "[%H:%M]")
 '(erc-timestamp-use-align-to t)
 '(mode-line-format (quote ("%e" #("-" 0 1 (help-echo "mouse-1: select (drag to resize), mouse-2 = C-x 1, mouse-3 = C-x 0" auto-composed t)) mode-line-mule-info mode-line-modified mode-line-remote mode-line-frame-identification mode-line-buffer-identification #("   " 0 3 (help-echo "mouse-1: select (drag to resize), mouse-2 = C-x 1, mouse-3 = C-x 0" auto-composed t)) #("[%P of %I (%l,%c)]" 0 18 (auto-composed t)) (vc-mode vc-mode) #("  " 0 2 (help-echo "mouse-1: select (drag to resize), mouse-2 = C-x 1, mouse-3 = C-x 0" auto-composed t)) mode-line-modes (which-func-mode ("" which-func-format #("--" 0 2 (help-echo "mouse-1: select (drag to resize), mouse-2 = C-x 1, mouse-3 = C-x 0" auto-composed t)))) (global-mode-string (#("--" 0 2 (help-echo "mouse-1: select (drag to resize), mouse-2 = C-x 1, mouse-3 = C-x 0" auto-composed t)) global-mode-string)) #("-%-" 0 3 (help-echo "mouse-1: select (drag to resize), mouse-2 = C-x 1, mouse-3 = C-x 0" auto-composed t)))))
 '(safe-local-variable-values (quote ((default-input-method . "vietnamese-telex") (input-method . "vietnamese-telex") (input-method . vietnamese-telex)))))
(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 )
 
VIP: No | Used: 99M/101M | 0.094 sec / GZIP-2