Portræt af Arne Jørgensen
Arne Jørgensen
[Download]
;;; .emacs --- Arne Jørgensens .emacs file

;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
;;     2003, 2004, 2005, 2006 Arne Jørgensen

;; Author: Arne Jørgensen <arne@arnested.dk>

;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or (at
;; your option) any later version.

;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

;;; Commentary:

;; This .emacs contains things that will only work in Emacs 22.

;;; Code:

;;; relocate and load customs (so we don't clutter this file with them)
(setq custom-file "~/.emacs.d/custom.el")
(load custom-file)

;; relocate other files so we don't clutter $HOME
(setq save-place-file "~/.emacs.d/save-places")
(setq abbrev-file-name "~/.emacs.d/abbrev_defs")
(setq url-configuration-directory "~/.emacs.d/url.d")
(setq gamegrid-user-score-file-directory "~/.emacs.d/games.d")
(setq auto-save-list-file-prefix "~/.emacs.d/auto-save-list.d/")

(setq gnus-home-directory "~/.emacs.d/gnus.d/")
(setq gnus-directory "~/.emacs.d/gnus.d/News/")
(setq message-directory "~/.emacs.d/gnus.d/Mail/")
(setq nnfolder-directory "~/.emacs.d/gnus.d/Mail/archive/")
(setq gnus-init-file "~/.emacs.d/gnus.d/init")

;; make emacs be more like in the ol' days
(setq resize-mini-windows nil)
(blink-cursor-mode 0)
(global-set-key [home] 'beginning-of-buffer)
(global-set-key [end] 'end-of-buffer)

;; editing convenience
(setq visible-bell t)
(setq default-indicate-buffer-boundaries t)
(when window-system (msb-mode 1))
(transient-mark-mode 1)
(mouse-wheel-mode 1)
(show-paren-mode 1)
(auto-compression-mode 1)
(global-font-lock-mode 1 nil)
(put 'narrow-to-region 'disabled nil)
(put 'iconify-or-deiconify-frame 'disabled t)

;; personalization
(setq user-full-name "Arne Jørgensen")
(setenv "ORGANIZATION" "Arne Jørgensen")

;; charset stuff
(require 'ucs-tables)
(set-language-environment "UTF-8")
(modify-coding-system-alist 'file "" 'utf-8)

;; localization
(setq default-input-method "danish-postfix")
(setq ispell-dictionary "dansk")

;; (eval-after-load 'ispell
;;   '(when ispell-aspell-supports-utf8
;;      (setq ispell-extra-args
;;         (append ispell-extra-args '("--encoding" "none")))))

(add-hook 'LaTeX-mode-hook (lambda nil
                             (setq ispell-local-dictionary "american")))

(setq sentence-end-double-space nil)

;; printer etc.
(setq ps-printer-name "hl5040")

;; here I keep locally downloaded and developed libraries
;;(add-to-list 'load-path "~/usr/src/gnus/lisp")
(add-to-list 'load-path "~/.emacs.d/misc.d")
(load-library "my-autoload")
(add-to-list 'load-path "~/.emacs.d/misc.d/nxml-mode-20041004")
(load-library "rng-auto")

;; now require/autoload them
(load "50cperl")
;(require 'php-mode)
(require 'apache-mode)
(require 'dns-mode)
(require 'php-mode)
(autoload 'css-mode "css-mode")

;; auto-mode-alist
(add-to-list 'auto-mode-alist '("\\.soa\\'" . dns-mode))
(add-to-list 'auto-mode-alist '("\\.css\\'" . css-mode))

;; misc
(add-hook 'text-mode-hook 'turn-on-auto-fill)
(setq browse-url-browser-function 'browse-url-gnome-moz)
(add-hook 'text-mode-hook (lambda nil
                            (set-input-method default-input-method)))
(add-to-list 'file-coding-system-alist
             '("\\.el\\'" iso-2022-7bit . iso-2022-7bit))
(add-hook 'before-save-hook 'copyright-update)

;; AUCTeX
(load "auctex.el" nil t t)
;; (load "preview-latex.el" nil t t)
(setq TeX-auto-global "")
(setq TeX-macro-global '("~/texmf/tex/" "/usr/local/share/texmf/tex/"
                         "/var/lib/texmf/tex/" "/usr/share/texmf/tex/"))
(setq-default TeX-master nil) ; Query for master file.
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq TeX-auto-local ".auctex-auto")
(setq TeX-style-local ".auctex-auto")
;; (setq TeX-electric-escape t)

(add-hook 'LaTeX-mode-hook #'LaTeX-install-toolbar)

(defun my-LaTeX-document-style-hook nil
  "Insert my default \\usepackages."
  (save-excursion
    (goto-char (point-min))
    (search-forward "\\documentclass" nil t)
    (forward-line)
    (insert "\\usepackage[T1]{fontenc}\n")
    (when (fboundp 'latexenc-coding-system-to-inputenc)
      (when (not (eq (latexenc-coding-system-to-inputenc
                      buffer-file-coding-system)
                     'undecided))
        (insert "\\usepackage[" (latexenc-coding-system-to-inputenc
                                 buffer-file-coding-system) "]{inputenc}\n")))
    (insert "\\usepackage{babel}\n")))

(add-hook 'LaTeX-mode-hook
          (lambda nil (add-hook 'LaTeX-document-style-hook
                                'my-LaTeX-document-style-hook nil t)))

;; BibTeX
(require 'bibtex)

(setq bibtex-autokey-name-case-convert 'identity
      bibtex-autokey-year-length 4
      bibtex-autokey-titlewords 0
      bibtex-autokey-titlewords-stretch 0
      bibtex-autokey-titleword-length 0
      bibtex-autokey-name-year-separator ":"
      bibtex-autokey-edit-before-use nil
      bibtex-autokey-before-presentation-function 'my-bibtex-autokey-unique)

(defun my-bibtex-autokey-unique (key)
  "Make a unique version of KEY."
  (save-excursion
    (let ((trykey key)
          (next ?a))
      (while (and (bibtex-find-entry trykey t)
                  (<= next ?z))
        (setq trykey (concat key (char-to-string next)))
        (setq next (1+ next)))
      trykey)))

(add-to-list 'bibtex-autokey-transcriptions '("\\\\r{a}" . "aa"))
(add-to-list 'bibtex-autokey-transcriptions '("\\\\r{A}" . "Aa"))
(add-to-list 'bibtex-autokey-transcriptions '("\\\\aa" . "aa"))
(add-to-list 'bibtex-autokey-transcriptions '("\\\\AA" . "Aa"))

;; RefTeX
(setq reftex-plug-into-AUCTeX t)
(autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)   ; with AUCTeX LaTeX mode
(add-hook 'latex-mode-hook 'turn-on-reftex)   ; with Emacs latex mode
(setq reftex-use-external-file-finders t)
(setq reftex-external-file-finders
      '(("tex" . "kpsewhich --format tex %f")
        ("bib" . "kpsewhich --format bib %f")))

;; smtpmail.el
(require 'smtpmail)
(setq smtpmail-auth-credentials "~/.authinfo")
(setq smtpmail-starttls-credentials '(("localhost" 587 "" "")))
;; (setq smtpmail-debug-info t)
(setq smtpmail-smtp-server "smtp.tiscali.dk"
      smtpmail-smtp-service 25
      message-send-mail-function 'message-smtpmail-send-it     ; for gnus/message
      send-mail-function 'smtpmail-send-it)                    ; for `mail'

;; BBDB
(require 'bbdb)
(bbdb-initialize 'gnus 'message 'w3 'sendmail)
(setq bbdb-north-american-phone-numbers-p nil)
(setq bbdb-user-mail-names (regexp-opt '("arne@daimi.au.dk"
                                         "arne+usenet@daimi.au.dk"
                                         "dk-tug-kasserer@sunsite.auc.dk"
                                         "arne.jorgensen@tug.dk"
                                         "treasurer@tug.dk"
                                         "kasserer@tug.dk"
                                         "arne@arnested.dk")))

(add-hook 'bbdb-load-hook (lambda nil (require 'bbdb-print)))
(setq bbdb-print-prolog "%%%% ====== Phone/Address list in -*-TeX-*- Format =====\n\n\\input bbdb-arne\n")
(setq bbdb-print-epilog "\\endaddresses\n\\bye\n\n%%% Local Variables: \n%%% mode: plain-tex\n%%% TeX-master: t\n%%% End: \n")
(setq bbdb-print-elide '(notes creation-date timestamp www tex-name aka mail-alias))
(setq bbdb-print-file-name (expand-file-name "~/Documents/adresseliste.tex"))
(setq bbdb-print-alist '((omit-area-code ."+45 *")
                         (phone-on-first-line . "Home")
                         (ps-fonts . nil)
                         (font-size . 6)
                         (quad-hsize . "3.15in")
                         (quad-vsize . "4.5in")))

(setq bbdb/gnus-summary-prefer-real-names t
      bbdb/gnus-summary-show-bbdb-names t)

;; server-start unless it is already running somewhere
(unless (= 0 (call-process "emacsclient" nil nil nil "--eval" "nil" "-a" "false"))
  (server-start))

(setq server-window '(lambda (buf)
  (let ((frame (make-frame)))
    (select-frame frame)
    (switch-to-buffer buf)
    (raise-frame frame)
    (add-hook 'server-done-hook 'delete-frame t t))))

;; Blosxom
(setq blosxom-file-regexp "/home/arne/blog/.*txt")

;; my mailto
(defvar my-mailto-frame nil)
(defun my-mailto-handler (url)
  "Compose new mail, using the mailto-url given"
  (require 'gnus)
  (require 'gnus-art)
  (require 'message)
  (require 'message-x)
  (make-variable-frame-local 'my-mailto-frame)
  (setq my-mailto-frame (make-frame))
  (select-frame-set-input-focus my-mailto-frame)
  (make-frame-visible my-mailto-frame)
  (raise-frame my-mailto-frame)
  (gnus-url-mailto url)
  (save-excursion 
    (message-goto-to)
    (message-x-tab))
  (set-buffer-modified-p nil)
  (message-add-action
   `(delete-frame my-mailto-frame)
   'exit 'kill 'postpone))

(defadvice handle-delete-frame (before my-kill-frame-message activate)
  "Kill message first"
  (message-kill-buffer))

;; Katsumi Yamaoka <yamaoka@jpl.org> posted this in
;; http://article.gmane.org/gmane.emacs.devel:39702
(defadvice raise-frame (after make-it-work (&optional frame) activate)
  "Work around some bug? in raise-frame/Emacs/GTK/Metacity/something.
Katsumi Yamaoka <yamaoka@jpl.org> posted this in
http://article.gmane.org/gmane.emacs.devel:39702"
  (call-process
   "wmctrl" nil nil nil "-i" "-R"
   (frame-parameter (or frame (selected-frame)) 'outer-window-id)))

(defun select-my-gnus nil
  "Make the window manager switch to my main Emacs window and get new news in Gnus."
  (with-temp-buffer
    (call-process "wmctrl" nil t nil "-l" "-p")
    (goto-char (point-min))
    (while (looking-at "\\([^ ]+\\) +\\([^ ]+\\) +\\([^ ]+\\) +\\([^ ]+\\) +\\(.*\\)\n")
      (when (string= (match-string 3)
                     (int-to-string (emacs-pid)))
        (call-process "wmctrl" nil nil nil "-i" "-a" (match-string 1)))
      (forward-line)))
  (switch-to-buffer gnus-group-buffer)
  (gnus-group-get-new-news))

;; Generate autoload for locally downloaded and developed elisp files
(defun my-autoloads nil
  "Generate autoloads for code in ~/.emacs.d/misc.d/."
  (interactive)
  (let ((generated-autoload-file "~/.emacs.d/misc.d/my-autoload.el"))
    (update-directory-autoloads "~/.emacs.d/misc.d")))

(when (> (safe-length command-line-args) 1)
  (setq inhibit-startup-message t))



;; Local Variables: ;; coding: iso-2022-7bit ;; eval: (add-hook 'after-save-hook 'emacs-lisp-byte-compile t t) ;; End: ;;; .emacs ends here