Difference between pages "Help:Namespaces" and "Package:Emacs"

(Difference between pages)
m (1 revision: Importing the public domain help content from Mediawiki)
 
(.folders)
 
Line 1: Line 1:
{{PD Help Page}}
+
[[File:emacs-logo.png]]
Pages on a MediaWiki wiki are grouped into collections called "'''namespaces'''", which differentiate between the purpose of the pages at a high level. Pages in certain namespaces can also have special properties or behave differently when they interact with other pages. 
+
  
Namespaces are indicated in page titles by prefixing the page name with "<tt>namespace:</tt>", so the prefix "<tt>{{NAMESPACE}}:</tt>" in this page's title ("{{FULLPAGENAME}}") indicates that this page is in the {{NAMESPACE}} namespace. Note, however, that colons and prefixes can also appear in page titles ''without'' indicating a namespace: The page [[Foo:{{PAGENAME}}]] is a page located in the [[#0: (Main)|mainspace]] because the namespace "Foo" does not existSimilarly the page [[{{NAMESPACE}}:Foo:{{PAGENAME}}]] is in the "{{NAMESPACE}}" namespace.
+
Emacs is a famous text editor, famous by its flexibility and extensibilityOne manual describes it as "the extensible, customizable, self-documenting, real-time display editor".
  
==Standard namespaces==
+
This page is designed to give users a good place to share their config and settings for a nice emacs setup.
  
The standard MediaWiki installation has sixteen namespaces which can contain user-generated content; there are also two special namespaces which contain pages created 'on the fly' by the MediaWiki software.  The standard namespaces are organised in pairs, with each pair containing a 'subject namespace' and a 'discussion namespace'.  The namespaces are numbered from zero such that all subject namespaces have even indices, and all talk namespaces have odd indices.
+
== Installing emacs ==
 +
To install {{Package|app-editors/emacs}}, run the following command:
 +
<console>
 +
###i## emerge -av emacs
 +
</console>
 +
for the standard gnu emacs {{Package|app-editors/xemacs}} and
 +
<console>
 +
###i## emerge -av xemacs
 +
</console>
  
====-2: {{ns:-2}}====
+
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.
  
This namespace is an alias used for direct linking to media files: the link [[{{ns:-2}}:Wiki.png]] links to just the image rather than the image description page, which would be [[:{{ns:6}}:Wiki.png]].
+
== What emacs is and what it is not ==
  
====-1: {{ns:-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.
 +
# Emacs provides commands for manipulate every kind of text and syntax highlighting.
  
This namespace is used to group [[Help:Special pages|special pages]], reports and interfaces that are generated 'on demand' by MediaWiki and which are not directly editable.  It is not possible to create pages in this namespace except by modifying or extending the MediaWiki software.
+
=== Customizability ===
  
====0: (Main)====
+
'''Emacs is highly customizable:'''
  
Namespace zero is the 'null' namespace, commonly called the "main namespace" or "mainspace".  This namespace typically contains the bulk of the content pages in a wiki. This namespace generally has no special properties.
+
* 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.
  
====1: {{ns:1}}====
+
=== Extensibility ===
  
The "Talk" namespace is the discussion namespace attached to the mainspace.  It has no special properties.
+
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:
  
====2: {{ns:2}}====
+
* 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
  
Each user has a corresponding page in the {{ns:2}} namespace, which is linked to from edit histories, watchlists, recent changes, etc; wherever an individual user is uniquely identified. This page, and subpages of it, can be used by users to record information about themselves or to test and draft new content.  Pages of the form "<tt style="whitespace:nowrap">{{ns:2}}:''UserName''/Foo'''.js'''</tt>" or "<tt style="whitespace:nowrap">{{ns:2}}:''UserName''/Foo'''.css'''</tt>" can only be edited by the user themselves or by [[Help:Sysops and permissions|administrators]].
+
== User Configs ==
 +
=== golodhrim's config ===
 +
==== .emacs ====
 +
Edit the file <tt>~/.emacs</tt>:
  
====3: {{ns:3}}====
+
<pre>
 +
;;;;;;;;;;;;;;;;;;;;;;
 +
;; General Settings ;;
 +
;;;;;;;;;;;;;;;;;;;;;;
  
This namespace is the talkspace associated with the {{ns:2}} namespace. Pages in this namespace are mainly used to leave messages for particular users or inform them of discussions that may be of interest to them. To facilitate this, when a page  [[{{ns:3}}:UserName]] is edited, whenever the user 'UserName' loads a page, a notice is displayed at the top of the page informing them of the edit:
+
(setq emacs-root-dir (concat (getenv "HOME") "/em/"))
<div class="usermessage plainlinks">You have [[{{ns:3}}:UserName|<span style="color:#002bb8">{{MediaWiki:newmessageslink}}</span>]] ([{{fullurl:{{ns:3}}:UserName&diff=cur}} <span style="color:#002bb8">{{MediaWiki:newmessagesdifflink}}</span>]).</div>
+
  
This notice continues to appear until the user loads their user talk page to read the message.
+
(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
  
====4: {{ns:4}}====
+
(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.
  
This is a content namespace that is normally used for meta-discussions related to the operation and development of the wiki. It has no special properties.
+
(line-number-mode 1)                ;; Show line-number in the mode line
 +
(column-number-mode 1)              ;; Show column-number in the mode line
  
====5: {{ns:5}}====
+
(setq auto-fill-mode 1)            ;; Line wrap
  
This is a talk namespace that is normally used for discussions related to the associated content pages.  It has no special properties.
+
(set-default-font "Inconsolata-12")
  
====6: {{ns:6}}====
+
(setq browse-url-browser-function 'browse-url-generic
[[Image:Wiki.png|right]]
+
      browse-url-generic-program "google-chrome")
The {{ns:6}} namespace is used to store metadata for images, videos, sound files and other media accessed via the {{ns:-2}} namespace.  Each file has a corresponding page in the {{ns:6}} namespace which is often used to hold licensing data.  Linking ''directly'' to a page in this namespace instead includes the media file inline in the page: <tt style="white-space:nowrap"><nowiki>[[</nowiki>{{ns:6}}<nowiki>:Wiki.png|right]]</nowiki></tt> produces the image to the right.  See [[Help:Images]] for more details of this link syntax.  To create an [[Help:Links|internal link]] to the file page, you need to add a colon to the front of the namespace: <tt style="white-space:nowrap"><nowiki>[[:</nowiki>{{ns:6}}<nowiki>:Wiki.png|right]]</nowiki></tt> produces [[:{{ns:6}}:Wiki.png]].
+
The standard MediaWiki installation has alias "Image" for {{ns:6}} namespace - See [[Help:Namespaces#Namespace aliases|Namespace aliases]].
+
  
====7: {{ns:7}}====
+
(global-set-key (kbd "C-<prior>") 'previous-buffer)
 +
(global-set-key (kbd "C-<next>" ) 'next-buffer    )
  
This is a talk namespace that is normally used for discussions related to the associated media files.  It has no special properties.
 
  
====8: {{ns:8}}====
+
(setq load-path (cons "~/.emacs.d/plugins" load-path))
  
The MediaWiki namespace is used to hold system messages and other important content. For instance, the page [[{{ns:8}}:Edit]] (or [[{{ns:8}}:Vector-view-edit]] in the default "Vector" skin) contains the text that fills the "{{MediaWiki:Edit}}" tab at the top of every page.  If that page exists, it overrides the default content, which is "edit this page". Similarly, [[{{ns:8}}:Common.css]] is the system message which holds the [[wikipedia:Cascading Style Sheets|CSS]] code that is loaded for all users for each page. It has the special property that the entire namespace is fully protected and can only be edited by administrators.
+
(setq global-font-lock-mode 1)
  
====9: {{ns:9}}====
+
(show-paren-mode 1)
  
This is a talk namespace that is normally used for discussions related to the associated system messages. It has no special properties.
+
;;;;;;;;;;;;;;;;;;
 +
;; 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)))
  
====10: {{ns:10}}====
+
(el-get 'sync)
  
The {{ns:10}} namespace is used to hold [[Help:Templates|templates]], blocks of text or wikicode that are intended to be transcluded in several other pages.  To facilitate this it has the special property that it is the ''default'' namespace for transclusions: the wikicode <tt style="white-space:nowrap"><nowiki>{{Foo}}</nowiki></tt> is equivalent to <tt style="white-space:nowrap"><nowiki>{{</nowiki>'''{{ns:10}}:'''<nowiki>Foo}}</nowiki></tt>.
+
;;;;;;;;;;;;;;;
 +
;; mediawiki ;;
 +
;;;;;;;;;;;;;;;
 +
(require 'mediawiki)
  
====11: {{ns:11}}====
+
;;;;;;;;;;;;;;;;;;;;
 +
;; Org-mode stuff ;;
 +
;;;;;;;;;;;;;;;;;;;;
  
This is a talk namespace that is normally used for discussions related to the associated template pages. It has no special properties.
+
;; 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
  
====12: {{ns:12}}====
+
;; 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)
  
The {{ns:12}} namespace is usually used to hold help files, instructions and 'how-to' guides.  It has no special properties.
+
(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
  
====13: {{ns:13}}====
+
(setq org-directory "~/notes")
  
This is a talk namespace that is normally used for discussions related to the associated help pages. It has no special properties.
+
;; Files that should be included in agenda views:
 +
(setq org-agenda-files (list "~/notes/business.org"
 +
                            "~/notes/personal.org"
 +
                            "~/notes/projects/"
 +
    "~/notes/projects/writing/"))
  
====14: {{ns:14}}====
+
(setq org-todo-keywords '((type "TODO" "Postponed" "Upcoming" "Doing" "|" "DONE(#)"))) ;; TODO workflows
  
The {{ns:14}} namespace contains [[Help:Categories|categories]], dynamic lists of other pages.  To facilitate this, linking ''directly'' to a category page does not output an inline link, but instead includes the page into the associated category page. So the code <tt style="white-space:nowrap"><nowiki>[[</nowiki>{{ns:14}}<nowiki>:Help]]</nowiki></tt> causes a category link to appear at the bottom of the page (at the bottom in the box marked "{{MediaWiki:Pagecategories}}"). Clicking on that link takes you to the category page, where this page is visible in the category list. To create an inline link to a category page, you need to add a colon to the front of the namespace: <tt style="white-space:nowrap"><nowiki>[[:</nowiki>{{ns:14}}<nowiki>:Help]]</nowiki></tt> produces [[:{{ns:14}}:Help]]. See [[Help:Categories]] for more details on category link syntax.
+
(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
  
====15: {{ns:15}}====
+
;; 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)
  
This is a talk namespace that is normally used for discussions related to the associated category pagesIt has no special properties.
+
(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")))
  
==Localisation==
+
(setq org-mobile-directory "~/Dropbox/MobileOrg")
Namespace names and aliases can be localized in TranslateWiki.net, using the special page [[translatewiki:Special:AdvancedTranslate|AdvancedTranslate]]. To get started, visit [[translatewiki:Special:FirstSteps]].
+
(setq org-mobile-use-encryption)
 +
(setq org-mobile-use-encryption-password "PASSWORD")
 +
(setq org-mobile-inbox-for-pull "~/notes/mobileorg/inbox.org")
  
===Renaming namespaces===
+
;;;;;;;;;;;;;;;;;;;
{| {{prettytable|width=0|style=float:right}}
+
;; Markdown Mode ;;
|-
+
;;;;;;;;;;;;;;;;;;;
!{{hl2}}|Canonical name
+
!{{hl2}}|Localized name
+
|-
+
| Media          || {{ns:-2}}
+
|-
+
| Special        || {{ns:-1}}
+
|-
+
|(Main)          || {{ns:0}}
+
|-
+
| Talk          || {{ns:1}}
+
|-
+
| User          || {{ns:2}}
+
|-
+
| User talk      || {{ns:3}}
+
|-
+
| Project        || {{ns:4}}
+
|-
+
| Project talk  || {{ns:5}}
+
|-
+
| File          || {{ns:6}}
+
|-
+
| File talk      || {{ns:7}}
+
|-
+
| MediaWiki      || {{ns:8}}
+
|-
+
| MediaWiki talk || {{ns:9}}
+
|-
+
| Template      || {{ns:10}}
+
|-
+
| Template talk  || {{ns:11}}
+
|-
+
| Help          || {{ns:12}}
+
|-
+
| Help talk      || {{ns:13}}
+
|-
+
| Category      || {{ns:14}}
+
|-
+
| Category talk  || {{ns:15}}
+
|}
+
  
Namespace names can be translated into languages other than English and individual namespaces can be renamed, as set by a wiki's system admins.  These names are known as the 'localized' namespace names. However, all namespaces have a 'canonical name', the original English name which will work on any installation of MediaWiki. So linking to [[User:Foo]] will always locate the user page for the user foo, whether the wiki is in French (where the localized name would be [[:Utilisateur:Foo]]), Russian ([[:Участник:Foo]]), or Hindi ([[:सदस्य:Foo]]). The canonical namespace names are given in the table to the right along with their localized names on this wiki.
+
(require 'markdown-mode)
 +
(add-to-list 'auto-mode-alist '("\\.markdown$" . markdown-mode))
 +
(add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))
  
===Namespace aliases===
+
;;;;;;;;;;;;;;;;
On some wikis there are also namespace ''aliases'': alternative names that will also be resolved to the localised names.  For instance, a wiki might define "T" as an alias for {{ns:10}}, such that typing [[T:Foo]] is equivalent to [[{{ns:10}}:Foo]], saving a few characters and seconds. An actual example would be on the [[wikipedia:|English Wikipedia]], where "WP" is an alias for {{ns:4}}, which is the namespace "Wikipedia". By default, "Image" is an alias for {{ns:6}}, so <tt style="white-space:nowrap;"><nowiki>[[Image:Wiki.png]]</nowiki></tt> is equivalent to <tt style="white-space:nowrap;"><nowiki>[[</nowiki>{{ns:6}}<nowiki>:Wiki.png]]</nowiki></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 . "* "))
 +
)
  
===Custom namespaces===
+
;; 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)
  
:''See {{mediawiki|Manual:Using custom namespaces}} for more information''.
+
;;;;;;;;;;;;
 +
;; 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))
  
Some wikis may wish to organise their content in ways that do not fit into this standard set of namespaces.  A wiki may define additional namespaces to facilitate this; these namespaces behave exactly like normal namespaces, and generally have indices greater than or equal to 100. These custom namespaces generally have no special properties.
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 +
;; Document Engineering (AUCTeX + ConTeXt) ;;
 +
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 +
(load "auctex.el" nil t t)
 +
(load "preview-latex.el" nil t t)
  
==Identifying namespaces==
+
(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)
  
There are a number of ways by which the namespace of a particular page can be identified:
+
(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)))
  
;Magic words
+
(add-hook 'TeX-mode-hook 'LaTeX-math-mode)
  
The [[Help:Magic word|magic word]] <tt><nowiki>{{NAMESPACE}}</nowiki></tt> returns the value of the namespace the page is in.
+
(autoload 'etexshow "etexshow" "Browser for ConTeXt commands." t)
  
;JavaScript
+
(setq etexshow-xml-files-alist
 +
  `((,(concat emacs-root-dir "libs/etexshow/cont-en.xml") .
 +
      ,(concat "/tmp/cont-en.cache"))))
  
The JavaScript variable <tt>wgCanonicalNamespace</tt> contains the full namespace name.  The variable <tt>wgNamespaceNumber</tt> contains the numerical index of the namespace.
+
(setq etexshow-comment-file
 +
  (concat emacs-root-dir "libs/etexshow/cont-en-comments.xml"))
  
;CSS
+
(setq TeX-PDF-mode 1)
 +
(setq revert-without-query '(".+pdf$"))
 +
(add-hook 'doc-view-mode-hook 'auto-revert-mode)
  
The <tt><nowiki><body></nowiki></tt> tag of the HTML page output is given two CSS classes that vary by namespace: A class <tt>ns-#</tt>, where # is the index of the namespace, and <tt>ns-XXX</tt>, where XXX is "<tt>subject</tt>" for all content namespaces, "<tt>special</tt>" for pages in the {{ns:-1}} namespace, and "<tt>talk</tt>" for talk namespaces. So CSS code such as the following can be used to change the appearance of an object based on its namespace:
+
;;;;;;;;;;
<source lang=css>
+
;; bbdb ;;
.ns-subject a
+
;;;;;;;;;;
{  /* All links on content pages to be green. */
+
(setq bbdb-file "~/.emacs.d/.bbdb")
    color: #00FF00;
+
(require 'bbdb)
}
+
(bbdb-initialize)
.ns-talk a
+
(setq
{     /* Links on talk pages to be blue. */
+
bbdb-offer-save 1                         ;; 1 means save-without-asking
    color: #0000FF;
+
bbdb-use-pop-up t                        ;; allow popups for addresses
}
+
bbdb-electric-p t                        ;; be disposable with SPC
.ns-3 a
+
bbdb-popup-target-lines 1                ;; very small
{        /* and links on user talk pages to be red */
+
bbdb-dwim-net-address-allow-redundancy t  ;; always use full name
    color: #FF0000;
+
bbdb-quiet-about-name-mismatches 2        ;; show name-mismatches 2 secs
}
+
bbdb-always-add-address t                ;; add new addresses to existing...
</source>
+
                                          ;; ...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")))
  
;API
+
;;;;;;;;;;;;;;;;;
 +
;; Jabber Mode ;;
 +
;;;;;;;;;;;;;;;;;
  
You can get a complete list of all the namespaces used on this wiki from the API:
+
(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
 +
)
  
:{{SERVER}}/w/api.php?action=query&meta=siteinfo&siprop=namespaces
+
(add-hook 'jabber-chat-mode-hook 'goto-address)
  
== See also ==
+
(load "~/.emacs.d/plugins/autosmiley.el")
* {{mediawiki|Manual:Namespace}}
+
(require 'autosmiley)
* {{mediawiki|Manual:Using custom namespaces}}
+
(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)
 +
</pre>
 +
 
 +
==== .wl ====
 +
<pre>
 +
;; 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)
 +
</pre>
 +
 
 +
==== .folders ====
 +
<pre>
 +
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"
 +
}
 +
</pre>
  
{{Languages}}
+
[[Category:HOWTO]]
[[Category:Help|Namespaces]]
+
[[Category:Featured]]
[[Category:Namespace|Namespaces]]
+

Revision as of 17:35, 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

;; 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

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"
}