Difference between pages "Cloud Backup" and "Package:Emacs"

(Difference between pages)
 
(User Configs)
 
Line 1: Line 1:
[[Category:HOWTO]]
+
[[File:emacs-logo.png]]
  
This howto will describe a method for automatically backing up your funtoo install to the internet, in this case dropbox, but any online storage will do. Gentoo describes a method of creating a stage 4 archive. The problem with a stage 4 is that it is large and it archives a lot of unnecessary files. Such as applications that can be reinstalled from an emerge world. Instead, this method will aim for more of a "stage 3.5."
+
Emacs is a famous text editor, famous by its flexibility and extensibility. One manual describes it as "the extensible, customizable, self-documenting, real-time display editor".
  
{{fancynote| This method does not attempt to backup everything. The intention is only to backup the system. Optionally you can also archive and copy your <tt>/home</tt> folder if you have enough online storage.}}
+
This page is designed to give users a good place to share their config and settings for a nice emacs setup.
  
== Use Case ==
+
== Installing emacs ==
A backup machine currently provides network drives on a home LAN to allow clients on the LAN to backup to, using apps such as Time Machine (Mac) and Genie Timeline (Windows). As this machine ''is'' the backup machine it doesn't have anywhere to backup to itself. In this situation a backup solution is provided by backing up to somewhere online - dropbox. If a restore from the backup is required, the client machine's backups would be trashed, and the backup machine restored.
+
To install {{Package|app-editors/emacs}}, run the following command:
 
+
== Automatic Backup Archives With Etckeeper ==
+
Etckeeper is a tool that is used to save versions of <tt>/etc</tt>, including meta-data in a version control repository such as git.
+
As etckeeper is not in the funtoo portage tree, layman is used to provide an overlay.
+
=== Install etckeeper via layman ===
+
Before you install layman it is worth mentioning that you probably want <tt>USE="git subversion"</tt> in <tt>/etc/portage/make.conf</tt>. After adjusting use flags, to install layman you run:
+
 
<console>
 
<console>
###i## emerge layman
+
###i## emerge -av emacs
 +
</console>
 +
for the standard gnu emacs {{Package|app-editors/xemacs}} and
 +
<console>
 +
###i## emerge -av xemacs
 
</console>
 
</console>
In order to backup the layman configuration, but not the portage overlay trees, make the following modifications to the default install.
 
Tell Portage about layman-fetched repositories by adding the following line to <tt>/etc/portage/make.conf</tt>:
 
  
<pre>
+
for the 1980 created fork of emacs, both should handle the same, while emacs on its own stands here for both. If you install additional extensions for both you might need to add <tt>app-emacs</tt> or <tt>app-xemacs</tt> to the package as there are two different versions for both.
source /etc/layman/make.conf
+
 
</pre>
+
== What emacs is and what it is not ==
 +
 
 +
# Emacs is primarily a text editor and not a word processor, it concentrates on manipulating any kind of text, rather than manipulating the font and look. It is client and GUI based, so can be used on local box in graphical environments with a GUI and remote on a server in a client mode.
 +
# Emacs provides commands for manipulate every kind of text and syntax highlighting.
 +
 
 +
=== Customizability ===
 +
 
 +
'''Emacs is highly customizable:'''
 +
 
 +
* the <tt>customize</tt> extension, which allows settings of customized variables, such as color themes, graphical interface, etc. This part is intended for emacs beginners, who do not want to work with Emacs lisp code.
 +
* combine keystrokes to execute complex makros.
 +
* using Emacs Lisp. Designed for the emacs professional.
  
Modify the following lines in <tt>/etc/layman/layman.cfg</tt>:
+
=== Extensibility ===
 +
 
 +
As a result of the above points, Emacs behaviour can be easily definied to all text behavings without limit. Like some of the examples below show you:
 +
 
 +
* AUCTeX, A suite for LaTeX and other TeX versions,
 +
* ERC, A Emacs IRC client,
 +
* ORG-mode, A Emacs PIM and Orga tool
 +
* Wanderlust, A highly flexible Mail tool for Emacs
 +
 
 +
== User Configs ==
 +
=== golodhrim's config ===
 +
==== .emacs ====
 +
Edit the file <tt>~/.emacs</tt>:
  
 
<pre>
 
<pre>
storage  : /var/lib/layman
+
;;;;;;;;;;;;;;;;;;;;;;
installed : /etc/layman/installed.xml
+
;; General Settings ;;
make_conf : /etc/layman/make.conf
+
;;;;;;;;;;;;;;;;;;;;;;
</pre>
+
  
Add the bgo-overlay. As described on their web page, [http://bgo.zugaina.org/ bgo.zugaina.org].
+
(setq emacs-root-dir (concat (getenv "HOME") "/em/"))
<console>
+
###i## layman -o http://gpo.zugaina.org/lst/gpo-repositories.xml -L
+
###i## layman -a bgo-overlay -o http://gpo.zugaina.org/lst/gpo-repositories.xml
+
</console>
+
  
More information about layman can be found here: http://www.gentoo.org/proj/en/overlays/userguide.xml
+
(setq inhibit-startup-message t)    ;; Suppress the startup message
 +
(setq standard-indent 4)            ;; Default indent level is 3 chars
 +
(setq-default indent-tabs-mode nil) ;; Indent with spaces, not tabs
  
Then unmask and install etckeeper.
+
(setq make-backup-files nil)          ;; Enable backup files.
<console>
+
(setq version-control nil)            ;; Enable versioning with default values
###i## emerge etckeeper --autounmask-write
+
(setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/"))))  ;; Save all backup file in this directory.
###i## emerge etckeeper
+
</console>
+
  
{{fancynote| To update layman overlays do:}}
+
(line-number-mode 1)                ;; Show line-number in the mode line
<console>
+
(column-number-mode 1)              ;; Show column-number in the mode line
###i## layman -S
+
</console>
+
  
 +
(setq auto-fill-mode 1)            ;; Line wrap
  
If you see the following error -- apply this fix:
+
(set-default-font "Inconsolata-12")
<console>
+
###i## emerge etckeeper
+
Calculating dependencies... done!
+
>>> Verifying ebuild manifests
+
!!! A file is not listed in the Manifest: '/var/lib/layman/bgo-overlay/sys-apps/etckeeper/files/etckeeper-gentoo-0.58.patch'
+
  
###i## cd /var/lib/layman/bgo-overlay/sys-apps/etckeeper
+
(setq browse-url-browser-function 'browse-url-generic
###i## ebuild etckeeper-0.58-r2.ebuild manifest
+
      browse-url-generic-program "google-chrome")
###i## emerge etckeeper
+
</console>
+
  
== Configure etckeeper ==
+
(global-set-key (kbd "C-<prior>") 'previous-buffer)
Move any config files that do not live in <tt>/etc</tt>. i.e.
+
(global-set-key (kbd "C-<next>" ) 'next-buffer    )
Check <tt>/root</tt> for any files to be archive, such as iptables scripts and move them to <tt>/etc</tt>.
+
  
{{fancynote| because funtoo uses [[Boot-Update]], this means <tt>/boot/grub/grub.cfg</tt> does not need to be archived.}}
 
  
To ensure your portage world file is archived, make the following link:
+
(setq load-path (cons "~/.emacs.d/plugins" load-path))
<console>
+
###i## ln /var/lib/portage/world /etc/world
+
</console>
+
  
Initialise the git repository.
+
(setq global-font-lock-mode 1)
<console>
+
###i## etckeeper init
+
Initialized empty Git repository in /etc/.git/
+
###i## etckeeper commit "Initial commit."
+
</console>
+
  
If you don't already have cron installed, emerge it now.
+
(show-paren-mode 1)
<console>
+
###i## emerge vixie-cron
+
</console>
+
And write the cron job to save an hourly version of <tt>/etc</tt>.
+
  
{{fancynote| git will only create a new version (commit) if there are changes from the previous one.}}
+
;;;;;;;;;;;;;;;;;;
Edit the file <tt>/etc/cron.hourly/etckeeper:
+
;; el-get setup ;;
 +
;;;;;;;;;;;;;;;;;;
 +
(add-to-list 'load-path "~/.emacs.d/el-get/el-get")
 +
(unless (require 'el-get nil t)
 +
  (with-current-buffer
 +
    (url-retrieve-synchronously "https://raw.github.com/golodhrim/el-get/master/el-get-install.el")
 +
  (end-of-buffer)
 +
  (eval-print-last-sexp)))
  
<pre>
+
(el-get 'sync)
#! /bin/bash
+
etckeeper commit "Hourly auto-commit"
+
</pre>
+
  
== Encrypt and copy backups online ==
+
;;;;;;;;;;;;;;;
=== Copy To Dropbox ===
+
;; mediawiki ;;
<console>
+
;;;;;;;;;;;;;;;
###i## emerge dropbox
+
(require 'mediawiki)
</console>
+
  
Add a dropbox user:
+
;;;;;;;;;;;;;;;;;;;;
<console>
+
;; Org-mode stuff ;;
###i## useradd dropbox
+
;;;;;;;;;;;;;;;;;;;;
</console>
+
  
Write the dropbox init files in <tt>/etc/conf.d/dropbox</tt>:
+
;; Tell emacs where org-mode is
 +
;;(setq load-path (cons "/usr/share/emacs/site-lisp/org-mode/" load-path))
 +
;;(setq load-path (cons "/usr/share/emacs/site-lisp/org-mode/contrib/" load-path))
 +
(require 'org-install) ;; Tell emacs to use org-mode
 +
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode)) ;; Turn on org-mode for all *.org files
  
<pre>
+
;; Some key sequences
DROPBOX_USERS="dropbox"  
+
(define-key global-map "\C-cl" 'org-store-link)
</pre>
+
(define-key global-map "\C-ca" 'org-agenda)
<br>
+
(global-set-key [f9]    'org-archive-subtree-default)
<pre>
+
#!/sbin/runscript
+
# Copyright 1999-2004 Gentoo Foundation
+
# Distributed under the terms of the GNU General Public License, v2 or later
+
# $Header: /var/cvsroot/gentoo-x86/sys-fs/dropbox/files/dropbox.init-1.0,v 1.4 2007/04/04 13:35:25 cardoe Exp $
+
  
NICENESS=5
+
(setq org-log-done t) ;; I have no idea what this does, it was in the manual -- think it controls whether or not to log time completed for tasks
  
depend() {
+
(setq org-directory "~/notes")
    need localmount net
+
    after bootmisc
+
}
+
  
start() {
+
;; Files that should be included in agenda views:
    ebegin "Starting dropbox..."  
+
(setq org-agenda-files (list "~/notes/business.org"
    for dbuser in $DROPBOX_USERS; do
+
                            "~/notes/personal.org"
        start-stop-daemon -S -b -m --pidfile /var/run/dropbox-$dbuser.pid  -N $NICENESS -u $dbuser -v -e HOME="/home/$dbuser" -x /opt/dropbox/dropboxd
+
                            "~/notes/projects/"
    done
+
    "~/notes/projects/writing/"))
    eend $?
+
}
+
  
stop() {
+
(setq org-todo-keywords '((type "TODO" "Postponed" "Upcoming" "Doing" "|" "DONE(#)"))) ;; TODO workflows
    ebegin "Stopping dropbox..."  
+
    for dbuser in $DROPBOX_USERS; do
+
        start-stop-daemon --stop --pidfile /var/run/dropbox-$dbuser.pid
+
    done
+
    eend $?
+
}
+
  
status() {
+
(setq org-tag-alist '(("work" . ?k) ("personal" . ?p) ("organization" . ?o) ("writing" . ?w) ("code" . ?c) ("blog" . ?b) ("funtoo" . ?f) ("social" . ?s))) ;; Most-used tags, with shortcuts
    for dbuser in $DROPBOX_USERS; do
+
        if [ -e /var/run/dropbox-$dbuser.pid ] ; then
+
            echo "dropboxd for USER $dbuser: running."  
+
        else
+
            echo "dropboxd for USER $dbuser: not running."  
+
        fi
+
    done
+
    eend $?  
+
}
+
</pre>
+
Start dropbox now and at boot time:
+
<console>
+
###i## chmod 0755 /etc/init.d/dropbox
+
###i## /etc/init.d/dropbox start
+
###i## rc-update add dropbox default
+
</console>
+
  
After starting the dropbox daemon, it will provide a http link. You will need to visit this site just once to associate your computer with your dropbox account.
+
;; Capture stuff
 +
(setq org-default-notes-file "~/.org/capture.org")
 +
(define-key global-map "\C-cc" 'org-capture)
 +
(setq org-refile-targets '((org-agenda-files :level . 1)(org-agenda-files :level . 2)))
 +
(setq org-refile-use-outline-path 'file)
  
Write the cron job to make the backup archive and move it online. Edit the file <tt>/etc/cron.daily/backup</tt>:
+
(setq org-capture-templates
 +
      '(("t" "Todo" entry (file+headline "~/.org/capture.org" "Tasks")
 +
            "- TODO %?\n  %i\n  %a")
 +
        ("j" "Journal" entry (file+datetree "~/.org/journal.org")
 +
            "- %?\nEntered on %U\n  %i\n  %a")))
  
<pre>
+
(setq org-mobile-directory "~/Dropbox/MobileOrg")
#! /bin/bash
+
(setq org-mobile-use-encryption)
cd /etc
+
(setq org-mobile-use-encryption-password "PASSWORD")
git bundle create /tmp/backup.bundle --all
+
(setq org-mobile-inbox-for-pull "~/notes/mobileorg/inbox.org")
cd /tmp
+
mv -v -f backup.bundle /home/dropbox/Dropbox/Private/
+
</pre>
+
  
Make the script executable:
+
;;;;;;;;;;;;;;;;;;;
<console>
+
;; Markdown Mode ;;
###i## chmod +x /etc/cron.daily/backup
+
;;;;;;;;;;;;;;;;;;;
</console>
+
  
=== Encrypt Backups ===
+
(require 'markdown-mode)
It is a good idea to encrypt your backup before moving it online. This can be done with gpg, using a symmetric (password only) or public/private key encryption. Additionally you can chose to sign the backup to check its integrity before restoring.
+
(add-to-list 'auto-mode-alist '("\\.markdown$" . markdown-mode))
<console>
+
(add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
###i## emerge gpg
+
</console>
+
  
==== Symmetric Encryption ====
+
;;;;;;;;;;;;;;;;
There is no preparation required to use a symmetric key as all that is required is simply a passphraseJust modify the cron job. Edit <tt>/etc/cron.daily/backup</tt>:
+
;; Python IDE ;;
 +
;;;;;;;;;;;;;;;;
 +
(c-add-style
 +
  "python-new"
 +
  '((indent-tabs-mode . nil)
 +
    (fill-column      . 78)
 +
    (c-basic-offset  . 4)
 +
    (c-offsets-alist . ((substatement-open . 0)
 +
                          (inextern-lang    . 0)
 +
                          (arglist-intro    . +)
 +
                          (knr-argdecl-intro . +)))
 +
    (c-hanging-braces-alist . ((brace-list-open)
 +
                                (brace-list-intro)
 +
                                (brace-list-close)
 +
                                (brace-entry-open)
 +
                                (substatement-open after)
 +
                                (block-close . c-snug-do-while)))
 +
    (c-block-comment-prefix . "* "))
 +
)
  
<pre>
+
;; This is a very crude hook that auto-selects the C style depending on
#! /bin/bash
+
;; whether it finds a line starting with tab in the first 3000 characters
cd /etc
+
;; in the file
git bundle create /tmp/backup.bundle --all
+
(defun c-select-style ()
cd /tmp
+
  (save-excursion
echo 'encryption_password' | gpg -o backup.gpg --batch --homedir /root/.gnupg -vvv  --passphrase-fd 0 --yes -c backup.bundle
+
    (if (re-search-forward "^\t" 3000 t)
mv -v -f router.gpg /home/dropbox/Dropbox/Private/
+
        (c-set-style "python")
</pre>
+
      (c-set-style "python-new"))))
{{fancyimportant| Remember to change "encryption_password"}}
+
(add-hook 'c-mode-hook 'c-select-style)
  
{{fancywarning| If you forget this password the backup will be unusable. Lose the password and you lose the backup.}}
+
;;;;;;;;;;;;
 +
;; Django ;;
 +
;;;;;;;;;;;;
 +
(yas/initialize)
 +
(add-to-list 'load-path "~/.emacs.d/el-get/django-mode/")
 +
(require 'django-html-mode)
 +
(require 'django-mode)
 +
(yas/load-directory "~/.emacs.d/el-get/django-mode/snippets")
 +
(add-to-list 'auto-mode-alist '("\\.djhtml$" . django-html-mode))
  
As there is now sensitive information in this file, you might want to remove read permission:
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
<console>
+
;; Document Engineering (AUCTeX + ConTeXt) ;;
###i## chmod og-r /etc/cron.daily/backup
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
</console>
+
(load "auctex.el" nil t t)
 +
(load "preview-latex.el" nil t t)
  
==== Private/Public key Encryption ====
+
(setq TeX-auto-save 1)
Make a private/public encryption/decryptions key pair. The public key will be used to encrypt and the private key to decrypt.
+
(setq TeX-parse-self 1)
<console>
+
(setq TeX-auto-untabify 1)
###i## gpg --gen-key
+
(setq TeX-display-help 1)
</console>
+
(setq TeX-save-query nil)
The public key is used to create the encrypted backup and needs to live on the computer being backed up. A copy of the private key needs to be made and stored securely in another place. If this machine becomes unbootable, and this is the only place the private key lives, the backup dies with it.
+
(setq TeX-clean-confirm nil)
The private key should not be kept:
+
(setq-default TeX-master nil)
# In the same place as the back up
+
# On the machine being backed up
+
{{fancynote| The private key is the only key that will decrypt the backup. Lose this key and/or it's password and you lose the backup.}}
+
  
List the private keys:
+
(add-hook 'TeX-mode-hook (lambda () (TeX-fold-mode 1)))
<console>
+
(add-hook 'TeX-mode-hook (lambda () (TeX-source-specials-mode 1)))
###i## gpg -K
+
(add-hook 'TeX-mode-hook (lambda () (TeX-toggle-debug-bad-boxes)))
/root/.gnupg/secring.gpg
+
(add-hook 'TeX-mode-hook (lambda () (TeX-toggle-debug-warnings)))
------------------------
+
(add-hook 'TeX-mode-hook (lambda () (outline-minor-mode)))
sec  2048R/0EF13559 2012-01-21
+
(add-hook 'TeX-mode-hook (lambda () (abbrev-mode t)))
uid                  my_key <noone@example.com>
+
(add-hook 'TeX-mode-hook (lambda () (auto-fill-mode 1)))
ssb  2048R/67417FEB 2012-01-21
+
</console>
+
  
The private key can be exported using either the key name or key number. In this case "my_key" or "0EF13559".
+
(add-hook 'TeX-mode-hook 'LaTeX-math-mode)
To cut and paste the key. Ie, if logging in remotely.
+
<console>
+
###i## gpg -a --export-secret-key 0EF13559
+
</console>
+
  
To create a key file:
+
(autoload 'etexshow "etexshow" "Browser for ConTeXt commands." t)
<console>
+
###i## gpg -o private_decryption.gpgkey --export-secret-key 0EF13559
+
</console>
+
  
Now store this key somewhere secure. The backup is only as secure as the private key.
+
(setq etexshow-xml-files-alist
 +
  `((,(concat emacs-root-dir "libs/etexshow/cont-en.xml") .
 +
      ,(concat "/tmp/cont-en.cache"))))
  
Modify the cron job at <tt>/etc/cron.daily/backup</tt>:
+
(setq etexshow-comment-file
 +
  (concat emacs-root-dir "libs/etexshow/cont-en-comments.xml"))
  
<pre>
+
(setq TeX-PDF-mode 1)
#! /bin/bash
+
(setq revert-without-query '(".+pdf$"))
cd /etc
+
(add-hook 'doc-view-mode-hook 'auto-revert-mode)
git bundle create /tmp/backup.bundle --all
+
cd /tmp
+
gpg -o backup.gpg -r 'my-key' --batch --homedir /root/.gnupg -vvv  --passphrase-fd 0 --yes -e backup.bundle
+
mv -v -f backup.gpg /home/dropbox/Dropbox/Private/
+
</pre>
+
  
Replace "my-key" with the appropriate name from the key list.
+
;;;;;;;;;;
Also note the change from -c for symmetric encryption to -e for private/public key encryption
+
;; bbdb ;;
 +
;;;;;;;;;;
 +
(setq bbdb-file "~/.emacs.d/.bbdb")
 +
(require 'bbdb)
 +
(bbdb-initialize)
 +
(setq
 +
bbdb-offer-save 1                        ;; 1 means save-without-asking
 +
bbdb-use-pop-up t                        ;; allow popups for addresses
 +
bbdb-electric-p t                        ;; be disposable with SPC
 +
bbdb-popup-target-lines 1                ;; very small
 +
bbdb-dwim-net-address-allow-redundancy t  ;; always use full name
 +
bbdb-quiet-about-name-mismatches 2        ;; show name-mismatches 2 secs
 +
bbdb-always-add-address t                ;; add new addresses to existing...
 +
                                          ;; ...contacts automatically
 +
bbdb-canonicalize-redundant-nets-p t      ;; x@foo.bar.cx => x@bar.cx
 +
bbdb-completion-type nil                  ;; complete on anything
 +
bbdb-complete-name-allow-cycling t        ;; cycle through matches
 +
                                          ;; this only works partially
 +
bbdb-message-caching-enabled t            ;; be fast
 +
bbdb-use-alternate-names t                ;; use AKA
 +
bbdb-elided-display t                    ;; single-line addresses
 +
;; auto-create addresses from mail
 +
bbdb/mail-auto-create-p 'bbdb-ignore-some-messages-hook
 +
bbdb-ignore-some-messages-alist          ;; don't ask about fake addresses
 +
;; NOTE: there can be only one entry per header (such as To, From)
 +
;; http://flex.ee.uec.ac.jp/texi/bbdb/bbdb_11.html
 +
'(( "From" . "no.?reply\\|DAEMON\\|daemon\\|facebookmail\\|twitter")))
  
==== Sign Backups ====
+
;;;;;;;;;;;;;;;;;
Create a 2nd private/public (signing) key pair. The private key is used to sign and the public key is used to check the authenticity/integrity.
+
;; Jabber Mode ;;
<console>
+
;;;;;;;;;;;;;;;;;
###i## gpg --gen-key
+
</console>
+
  
{{fancynote| The password for this key will be required in the script below.}}
+
(require 'jabber-autoloads)
In this case the private key is required to sign the backup and the public key is used to check the integrity of the backup.
+
(setq jabber-account-list '(
Follow a similar process as above to copy the public key to to another computer/storage media.
+
                            ("USER@jabber-server.tld"
 +
                            (:password . "PASSWORD")
 +
                            )
 +
                          )
 +
)
 +
(setq
 +
    jabber-history-enabled t
 +
    jabber-use-global-history nil
 +
    jabber-backlog-number 40
 +
    jabber-backlog-days 30
 +
)
  
List the private keys:
+
(add-hook 'jabber-chat-mode-hook 'goto-address)
<console>
+
###i## gpg -k
+
</console>
+
{{fancynote| <tt>-K</tt> lists private keys while <tt>-k</tt> lists public keys.}}
+
  
Then export this public key via cut and paste:
+
(load "~/.emacs.d/plugins/autosmiley.el")
<console>
+
(require 'autosmiley)
###i## gpg -a --export <key name or number>
+
(add-hook 'jabber-chat-mode-hook 'autosmiley-mode)
</console>
+
  
Or to create a key file:
+
(defvar libnotify-program "/usr/bin/notify-send")
<console>
+
###i## gpg -o public_signing.gpgkey --export <key name or number>
+
</console>
+
  
Now store this key somewhere secure.
+
(defun notify-send (title message)
 +
  (start-process "notify" " notify"
 +
                libnotify-program "--expire-time=4000" title message))
  
Modify the backup cron job at <tt>/etc/cron.daily/backup</tt>:
+
(defun libnotify-jabber-notify (from buf text proposed-alert)
 +
  "(jabber.el hook) Notify of new Jabber chat messages via libnotify"
 +
  (when (or jabber-message-alert-same-buffer
 +
                        (not (memq (selected-window) (get-buffer-window-list buf))))
 +
    (if (jabber-muc-sender-p from)
 +
        (notify-send (format "(PM) %s"
 +
                            (jabber-jid-displayname (jabber-jid-user from)))
 +
                    (format "%s: %s" (jabber-jid-resource from) text)))
 +
    (notify-send (format "%s" (jabber-jid-displayname from))
 +
                text)))
  
<pre>
+
(add-hook 'jabber-alert-message-hooks 'libnotify-jabber-notify)
#! /bin/bash
+
cd /etc
+
git bundle create /tmp/backup.bundle --all
+
cd /tmp
+
echo 'signing_key_password' | gpg -s -o backup.gpg -r 'my-encryption-key' --batch --homedir /root/.gnupg -vvv  --passphrase-fd 0 --yes -e backup.bundle
+
mv -v -f backup.gpg /home/dropbox/Dropbox/Private/
+
</pre>
+
  
{{fancynote| the script will require the password for your private (signing) key to sign the backup. Replace "password" with the password for your signing private key.
+
(defun jabber-visit-history (jid)
And as there is sensitive information in this file don't forget to remove read permission.}}
+
  "Visit jabber history with JID in a new buffer.
<console>
+
###i## chmod og-r /etc/cron.daily/backup
+
</console>
+
  
== To Restore From A Backup ==
+
Performs well only for small files. Expect to wait a few seconds
This restore will assume your are starting with a new blank disk.
+
for large histories. Adapted from `jabber-chat-create-buffer'."
Start by performing a stage 3 install, upto and including section 5 "Chroot into your new system." http://www.funtoo.org/wiki/Funtoo_Linux_Installation
+
  (interactive (list (jabber-read-jid-completing "JID: ")))
 +
  (let ((buffer (generate-new-buffer (format "*-jabber-history-%s-*"
 +
                                            (jabber-jid-displayname jid)))))
 +
    (switch-to-buffer buffer)
 +
    (make-local-variable 'jabber-chat-ewoc)
 +
    (setq jabber-chat-ewoc (ewoc-create #'jabber-chat-pp))
 +
    (mapc 'jabber-chat-insert-backlog-entry
 +
          (nreverse (jabber-history-query nil nil t t "."
 +
                                          (jabber-history-filename jid))))
 +
    (view-mode)))
  
Then the restore process is:
+
;;;;;;;;;;
# Download backup from dropbox
+
;; EMMS ;;
# Decrypt
+
;;;;;;;;;;
# Clone
+
(require 'emms-setup)
# Link world file
+
(emms-devel)
# Emerge world
+
(emms-default-players)
# Compile the kernel
+
# Restore grub bootloader
+
# Reboot
+
  
== Download backup from dropbox ==
+
;;;;;;;;;
Log into your dropbox account and find your backup file. Move it to a public area if it isn't already in one. Then right click on it and click "copy public link."
+
;; ERC ;;
Now on the computer to be restored, delete the contents of the /etc folder and download the backup file.
+
;;;;;;;;;
 +
(require 'erc)
 +
(require 'erc-extension)
 +
(require 'erc-services)
 +
(require 'erc-tex)
 +
(require 'tls)
 +
(require 'erc-nicklist)
  
(Need to check if this needs done before chrooting into the new install).
+
(and
<console>
+
(require 'erc-highlight-nicknames)
###i## cd /etc
+
(add-to-list 'erc-modules 'highlight-nicknames)
###i## rm -rf *
+
(erc-update-modules))
###i## cd /tmp
+
###i## wget http://dl.dropbox.com/link-to-backup-file/backup.gpg
+
</console>
+
  
{{fancynote| if you have to copy the link from another computer and therefore can not cut and paste it, there is a "shorten link" option.}}
+
(erc-services-mode 1)
  
== Decrypt ==
+
(setq tls-program '("openssl s_client -connect %h:%p -no_ssl2 -ign_eof
If you used a public/private key to encrypt, and optionally signed the backup, import the decryption and signing keys.
+
                            -CAfile /home/USER/.ssl/USER.pem
 +
                            -cert /home/USER/.ssl/USER.pem"
 +
                    "gnutls-cli --priority secure256
 +
                                --x509cafile /home/USER/.ssl/USER.pem
 +
                                --x509certfile /home/USER/.ssl/USER.pem -p %p %h"
 +
                    "gnutls-cli --priority secure256 -p %p %h"))
  
Note:
+
(autoload 'erc-nick-notify-mode "erc-nick-notify" "Minor mode that calls `erc-nick-notify-cmd' when his nick gets mentioned in an erc channel" t)
# The decryption key is the private key of the encryption key pair - private_decryption.gpgkey
+
(eval-after-load 'erc '(erc-nick-notify-mode t))
# The signing key is the public key of the signing key pair - public_signing.gpgkey
+
(defun irc-erc ()
 +
  "Fire up IRC."
 +
  (interactive)
 +
  (erc-tls :server "chat.freenode.net" :port 7000 :nick "USER" :full-name "FULL NAME" :password "PASSWORD"))
  
To import the keys by cut and paste:
+
(setq erc-autojoin-channels-alist '(("freenode.net" "#frogandowl" "#funtoo" "#funtoo-quebec" "#syntazia" "#context" "#nginx" "#emacs" "#openvswitch")))
<console>
+
(setq erc-log-channels-directory "~/.erc/logs/")
###i## gpg --import <<EOF
+
(setq erc-log-insert-log-on-open nil)
</console>
+
(setq erc-save-buffer-on-part nil
{{fancynote| The last line after pasting the key should be "EOF"}}
+
      erc-save-buffer-queries-on-quit nil
Repeat for both keys.
+
      erc-log-write-after-send t
 +
      erc-log-write-after-insert t)
  
To import the keys by file:
+
(require 'smiley)
<console>
+
    (add-to-list 'smiley-regexp-alist '("\\(:-?]\\)\\W" 1 "forced"))
###i## gpg --import private_decryption.gpgkey
+
    (add-to-list 'smiley-regexp-alist '("\\s-\\(:-?/\\)\\W" 1 "wry"))
###i## gpg --import public_signing.gpgkey
+
    (add-to-list 'smiley-regexp-alist '("\\(:-?(\\)\\W" 1 "sad"))
</console>
+
    (add-to-list 'smiley-regexp-alist '("\\((-?:\\)\\W" 1 "reverse-smile"))
 +
    (add-to-list 'smiley-regexp-alist '("\\(:-?D\\)\\W" 1 "grin"))
 +
    (add-to-list 'smiley-regexp-alist '("\\(:-?P\\)\\W" 1 "poke"))
  
Decrypt the backup:
+
;; (setq smiley-cached-regexp-alist nil)
<console>
+
;; (smiley-update-cache)
###i## gpg -d backup.gpg > backup.bundle
+
</console>
+
  
If the backup was signed and you have correctly imported the signing public key you should see a message similar to:
+
;;;;;;;;;;;;;;;;
<console>
+
;; Wanderlust ;;
gpg: Good signature from "my_signing_key <noone@example.com>"
+
;;;;;;;;;;;;;;;;
</console>
+
(autoload 'wl "wl" "Wanderlust" t)
  
== Clone ==
+
;;;;;;;;;;;;;;;
<console>
+
;; mailcrypt ;;
###i## git clone /tmp/backup.bundle /etc/
+
;;;;;;;;;;;;;;;
</console>
+
(require 'mailcrypt)
 +
(add-hook 'wl-summary-mode-hook 'mc-install-read-mode)
 +
(add-hook 'wl-mail-setup-hook 'mc-install-write-mode)
  
== Link world file ==
+
(defun mc-wl-verify-signature ()
<console>
+
  (interactive)
###i## ln /etc/world /var/lib/portage/world
+
  (save-window-excursion
</console>
+
    (wl-summary-jump-to-current-message)
 +
    (mc-verify)))
  
== Emerge world ==
+
(defun mc-wl-decrypt-message ()
<console>
+
  (interactive)
###i## emerge --sync
+
  (save-window-excursion
###i## layman -S
+
    (wl-summary-jump-to-current-message)
###i## emerge -uDaNv world
+
    (let ((inhibit-read-only t))
</console>
+
      (mc-decrypt))))
  
== Compile the kernel (genkernel)==
+
(eval-after-load "mailcrypt"
If you have genkernel set to save config files (the default):
+
  '(setq mc-modes-alist
<console>
+
        (append
###i## cp /etc/kernels/kernel-config-x86_64-<latest version>-gentoo /usr/src/linux/.config
+
          (quote
</console>
+
          ((wl-draft-mode (encrypt . mc-encrypt-message)
 +
                          (sign . mc-sign-message))
 +
            (wl-summary-mode (decrypt . mc-wl-decrypt-message)
 +
                            (verify . mc-wl-verify-signature))))
 +
          mc-modes-alist)))
  
Otherwise use the currently loaded kernel's config:
+
;;;;;;;;;;;;;;;;;;;;;
<console>
+
;; notify function ;;
###i## zcat /proc/config.gz > /usr/src/linux/.config
+
;;;;;;;;;;;;;;;;;;;;;
</console>
+
(defun djcb-popup (title msg &optional icon sound)
 +
  "Show a popup if we're on X, or echo it otherwise; TITLE is the title of the message, MSG is the context. Optionally, you can provide an ICON and a sound to be played"
 +
  (interactive)
 +
  (when sound (shell-command
 +
              (concat "mplayer2 -really-quiet " sound " 2> /dev/null")))
 +
  (if (eq window-system 'x)
 +
      (shell-command (concat "notify-send "
 +
                           
 +
                            (if icon (concat "-i " icon) "")
 +
                            " '" title "' '" msg "'"))
 +
    ;; text only version
 +
    (message (concat title ": " msg))))
 +
 
 +
;; the appointment notification facility
 +
(setq
 +
appt-message-warning-time 15 ;; warn 15 min in advance
 +
appt-display-mode-line t    ;; show in the modeline
 +
appt-display-format 'window) ;; usr our func
 +
(appt-activate t)            ;; active appt (appointment notification)
 +
(display-time)
  
Then compile the kernel:
+
;; update appt each time agenda opened
 +
(add-hook 'org-finalize-agenda-hook 'org-agenda-to-appt)
 +
 
 +
;; our little facade-function for djcb-popup
 +
(defun djcb-appt-display (min-to-app new-time msg)
 +
  (djcb-popup (format "Appointment in %s minute(s)" min-to-app) msg
 +
              "/usr/share/icons/gnome/32x32/status/appointment-soon.png"
 +
              "/usr/share/sounds/purple/alert.wav"))
 +
(setq appt-disp-window-function (function djcb-appt-display))
 +
 
 +
;;;;;;;;;;;;;;;;;;;;;;;;;;
 +
;; Custom Variable sets ;;
 +
;;;;;;;;;;;;;;;;;;;;;;;;;;
 +
(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.
 +
'(TeX-command-list (quote (("TeX" "%(PDF)%(tex) %`%S%(PDFout)%(mode)%' %t" TeX-run-TeX nil (plain-tex-mode texinfo-mode ams-tex-mode) :help "Run plain TeX") ("LaTeX" "%`%l%(mode)%' %t" TeX-run-TeX nil (latex-mode doctex-mode) :help "Run LaTeX") ("Makeinfo" "makeinfo %t" TeX-run-compile nil (texinfo-mode) :help "Run Makeinfo with Info output") ("Makeinfo HTML" "makeinfo --html %t" TeX-run-compile nil (texinfo-mode) :help "Run Makeinfo with HTML output") ("AmSTeX" "%(PDF)amstex %`%S%(PDFout)%(mode)%' %t" TeX-run-TeX nil (ams-tex-mode) :help "Run AMSTeX") ("ConTeXt MKIV" "context %t" TeX-run-TeX nil (context-mode) :help "Run ConTeXt MKIV") ("ConTeXt" "texexec --once --texutil %(execopts)%t" TeX-run-TeX nil (context-mode) :help "Run ConTeXt once") ("ConTeXt Full" "texexec %(execopts)%t" TeX-run-TeX nil (context-mode) :help "Run ConTeXt until completion") ("BibTeX" "bibtex %s" TeX-run-BibTeX nil t :help "Run BibTeX") ("View" "%V" TeX-run-discard-or-function t t :help "Run Viewer") ("Print" "%p" TeX-run-command t t :help "Print the file") ("Queue" "%q" TeX-run-background nil t :help "View the printer queue" :visible TeX-queue-command) ("File" "%(o?)dvips %d -o %f " TeX-run-command t t :help "Generate PostScript file") ("Index" "makeindex %s" TeX-run-command nil t :help "Create index file") ("Check" "lacheck %s" TeX-run-compile nil (latex-mode) :help "Check LaTeX file for correctness") ("Spell" "(TeX-ispell-document \"\")" TeX-run-function nil t :help "Spell-check the document") ("Clean" "TeX-clean" TeX-run-function nil t :help "Delete generated intermediate files") ("Clean All" "(TeX-clean t)" TeX-run-function nil t :help "Delete generated intermediate and output files") ("Other" "" TeX-run-command t t :help "Run an arbitrary command"))))
 +
'(column-number-mode t)
 +
'(erc-modules (quote (autojoin bbdb button completion fill irccontrols list log match menu move-to-prompt netsplit networks noncommands readonly ring services smiley stamp spelling track)))
 +
'(mediawiki-site-alist (quote (("Funtoo" "http://www.funtoo.org/" "USER" "PASSWORD" "")))))
 +
(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.
 +
)
 +
 
 +
;;;;;;;;;;;;;;;;;;
 +
;; Color-Themes ;;
 +
;;;;;;;;;;;;;;;;;;
 +
;;(add-to-list 'load-path "/usr/share/emacs/site-lisp/color-theme/color-theme.el")
 +
;;(add-to-list 'load-path "~/.emacs.d/themes/")
 +
(require 'color-theme)
 +
(color-theme-initialize)
 +
;;(color-theme-subtle-hacker)
 +
(color-theme-twilight)
 +
;;(eval-after-load "color-theme"
 +
;;  '(progn
 +
;;    (color-theme-initialize)
 +
;;    (require 'color-theme-citrus)
 +
;;    (require 'color-theme-candy)
 +
;;    (require 'color-theme-autumn-leaves)
 +
;;    (require 'color-theme-inthedark)
 +
;;    (require 'color-theme-marine)
 +
;;    (require 'color-theme-october)
 +
;;    (require 'color-theme-eatyourgreens)
 +
;;    (require 'color-theme-august)
 +
;;    (require 'color-theme-saddle-2)
 +
;;    (color-theme-saddle-2)))
 +
;;    (color-theme-subtle-hacker)))
 +
 
 +
(setq css-indent-offset 2)
 +
</pre>
 +
 
 +
==== .wl ====
 
<console>
 
<console>
###i## genkernel --oldconfig --no-mrproper all
+
###i## nano ~/.wl
</console>
+
;; load bbdb support
 +
(require 'bbdb-wl)
 +
(bbdb-wl-setup)
 +
 
 +
;; setup from where to get addresses
 +
(setq bbdb-wl-folder-regexp "^\.INBOX|^\.inbox|^\.Sent|^\.sent|^\.\[IMAPS\]\\Sent")
 +
 
 +
;; define keybinding
 +
(define-key wl-draft-mode-map (kbd "<C-tab>") 'bbdb-complete-name)
 +
 
 +
;; set multiple e-mail addresses
 +
(setq wl-user-mail-address-list (quote ("User@googlemail.com" "USER@own-server.tld")))
 +
 
 +
;; handle ("d") mark
 +
;; remove = instant removal (same as "D"), thrash = move to wl-trash-folder
 +
;; string = move to string
 +
(setq wl-dispose-folder-alist
 +
      '(
 +
        ("\.\*googlemail\\.com" "%[Imap]/Trash:"User@googlemail.com"/clear@imap.gmail.com:993!")
 +
        ("\.\*@own\-\server\\.tld" "%INBOX.Trash:"USER"/clear@imap.own-server.tld")
 +
))
 +
 
 +
;; notify hook
 +
(add-hook 'wl-biff-notify-hook
 +
          (lambda()
 +
            (djcb-popup "Wanderlust" "You have new mail!"
 +
                        "/usr/share/icons/gnome/32x32/status/mail-unread.png"
 +
                        "/usr/share/sounds/purple/alert.wav")))
 +
 
 +
;; timer settings
 +
(setq
 +
wl-biff-check-interval 30 ;; check every 30 seconds
 +
wl-biff-use-idle-timer t) ;; in the background
  
== Restore grub bootloader ==
+
;; Name of top-folder, default "Desktop"
<console>
+
(setq wl-folder-desktop-name "e-Mail")
###i## grub-install --no-floppy /dev/sda
+
###i## boot-update
+
</console>
+
  
Adjust the device as required if installing to another location.
+
;; select correct email address when we _start_ writing a draft.
 +
(add-hook 'wl-mail-setup-hook 'wl-draft-config-exec)
  
== Reboot ==
+
(setq wl-draft-config-alist
 +
      '(
 +
        ((string-match "googlemail.com" wl-draft-parent-folder)
 +
        (template . "User"))
 +
        ((string-match "own-server.tld" wl-draft-parent-folder)
 +
        (template . "USER"))
 +
))
 +
 
 +
;; choose template with C-c C-j
 +
(setq wl-template-alist
 +
      '(("User"
 +
        (wl-from . "Full Name <User@googlemail.com>")
 +
        ("From" . wl-from)
 +
        (wl-smtp-posting-user . "User")
 +
        (wl-smtp-posting-server . "smtp.gmail.com")
 +
        (wl-smtp-authenticate-type . "plain")
 +
        (wl-smtp-connection-type . 'starttls)
 +
        (wl-smtp-posting-port . 587)
 +
        (wl-local-domain . "googlemail.com")
 +
        (wl-message-id-domain . "smtp.gmail.com")
 +
       
 +
        (wl-fcc .  "%[IMAPS]/Sent:\"User@googlemail.com\"/clear@imap.gmail.com:993!")
 +
        (wl-draft-folder .  "%[IMAPS]/Draft:\"User@googlemail.com\"/clear@imap.gmail.com:993!")
 +
        )
 +
        ("USER"
 +
        (wl-from  . "Full Name <USER@own-server.tld>")
 +
        ("From"  . wl-from)
 +
        (wl-smtp-posting-user  . "USER")
 +
        (wl-smtp-posting-server  . "smtp.own-server.tld")
 +
        (wl-local-domain . "own-server.tld")
 +
       
 +
        (wl-fcc  "%INBOX.Sent:USER/digest-md5@imap.own-server.tld:143")
 +
        (wl-draft-folder  "%INBOX.Drafts:USER/digest-md5@imap.own-server.tld:143")
 +
        )
 +
      )
 +
)
 +
 
 +
(define-key wl-template-mode-map (kbd "<right>") 'wl-template-next)
 +
(define-key wl-template-mode-map (kbd "<left>") 'wl-template-prev)
 +
 
 +
(setq wl-default-spec "%")
 +
 
 +
(setq wl-fcc-force-as-read t)
 +
(setq wl-auto-save-drafts-interval nil)
 +
</console>
 +
 
 +
==== .folders ====
 
<console>
 
<console>
###i## reboot
+
###i## nano ~/.folders
 +
User@googlemail{
 +
        %INBOX:"User@googlemail.com"/clear@imap.gmail.com:993!    "Inbox"
 +
        [IMAPS-gmail]{
 +
                %[IMAPS]/Sent:"User@googlemail.com"/clear@imap.gmail.com:993!      "Sent"
 +
                %[IMAPS]/Draft:"User@googlemail.com"/clear@imap.gmail.com:993!      "Draft"
 +
                %[IMAPS]/Spam:"User@googlemail.com"/clear@imap.gmail.com:993!      "Spam"
 +
                %[IMAPS]/Trash:"User@googlemail.com"/clear@imap.gmail.com:993!      "Trash"
 +
        }
 +
}
 +
USER@own-server.tld{
 +
        %INBOX:USER/digest-md5@imap.own-server.tld  "Inbox"
 +
        %INBOX.Sent:USER/digest-md5@imap.own-server.tld "Sent"
 +
        %INBOX.Drafts:USER/digest-md5@imap.own-server.tld "Drafts"
 +
}
 
</console>
 
</console>
  
[[Category:First Steps]]
+
[[Category:HOWTO]]
 +
[[Category:Featured]]

Revision as of 17:34, February 22, 2014

Emacs-logo.png

Emacs is a famous text editor, famous by its flexibility and extensibility. One manual describes it as "the extensible, customizable, self-documenting, real-time display editor".

This page is designed to give users a good place to share their config and settings for a nice emacs setup.

Installing emacs

To install app-editors/emacs (package not on wiki - please add), run the following command:

# emerge -av emacs

for the standard gnu emacs app-editors/xemacs (package not on wiki - please add) and

# emerge -av xemacs

for the 1980 created fork of emacs, both should handle the same, while emacs on its own stands here for both. If you install additional extensions for both you might need to add app-emacs or app-xemacs to the package as there are two different versions for both.

What emacs is and what it is not

  1. Emacs is primarily a text editor and not a word processor, it concentrates on manipulating any kind of text, rather than manipulating the font and look. It is client and GUI based, so can be used on local box in graphical environments with a GUI and remote on a server in a client mode.
  2. Emacs provides commands for manipulate every kind of text and syntax highlighting.

Customizability

Emacs is highly customizable:

  • the customize extension, which allows settings of customized variables, such as color themes, graphical interface, etc. This part is intended for emacs beginners, who do not want to work with Emacs lisp code.
  • combine keystrokes to execute complex makros.
  • using Emacs Lisp. Designed for the emacs professional.

Extensibility

As a result of the above points, Emacs behaviour can be easily definied to all text behavings without limit. Like some of the examples below show you:

  • AUCTeX, A suite for LaTeX and other TeX versions,
  • ERC, A Emacs IRC client,
  • ORG-mode, A Emacs PIM and Orga tool
  • Wanderlust, A highly flexible Mail tool for Emacs

User Configs

golodhrim's config

.emacs

Edit the file ~/.emacs:

;;;;;;;;;;;;;;;;;;;;;;
;; General Settings ;;
;;;;;;;;;;;;;;;;;;;;;;

(setq emacs-root-dir (concat (getenv "HOME") "/em/"))

(setq inhibit-startup-message t)    ;; Suppress the startup message
(setq standard-indent 4)            ;; Default indent level is 3 chars
(setq-default indent-tabs-mode nil) ;; Indent with spaces, not tabs

(setq make-backup-files nil)          ;; Enable backup files.
(setq version-control nil)            ;; Enable versioning with default values
(setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/"))))  ;; Save all backup file in this directory.

(line-number-mode 1)                ;; Show line-number in the mode line
(column-number-mode 1)              ;; Show column-number in the mode line

(setq auto-fill-mode 1)             ;; Line wrap

(set-default-font "Inconsolata-12")

(setq browse-url-browser-function 'browse-url-generic
      browse-url-generic-program "google-chrome")

(global-set-key (kbd "C-<prior>") 'previous-buffer)
(global-set-key (kbd "C-<next>" ) 'next-buffer    )


(setq load-path (cons "~/.emacs.d/plugins" load-path))

(setq global-font-lock-mode 1)

(show-paren-mode 1)

;;;;;;;;;;;;;;;;;;
;; el-get setup ;;
;;;;;;;;;;;;;;;;;;
(add-to-list 'load-path "~/.emacs.d/el-get/el-get") 
(unless (require 'el-get nil t) 
  (with-current-buffer 
    (url-retrieve-synchronously "https://raw.github.com/golodhrim/el-get/master/el-get-install.el") 
  (end-of-buffer) 
  (eval-print-last-sexp)))

(el-get 'sync)

;;;;;;;;;;;;;;;
;; mediawiki ;;
;;;;;;;;;;;;;;;
(require 'mediawiki)

;;;;;;;;;;;;;;;;;;;;
;; Org-mode stuff ;;
;;;;;;;;;;;;;;;;;;;;

;; Tell emacs where org-mode is
;;(setq load-path (cons "/usr/share/emacs/site-lisp/org-mode/" load-path))
;;(setq load-path (cons "/usr/share/emacs/site-lisp/org-mode/contrib/" load-path))
(require 'org-install) ;; Tell emacs to use org-mode
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode)) ;; Turn on org-mode for all *.org files

;; Some key sequences
(define-key global-map "\C-cl" 'org-store-link) 
(define-key global-map "\C-ca" 'org-agenda)
(global-set-key [f9]    'org-archive-subtree-default)

(setq org-log-done t) ;; I have no idea what this does, it was in the manual -- think it controls whether or not to log time completed for tasks

(setq org-directory "~/notes")

;; Files that should be included in agenda views:
(setq org-agenda-files (list "~/notes/business.org"
                             "~/notes/personal.org" 
                             "~/notes/projects/"
			     "~/notes/projects/writing/"))

(setq org-todo-keywords '((type "TODO" "Postponed" "Upcoming" "Doing" "|" "DONE(#)"))) ;; TODO workflows

(setq org-tag-alist '(("work" . ?k) ("personal" . ?p) ("organization" . ?o) ("writing" . ?w) ("code" . ?c) ("blog" . ?b) ("funtoo" . ?f) ("social" . ?s))) ;; Most-used tags, with shortcuts

;; Capture stuff
(setq org-default-notes-file "~/.org/capture.org")
(define-key global-map "\C-cc" 'org-capture)
(setq org-refile-targets '((org-agenda-files :level . 1)(org-agenda-files :level . 2)))
(setq org-refile-use-outline-path 'file)

(setq org-capture-templates
      '(("t" "Todo" entry (file+headline "~/.org/capture.org" "Tasks")
             "- TODO %?\n  %i\n  %a")
        ("j" "Journal" entry (file+datetree "~/.org/journal.org")
             "- %?\nEntered on %U\n  %i\n  %a")))

(setq org-mobile-directory "~/Dropbox/MobileOrg")
(setq org-mobile-use-encryption)
(setq org-mobile-use-encryption-password "PASSWORD")
(setq org-mobile-inbox-for-pull "~/notes/mobileorg/inbox.org")

;;;;;;;;;;;;;;;;;;;
;; Markdown Mode ;;
;;;;;;;;;;;;;;;;;;;

(require 'markdown-mode)
(add-to-list 'auto-mode-alist '("\\.markdown$" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))

;;;;;;;;;;;;;;;;
;; Python IDE ;;
;;;;;;;;;;;;;;;;
(c-add-style
   "python-new"
   '((indent-tabs-mode . nil)
     (fill-column      . 78)
     (c-basic-offset   . 4)
     (c-offsets-alist  . ((substatement-open . 0)
                          (inextern-lang     . 0)
                          (arglist-intro     . +)
                          (knr-argdecl-intro . +)))
     (c-hanging-braces-alist . ((brace-list-open)
                                (brace-list-intro)
                                (brace-list-close)
                                (brace-entry-open)
                                (substatement-open after)
                                (block-close . c-snug-do-while)))
     (c-block-comment-prefix . "* "))
)

;; This is a very crude hook that auto-selects the C style depending on
;; whether it finds a line starting with tab in the first 3000 characters
;; in the file
(defun c-select-style ()
   (save-excursion
     (if (re-search-forward "^\t" 3000 t)
         (c-set-style "python")
       (c-set-style "python-new"))))
(add-hook 'c-mode-hook 'c-select-style)

;;;;;;;;;;;;
;; Django ;;
;;;;;;;;;;;;
(yas/initialize)
(add-to-list 'load-path "~/.emacs.d/el-get/django-mode/")
(require 'django-html-mode)
(require 'django-mode)
(yas/load-directory "~/.emacs.d/el-get/django-mode/snippets")
(add-to-list 'auto-mode-alist '("\\.djhtml$" . django-html-mode))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Document Engineering (AUCTeX + ConTeXt) ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)

(setq TeX-auto-save 1)
(setq TeX-parse-self 1)
(setq TeX-auto-untabify 1)
(setq TeX-display-help 1)
(setq TeX-save-query nil)
(setq TeX-clean-confirm nil)
(setq-default TeX-master nil)

(add-hook 'TeX-mode-hook (lambda () (TeX-fold-mode 1)))
(add-hook 'TeX-mode-hook (lambda () (TeX-source-specials-mode 1)))
(add-hook 'TeX-mode-hook (lambda () (TeX-toggle-debug-bad-boxes)))
(add-hook 'TeX-mode-hook (lambda () (TeX-toggle-debug-warnings)))
(add-hook 'TeX-mode-hook (lambda () (outline-minor-mode)))
(add-hook 'TeX-mode-hook (lambda () (abbrev-mode t)))
(add-hook 'TeX-mode-hook (lambda () (auto-fill-mode 1)))

(add-hook 'TeX-mode-hook 'LaTeX-math-mode)

(autoload 'etexshow "etexshow" "Browser for ConTeXt commands." t)

(setq etexshow-xml-files-alist
   `((,(concat emacs-root-dir "libs/etexshow/cont-en.xml") .
      ,(concat "/tmp/cont-en.cache"))))

(setq etexshow-comment-file
   (concat emacs-root-dir "libs/etexshow/cont-en-comments.xml"))

(setq TeX-PDF-mode 1)
(setq revert-without-query '(".+pdf$"))
(add-hook 'doc-view-mode-hook 'auto-revert-mode)

;;;;;;;;;;
;; bbdb ;;
;;;;;;;;;;
(setq bbdb-file "~/.emacs.d/.bbdb")
(require 'bbdb)
(bbdb-initialize)
(setq
 bbdb-offer-save 1                         ;; 1 means save-without-asking
 bbdb-use-pop-up t                         ;; allow popups for addresses
 bbdb-electric-p t                         ;; be disposable with SPC
 bbdb-popup-target-lines 1                 ;; very small
 bbdb-dwim-net-address-allow-redundancy t  ;; always use full name
 bbdb-quiet-about-name-mismatches 2        ;; show name-mismatches 2 secs
 bbdb-always-add-address t                 ;; add new addresses to existing...
                                           ;; ...contacts automatically
 bbdb-canonicalize-redundant-nets-p t      ;; x@foo.bar.cx => x@bar.cx
 bbdb-completion-type nil                  ;; complete on anything
 bbdb-complete-name-allow-cycling t        ;; cycle through matches
                                           ;; this only works partially
 bbdb-message-caching-enabled t            ;; be fast
 bbdb-use-alternate-names t                ;; use AKA
 bbdb-elided-display t                     ;; single-line addresses
 ;; auto-create addresses from mail
 bbdb/mail-auto-create-p 'bbdb-ignore-some-messages-hook
 bbdb-ignore-some-messages-alist           ;; don't ask about fake addresses
 ;; NOTE: there can be only one entry per header (such as To, From)
 ;; http://flex.ee.uec.ac.jp/texi/bbdb/bbdb_11.html
 '(( "From" . "no.?reply\\|DAEMON\\|daemon\\|facebookmail\\|twitter")))

;;;;;;;;;;;;;;;;;
;; Jabber Mode ;;
;;;;;;;;;;;;;;;;;

(require 'jabber-autoloads)
(setq jabber-account-list '(
                            ("USER@jabber-server.tld"
                            (:password . "PASSWORD")
                            )
                           )
)
(setq
    jabber-history-enabled t
    jabber-use-global-history nil
    jabber-backlog-number 40
    jabber-backlog-days 30
)

(add-hook 'jabber-chat-mode-hook 'goto-address)

(load "~/.emacs.d/plugins/autosmiley.el")
(require 'autosmiley)
(add-hook 'jabber-chat-mode-hook 'autosmiley-mode)

(defvar libnotify-program "/usr/bin/notify-send")

(defun notify-send (title message)
  (start-process "notify" " notify"
                 libnotify-program "--expire-time=4000" title message))

(defun libnotify-jabber-notify (from buf text proposed-alert)
  "(jabber.el hook) Notify of new Jabber chat messages via libnotify"
  (when (or jabber-message-alert-same-buffer
                        (not (memq (selected-window) (get-buffer-window-list buf))))
    (if (jabber-muc-sender-p from)
        (notify-send (format "(PM) %s"
                             (jabber-jid-displayname (jabber-jid-user from)))
                     (format "%s: %s" (jabber-jid-resource from) text)))
    (notify-send (format "%s" (jabber-jid-displayname from))
                 text)))

(add-hook 'jabber-alert-message-hooks 'libnotify-jabber-notify)

(defun jabber-visit-history (jid)
  "Visit jabber history with JID in a new buffer.

Performs well only for small files. Expect to wait a few seconds
for large histories. Adapted from `jabber-chat-create-buffer'."
  (interactive (list (jabber-read-jid-completing "JID: ")))
  (let ((buffer (generate-new-buffer (format "*-jabber-history-%s-*"
                                             (jabber-jid-displayname jid)))))
    (switch-to-buffer buffer)
    (make-local-variable 'jabber-chat-ewoc)
    (setq jabber-chat-ewoc (ewoc-create #'jabber-chat-pp))
    (mapc 'jabber-chat-insert-backlog-entry
          (nreverse (jabber-history-query nil nil t t "."
                                          (jabber-history-filename jid))))
    (view-mode)))

;;;;;;;;;;
;; EMMS ;;
;;;;;;;;;;
(require 'emms-setup)
(emms-devel)
(emms-default-players)

;;;;;;;;;
;; ERC ;;
;;;;;;;;;
(require 'erc)
(require 'erc-extension)
(require 'erc-services)
(require 'erc-tex)
(require 'tls)
(require 'erc-nicklist)

(and
 (require 'erc-highlight-nicknames)
 (add-to-list 'erc-modules 'highlight-nicknames)
 (erc-update-modules))

(erc-services-mode 1)

(setq tls-program '("openssl s_client -connect %h:%p -no_ssl2 -ign_eof
                            -CAfile /home/USER/.ssl/USER.pem 
                            -cert /home/USER/.ssl/USER.pem"
                    "gnutls-cli --priority secure256
                                --x509cafile /home/USER/.ssl/USER.pem 
                                --x509certfile /home/USER/.ssl/USER.pem -p %p %h"
                    "gnutls-cli --priority secure256 -p %p %h"))

(autoload 'erc-nick-notify-mode "erc-nick-notify" "Minor mode that calls `erc-nick-notify-cmd' when his nick gets mentioned in an erc channel" t)
(eval-after-load 'erc '(erc-nick-notify-mode t))
(defun irc-erc ()
  "Fire up IRC."
  (interactive)
  (erc-tls :server "chat.freenode.net" :port 7000 :nick "USER" :full-name "FULL NAME" :password "PASSWORD"))

(setq erc-autojoin-channels-alist '(("freenode.net" "#frogandowl" "#funtoo" "#funtoo-quebec" "#syntazia" "#context" "#nginx" "#emacs" "#openvswitch")))
(setq erc-log-channels-directory "~/.erc/logs/")
(setq erc-log-insert-log-on-open nil)
(setq erc-save-buffer-on-part nil
      erc-save-buffer-queries-on-quit nil
      erc-log-write-after-send t
      erc-log-write-after-insert t)

(require 'smiley)
    (add-to-list 'smiley-regexp-alist '("\\(:-?]\\)\\W" 1 "forced"))
    (add-to-list 'smiley-regexp-alist '("\\s-\\(:-?/\\)\\W" 1 "wry"))
    (add-to-list 'smiley-regexp-alist '("\\(:-?(\\)\\W" 1 "sad"))
    (add-to-list 'smiley-regexp-alist '("\\((-?:\\)\\W" 1 "reverse-smile"))
    (add-to-list 'smiley-regexp-alist '("\\(:-?D\\)\\W" 1 "grin"))
    (add-to-list 'smiley-regexp-alist '("\\(:-?P\\)\\W" 1 "poke"))

;; (setq smiley-cached-regexp-alist nil)
;; (smiley-update-cache)

;;;;;;;;;;;;;;;;
;; Wanderlust ;;
;;;;;;;;;;;;;;;;
(autoload 'wl "wl" "Wanderlust" t)

;;;;;;;;;;;;;;;
;; mailcrypt ;;
;;;;;;;;;;;;;;;
(require 'mailcrypt)
(add-hook 'wl-summary-mode-hook 'mc-install-read-mode)
(add-hook 'wl-mail-setup-hook 'mc-install-write-mode)

(defun mc-wl-verify-signature ()
  (interactive)
  (save-window-excursion
    (wl-summary-jump-to-current-message)
    (mc-verify)))

(defun mc-wl-decrypt-message ()
  (interactive)
  (save-window-excursion
    (wl-summary-jump-to-current-message)
    (let ((inhibit-read-only t))
      (mc-decrypt))))

(eval-after-load "mailcrypt"
  '(setq mc-modes-alist
         (append
          (quote
           ((wl-draft-mode (encrypt . mc-encrypt-message)
                           (sign . mc-sign-message))
            (wl-summary-mode (decrypt . mc-wl-decrypt-message)
                             (verify . mc-wl-verify-signature))))
          mc-modes-alist)))

;;;;;;;;;;;;;;;;;;;;;
;; notify function ;;
;;;;;;;;;;;;;;;;;;;;;
(defun djcb-popup (title msg &optional icon sound)
  "Show a popup if we're on X, or echo it otherwise; TITLE is the title of the message, MSG is the context. Optionally, you can provide an ICON and a sound to be played"
  (interactive)
  (when sound (shell-command
               (concat "mplayer2 -really-quiet " sound " 2> /dev/null")))
  (if (eq window-system 'x)
      (shell-command (concat "notify-send "
                             
                             (if icon (concat "-i " icon) "")
                             " '" title "' '" msg "'"))
    ;; text only version
    (message (concat title ": " msg))))

;; the appointment notification facility
(setq
 appt-message-warning-time 15 ;; warn 15 min in advance
 appt-display-mode-line t     ;; show in the modeline
 appt-display-format 'window) ;; usr our func
(appt-activate t)             ;; active appt (appointment notification)
(display-time)

;; update appt each time agenda opened
(add-hook 'org-finalize-agenda-hook 'org-agenda-to-appt)

;; our little facade-function for djcb-popup
(defun djcb-appt-display (min-to-app new-time msg)
  (djcb-popup (format "Appointment in %s minute(s)" min-to-app) msg
              "/usr/share/icons/gnome/32x32/status/appointment-soon.png"
              "/usr/share/sounds/purple/alert.wav"))
(setq appt-disp-window-function (function djcb-appt-display))

;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Custom Variable sets ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;
(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.
 '(TeX-command-list (quote (("TeX" "%(PDF)%(tex) %`%S%(PDFout)%(mode)%' %t" TeX-run-TeX nil (plain-tex-mode texinfo-mode ams-tex-mode) :help "Run plain TeX") ("LaTeX" "%`%l%(mode)%' %t" TeX-run-TeX nil (latex-mode doctex-mode) :help "Run LaTeX") ("Makeinfo" "makeinfo %t" TeX-run-compile nil (texinfo-mode) :help "Run Makeinfo with Info output") ("Makeinfo HTML" "makeinfo --html %t" TeX-run-compile nil (texinfo-mode) :help "Run Makeinfo with HTML output") ("AmSTeX" "%(PDF)amstex %`%S%(PDFout)%(mode)%' %t" TeX-run-TeX nil (ams-tex-mode) :help "Run AMSTeX") ("ConTeXt MKIV" "context %t" TeX-run-TeX nil (context-mode) :help "Run ConTeXt MKIV") ("ConTeXt" "texexec --once --texutil %(execopts)%t" TeX-run-TeX nil (context-mode) :help "Run ConTeXt once") ("ConTeXt Full" "texexec %(execopts)%t" TeX-run-TeX nil (context-mode) :help "Run ConTeXt until completion") ("BibTeX" "bibtex %s" TeX-run-BibTeX nil t :help "Run BibTeX") ("View" "%V" TeX-run-discard-or-function t t :help "Run Viewer") ("Print" "%p" TeX-run-command t t :help "Print the file") ("Queue" "%q" TeX-run-background nil t :help "View the printer queue" :visible TeX-queue-command) ("File" "%(o?)dvips %d -o %f " TeX-run-command t t :help "Generate PostScript file") ("Index" "makeindex %s" TeX-run-command nil t :help "Create index file") ("Check" "lacheck %s" TeX-run-compile nil (latex-mode) :help "Check LaTeX file for correctness") ("Spell" "(TeX-ispell-document \"\")" TeX-run-function nil t :help "Spell-check the document") ("Clean" "TeX-clean" TeX-run-function nil t :help "Delete generated intermediate files") ("Clean All" "(TeX-clean t)" TeX-run-function nil t :help "Delete generated intermediate and output files") ("Other" "" TeX-run-command t t :help "Run an arbitrary command"))))
 '(column-number-mode t)
 '(erc-modules (quote (autojoin bbdb button completion fill irccontrols list log match menu move-to-prompt netsplit networks noncommands readonly ring services smiley stamp spelling track)))
 '(mediawiki-site-alist (quote (("Funtoo" "http://www.funtoo.org/" "USER" "PASSWORD" "")))))
(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.
 )

;;;;;;;;;;;;;;;;;;
;; Color-Themes ;;
;;;;;;;;;;;;;;;;;;
;;(add-to-list 'load-path "/usr/share/emacs/site-lisp/color-theme/color-theme.el")
;;(add-to-list 'load-path "~/.emacs.d/themes/")
(require 'color-theme)
(color-theme-initialize)
;;(color-theme-subtle-hacker)
(color-theme-twilight)
;;(eval-after-load "color-theme"
;;  '(progn
;;     (color-theme-initialize)
;;     (require 'color-theme-citrus)
;;     (require 'color-theme-candy)
;;     (require 'color-theme-autumn-leaves)
;;     (require 'color-theme-inthedark)
;;     (require 'color-theme-marine)
;;     (require 'color-theme-october)
;;     (require 'color-theme-eatyourgreens)
;;     (require 'color-theme-august)
;;     (require 'color-theme-saddle-2)
;;     (color-theme-saddle-2)))
;;     (color-theme-subtle-hacker)))

(setq css-indent-offset 2)

.wl

# nano ~/.wl
;; load bbdb support
(require 'bbdb-wl)
(bbdb-wl-setup)

;; setup from where to get addresses
(setq bbdb-wl-folder-regexp "^\.INBOX|^\.inbox|^\.Sent|^\.sent|^\.\[IMAPS\]\\Sent")

;; define keybinding
(define-key wl-draft-mode-map (kbd "<C-tab>") 'bbdb-complete-name)

;; set multiple e-mail addresses
(setq wl-user-mail-address-list (quote ("User@googlemail.com" "USER@own-server.tld")))

;; handle ("d") mark
;; remove = instant removal (same as "D"), thrash = move to wl-trash-folder
;; string = move to string
(setq wl-dispose-folder-alist
      '(
        ("\.\*googlemail\\.com" "%[Imap]/Trash:"User@googlemail.com"/clear@imap.gmail.com:993!")
        ("\.\*@own\-\server\\.tld" "%INBOX.Trash:"USER"/clear@imap.own-server.tld")
))

;; notify hook
(add-hook 'wl-biff-notify-hook
          (lambda()
            (djcb-popup "Wanderlust" "You have new mail!"
                        "/usr/share/icons/gnome/32x32/status/mail-unread.png"
                        "/usr/share/sounds/purple/alert.wav")))

;; timer settings
(setq
 wl-biff-check-interval 30 ;; check every 30 seconds
 wl-biff-use-idle-timer t) ;; in the background

;; Name of top-folder, default "Desktop"
(setq wl-folder-desktop-name "e-Mail")

;; select correct email address when we _start_ writing a draft.
(add-hook 'wl-mail-setup-hook 'wl-draft-config-exec)

(setq wl-draft-config-alist
      '(
        ((string-match "googlemail.com" wl-draft-parent-folder)
         (template . "User"))
        ((string-match "own-server.tld" wl-draft-parent-folder)
         (template . "USER"))
))

;; choose template with C-c C-j
(setq wl-template-alist
      '(("User"
         (wl-from . "Full Name <User@googlemail.com>")
         ("From" . wl-from)
         (wl-smtp-posting-user . "User")
         (wl-smtp-posting-server . "smtp.gmail.com")
         (wl-smtp-authenticate-type . "plain")
         (wl-smtp-connection-type . 'starttls)
         (wl-smtp-posting-port . 587)
         (wl-local-domain . "googlemail.com")
         (wl-message-id-domain . "smtp.gmail.com")
         
         (wl-fcc .  "%[IMAPS]/Sent:\"User@googlemail.com\"/clear@imap.gmail.com:993!")
         (wl-draft-folder .  "%[IMAPS]/Draft:\"User@googlemail.com\"/clear@imap.gmail.com:993!")
        )
        ("USER"
         (wl-from  . "Full Name <USER@own-server.tld>")
         ("From"  . wl-from)
         (wl-smtp-posting-user  . "USER")
         (wl-smtp-posting-server  . "smtp.own-server.tld")
         (wl-local-domain . "own-server.tld")
         
         (wl-fcc  "%INBOX.Sent:USER/digest-md5@imap.own-server.tld:143")
         (wl-draft-folder  "%INBOX.Drafts:USER/digest-md5@imap.own-server.tld:143")
        )
       )
)

(define-key wl-template-mode-map (kbd "<right>") 'wl-template-next)
(define-key wl-template-mode-map (kbd "<left>") 'wl-template-prev)

(setq wl-default-spec "%")

(setq wl-fcc-force-as-read t)
(setq wl-auto-save-drafts-interval nil)

.folders

# nano ~/.folders
User@googlemail{
         %INBOX:"User@googlemail.com"/clear@imap.gmail.com:993!    "Inbox"
        [IMAPS-gmail]{
                %[IMAPS]/Sent:"User@googlemail.com"/clear@imap.gmail.com:993!      "Sent"
                %[IMAPS]/Draft:"User@googlemail.com"/clear@imap.gmail.com:993!      "Draft"
                %[IMAPS]/Spam:"User@googlemail.com"/clear@imap.gmail.com:993!      "Spam"
                %[IMAPS]/Trash:"User@googlemail.com"/clear@imap.gmail.com:993!      "Trash"
        }
}
USER@own-server.tld{
        %INBOX:USER/digest-md5@imap.own-server.tld   "Inbox"
        %INBOX.Sent:USER/digest-md5@imap.own-server.tld "Sent"
        %INBOX.Drafts:USER/digest-md5@imap.own-server.tld "Drafts"
}