;;;; core.el ;;; veneration.el ;;; ;;; Copyright (C) 2000, 2002, 2003, 2004, 2006, 2007, 2008 Thien-Thi Nguyen ;;; ;;; This file is part of ttn's personal elisp library, released under ;;; the terms of the GNU General Public License as published by the ;;; Free Software Foundation; either version 3, or (at your option) any ;;; later version. There is NO WARRANTY. See file COPYING for details. ;;; ;;; Description: Compatibility for older versions of Emacs. (unless (fboundp 'display-color-p) (defun display-color-p () window-system)) (unless (fboundp 'add-to-list) ;; unmodified from the repo 2004-10-13 (defun add-to-list (list-var element &optional append) "Add to the value of LIST-VAR the element ELEMENT if it isn't there yet. The test for presence of ELEMENT is done with `equal'. If ELEMENT is added, it is added at the beginning of the list, unless the optional argument APPEND is non-nil, in which case ELEMENT is added at the end. The return value is the new value of LIST-VAR. If you want to use `add-to-list' on a variable that is not defined until a certain package is loaded, you should put the call to `add-to-list' into a hook function that will be run only after loading the package. `eval-after-load' provides one way to do this. In some cases other hooks, such as major mode hooks, can do the job." (if (member element (symbol-value list-var)) (symbol-value list-var) (set list-var (if append (append (symbol-value list-var) (list element)) (cons element (symbol-value list-var))))))) (unless (fboundp 'number-sequence) ;; unmodified from the repo 2004-12-09 (defun number-sequence (from &optional to inc) "Return a sequence of numbers from FROM to TO (both inclusive) as a list. INC is the increment used between numbers in the sequence and defaults to 1. So, the Nth element of the list is \(+ FROM \(* N INC)) where N counts from zero. TO is only included if there is an N for which TO = FROM + N * INC. If TO is nil or numerically equal to FROM, return \(FROM). If INC is positive and TO is less than FROM, or INC is negative and TO is larger than FROM, return nil. If INC is zero and TO is neither nil nor numerically equal to FROM, signal an error. This function is primarily designed for integer arguments. Nevertheless, FROM, TO and INC can be integer or float. However, floating point arithmetic is inexact. For instance, depending on the machine, it may quite well happen that \(number-sequence 0.4 0.6 0.2) returns the one element list \(0.4), whereas \(number-sequence 0.4 0.8 0.2) returns a list with three elements. Thus, if some of the arguments are floats and one wants to make sure that TO is included, one may have to explicitly write TO as \(+ FROM \(* N INC)) or use a variable whose value was computed with this exact expression. Alternatively, you can, of course, also replace TO with a slightly larger value \(or a slightly more negative value if INC is negative)." (if (or (not to) (= from to)) (list from) (or inc (setq inc 1)) (when (zerop inc) (error "The increment can not be zero")) (let (seq (n 0) (next from)) (if (> inc 0) (while (<= next to) (setq seq (cons next seq) n (1+ n) next (+ from (* n inc)))) (while (>= next to) (setq seq (cons next seq) n (1+ n) next (+ from (* n inc))))) (nreverse seq))))) (unless (fboundp 'delete-dups) ;; unmodified from the repo 2004-12-09 (defun delete-dups (list) "Destructively remove `equal' duplicates from LIST. Store the result in LIST and return it. LIST must be a proper list. Of several `equal' occurrences of an element in LIST, the first one is kept." (let ((tail list)) (while tail (setcdr tail (delete (car tail) (cdr tail))) (setq tail (cdr tail)))) list)) (unless (fboundp 'invisible-p) (cond ((fboundp 'line-move-invisible-p) (fset 'invisible-p 'line-move-invisible-p)) ((fboundp 'line-move-invisible) (fset 'invisible-p 'line-move-invisible)) (t (defun invisible-p (pos) "Return non-nil if the character after POS is currently invisible." (let ((prop (get-char-property pos 'invisible))) (if (eq buffer-invisibility-spec t) prop (or (memq prop buffer-invisibility-spec) (assq prop buffer-invisibility-spec)))))))) ;;; veneration.el ends here ;;; vars.el ;;; ;;; Copyright (C) 1996, 1997, 1998, 2000, 2001, ;;; 2002, 2003, 2004, 2006, 2007, 2008 Thien-Thi Nguyen ;;; This file is part of ttn's personal elisp library, released under GNU ;;; GPL with ABSOLUTELY NO WARRANTY. See the file COPYING for details. ;;; Description: Set variables variously for various things. ;;;--------------------------------------------------------------------------- ;;; Garden-variety editing. (setq inhibit-startup-message t ; hehe, no longer a novice default-major-mode 'text-mode ; (see text-mode-hook) default-fill-column 78 ; big enough backup-by-copying-when-linked t ; for symlinks auto-save-interval 600 ; keystrokes NOT seconds version-control nil ; heh, why be like vms?! delete-auto-save-files t ; limited disk space, yasee require-final-newline t ; for other programs scroll-conservatively 999 ; smoother scrolling completion-ignored-extensions ; don't do completion for these files '(".bak" "~" ".lpt" ".bin" ".o" ".lo" ".elc" ".elc.gz" ".err" ".dvi" ".aux" ".otl" ".ckp" ".lst") auto-save-timeout nil ; disable saving based on time window-min-height 1 ; sure, why not? display-time-24hr-format t ; save mode-line space next-line-add-newlines nil ; do not add newlines at EOB vc-keep-workfiles t ; sure, why not? vc-command-messages t ; keep me entertained vc-mistrust-permissions t ; use the SOURCE dammit! vc-make-backup-files nil ; don't need em vc-initial-comment nil ; why bother? visible-bell t ; shut up you infernal machine! inferior-lisp-program "gcl" ; keep the faith, man! split-window-keep-point nil ; less motion is good view-scroll-auto-exit t ; get out! display-time-24hr-format t ; less ambiguity more space *emacs-start-time* (current-time) ; for `emacs-uptime' add-log-always-start-new-record t ; finally, sanity reigns mode-line-in-non-selected-windows nil ; keep things quiet for now diff-switches "-u" ; --unified=1 confuses cvs, sigh font-lock-verbose nil ; yeah, whatever dired-deletion-confirmer 'identity ; no questions asked dired-listing-switches "-alF" ; include file type suffix enable-recursive-minibuffers t ; contemplate crass confusion add-log-time-zone-rule t ; reduce confusion on earth confirm-kill-emacs 'y-or-n-p ; be sure but not too sure ange-ftp-try-passive-mode t ; keep the bits flowing next-error-recenter 2 ; useful for grep, too max-mini-window-height 0.8 ; in case we near the minotaur jit-lock-context-time 1.5 ; a little less eager, thanks ;; add simple var jamming here. Man-width (1- (frame-width)) time-stamp-start "[tT]ime-stamp:[ \t]+\\\\?[\"<]+") ;;;--------------------------------------------------------------------------- ;;; Buffer management. (add-to-list 'same-window-buffer-names "*compilation*") ;;;--------------------------------------------------------------------------- ;;; Mode line customization. (setq-default mode-line-mule-info nil mode-line-frame-identification nil mode-line-buffer-identification '("%5b") mode-line-modified '("-%1*%1* " (-3 "%P") " ") mode-line-position nil mode-line-format (delete '(-3 . "%p") mode-line-format)) ;; old skool: put the time/mail info to the left of "(MODE ...)". (let ((cut (position 'global-mode-string mode-line-format :key (lambda (x) (and (consp x) (car x))))) (jam (position 'mode-line-modes mode-line-format))) (when (and cut jam (< jam cut)) (setq-default mode-line-format (append (subseq mode-line-format 0 jam) (list 'global-mode-string " ") (subseq (delete (nth cut mode-line-format) mode-line-format) jam))))) (let* ((t-cell (last mode-line-format)) (trailing (car t-cell))) (setcar t-cell (concat user-login-name ":" (if (string-match "\\(^[^.]+\\)" system-name) (match-string 1 system-name) system-name) (let ((w (getenv "WINDOW"))) ; set by screen(1) (when w (concat "/" w))) (let ((r (getenv "RATPOISONSERIALID"))) (when r (concat "/" r))))) (setcdr t-cell (list trailing))) ;;;--------------------------------------------------------------------------- ;;; Properties. (mapc (lambda (cmd) (put cmd 'disabled nil)) '(eval-expression upcase-region downcase-region narrow-to-page narrow-to-region erase-buffer image-toggle-display ;; add liberated commands here. )) ;;;--------------------------------------------------------------------------- ;;; Munge `auto-mode-alist'. (mapc (lambda (x) (pushnew (cons (format "\\.%s\\'" (car x)) (cdr x)) auto-mode-alist :test 'equal)) '((pl . perl-mode) (ph . perl-mode) (perl . perl-mode) (thud . scheme-mode) (th . scheme-mode) (v . verilog-mode) (twerp . texinfo-mode) (html-data . scheme-mode) (mms . makefile-mode) (af . scheme-mode) (laml . scheme-mode) ;; Add auto-mode hints here. )) ;;;--------------------------------------------------------------------------- ;;; Hack to use own copy of hideshow. (unless (featurep 'hideshow) (makunbound 'hs-special-modes-alist)) ;;;--------------------------------------------------------------------------- ;;; Indentation specifications. ;;; These are for properties other than `lisp-indent-function'. (dolist (sym '(cron and-let* ;; from Guile's ice-9/testing-lib.scm pass-if pass-if-exception expect-fail expect-fail-exception with-test-prefix ;; from QA qa-do-test qa-do-test-expect-fail)) (put sym 'scheme-indent-function 1)) ;;;--------------------------------------------------------------------------- ;;; Local variables policy (setq safe-local-variable-values '((outline-regexp . "\\([ ][ ]\\)*- ") (outline-regexp . "\\([ ][ ]\\)*[-+] ") (backup-inhibited . t) (fill-prefix . "\t"))) ;;;--------------------------------------------------------------------------- ;;; vars.el ends here ;;; hooks.el ;;; ;;; Copyright (C) 1996, 1997, 1998, 2000, 2002, ;;; 2003, 2004, 2005, 2006, 2007, 2008 Thien-Thi Nguyen ;;; This file is part of ttn's personal elisp library, released under GNU ;;; GPL with ABSOLUTELY NO WARRANTY. See the file COPYING for details. ;;; Description: Hooks: Load time, normal and advice. ;;;--------------------------------------------------------------------------- ;;; Load time hooks. ;;; Some files are pre-loaded in the dumped Emacs; ;;; their associated forms are evaluated immediately. (let (file) (while (setq file (read)) (eval-next-after-load file))) "subr" (define-keys minibuffer-local-completion-map ;; 2005-08-29 09:21:39. "hang on... just a little bit longer now..." ;; beautiful drop from tonic to the fifth, sweeping down one whole for a bit ;; to end up back on the fifth for the hold and recycle prep. i miss it. "\M-o" (lambda () (interactive) (when (equal ?/ (char-before)) (delete-char -1)) (when (re-search-backward "/[^/]+" (point-min) t) (forward-char 1) (delete-region (point) (match-end 0)))) ;; 2000/02/02 12:00:34. a beautiful day, warm breeze blowing in, hiding the ;; sound of traffic. i think of friends on the east coast and my parents, ;; who are hip-deep in snow. "~" (lambda () (interactive) (insert (if (let ((c (char-before (point)))) (or (not c) (/= ?/ c))) "~" ;; this doesn't work w/ emacs 21 because the prompt is ;; considered part of the buffer and has `read-only' text ;; property. ;;- (erase-buffer) ;; so instead, we zonk manually... (while (ignore-errors (delete-char -1) t)) "~/")))) ;; 2001/11/06 17:18:40. silence. "view" (lambda () (define-keys view-mode-map "{" 'backward-page-ignore-narrow "}" 'forward-page-ignore-narrow)) ;; 2004/07/08 14:21:00. piova leggermente. ucelli mati come al solito. "subr" (define-keys minibuffer-local-map "\M-m" 'exit-minibuffer) "emacs-lisp/lisp-mode" (progn (define-keys lisp-interaction-mode-map "\C-j" 'ppq "\C-\M-z" (defun zonk-definition () "Do `makunbound' or `fmakunbound' on current top-level form. Additionally, delete the form and any extra blank lines." (interactive) (beginning-of-defun) (let ((p (point)) (form (read (current-buffer)))) (funcall (case (car form) ((setq) 'makunbound) ((defun defmacro) 'fmakunbound) (t 'identity)) (cadr form)) (delete-region p (point))) (delete-blank-lines))) (define-keys emacs-lisp-mode-map "\C-\M-z" 'zonk-definition)) "help" (define-keys help-map "a" 'apropos "\C-o" (lambda (ref) (interactive "sDisplay Commentary: ") (let ((buf (format "*Commentary* %s" ref))) (shell-command (format "guile-tools display-commentary %S" ref) buf) (set-buffer buf) (view-mode 1) (set (make-local-variable 'view-scroll-auto-exit) nil) (setq view-exit-action 'kill-buffer)))) "vc-hooks" (define-keys vc-prefix-map "p" 'display-previous-revision) "isearch" (define-keys isearch-mode-map "\C-y" (lambda () (interactive) ;; 1999/08/08 03:40:00. this used to use X properties ;; (ugh). however, this may fail for older emacs ;; versions. cannot determine when `isearch-yank-string' ;; was introduced. (isearch-yank-string (thing-at-point 'symbol)))) "bookmark" (define-keys bookmark-map "?" (lambda () (interactive) (message "Make Jump Save Load Edit Rename Delete Insert"))) "dired" (define-keys dired-mode-map "\C-m" 'dired-view-file "q" (lambda () (interactive) (kill-buffer nil)) "z" 'gzip-or-gunzip-from-dired "W" 'dired-wipe "/" 'dired-mark-directories "@" 'dired-mark-symlinks "U" 'browse-url-of-dired-file ;; 1998.1010.00:37:10-0700. KCSM 91FM commercial-free jazz. a standard, ;; "feelings"... original tune recorded in 1978. strange, this is more ;; "easy-listening" than usual, but i guess the hour is late and bebop ;; might keep one awake. because they are commercial-free, KCSM must ;; periodically undergo a pledge-drive, where they interrupt the usually ;; continuous music with annoying begging. we are currently in the midst ;; of one of these month-long drives, but luckily it will be ending soon ;; (sunday). "I" (lambda () (interactive) (info (dired-get-filename))) ;; 1998.1015.00:11:28-0700. 92.3 KSJO mainstream rock station. guns and ;; roses -- "knocking on heaven's door". tomorrow (actually right now) ;; is lucy's birthday, the ides of october, i wonder if she's planning to ;; do anything special. will give her a call... ;; ;; finally got hideshow.el xemacs-compatible. seems silly to me that ;; emacs and xemacs should diverge, the why-can't-we-all-work-together ;; part of me is saddened. although, i suppose personal experience ;; should teach me that sometimes viewpoints are so tenaciously held that ;; wresting compromise from the hardness of the righteous heart is too ;; much to ask. "\C-c\C-r" (lambda () (interactive) (save-window-excursion (release (dired-get-filename))) (dired-do-redisplay) (dired-next-line 1)) ;; 1999/06/05 13:39:13. more dired fun. "_" (lambda () (interactive) (hexl-find-file (dired-get-filename))) ;; 2007-08-25 17:52:59. meno male, ritrovato . "\C-c\C-d" (lambda () "Do `edb-interact' or `db-find-file' on current file." (interactive) (let ((filename (dired-get-filename))) (if (string-match "[.]edb$" filename) (edb-interact filename nil) (db-find-file filename))))) "info" (dolist (x (list "/usr/info" "/usr/share/info" "/usr/local/info" (expand-file-name "~/local/info"))) (when (file-exists-p x) (add-to-list 'Info-directory-list x))) "ebuff-menu" (define-keys electric-buffer-menu-mode-map "\C-b" (lambda () (interactive) (let (buffer-read-only) (keep-lines "\\(Inferior Scheme\\)\\|\\(Comint\\)"))) "\C-o" (lambda () (interactive) (let (buffer-read-only) (call-interactively 'keep-lines)))) "compile" (progn (eval `(defadvice ,(if (fboundp 'compilation-start) 'compilation-start 'compile-internal) (before rewrite-compilation-command-w/cd activate) "Replace COMMAND using `rewrite-shell-command-w/cd'." (ad-set-arg 0 (rewrite-shell-command-w/cd (ad-get-arg 0))))) (defun ttn-hey-compilation-finished! (buf status-string) (unless (eq (car (buffer-list)) buf) (with-current-buffer (car (buffer-list)) (yo! (substring status-string 0 -1) 'funky-flash)))) (if (boundp 'compilation-finish-functions) (add-to-list 'compilation-finish-functions 'ttn-hey-compilation-finished!) (set 'compilation-finish-function 'ttn-hey-compilation-finished!)) (define-keys compilation-mode-map "\C-c\C-q" 'kill-compilation ":" (lambda (line) (interactive "sLine: ") (let ((proc (get-buffer-process (current-buffer))) (buffer-read-only nil)) (goto-char (process-mark proc)) (insert (propertize line 'font-lock-face 'bold) "\n") (set-marker (process-mark proc) (point))) (process-send-string (buffer-name) (concat line "\n"))) "\C-c\C-v" (lambda () (interactive) (find-file (thing-at-point 'filename)) (vc-print-log)))) "isearch" (define-key isearch-mode-map "\C-?" (lambda () (interactive) ; from gnu.emacs.help probably (setq isearch-string (substring isearch-string 0 -1) isearch-message (mapconcat 'isearch-text-char-description isearch-string "")) (isearch-update))) "make-mode" (add-to-list 'makefile-font-lock-keywords (list (concat "[$][({]" (regexp-opt (cons "call" (mapcar 'car makefile-gnumake-functions-alist)) 'words)) 1 font-lock-keyword-face) 'append) "vc-rcs" (setup-anticipatory-vc-rcs-annotation) "vc-cvs" (progn (fset 'vc-cvs-show-log 'pretty-up-vc-print-log-output) (if (fboundp 'vc-rollback) (unless (fboundp 'vc-rcs-rollback) (defalias 'vc-cvs-rollback 'ttn-cvs-rollback)) (unless (fboundp 'vc-cvs-cancel-version) (defalias 'vc-cvs-cancel-version 'ttn-cvs-cancel-version)))) "man" (define-keys Man-mode-map "\M-n" 'down-holdcursor "\M-p" 'up-holdcursor "f" 'Man-follow-manual-reference "\C-m" 'Man-follow-manual-reference) "comint" (progn (add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m t) (define-keys comint-mode-map "\C-a" 'comint-bol ;; 1998.0129.23:58:54-0800. silence. getting hungry. ;; this is support for the "go" programming convention. "\M-\C-g" 'go ;; 2004-12-04 14:28:23. che bello poco movimento. "\M-m" (lambda () (interactive) (case last-command ((comint-previous-input comint-next-input move-end-of-line) (comint-send-input)) (t (call-interactively (lookup-key global-map "\M-m"))))) ;; 2006-08-31 13:13:38. whir nowhir whir nowhir whir. ;; Gotta make rent, gotta track sent, ;; don't forget received, and all that was spent. ;; Zero is not failure if mind can twist to tailor ;; that which only ghosts can find to be more paler. ;; New line to nowhere, decide now to go there, ;; loss is a circle whose endpoint is stowed, shared. "\M-j" 'erase-buffer)) "sendmail" (define-keys mail-mode-map "\M-&" (lambda (tag) (interactive "sTag: ") (rename-buffer (concat "*mail-" tag "*")))) "help-mode" (define-keys help-mode-map "\M-r" (lambda () (interactive) ; remember (rename-buffer (concat "*Help* " (buffer-substring-no-properties (point) (save-excursion (end-of-line) (point))))))) "scheme" (progn (font-lock-add-keywords 'scheme-mode '(("\\<\\(defmacro\\)\\>\\s-+\\(\\S-+\\)" (1 font-lock-keyword-face) (2 font-lock-function-name-face)) ("\\<\\(define-module\\)\\>\\s-+(\\(\\S)+\\))" (1 font-lock-keyword-face) (2 font-lock-function-name-face)) ("\\<\\(define-.*\\)\\>\\s-+\\(\\S-+\\)" ; hmm, is this right? (1 font-lock-keyword-face) (2 font-lock-function-name-face)))) ;; 2005-08-23 12:23:26. trapano e martello degli vicini lavorando. (ignore-errors (load-file "~/.emacs.d/ttn/scheme-indent-function-1.el")) ;; 2005-08-15 21:52:42. random boombox. some emacsen define this to ;; have string delim syntax, which is allowed, i suppose, but ugly... (modify-syntax-entry ?| "_ 23b" scheme-mode-syntax-table) ;; 1997.1122.02:57:53-0800. middle of the night, why didn't i think of ;; this sooner?! (define-keys scheme-mode-map "\M-\C-m" 'scheme-send-definition-and-go)) ;; 1998.1013.00:27:42-0700. 89.7 KFJC college station. strange ;; noise-type sounds, but works for hacking since mostly instrumental. ;; i remember when living at 421 century getting seriously twisted and ;; hacking THUD to this radio station... "outline" (define-keys outline-mode-map "\C-c\C-d" (global-key-binding "\C-c\C-d") "\C-c\C-h" 'hide-subtree) ;; 1999/04/19 00:33:52. silence. "gud" (define-keys gud-mode-map [f9] 'gud-cont [f10] 'gud-finish [f11] 'gud-step [f12] 'gud-next) ;; 1999/10/04 08:24:13. "sgml-mode" (define-keys sgml-mode-map [f11] (lambda () (interactive) (execute-kbd-macro 'spew))) "vc" (define-keys vc-annotate-mode-map "a" 'vc-annotate-display-autoscale) "diff-mode" (progn (when (facep 'diff-header) (set-face-background 'diff-header "gray20")) (when (facep 'diff-refine-change) (set-face-background 'diff-refine-change 'unspecified) (set-face-foreground 'diff-refine-change "green")) (define-keys diff-mode-map "\M-r" 'diff-auto-refine-mode "\M-z" (lambda () (interactive) (let ((p (point)) (inhibit-read-only t)) (diff-apply-hunk) (delete-region p (point)))))) "grep" (setq grep-find-command (concat "find . " (mapconcat (lambda (subdir) (format "-name %s -prune" subdir)) '(RCS CVS) " -o ") " -o" " -type f -print0" " | xargs -0 -e grep -nH -e ")) "texinfo" (define-keys texinfo-mode-map [(control x) (n) (N)] (lambda () (interactive) (let ((page-delimiter "^@node\\s-+")) (narrow-to-page)))) ;; Add load-time hooks here. nil ;;;--------------------------------------------------------------------------- ;;; Normal hooks. ;; To paraphrase some moby CS dude: You KNOW when you are a programmer. (let (hook) (while (setq hook (read)) (add-hook hook 'my-prog-env))) c-mode-common-hook sh-mode-hook emacs-lisp-mode-hook lisp-mode-hook asm-mode-hook verilog-mode-hook perl-mode-hook sgml-mode-hook scheme-mode-hook ;; 1998.0730.15:55:35-0700. useful for wrapping, etc. makefile-mode-hook ;; 1998.1020.02:39:00-0700. KCSM 91FM. some nice Count Basie, perky. i ;; suppose that's fitting for this entry, my first bow to the inevitable. java-mode-hook ;; Add programming major modes here. nil ;; However, when you don't know, you can at least learn... (let (hook) (while (setq hook (read)) (add-hook hook (read) t))) ;; You might think that some text mode functionality should be bubbled up. ;; But, I ask: to where? Since only bogus *scratch* buffer generation ;; seems to be uninterested, having text mode as default basically allows ;; it a large amount of the required functionality. Btw, this hook fixes ;; that. text-mode-hook (lambda () (setq truncate-lines t) (setq fill-column 78) ;; (abbrev-mode 1) ;; need abbrevs table (auto-fill-mode 1)) ;; Keep things visually consistent in Dired. Try for "instant response". dired-mode-hook (lambda () (scroll-LR-by-20-minor-mode 1) (setq truncate-lines t)) ;; C and C++ modes are similar. c-mode-common-hook (lambda () (local-set-keys "\C-c\C-d" (global-key-binding "\C-c\C-d") "\C-?" 'backward-delete-char)) asm-mode-hook (lambda () (setq comment-column 32)) compilation-mode-hook (lambda () (scroll-LR-by-20-minor-mode 1) (setq truncate-lines t)) Man-mode-hook (lambda () (scroll-LR-by-20-minor-mode 1)) electric-buffer-menu-mode-hook (lambda () (scroll-LR-by-20-minor-mode 1) ;; Replace parentdirs w/ environment variables, plus others. (buffer-substitute-file-env-vars) ;; zonk the header line and adjust the window (setq header-line-format nil) (unless (one-window-p) (enlarge-window -1))) verilog-mode-hook (lambda () (hs-minor-mode -1) (auto-save-mode -1) (abbrev-mode -1) (set (make-local-variable 'compile-command) "make ") (set (make-local-variable 'compilation-error-regexp-alist) '(("^Error!.*\n\\([^\n]+\n\\)*\\s-+\"\\(.*\\)\", \\([0-9]+\\):" 2 3) ("^Warning!.*\n\\([^\n]+\n\\)*\\s-+\"\\(.*\\)\", \\([0-9]+\\):" 2 3)))) comint-mode-hook (lambda () (setq comint-scroll-show-maximum-output t)) mail-mode-hook (lambda () ;; easier to quote (set-fill-column 72) ;; 2004/05/27 15:24:26. uccelli mati. (setq truncate-lines t)) view-mode-hook (lambda () (setq truncate-lines t) (scroll-LR-by-20-minor-mode 1)) help-mode-hook (lambda () ;; recent emacs does this automatically (when (eq this-command 'describe-bindings) (let (buffer-read-only) (goto-char (point-min)) (flush-lines "\t\tundefined$")))) ;; 1997-10-14 04:11. make "man -k" pretty and useful. it surprises me ;; that this wasn't thought of before. the best way to rephrase the ;; following is: ;; ;; i like references to be useful. the original code does not ;; recognize the reference nature of the output. thus, the output needs ;; to be massaged. ;; ;; some hints to ong-da: (a) what do we look for? (b) is there a better ;; way? Man-mode-hook (lambda () (when (string-match "[Mm]an -k" (buffer-name)) (let (buffer-read-only ents ent txt sec pivot) (goto-char (point-min)) (insert Man-see-also-regexp "\n\n") (while (re-search-forward "^\\(.*\\)\\(([^ ]+)\\)\\(\\s-+-\\s-+.*\\)$" (point-max) t) (setq ents (match-string 1) pivot (list (match-beginning 2) (match-string 2)) txt (list (match-end 3) (match-string 3))) (goto-char (match-beginning 1)) (do ((i (count ?, ents) (1- i))) ((= i 0) nil) (re-search-forward "\\(,\\|\n\\)" (point-max) t) (delete-char -1) (delete-horizontal-space) (insert (cadr pivot) "\t" (cadr txt) "\n")) (re-search-forward "\\(\\s-+\\)(") (delete-region (match-beginning 1) (match-end 1)) (end-of-line) (insert "\n")) (Man-build-references-alist)))) ;; 2007-02-20 16:10:21. piccoli movimenti da tmv. si è addormentata ;; tornando dal'ipercoop e adesso esploriamo il nuovo sistema di gnuvola. ;; ;; ;; 1998.0825.12:53:42-0700. the whirring of the espresso machine gently ;; ;; drowns out the baroque guitar (there is also some piano). baroque ;; ;; harmonies rule! typical comment, i know, but all those geeks can't be ;; ;; wrong! ;; ;; mail-send-hook ;; (lambda () ;; (and (boundp 'ttn-jammed-from) ;; (save-excursion ;; (goto-char (point-min)) ;; (let ((reply-to (concat "Reply-to: " ttn-jammed-from))) ;; (unless (search-forward reply-to nil t) ;; (goto-char (point-min)) ;; (insert reply-to "\n")))))) ;; 1999/03/05 07:42:52. silence. view-mode-hook (lambda () (when (eq major-mode 'outline-mode) (define-keys view-mode-map "{" 'outline-previous-visible-heading "}" 'outline-next-visible-heading "+" (lambda () (interactive) (let ((nlp (save-excursion (next-line 1) (point)))) (hide-subtree) (when (= nlp (save-excursion (next-line 1) (point))) (show-subtree))))))) vc-before-checkin-hook (lambda () (save-excursion (goto-char (point-min)) (hs-show-block)) ;; 1999/05/15 15:51:10. well this should have been done a long time ago. ;; 2007-09-16 12:38:38. never too late to improve things a bit, however... (when (and buffer-file-name (vc-registered buffer-file-name)) (unless (eq 'change-log-mode major-mode) (let ((diff-switches (cons (case major-mode ((emacs-lisp-mode scheme-mode lisp-mode) "-F^(") ((texinfo-mode) "-F^@node") (t "-p")) (if (stringp diff-switches) (list diff-switches) diff-switches)))) (vc-diff nil))))) ediff-prepare-buffer-hook (lambda () (hs-minor-mode -1)) ;; 2004-11-09 12:36:36. camion e vicini. ;; magari questa cosa non ci serve più. perl-mode-hook (lambda () (setq perl-indent-level 2 ; stile GNU perl-continued-statement-offset 2 perl-continued-brace-offset 0 perl-brace-offset 0 perl-brace-imaginary-offset 0 perl-label-offset -2)) ;; 2003/09/04 15:40:45. camion e vicini. write-file-hooks time-stamp change-log-mode-hook (lambda () (local-set-keys "\M-i" 'indent-according-to-mode "\C-i" 'indent-according-to-mode) (set (make-local-variable 'backup-inhibited) t)) display-time-hook (lambda () (put-text-property 0 5 'help-echo '(italy-time t) display-time-string)) log-edit-mode-hook abbrev-mode next-error-hook where-am-i find-file-hook (lambda () (when vc-mode (update-rmanglement) (add-hook 'after-revert-hook 'update-rmanglement nil t))) change-log-mode-hook more-vc-make-sure-writeable log-view-mode-hook more-vc-pretty-up-log ;; Add normal hooks here. nil ;;;--------------------------------------------------------------------------- ;;; Advice hooks. ;;; ;;; TODO: Define some consistent naming convention. ;; Do the right thing after a `C-c C-l' when using gud. ;; (defadvice gud-refresh (after gud-refresh-with-ttn-env) "Take into account recenter may be weird!" (call-interactively (key-binding "\M->"))) (defadvice dired-diff (around diff-last-release) (if (not (and (string= (file-name-nondirectory (ad-get-arg 0)) "") (string= (file-name-nondirectory (dired-get-filename)) ".last-release"))) ad-do-it (find-file ".last-release") (goto-char (point-min)) (let ((here default-directory) (lr (prog1 (read (current-buffer)) (kill-buffer nil)))) (switch-to-buffer (get-buffer-create (format "*%s*" lr))) (erase-buffer) (shell-command "diff-last-release" 1) (diff-mode) (setq buffer-read-only t) (set (make-local-variable 'list-buffers-directory) here)))) (defadvice shrink-window-if-larger-than-buffer (after post-eob-lines-too) "Unconditionally eliminate post-eob lines, as well." (when (pos-visible-in-window-p (point-max)) (let ((window-min-height 1)) (shrink-window (- (window-height) 1 ; todo: minibuffer/header-line accounting (if (= ?\C-j (char-before (point-max))) 1 0) (count-lines (window-start) (window-end))))))) ;; Add advice here. ;;;--------------------------------------------------------------------------- ;;; hooks.el ends here ;;; keys.el ;;; ;;; Copyright (C) 1996, 1997, 1998, 1999, 2000, ;;; 2002, 2003, 2004, 2006, 2007, 2008 Thien-Thi Nguyen ;;; This file is part of ttn's personal elisp library, released under GNU ;;; GPL with ABSOLUTELY NO WARRANTY. See the file COPYING for details. ;;; Description: Global keymap bindings. (let ((sel *ttn-select-global-keys*)) (let (key command) (while (setq key (read)) (setq command (eval (read))) (and sel (or (and (eq 'only (car sel)) (member key (cdr sel))) (and (eq 'except (car sel)) (not (member key (cdr sel))))) (global-set-key key command))))) ;; First the simple... "\C-x\C-b" 'electric-buffer-list ; thanks, dave asher! "\M-n" 'down-holdcursor ; ah, this is the way it should be! "\M-p" 'up-holdcursor ; "\C-c\C-m" 'gnus-no-server ; mail reading stuff "\M-m" 'compile ; water the seed "\C-xg" 'grep ; basic editing and movement "\M-+" 'delete-region ; "\M-g" 'goto-line ; [home] 'delete-other-windows ; [end] 'delete-window ; [pause] 'split-window-vertically ; "\M-*" 'replace-string ; "\C-x\C-v" 'view-file ; "\C-cv" 'view-buffer ; "\C-xt" 'toggle-truncate-lines ; "\M-l" 'what-line ; "\M-!" 'saved-shell-command ; "\C-xs" 'multi-shell ; "\C-x[" 'backward-page-ignore-narrow ; "\C-x]" 'forward-page-ignore-narrow ; "\C-x\M-b" bookmark-map ; "\C-x\C-m\C-m" 'mail-this-buffer ; "\C-ct" 'insert-time-stamp ; "\C-c-" 'insert-separator ; "\M-&" 'bg-shell-command ; "\C-x\C-q" 'vc-toggle-read-only ; old skool [f11] 'describe-text-properties ; welcome to 2004 old fogie! "\C-c+" 'cycle-font ; either this or new glasses [(shift up)] 'scroll-down ; for X; most terminals lose here [(shift down)] 'scroll-up "\C-cI" 'Info-on-current-buffer ; while browsing tgz, zip, ... "\C-x\C-d" 'dired-especially-this-file ; `list-directory' not so useful "\C-cR" 'rename-buffer ; for diff, etc "\C-c_" 'raise-sexp ; leaving peers underneath [(shift return)] 'invisible-cursor-mode ; more fun under X [(control c) (shift d)] 'disassemble ; curiosity can only hurt a little... "\C-ca" 'clone-indirect-buffer ; for quick local searching [Scroll_Lock] 'emacs-uptime ; olio per il kvm [(super /)] 'switch-window-contents ; limited patience for heuristics "\C-c " 'transient-mark-mode ; sometimes it can be annoying [(control x) (m)] 'message-mail ; fancy [(super ?\[)] 'previous-error ; can curiosity be so wrong? [(super ?\])] 'next-error "\C-xv\M-r" 'release-dired ; mark and then Rel, woo hoo! "\M-#" 'delete-indentation ; M-^ is too much of a stretch "\C-x\M-f" 'watch-file-preciously ; thanks buggy compilers everywhere ;; Add new simple global keybindings here. ;; Then the complex. "\C-cr" (defun revert-buffer-t-t () (interactive) (revert-buffer t t)) "\M-\"" (lambda () (interactive) (if (looking-at "\"") (forward-char 1) (insert ?" ?") (forward-char -1))) "\M-o" (lambda () (interactive) (if (/= 1 (length (remove-if (lambda (frame) (let ((parms (frame-parameters frame))) (or (eq 'icon (cdr (assq 'visibility parms))) (string= "Calendar" (cdr (assq 'name parms)))))) (frame-list)))) (other-frame 1) (switch-to-buffer (let ((bl (cdr (buffer-list)))) ;; SPC after question-mark intentional (while (= (elt (buffer-name (car bl)) 0) ? ) (setq bl (cdr bl))) (car bl))))) "\C-x\C-k" (lambda (arg) (interactive "P") ; kill-buffer-close-window (if arg (bury-buffer) (kill-buffer nil)) (unless (one-window-p 'nomini) (delete-window))) "\C-c\C-d" (lambda () (interactive) ; delete-eol-dead-space (save-excursion (goto-char 1) (while (re-search-forward "[ \t]+$" (point-max) t) (delete-region (match-beginning 0) (match-end 0))))) "\M->" (lambda () (interactive) ; my-end-of-buffer (end-of-buffer) (recenter -1)) "\M-<" (lambda () (interactive) ; my-beginning-of-buffer (beginning-of-buffer) (recenter 1)) "\C-cl" (lambda () (interactive) ; line-to-top-of-window (recenter 1)) "\C-xw" (lambda () (interactive) ; where-am-i (message (or (buffer-file-name) (concat default-directory " (no file)")))) "\M-]" (lambda () (interactive) ; rotate-top-2-windows (message "`rotate-top-2-windows' not implemented yet!")) "\C-xp" (lambda () (interactive) ; other-previous-window (other-window -1)) "\C-x\C-i" (lambda (start end prefix) ; indent-rigidly-with-prefix (interactive "*r\nsPrefix to insert (don't need quotes): ") (apply-macro-to-region-lines start end prefix)) "\C-x3" (lambda (arg) ; split-into-3-windows (interactive "P") (let* ((old (if arg (window-width) (window-height))) (v (/ (- old 2) 3))) (if arg (progn (split-window-horizontally) (while (> (window-width) v) (shrink-window-horizontally 1)) (other-window 1) (split-window-horizontally) (other-window -1)) (split-window-vertically) (while (> (window-height) v) (shrink-window 1)) (other-window 1) (split-window-vertically) (other-window -1)))) ;; 2006-11-29 13:04:58. un mal di testa alla volta, grazie! ;; ;;- "\C-x\C-c" ;;- (lambda (arg) ; make-sure-before-exiting ;;- (interactive "P") ;;- (when (or arg (y-or-n-p "Logout? ")) ;;- (save-buffers-kill-emacs))) "\C-x\C-f" (lambda (filename) ; find-file-possibly-rcs (interactive "FFilename: ") (if (not (string-match ",v$" filename)) (find-file filename) (if (y-or-n-p "RCS master file: `y' to open, or `n' to d.t.r.t. ") (find-file filename) (let* ((cut-point (string-match "RCS/" filename)) (new-filename (concat (substring filename 0 cut-point) (substring filename (+ 4 cut-point) -2)))) (find-file new-filename))))) "\C-c\C-@" (lambda () (interactive) ; xx (save-excursion (let (buffer-read-only) (goto-char 1) (while (search-forward "\C-@" nil t) (replace-match "" nil t))))) ;; 2006-11-29 12:56:47. fa farlo ratpoison (C-t T). comunque non c'è xterm. ;; ;;- "\C-cp" ;;- (lambda () ;;- (interactive) ;;- (save-window-excursion ;;- (shell-command "xterm -geom 100x45 -e top -d1 &"))) ;; 1997-10-11 19:38. listening to some interesting banjo (i think). i ;; really like the tightness and yet looseness -- the principal is slightly ;; on the lagging side. :-D ;; ;; anyway, the best way to rephrase the following is: ;; ;; i like `C-l' to move me to a better place. the original name captures ;; some of it, we can all see and appreciate that. a better place means ;; more higher comfort but with the memories not lost. the memories are ;; important. ;; ;; binding for `M-r' has right idea but does not cover all the cases. ;; so, merge the two, you can call it `home'. ;; ;; some hints to ong-da: (a) how many dimensions does this expression have? ;; (b) where is the most data motion? "\C-l" (lambda (arg &optional arg1) ; gnarly, dude! (interactive "P") (if arg1 (let ((arg0 arg)) (and (<= (point-min) arg0) (< arg1 (point-max)) (<= arg0 arg1) (font-lock-fontify-region arg0 arg1))) (cond ((null arg) (recenter (or (and (boundp 'C-l-gravity) C-l-gravity) '(4)))) ((integerp arg) (recenter arg)) ((and (listp arg) (integerp (car arg))) (case (car arg) (4 (recenter nil)) (16 (setq C-l-gravity (count-lines (window-start) (save-excursion (beginning-of-line) (point))))) (64 (when (featurep 'font-lock) (font-lock-fontify-buffer)))))))) ;; 1998.0506.00:01:20-0700. see above for meaning of `C-x C-k'. [mode-line mouse-3] (key-binding "\C-x\C-k") ;; 1998.0707.02:41:49-0700. this used to be just `bury-buffer', but it's ;; better to make Emacs understand Real Intent. :-> "\M-_" (lambda (below-electric-buffer-notice) (interactive "P") (and below-electric-buffer-notice (rename-buffer (concat " " (buffer-name)))) (bury-buffer)) ;; 2002/03/23 20:06:50. [?\H-l] 'locate ;; 2007-08-25 18:30:40. tick tick tick... [f5] (lambda () (interactive) (set-theme "caffeine")) [f6] (lambda () (interactive) (set-theme "new-earthy")) ;; Add new complex global keybindings here. ;; Done! nil ;;; keys.el ends here ;;; do-it-now.el ;;; ;;; Copyright (C) 1996, 1997, 1998, 2000, 2002, ;;; 2003, 2004, 2006, 2007, 2008 Thien-Thi Nguyen ;;; This file is part of ttn's personal elisp library, released under GNU ;;; GPL with ABSOLUTELY NO WARRANTY. See the file COPYING for details. ;;; Description: No definitions, just actions. ;;;--------------------------------------------------------------------------- ;;; Language environment. (set-language-environment "Latin-1") ;;;--------------------------------------------------------------------------- ;;; Set directory environment variables. (let ((dir-env-var-file "~/.directory-env-vars")) (if (not (file-exists-p dir-env-var-file)) (message "Env var file not found, skipping: %s" dir-env-var-file) (message "Setting env vars from file: %s" dir-env-var-file) (jamenv-from-file dir-env-var-file))) ;;;--------------------------------------------------------------------------- ;;; Ensure the agreeableness of things. (map-table-2col (lambda (thing setting) (when (fboundp thing) (funcall thing setting))) '(line-number-mode -1 column-number-mode -1 menu-bar-mode -1 transient-mark-mode 1 scroll-bar-mode -1 tooltip-mode -1 blink-cursor-mode -1 ;; add here. )) ;;;--------------------------------------------------------------------------- ;;; Keep track of time. (display-time) ;;;--------------------------------------------------------------------------- ;;; Window system stuff. (when (or window-system (and (fboundp 'display-color-p) (display-color-p))) (unless noninteractive (turn-on-mic-paren)) (set-theme (if window-system 'new-earthy 'dream)) (set-face-background 'modeline "black") (set-cursor-color "lightblue") (set-face-foreground 'region "green") (set-face-background 'region "black") (set-face-background 'highlight "gray20") (global-font-lock-mode t) ;; old skool (when (fboundp 'fringe-mode) (fringe-mode 0)) ;; enough ghosts in the machine (when (boundp 'cursor-in-non-selected-windows) (setq-default cursor-in-non-selected-windows nil))) ;;;--------------------------------------------------------------------------- ;;; Poor man's face customization. (mapc (lambda (spec) (apply 'set-face-attribute (car spec) nil (cdr spec))) '((font-lock-comment-face :foreground "moccasin") (font-lock-string-face :foreground "orange") (font-lock-keyword-face :bold t :foreground "skyblue") (match :background "gray20"))) ;;;--------------------------------------------------------------------------- ;;; Autoloads ;; database (autoload 'db-find-file "database" "EDB database package" t) ;; ttn-do (autoload 'ttn-do "ttn-do" "There is no try." t) ;; pk-unpk (when (ignore-errors (require 'add-guile-dirs)) (autoload 'pk "pk-unpk" nil t) (autoload 'unpk "pk-unpk" nil t)) ;;;--------------------------------------------------------------------------- ;;; Aliases (defalias 'fdap 'dired-at-point) (defalias 'make 'compile) (defalias 'next-buffer 'bury-buffer) ;;;--------------------------------------------------------------------------- ;;; Elisp indentation specs (put other languages in a mode hook) (mapcar (lambda (x) (put x 'lisp-indent-function 1)) '(edit-vc-file with-vc-file)) ;;; do-it-now.el ends here ;;;; core.el ends here