head 1.4; access; symbols; locks sacha:1.4; strict; comment @; @; 1.4 date 2007.03.01.16.41.01; author sacha; state Exp; branches; next 1.3; 1.3 date 2006.11.02.16.50.27; author sacha; state Exp; branches; next 1.2; 1.2 date 2006.11.02.16.50.06; author sacha; state Exp; branches; next 1.1; 1.1 date 2006.10.25.02.20.53; author sacha; state Exp; branches; next ; desc @@ 1.4 log @Added ROSI @ text @;; URL: http://sacha.free.net.ph/notebook/emacs/dotemacs.el (when (getenv "SPEAK") (load "~/notebook/emacs/emacspeak-config.el" t)) (load-library "~/.emacs.secrets") (setq bbdb-file-coding-system 'utf-8) (defmacro sacha/gnu-vs-x (a b) "Execute A under GNU Emacs and B under XEmacs." `(if (featurep 'xemacs) ,b ,a)) (setq flavor 'emacs21) (when (load "/usr/share/emacs/site-lisp/debian-startup.el" t) (debian-startup (sacha/gnu-vs-x 'emacs21 'xemacs21))) (with-temp-buffer (cd "/usr/share/emacs/site-lisp") (if (fboundp 'normal-top-level-add-subdirs-to-load-path) (normal-top-level-add-subdirs-to-load-path)) (cd (sacha/gnu-vs-x "/usr/share/emacs21/site-lisp" "/usr/share/xemacs21/site-lisp")) (if (fboundp 'normal-top-level-add-subdirs-to-load-path) (normal-top-level-add-subdirs-to-load-path))) ; I like menus under XEmacs, but not under GNU Emacs. ;; (set-specifier menubar-visible-p t) (unless (featurep 'xemacs) (menu-bar-mode -1)) ;; No toolbars or scrollbars in either. (sacha/gnu-vs-x (tool-bar-mode -1) (set-specifier default-toolbar-visible-p t)) (sacha/gnu-vs-x (scroll-bar-mode -1) (set-specifier scrollbar-width (cons (selected-frame) 0))) ;; For syntax highlighting of random files. (unless (featurep 'xemacs) (require 'generic-x)) ;(set-language-environment "Japanese") ;(prefer-coding-system 'iso-2022-jp) (sacha/gnu-vs-x (set-coding-priority '(coding-category-utf-8)) (progn (require 'un-define) (set-coding-priority-list '(utf-8)) (set-coding-category-system 'utf-8 'utf-8))) ;;; Nothing, just a sentinel for debian-startup. (add-to-list 'load-path "/etc/emacs/site-start.d") (add-to-list 'load-path "/usr/local/sentinel") (defun sacha/always-recover-autosave-file () "Attempt to recover file." (condition-case err (recover-this-file) (error nil))) (add-hook (sacha/gnu-vs-x 'find-file-hook 'find-file-hooks) 'sacha/always-recover-autosave-file) (setq user-mail-address "sacha@@sachachua.com") ;; Get around recently-added emacs bug that made add-hook ignore ;; the auto-local of some variables (make-variable-buffer-local 'local-write-file-hooks) (add-to-list 'load-path "/home/sacha/notebook/emacs/") (defvar erc-sound-path nil) (load-library "erc-config") (require 'erc) ;; Store my customizations somewhere else. ;; You can find this at http://sacha.free.net.ph/notebook/emacs/custom-config.el (setq custom-file "~/notebook/emacs/custom-config.el") (load custom-file t) (add-to-list 'load-path "/usr/share/emacs/site-lisp/php-elisp") (add-to-list 'load-path "/usr/src/planner-el") (add-to-list 'load-path "/usr/src/muse-el/lisp") (mapcar 'load-library (list ;"ruby-config" ;"emacspeak-config" "wearable" "eshell-config" "ledger-config" ; "xtla-config" ; "flashcard-config" ; "block-comm-config" ; "bibl-config" ; "nethack-config" ; "htmlfontify-config" "bbdb-config" ; "erc-config" ; "dotgnus" ; "ges-post" ; "html-helper-mode" ; "outline" ; "message" ; "cycle-config" ; "backup-config" ; "emacs-wiki-config" ; "jikes-config" "kbd-config" ; "todl-config" ; "gesture-config" ; "allout-config" ; "reportmail-config" ; "tempbuf-config" "w3m-config" "miniedit" "hideshow-config" ; "muse-config" "planner-muse-config" "remember-config" ;; "remem-config" ; "tramp-config" ; "tnt-config" ; "edict-config" "hippie-config" ; "wearable" ; "dired-config" ; "chess-config" ; "miniedit" ; "dpkg-dev-el" ; "develock")) )) (miniedit-install) ;;(load "remem-config" t) ;;(load "ateneo-library") (when (load "mwheel" t) (mwheel-install)) ;; I'm lazy. (defalias 'yes-or-no-p 'y-or-n-p) ;; Allow #includes in ~/diary (add-hook 'list-diary-entries-hook 'include-other-diary-files) ;; Page-up after a Page-down returns to the same position. (sacha/gnu-vs-x (setq scroll-preserve-screen-position t) (require 'scroll-in-place)) (add-to-list 'auto-mode-alist '("\\.rdf$" . sgml-mode)) (autoload 'ruby-mode "ruby-mode" nil t) (add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode)) (add-to-list 'auto-mode-alist '("\\.diff$" . unidiff-mode)) (add-to-list 'auto-mode-alist '("\\.php" . php-mode)) (autoload 'php-mode "php-mode" nil t) (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode)) (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode)) (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode)) (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode)) (defun run-command-other-frame (command) "Run COMMAND in a new frame." (interactive "CC-x 5 M-x ") (select-frame (make-frame)) (call-interactively command)) (global-set-key "\C-x5\M-x" 'run-command-other-frame) (quietly-read-abbrev-file) ;; Add very basic syntax highlighting for all sorts of files ;; Allow other processes to connect to this Emacs ;(unless (featurep 'xemacs) ; (load "/etc/emacs21/site-start.d/50gnuserv.el")) ;(gnuserv-start) ;; I like having flashing parentheses (sacha/gnu-vs-x (show-paren-mode t) (progn (require 'paren) (paren-set-mode 'paren))) (auto-compression-mode t) ;; XEmacs defaults seem to work (when (fboundp 'auto-image-file-mode) (auto-image-file-mode t)) ;; For some reason, many people don't like tabs. (setq-default indent-tabs-mode nil) ;; So that horizontally-split windows will wrap unless told otherwise (setq truncate-partial-width-windows nil) (defun sacha/compile-adjust-variable () (unless (file-exists-p "Makefile") (set (make-local-variable 'compile-command) (let ((file (file-name-nondirectory buffer-file-name))) (concat "gcc -O2 -Wall -o " (file-name-sans-extension file) " " file))))) (eval-after-load 'compile (lambda () (add-hook 'c-mode-hook 'sacha/compile-adjust-variable))) (sacha/gnu-vs-x (progn (add-hook 'suspend-hook 'resume-suspend-hook) (add-hook 'suspend-resume-hook 'resume-process-args)) (require 'resume)) (sacha/gnu-vs-x (global-font-lock-mode 1) (setq font-lock-auto-fontify t)) (sacha/gnu-vs-x (when (load "ido" t) (ido-mode 'buffers)) (progn (require 'iswitchb) (iswitchb-default-keybindings))) (when (load "ibuffer" t) (global-set-key "\C-x\C-b" 'ibuffer)) ;; Incremental completion for the minibuffer. (icomplete-mode 1) (put 'upcase-region 'disabled nil) (put 'narrow-to-region 'disabled nil) (put 'downcase-region 'disabled nil) (setq message-sendmail-f-is-evil t) (unless (featurep 'xemacs) (setq sgml-font-lock-keywords-2 nil)) (setq browse-url-browser-function 'w3m-browse-url) (setq sentence-end-double-space nil) (setq sentence-end "[.?!][]\"')]*\\($\\|\t\\| \\)[ \t\n]*") (add-hook 'LaTeX-mode-hook 'turn-on-reftex) (setq reftex-plug-into-AUCTeX t) (setq debian-changelog-full-name "Sandra Jean Chua (Sacha)") (setq change-log-default-name nil) ;; use a modified Ellemtel style for all C like languages (eval-after-load 'cc-mode '(progn (c-set-offset (quote substatement-open) 0 nil))) (autoload 'typing-of-emacs "typing" "The Typing Of Emacs, a game." t) (defun sacha/sha1-region (start end) (interactive "r") (save-excursion (let ((s (sha1 (buffer-substring start end)))) (delete-region start end) (insert s)))) ;; FIXME: This is a workaround for a new Emacs bug (bbdb-records) (setq-default local-write-file-hooks nil) (unless (featurep 'xemacs) (prefer-coding-system 'utf-8)) ;; 2003.11.27: I usually work with one frame, so I want the filename ;; all the time (setq frame-title-format "%b") ;; 2004.02.16: I hate XLS files (add-to-list 'auto-mode-alist '("\\.xls\\'" . no-xls)) (defun no-xls (&optional filename) "Run xlhtml and w3m -dump on the entire buffer. Optional FILENAME says what filename to use. This is only necessary for buffers without proper `buffer-file-name'. FILENAME should be a real filename, not a path." (interactive "fExcel File: ") (when (and filename (not (buffer-file-name))) (write-file (make-temp-file filename))) (erase-buffer) (shell-command (format "xlhtml -nc -te %s | w3m -dump -T text/html" (buffer-file-name)) (current-buffer)) (setq buffer-file-name nil) (set-buffer-modified-p nil)) (add-hook 'c-mode-hook (lambda () (c-set-style "ellemtel"))) ;;(start-remem) ;;(load "/usr/share/emacs/site-lisp/debian-startup.el") ;;(debian-startup 'emacs21) ;; For macro prompting, from http://www.emacswiki.org/cgi-bin/wiki?action=browse;diff=1;id=KeyboardMacros (defun my-macro-query (arg) "Prompt for input using minibuffer during kbd macro execution. With prefix argument, allows you to select what prompt string to use." (interactive "P") (let* ((query (lambda () (kbd-macro-query t))) (prompt (if arg (read-from-minibuffer "PROMPT: ") "Input: ")) (input (unwind-protect (progn (add-hook 'minibuffer-setup-hook query) (read-from-minibuffer prompt)) (remove-hook 'minibuffer-setup-hook query)))) (unless (string= "" input) (insert input)))) (defvar sacha/screenshot-file "/home/sacha/public_html/notebook/pics/screen.png" "Filename for screenshots.") (defun sacha/take-screenshot () (interactive) (shell-command (concat "import -window root " sacha/screenshot-file))) (defun sacha/display-screenshot () (interactive) (call-process "display" nil 0 sacha/screenshot-file)) (defun sacha/yank-push () (interactive) (yank-pop -1)) (global-set-key "\331" 'sacha/yank-push) ;; M-Y (global-set-key "\C-xQ" 'my-macro-query) (autoload 'sacha/list-web-stats "website-config" nil t) (put 'erase-buffer 'disabled nil) ;(load-library "/etc/emacs/site-start.d/55prime-el.el") ;(setq default-input-method "japanese-prime") ;; 2004.11.26 sindre #emacs (setq icomplete-show-key-bindings t) ;; 2004.11.14 (defun sacha/ffap-quick () "Quickly open URL at point in background." (interactive) (save-window-excursion (save-excursion (ffap (ffap-guesser))))) ;; 2004.01.11 ;; [[gnus://mail.planner/][E-Mail from Wei-Hao Lin]] (setq minibuffer-prompt-properties '(face minibuffer-prompt)) (defun sacha/filter-irclog () (interactive) (delete-matching-lines "....... \\(>>>\\|<<<\\|---\\|<--\\|-->\\)")) (defun sacha/irclog-markup () (interactive) (let ((emacs-wiki-publishing-header "") (emacs-wiki-publishing-footer "")) (emacs-wiki-mode) (emacs-wiki-replace-markup) (fundamental-mode))) ;; 2005.02.27 ;; From http://www.emacswiki.org/cgi-bin/wiki/PopularOptions (setq enable-recursive-minibuffers t) ;;;_+ 2005.03.24: Random taglines (defun sacha/random-tagline (&optional file) "Return a random tagline and put it in the kill ring." (interactive) (with-current-buffer (find-file-noselect (or file "~/.taglines")) (goto-char (random (point-max))) (let ((string (buffer-substring (line-beginning-position) (line-end-position)))) (when (interactive-p) (kill-new string)) string))) ;; grep -h -w -E 'cats?' ~/notebook/japan/examples* > ~/.taglines (eval-after-load 'remember '(progn (defadvice remember (after sacha-tagline activate) "Add random tagline." (save-excursion (goto-char (point-max)) (insert "\n\nRandom Emacs symbol: " (sacha/random-tagline "~/.taglines.random-emacs-symbols") "\n\n"))))) ; (insert "\n\nRandom Japanese sentence: " (sacha/random-tagline "~/.taglines") "\n\n"))))) (when (featurep 'xemacs) (setq interprogram-cut-function nil interprogram-paste-function nil)) ;;;_+ Backup configuration (setq backup-by-copying t) (setq backup-directory-alist '(("." . "~/.saves"))) (setq delete-old-versions t) (setq kept-new-versions 6) (setq kept-old-versions 2) (setq version-control t) ;;;_+ Recentf ;(require 'recentf) ;(recentf-mode 1) ;(global-set-key (kbd "C-M-r") 'recentf-open-files) ;;;_+ Canada (defun sacha/canada-days () "Display how many days I've been in Canada." (interactive) (let ((days (- (time-to-days (current-time)) (time-to-days (encode-time 0 0 19 15 7 2005))))) (prog1 days (when (interactive-p) (message "%d days so far" days) (kill-new (format "%d days so far" days)))))) (setq undo-limit 50000) (set-cursor-color "wheat") (display-battery-mode 1) ;;;_+ Font size (defun sacha/increase-font-size () (interactive) (set-face-attribute 'default nil :height (ceiling (* 1.10 (face-attribute 'default :height))))) (defun sacha/decrease-font-size () (interactive) (set-face-attribute 'default nil :height (floor (* 0.9 (face-attribute 'default :height))))) (global-set-key (kbd "C-+") 'sacha/increase-font-size) (global-set-key (kbd "C--") 'sacha/decrease-font-size) (setq bbdb-file-coding-system 'utf-8) (load-library "hideshow") (add-hook 'emacs-lisp-mode-hook (lambda () (hs-minor-mode 1) (hs-hide-all) (set (make-variable-buffer-local 'my-hs-hide) t))) (defvar my-hs-hide t "Current state of hideshow for toggling all.") ;;;###autoload (defun my-toggle-hideshow-all () "Toggle hideshow all." (interactive) (set (make-variable-buffer-local 'my-hs-hide) (not my-hs-hide)) (if my-hs-hide (hs-hide-all) (hs-show-all))) (global-set-key (kbd "C-c @@ @@") 'my-toggle-hideshow-all) (global-set-key (kbd "C-c @@ h") 'hs-hide-block) (global-set-key (kbd "C-c @@ s") 'hs-show-block) (global-set-key (kbd "C-c @@ SPC") 'hs-show-block) (defun sacha/emacswiki-random-page () "Display random page on emacswiki.org." (interactive) (browse-url "http://www.emacswiki.org/cgi-bin/wiki?action=random")) ;;; This .emacs file belongs to Sacha Chua (sacha/gnu-vs-x (display-time-mode 1) (display-time)) (sacha/gnu-vs-x (appt-activate 1) (appt-initialize)) (defun sacha/kill-rosi () "Converts the ROSI detailed financial account into a ledger file using my settings." (interactive) (go (keep-lines "^200") (let (list) (while (re-search-forward "^\\(....-..-..\\) +\\(.+?\\) +\\([0-9]+\\.[0-9]+\\)\\(CR\\)?" nil t) (let ((date (match-string 1)) (description (match-string 2)) (amount (if (> (length (match-string 4)) 0) (match-string 3) (concat "-" (match-string 3)))) account) (setq account (cond ((string-match "Graduate House" description) "Expenses:Rent") ((string-match "Deposit" description) "Expenses:Rent") ((string-match "Transfer" description) "Income:Fellowship") ((string-match "Award" description) "Income:Fellowship") ((string-match "Bank Payment" description) "Assets:Checking:PCFinancial") (t "Expenses:Tuition"))) (setq list (cons (list date description amount account) list)))) (kill-new (mapconcat (lambda (tuple) (apply 'format "%s * %s\n Liabilities:ROSI $%s\n %s\n\n" tuple)) (nreverse list) ""))))) @ 1.3 log @ledger-config @ text @d82 1 d147 2 a148 1 a468 1 (plan) d471 40 @ 1.2 log @Emacswiki random page @ text @d83 1 @ 1.1 log @Initial revision @ text @d458 4 a461 2 @