(custom-set-variables
;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
'(canlock-password "8516d6bf23385b0834882d82845c0a17bb8c90c0")
'(case-fold-search t)
'(current-language-environment "UTF-8")
'(default-input-method "rfc1345")
'(global-font-lock-mode t nil (font-lock))
'(transient-mark-mode t))
(custom-set-faces
;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
)
;; set CVS environment variables
(setq cvs-cvsroot ":ext:user@example.com:/srv/scm/cvs")
(setenv "CVS_RSH" "/usr/bin/ssh")
;; set encoding for xml and xhtml files to utf-8
(setq file-coding-system-alist
(append '(("\\.xml$" . utf-8)
("\\.x?html$" . utf-8)
("\\.ldif$" . utf-8))
file-coding-system-alist))
;; functions to convert from DOS endline to UNIX endline
(defun dos2unix ()
(interactive)
(goto-char (point-min))
(while (search-forward "\r" nil t) (replace-match "")))
(defun unix2dos ()
(interactive)
(goto-char (point-min))
(while (search-forward "\n" nil t) (replace-match "\r\n")))
;; I want auto-fill in text-mode
(add-hook 'text-mode-hook
(lambda()
(turn-on-auto-fill)))
;; date function
(defun insert-date()
"Insert date at point."
(interactive)
(insert (format-time-string "%a %b %e, %Y, %l:%M %p")))
;; remove auto-fill in xml and java mode
(add-hook 'xml-mode-hook
(lambda ()
(turn-off-auto-fill)))
(add-hook 'java-mode-hook
(lambda()
(turn-off-auto-fill)))
;; SGML section
;; create faces to assign markup categories
(make-face 'sgml-doctype-face)
(make-face 'sgml-pi-face)
(make-face 'sgml-comment-face)
(make-face 'sgml-sgml-face)
(make-face 'sgml-start-tag-face)
(make-face 'sgml-end-tag-face)
(make-face 'sgml-entity-face)
; assign attributes to faces
(set-face-foreground 'sgml-doctype-face "saddle brown")
(set-face-foreground 'sgml-sgml-face "cyan1")
(set-face-foreground 'sgml-pi-face "magenta")
(set-face-foreground 'sgml-comment-face "red")
(set-face-foreground 'sgml-start-tag-face "forest green")
(set-face-foreground 'sgml-end-tag-face "forest green")
(set-face-foreground 'sgml-entity-face "Blue")
; assign faces to markup categories
(setq sgml-markup-faces
'((doctype . sgml-doctype-face)
(pi . sgml-pi-face)
(comment . sgml-comment-face)
(sgml . sgml-sgml-face)
(start-tag . sgml-start-tag-face)
(end-tag . sgml-end-tag-face)
(entity . sgml-entity-face)))
(setq sgml-custom-dtd '
(
( "HTML 4.01 Strict"
"\n" )
( "HTML 4.01 Transitional"
"\n" )
( "HTML 4.01 Frameset"
"\n" )
( "XHTML 1.0 Strict"
"\n\n" )
( "XHTML 1.0 Transitional"
"\n\n" )
( "XHTML 1.0 Frameset"
"\n\n" )
( "XHTML 1.1"
"\n\n" )
)
)
;; autodetect xml
(defun sgml-autodetect-xml ()
"Check for initial declaration and set flags accordingly.
Used to determine whether the HTML is SGML or XML (XHTML).
Code inspired by tdtd.el"
(interactive)
(save-excursion
(goto-char (point-min))
(skip-chars-forward "\\s-")
(cond
((looking-at "<\\?xml")
(xml-mode))
(t
(sgml-mode))
))
)
;; PSGML -enable face settings
(setq sgml-set-face t)
(setq sgml-auto-activate-dtd t)
(setq sgml-indent-data t)
;; automatic timestamp, taking from html-helper.el
(defvar sgml-timestamp-start ""
"*Begin delimiter for timestamps.")
(defvar sgml-timestamp-end ""
"*End delimiter for timestamps.")
(defvar sgml-timestamp-hook 'sgml-insert-timestamp
"*Hook called for timestamp insertion.")
(defun sgml-update-timestamp ()
"Basic function for updating timestamps.
It finds the timestamp in the buffer by looking for
'sgml-timestamp-start', deletes all text up to
'sgml-timestamp-end', and runs 'sgml-insert-timestamp'."
(save-excursion
(goto-char (point-max))
(if (not (search-backward sgml-timestamp-start nil t))
(message "timestamp delimiter start was not found")
(let ((ts-start (+ (point) (length sgml-timestamp-start)))
(ts-end (if (search-forward sgml-timestamp-end nil t)
(- (point) (length sgml-timestamp-end))
nil)))
(if (not ts-end)
(message "timestamp delimiter end was not found. Type C-c C-t to insert one.")
(delete-region ts-start ts-end)
(goto-char ts-start)
(insert "\n")
(run-hooks 'sgml-timestamp-hook)
(insert "\n")))))
nil)
(defun sgml-insert-timestamp ()
"Default timestamp insertion function"
(let ((time (current-time-string)))
(insert "Last modified: "
(substring time 0 20)
(nth 1 (current-time-zone))
" "
(substring time -4)
" ")))
(defun sgml-insert-timestamp-delimiter ()
"Simple function that inserts delimiters at point."
(interactive)
(insert sgml-timestamp-start)
(insert "\n")
(insert sgml-timestamp-end))
(defun xhtml-mode ()
(interactive)
(sgml-autodetect-xml)
(make-local-variable 'sgml-default-doctype-name)
(setq sgml-default-doctype-name "html")
(add-hook 'local-write-file-hooks 'sgml-update-timestamp)
(turn-off-auto-fill)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Useful skeletons
(setq html-web-address "user@example.com")
; HTML skeleton
(define-skeleton html-skeleton
"HTML skeleton for xhtml 1.0"
nil
"\n"
"" \n
"" \n
"
" \n
"" \n
"" \n
"" \n
"" _ "" \n
-2 "" \n
"" \n \n
"" \n
-2 "" \n
-2 "\n")
; XHTML skeleton
; XHTML skeleton is slightly different from HTML because of the
; content type
(define-skeleton xhtml-skeleton
"HTML skeleton for xhtml 1.1"
nil
"\n"
"" \n
"" \n
"" \n
"" \n
"" \n
"" \n
"" _ "" \n
-2 "" \n
"" \n \n
"
" \n
"Webmaster" \n
"" \n
"\n"
sgml-timestamp-start "\n"
sgml-timestamp-end \n
-2 "
" \n
"" \n
"This page was created using
Emacs" \n
-2 "
" \n
-2 "" \n
-2 "\n")
; XML skeleton
; XML skeleton is slightly different from HTML because of the
; content type
(define-skeleton xml-skeleton
"XML skeleton for xml 1.0"
nil
"\n"
_
)
; Perl skeleton
; Perl skeleton is slightly different from HTML because of the
; content type
(define-skeleton perl-skeleton
"Perl skeleton"
nil
"#!/usr/bin/perl -w\n"
"#\n"
"# @file " (file-name-nondirectory buffer-file-name) "\n"
"# @author " (user-full-name) "\n"
"# @date " (format-time-string "%d %b, %Y" (current-time)) "\n"
"# @version $Revision$\n"
"#\n"
"# @brief \n"
"#\n"
"# @remarks \n"
"# Copyright © "(format-time-string "%Y" (current-time)) " "(user-full-name)"\n"
"#\n"
"#############################################################\n\n"
"use strict;\n"
"use warnings;\n\n"
_
)
; SHELL skeleton
(define-skeleton bourne-shell-skeleton
"Skeleton for shell scripts"
nil
"#!/bin/sh\n"
"#\n"
"# @file " (file-name-nondirectory buffer-file-name) "\n"
"# @author " (user-full-name) "\n"
"# @date " (format-time-string "%d %b, %Y" (current-time)) "\n"
"# @version $Revision$\n"
"#\n"
"# @brief \n"
"#\n"
"# @remarks \n"
"# Copyright © "(format-time-string "%Y" (current-time)) " "(user-full-name)"\n"
"#\n"
"#############################################################\n\n"
_
)
; Java skeleton
(define-skeleton java-body-skeleton
"Java skeleton"
nil
"/**\n"
" * @file " (file-name-nondirectory buffer-file-name) "\n"
" * @author " (user-full-name) "\n"
" * @date " (format-time-string "%d %b, %Y" (current-time)) "\n"
" * @version $Revision$\n"
" * \n"
" * @brief \n"
" * \n"
" * @remarks\n"
" * Copyright © "(format-time-string "%Y" (current-time)) " "(user-full-name)"\n"
" *\n"
" * @brief \n"
" *\n"
" * @remarks \n"
" * \n"
" */\n"
"/*"
(make-string fill-column ?*)
"*/\n"
_
"\n\nclass "
(setq v1
(file-name-sans-extension
(file-name-nondirectory buffer-file-name)))
"\n{\n\n"
"} /* ! class " v1 " */" \n \n
)
(defun test-cpp-filename-p ()
"Tests whether this is a c++ or c file"
(equal
"cpp" (file-name-extension (file-name-nondirectory buffer-file-name)))
)
(defun test-hpp-filename-p ()
"Tests whether this is a c++ or c file"
(equal
"hpp" (file-name-extension (file-name-nondirectory buffer-file-name)))
)
; C header skeleton
(define-skeleton c-header-skeleton
"C and C++ header skeleton"
nil
"/**\n"
" * @file " (file-name-nondirectory buffer-file-name) "\n"
" * @author " (user-full-name) "\n"
" * @date " (format-time-string "%d %b, %Y" (current-time)) "\n"
" * @version $Revision$\n"
" *\n"
" * @brief \n"
" *\n"
" * @remarks \n"
" * Copyright © "(format-time-string "%Y" (current-time)) " "(user-full-name)"\n"
" *\n"
" */\n"
"/*"
(make-string fill-column ?*)
"*/\n"
"#ifndef "
(setq v1
(upcase (file-name-sans-extension
(file-name-nondirectory buffer-file-name))))
(if (test-hpp-filename-p)
"_HPP"
"_H")
"_INCLUDED_" \n
"#define " v1
(if (test-hpp-filename-p)
"_HPP"
"_H")
"_INCLUDED_" \n \n
_ \n \n
"#endif /* " v1
(if (test-hpp-filename-p)
"_HPP"
"_H")
"_INCLUDED_ */\n"
)
(defun c-header-name ()
"Sets the c header file based on source filename"
(concat
(file-name-sans-extension (file-name-nondirectory buffer-file-name))
".h")
)
(defun cpp-header-name ()
"Sets the c++ header file based on source filename"
(concat
(file-name-sans-extension (file-name-nondirectory buffer-file-name))
".hpp")
)
; C and C++ body skeleton
(define-skeleton c-body-skeleton
"C and CPP body skeleton"
nil
"/**\n"
" * @file " (file-name-nondirectory buffer-file-name) "\n"
" * @author " (user-full-name) "\n"
" * @version $Revision$\n"
" * @remarks \n"
" * Copyright © "(format-time-string "%Y" (current-time)) " "(user-full-name)"\n"
" */\n"
"/*" (make-string fill-column ?*)
"*/\n"
(cond ((file-exists-p (c-header-name))
(concat
"#include \""
(c-header-name)
"\"\n"))
((file-exists-p (cpp-header-name))
(concat
"#include \""
(cpp-header-name)
"\"\n\n"))
)
_ )
(define-skeleton c-main-skeleton
"main c skeleton"
nil
"/**\n"
" * @file " (file-name-nondirectory buffer-file-name) "\n"
" * @author " (user-full-name) "\n"
" * @version $Revision$\n"
" * @remarks\n"
" * Copyright © "(format-time-string "%Y" (current-time)) " "(user-full-name)"\n"
" */\n"
"/*" (make-string fill-column ?*)
"*/\n"
(if (test-cpp-filename-p)
"#include "
"#include ")
\n \n
"int" \n
"main( int argc, char *argv[] )\n"
"{" \n _ \n \n
"return EXIT_SUCCESS;\n"
"}")
(define-skeleton cpp-main-skeleton
"main cpp skeleton"
nil
"/**\n"
" * @file " (file-name-nondirectory buffer-file-name) "\n"
" * @author " (user-full-name) "\n"
" * @version $Revision$\n"
" * @remarks\n"
" * Copyright © "(format-time-string "%Y" (current-time)) " "(user-full-name)"\n"
" */\n"
"/*" (make-string fill-column ?*)
"*/\n"
"#include \"cstdlib\"\n\n"
"int\n"
"main( int argc, char* argv[] )\n"
"{" \n _ \n
"return EXIT_SUCCESS;" \n
"}")
;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'find-file-hooks 'auto-insert)
(setq auto-insert-query nil)
(setq executable-query nil)
(setq executable-insert t)
(setq auto-insert-alist '(("main.c$" . [c-mode c-main-skeleton])
("main.cpp$" . [c++-mode c-main-skeleton])
("\\.h$" . [c-mode c-header-skeleton])
("\\.cpp$" . [c++-mode c-body-skeleton])
("\\.hpp$" . [c++-mode c-header-skeleton])
("\\.c$" . [c-mode c-body-skeleton])
("\\.cc$" . [c++-mode c-body-skeleton])
("\\.tcc$" . [c++-mode c-body-skeleton])
("\\.java$" . [java-mode java-body-skeleton])
("\\.html$" . [xhtml-mode html-skeleton])
("\\.xhtml$" . [xhtml-mode xhtml-skeleton])
("\\.xml$" . [sgml-mode xml-skeleton])
("\\.xsl$" . [xml-mode xml-skeleton])
("\\.pl$" . [perl-mode perl-skeleton])
("\\.pm$" . [perl-mode perl-skeleton])
("\\.sh$" . [shell-script-mode bourne-shell-skeleton])
))
(setq auto-mode-alist
(append '(("\\.htm$" . xhtml-mode)
("\\.html$" . xhtml-mode)
("\\.xhtml$" . xhtml-mode)
("\\.y$" . wisent-grammar-mode)
("\\.l$" . wisent-grammar-mode)
("\\.tcc$" . c++-mode)
("\\.cs$" . c++-mode)
("\\.js$" . c++-mode)
("\\.xsl$" . xml-mode)
("\\.java$" . java-mode)
("\\.rng$" . rnc-mode)
("CMakeLists\\.txt$" . cmake-mode)
("\\.cmake$" . cmake-mode)
("README$" . text-mode))
auto-mode-alist))
;; jdee
(setq defer-loading-jde t)
;;
(if defer-loading-jde
(progn
(autoload 'jde-mode "jde" "JDE mode." t)
(setq auto-mode-alist
(append
'(("\\.java$\\'" . jde-mode))
auto-mode-alist)))
(require 'jde))
(add-hook 'jde-mode-hook
(lambda ()
(turn-off-auto-fill)))
;; C++ and C modes
(setq my-tab-offset 6)
(c-add-style "fjellstad-c++-style"
'("Stroustrup"
(c-basic-offset . 6)
(c-offsets-alist
(inline-open . 0)
(substatement-open . 0)
(statement-cont . 0))
(indent-tabs-mode . nil)))
(c-add-style "fjellstad-c-style"
'("K&R"
(c-basic-offset . 6)
(indent-tabs-mode . nil)))
(add-hook 'c-mode-hook
(lambda ()
(c-set-style "fjellstad-c-style")
(local-set-key "\M-f" 'c-forward-into-nomenclature)
(local-set-key "\M-b" 'c-backward-into-nomenclature)
(turn-off-auto-fill)
(c-toggle-hungry-state 1)))
(add-hook 'c++-mode-hook
(lambda ()
(c-set-style "fjellstad-c++-style")
(local-set-key "\M-f" 'c-forward-into-nomenclature)
(local-set-key "\M-b" 'c-backward-into-nomenclature)
(turn-off-auto-fill)
(c-toggle-hungry-state 1)))
;; set calendar format to European
(setq european-calendar-style t)
(setq mail-citation-prefix-regexp "[ ]*[-a-z0-9A-Z]*>+[ ]*\\|[ ]*|[ ]*[-a-z0-9A-Z]*:+[ ]*\\")
(setq diary-file "~/documents/diary")
(load "~/.emacs-records")
;; calendar
;; adding Norwegian holidays
(setq other-holidays
'((holiday-fixed 5 1 "1. mai")
(holiday-fixed 5 17 "Grunnlovsdagen")
(holiday-fixed 12 25 "Første juledag")
(holiday-fixed 12 26 "Andre juledag")))
;; records
;; turning off automatic backup of files
;(add-hook 'records-mode-hooks
; (lambda ()
; (setq backup-inhibited t)))
(put 'upcase-region 'disabled nil)
;; backup
(setq backup-directory-alist '(("" . "~/.emacs.d/auto-backup-list")))
;; diary directory using emacs-planner/emacs-muse
(require 'planner)
(require 'remember-planner)
(require 'muse-journal)
(setq planner-project "Journal")
(setq muse-project-alist
; '(("Journal"
; ("~/Documents/journal" ;; Or wherever you want your planner files to be
; :default "index"
; :major-mode planner-mode
; :visit-link planner-visit-link))))
`(("Journal"
(,@(muse-project-alist-dirs "~/Documents/journal")
:default "index")
,@(muse-project-alist-styles "~/Documents/journal"
"~/Documents/journal-publish"
"journal-xhtml"))))
(setq remember-handler-functions '(remember-planner-append))
(setq remember-annotation-functions planner-annotation-functions)
(setq remember-append-to-planner-hook
'(remember-planner-add-timestamp remember-planner-add-xref))