diff --git a/.emacs.d/.gitignore b/.emacs.d/.gitignore deleted file mode 100644 index 326a586..0000000 --- a/.emacs.d/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -tramp -elpa -bookmarks -abbrev_defs -custom.el -*.elc -ac-comphist.dat -auto-save-list/ -url/ -packages/ -newsticker/ -templates/ -themes/ -rinit.* -!rinit.org -history diff --git a/.emacs.d/.gitmodules b/.emacs.d/.gitmodules deleted file mode 100644 index 2559e06..0000000 --- a/.emacs.d/.gitmodules +++ /dev/null @@ -1,9 +0,0 @@ -[submodule "site-lisp/identica-mode"] - path = site-lisp/identica-mode - url = git://git.sv.gnu.org/identica-mode.git -[submodule "site-lisp/tron-theme"] - path = site-lisp/tron-theme - url = git://gitorious.org/ryuslash/tron-theme.git -[submodule "site-lisp/git-auto-commit-mode"] - path = site-lisp/git-auto-commit-mode - url = git://gitorious.org/git-auto-commit-mode/git-auto-commit-mode.git diff --git a/.emacs.d/eshell/.gitignore b/.emacs.d/eshell/.gitignore deleted file mode 100644 index 7a28188..0000000 --- a/.emacs.d/eshell/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -* -!.gitignore -!login -!alias diff --git a/.emacs.d/eshell/login b/.emacs.d/eshell/login deleted file mode 100644 index f898d68..0000000 --- a/.emacs.d/eshell/login +++ /dev/null @@ -1,2 +0,0 @@ -(defun inspect (var) - (symbol-value (intern var))) diff --git a/.emacs.d/init3.el b/.emacs.d/init3.el deleted file mode 100644 index 1b5abdf..0000000 --- a/.emacs.d/init3.el +++ /dev/null @@ -1,13 +0,0 @@ -;; -*- mode: Emacs-Lisp; eval: (git-auto-commit-mode 1) -*- -(require 'bytecomp) - -(defvar startup-files - (directory-files "~/.emacs.d/startup/" t "^[^.].*\\.el$") - "A list of the files that should be loaded during startup.") - -(while startup-files - (let ((filename (car startup-files)) - (byte-compile-warnings nil)) - (if (not (eq (byte-recompile-file filename nil 0) nil)) - (load (substring filename 0 -3)))) - (setq startup-files (cdr startup-files))) diff --git a/.emacs.d/site-lisp/.gitignore b/.emacs.d/site-lisp/.gitignore deleted file mode 100644 index 813048b..0000000 --- a/.emacs.d/site-lisp/.gitignore +++ /dev/null @@ -1 +0,0 @@ -rudel/ diff --git a/.emacs.d/site-lisp/autosmiley.el b/.emacs.d/site-lisp/autosmiley.el deleted file mode 100644 index 1037e43..0000000 --- a/.emacs.d/site-lisp/autosmiley.el +++ /dev/null @@ -1,95 +0,0 @@ -;;; autosmiley.el --- Convert smileys into their graphical representation - -;; Author: Damyan Pepper (gmail account, username damyanp) -;; Created: 20060315 - -;; This program is free software; you can redistribute it and/or -;; modify it under the terms of the GNU General Public License as -;; published by the Free Software Foundation; either version 2, or (at -;; your option) any later version. - -;; This program is distributed in the hope that it will be useful, but -;; WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -;; General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program; if not, you can either send email to this -;; program's maintainer or write to: The Free Software Foundation, -;; Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA. - -;;; Commentary: - -;; Defines the minor mode autosmiley-mode that converts smileys like -;; :-) into their graphical representations on the fly. - -;; Tested on: -;; -;; GNU Emacs 22.0.50.1 (i386-mingw-nt5.1.2600) of 2006-03-14 on W2ONE -;; -;; History: -;; -;; 20060315 - First Release - - - -(require 'smiley) - -(defun autosmiley-overlay-p (overlay) - "Return whether OVERLAY is an overlay of autosmiley mode." - (memq (overlay-get overlay 'category) - '(autosmiley))) - -(defun autosmiley-remove-smileys (beg end) - (dolist (o (overlays-in beg end)) - (when (autosmiley-overlay-p o) - (delete-overlay o)))) - -(defvar *autosmiley-counter* 0 - "Each smiley needs to have a unique display string otherwise - adjacent smileys will be merged into a single image. So we put - a counter on each one to make them unique") - -(defun autosmiley-add-smiley (beg end image) - (let ((overlay (make-overlay beg end))) - (overlay-put overlay 'category 'autosmiley) - (overlay-put overlay 'display (append image (list :counter (incf *autosmiley-counter*)))))) - - -(defun autosmiley-add-smileys (beg end) - (save-excursion - (dolist (entry smiley-cached-regexp-alist) - (let ((regexp (car entry)) - (group (nth 1 entry)) - (image (nth 2 entry))) - (when image - (goto-char beg) - (while (re-search-forward regexp end t) - (autosmiley-add-smiley (match-beginning group) (match-end group) image))))))) - - -(defun autosmiley-change (beg end &optional old-len) - (let ((beg-line (save-excursion (goto-char beg) (line-beginning-position))) - (end-line (save-excursion (goto-char end) (line-end-position)))) - (autosmiley-remove-smileys beg-line end-line) - (autosmiley-add-smileys beg-line end-line))) - - -;;;###autoload -(define-minor-mode autosmiley-mode - "Minor mode for automatically replacing smileys in text with -cute little graphical smileys." - :group 'autosmiley :lighter " :)" - (save-excursion - (save-restriction - (widen) - (autosmiley-remove-smileys (point-min) (point-max)) - (if autosmiley-mode - (progn - (unless smiley-cached-regexp-alist - (smiley-update-cache)) - (jit-lock-register 'autosmiley-change)) - (jit-lock-unregister 'autosmiley-change))))) - - -(provide 'autosmiley) diff --git a/.emacs.d/site-lisp/org-contacts.el b/.emacs.d/site-lisp/org-contacts.el deleted file mode 100644 index b6d9e50..0000000 --- a/.emacs.d/site-lisp/org-contacts.el +++ /dev/null @@ -1,620 +0,0 @@ -;;; org-contacts.el --- Contacts management - -;; Copyright (C) 2010-2012 Julien Danjou - -;; Author: Julien Danjou -;; Keywords: outlines, hypermedia, calendar -;; -;; This file is NOT part of GNU Emacs. -;; -;; GNU Emacs is free software: you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; GNU Emacs is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs. If not, see . -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; Commentary: - -;; This file contains the code for managing your contacts into Org-mode. - -;; To enter new contacts, you can use `org-capture' and a template just like -;; this: - -;; ("c" "Contacts" entry (file "~/Org/contacts.org") -;; "* %(org-contacts-template-name) -;; :PROPERTIES: -;; :EMAIL: %(org-contacts-template-email) -;; :END:"))) -;; -;;; Code: - -(eval-when-compile - (require 'cl)) - -(eval-and-compile - (require 'org)) - -(defgroup org-contacts nil - "Options concerning contacts management." - :group 'org) - -(defcustom org-contacts-files nil - "List of Org files to use as contacts source. -If set to nil, all your Org files will be used." - :type '(repeat file) - :group 'org-contacts) - -(defcustom org-contacts-email-property "EMAIL" - "Name of the property for contact email address." - :type 'string - :group 'org-contacts) - -(defcustom org-contacts-address-property "ADDRESS" - "Name of the property for contact address." - :type 'string - :group 'org-contacts) - -(defcustom org-contacts-birthday-property "BIRTHDAY" - "Name of the property for contact birthday date." - :type 'string - :group 'org-contacts) - -(defcustom org-contacts-birthday-format "Birthday: %l (%Y)" - "Format of the anniversary agenda entry. The following replacements are available: - - %h - Heading name - %l - Link to the heading - %y - Number of year - %Y - Number of year (ordinal)" - :type 'string - :group 'org-contacts) - -(defcustom org-contacts-last-read-mail-property "LAST_READ_MAIL" - "Name of the property for contact last read email link storage." - :type 'string - :group 'org-contacts) - -(defcustom org-contacts-icon-property "ICON" - "Name of the property for contact icon." - :type 'string - :group 'org-contacts) - -(defcustom org-contacts-nickname-property "NICKNAME" - "Name of the property for IRC nickname match." - :type 'string - :group 'org-contacts) - -(defcustom org-contacts-icon-size 32 - "Size of the contacts icons." - :type 'string - :group 'org-contacts) - -(defcustom org-contacts-icon-use-gravatar (fboundp 'gravatar-retrieve) - "Whether use Gravatar to fetch contact icons." - :type 'boolean - :group 'org-contacts) - -(defcustom org-contacts-completion-ignore-case t - "Ignore case when completing contacts." - :type 'boolean - :group 'org-contacts) - -(defcustom org-contacts-group-prefix "+" - "Group prefix." - :type 'string - :group 'org-contacts) - -(defcustom org-contacts-matcher (concat org-contacts-email-property "<>\"\"") - "Matching rule for finding heading that are contacts. -This can be a tag name, or a property check." - :type 'string - :group 'org-contacts) - -(defcustom org-contacts-email-link-description-format "%s (%d)" - "Format used to store links to email. -This overrides `org-email-link-description-format' if set." - :group 'org-contacts - :type 'string) - -(defcustom org-contacts-vcard-file "contacts.vcf" - "Default file for vcard export." - :group 'org-contacts - :type 'file) - -(defvar org-contacts-keymap - (let ((map (make-sparse-keymap))) - (define-key map "M" 'org-contacts-view-send-email) - (define-key map "i" 'org-contacts-view-switch-to-irc-buffer) - map) - "The keymap used in `org-contacts' result list.") - -(defun org-contacts-files () - "Return list of Org files to use for contact management." - (or org-contacts-files (org-agenda-files t 'ifmode))) - -(defun org-contacts-filter (&optional name-match tags-match) - "Search for a contact maching NAME-MATCH and TAGS-MATCH. -If both match values are nil, return all contacts." - (let* (todo-only - (tags-matcher - (if tags-match - (cdr (org-make-tags-matcher tags-match)) - t)) - (name-matcher - (if name-match - '(org-string-match-p name-match (org-get-heading t)) - t)) - (contacts-matcher - (cdr (org-make-tags-matcher org-contacts-matcher))) - markers result) - (dolist (file (org-contacts-files)) - (org-check-agenda-file file) - (with-current-buffer (org-get-agenda-file-buffer file) - (unless (eq major-mode 'org-mode) - (error "File %s is no in `org-mode'" file)) - (org-scan-tags - '(add-to-list 'markers (set-marker (make-marker) (point))) - `(and ,contacts-matcher ,tags-matcher ,name-matcher) - todo-only))) - (dolist (marker markers result) - (org-with-point-at marker - (add-to-list 'result - (list (org-get-heading t) marker (org-entry-properties marker 'all))))))) - -(when (not (fboundp 'completion-table-case-fold)) - ;; That function is new in Emacs 24... - (defun completion-table-case-fold (table &optional dont-fold) - (lambda (string pred action) - (let ((completion-ignore-case (not dont-fold))) - (complete-with-action action table string pred))))) - -(defun org-contacts-complete-name (&optional start) - "Complete text at START with a user name and email." - (let* ((end (point)) - (start (or start - (save-excursion - (re-search-backward "\\(\\`\\|[\n:,]\\)[ \t]*") - (goto-char (match-end 0)) - (point)))) - (orig (buffer-substring start end)) - (completion-ignore-case org-contacts-completion-ignore-case) - (group-completion-p (org-string-match-p (concat "^" org-contacts-group-prefix) orig)) - (completion-list - (if group-completion-p - (mapcar (lambda (group) (propertize (concat org-contacts-group-prefix group) 'org-contacts-group group)) - (org-uniquify - (loop for contact in (org-contacts-filter) - with group-list - nconc (org-split-string - (or (cdr (assoc-string "ALLTAGS" (caddr contact))) "") ":")))) - (loop for contact in (org-contacts-filter) - ;; The contact name is always the car of the assoc-list - ;; returned by `org-contacts-filter'. - for contact-name = (car contact) - ;; Build the list of the user email addresses. - for email-list = (split-string (or - (cdr (assoc-string org-contacts-email-property (caddr contact))) - "")) - ;; If the user has email addresses… - if email-list - ;; … append a list of USER . - nconc (loop for email in email-list - collect (org-contacts-format-email contact-name email))))) - (completion-list (all-completions orig completion-list))) - ;; If we are completing a group, and that's the only group, just return - ;; the real result. - (when (and group-completion-p - (= (length completion-list) 1)) - (setq completion-list - (list (concat (car completion-list) ";: " - (mapconcat 'identity - (loop for contact in (org-contacts-filter - nil - (get-text-property 0 'org-contacts-group (car completion-list))) - ;; The contact name is always the car of the assoc-list - ;; returned by `org-contacts-filter'. - for contact-name = (car contact) - ;; Grab the first email of the contact - for email = (car (split-string (or - (cdr (assoc-string org-contacts-email-property (caddr contact))) - ""))) - ;; If the user has an email address, append USER . - if email collect (org-contacts-format-email contact-name email)) - ", "))))) - (list start end (completion-table-case-fold completion-list (not org-contacts-completion-ignore-case))))) - -(defun org-contacts-message-complete-function () - "Function used in `completion-at-point-functions' in `message-mode'." - (let ((mail-abbrev-mode-regexp - "^\\(Resent-To\\|To\\|B?Cc\\|Reply-To\\|From\\|Mail-Followup-To\\|Mail-Copies-To\\|Disposition-Notification-To\\|Return-Receipt-To\\):")) - (when (mail-abbrev-in-expansion-header-p) - (org-contacts-complete-name)))) - -(defun org-contacts-gnus-get-name-email () - "Get name and email address from Gnus message." - (if (gnus-alive-p) - (gnus-with-article-headers - (mail-extract-address-components - (or (mail-fetch-field "From") ""))))) - -(defun org-contacts-gnus-article-from-get-marker () - "Return a marker for a contact based on From." - (let* ((address (org-contacts-gnus-get-name-email)) - (name (car address)) - (email (cadr address))) - (cadar (or (org-contacts-filter - nil - (concat org-contacts-email-property "={\\b" (regexp-quote email) "\\b}")) - (when name - (org-contacts-filter - (concat "^" name "$"))))))) - -(defun org-contacts-gnus-article-from-goto () - "Go to contact in the From address of current Gnus message." - (interactive) - (let ((marker (org-contacts-gnus-article-from-get-marker))) - (when marker - (switch-to-buffer-other-window (marker-buffer marker)) - (goto-char marker) - (when (eq major-mode 'org-mode) - (org-show-context 'agenda) - (save-excursion - (and (outline-next-heading) - ;; show the next heading - (org-flag-heading nil))))))) - -(defun org-contacts-anniversaries (&optional field format) - "Compute FIELD anniversary for each contact, returning FORMAT. -Default FIELD value is \"BIRTHDAY\". - -Format is a string matching the following format specification: - - %h - Heading name - %l - Link to the heading - %y - Number of year - %Y - Number of year (ordinal)" - (let ((calendar-date-style 'american) - (entry "")) - (unless format (setq format org-contacts-birthday-format)) - (loop for contact in (org-contacts-filter) - for anniv = (let ((anniv (cdr (assoc-string - (or field org-contacts-birthday-property) - (caddr contact))))) - (when anniv - (calendar-gregorian-from-absolute - (org-time-string-to-absolute anniv)))) - ;; Use `diary-anniversary' to compute anniversary. - if (and anniv (apply 'diary-anniversary anniv)) - collect (format-spec format - `((?l . ,(org-with-point-at (cadr contact) (org-store-link nil))) - (?h . ,(car contact)) - (?y . ,(- (calendar-extract-year date) - (calendar-extract-year anniv))) - (?Y . ,(let ((years (- (calendar-extract-year date) - (calendar-extract-year anniv)))) - (format "%d%s" years (diary-ordinal-suffix years))))))))) - -(defun org-completing-read-date (prompt collection - &optional predicate require-match initial-input - hist def inherit-input-method) - "Like `completing-read' but reads a date. -Only PROMPT and DEF are really used." - (org-read-date nil nil nil prompt nil def)) - -(add-to-list 'org-property-set-functions-alist - `(,org-contacts-birthday-property . org-completing-read-date)) - -(defun org-contacts-template-name (&optional return-value) - "Try to return the contact name for a template. -If not found return RETURN-VALUE or something that would ask the user." - (or (car (org-contacts-gnus-get-name-email)) - return-value - "%^{Name}")) - -(defun org-contacts-template-email (&optional return-value) - "Try to return the contact email for a template. -If not found return RETURN-VALUE or something that would ask the user." - (or (cadr (org-contacts-gnus-get-name-email)) - return-value - (concat "%^{" org-contacts-email-property "}p"))) - -(defun org-contacts-gnus-store-last-mail () - "Store a link between mails and contacts. - -This function should be called from `gnus-article-prepare-hook'." - (let ((marker (org-contacts-gnus-article-from-get-marker))) - (when marker - (with-current-buffer (marker-buffer marker) - (save-excursion - (goto-char marker) - (let* ((org-email-link-description-format (or org-contacts-email-link-description-format - org-email-link-description-format)) - (link (gnus-with-article-buffer (org-store-link nil)))) - (org-set-property org-contacts-last-read-mail-property link))))))) - -(defun org-contacts-icon-as-string () - (let ((image (org-contacts-get-icon))) - (concat - (propertize "-" 'display - (append - (if image - image - `'(space :width (,org-contacts-icon-size))) - '(:ascent center))) - " "))) - -;;;###autoload -(defun org-contacts (name) - "Create agenda view for contacts matching NAME." - (interactive (list (read-string "Name: "))) - (let ((org-agenda-files (org-contacts-files)) - (org-agenda-skip-function - (lambda () (org-agenda-skip-if nil `(notregexp ,name)))) - (org-agenda-format (propertize - "%(org-contacts-icon-as-string)% p% s%(org-contacts-irc-number-of-unread-messages)%+T" - 'keymap org-contacts-keymap)) - (org-agenda-overriding-header - (or org-agenda-overriding-header - (concat "List of contacts matching `" name "':")))) - (setq org-agenda-skip-regexp name) - (org-tags-view nil org-contacts-matcher) - (with-current-buffer org-agenda-buffer-name - (setq org-agenda-redo-command - (list 'org-contacts name))))) - -(defun org-contacts-completing-read (prompt - &optional predicate - initial-input hist def inherit-input-method) - "Call `completing-read' with contacts name as collection." - (org-completing-read - prompt (org-contacts-filter) predicate t initial-input hist def inherit-input-method)) - -(defun org-contacts-format-email (name email) - "Format a mail address." - (unless email - (error "`email' cannot be nul")) - (if name - (concat name " <" email ">") - email)) - -(defun org-contacts-check-mail-address (mail) - "Add MAIL address to contact at point if it does not have it." - (let ((mails (org-entry-get (point) org-contacts-email-property))) - (unless (member mail (split-string mails)) - (when (yes-or-no-p - (format "Do you want to add this address to %s?" (org-get-heading t))) - (org-set-property org-contacts-email-property (concat mails " " mail)))))) - -(defun org-contacts-gnus-check-mail-address () - "Check that contact has the current address recorded. -This function should be called from `gnus-article-prepare-hook'." - (let ((marker (org-contacts-gnus-article-from-get-marker))) - (when marker - (org-with-point-at marker - (org-contacts-check-mail-address (cadr (org-contacts-gnus-get-name-email))))))) - -(defun org-contacts-gnus-insinuate () - "Add some hooks for Gnus user. -This adds `org-contacts-gnus-check-mail-address' and -`org-contacts-gnus-store-last-mail' to -`gnus-article-prepare-hook'. It also adds a binding on `;' in -`gnus-summary-mode-map' to `org-contacts-gnus-article-from-goto'" - (require 'gnus) - (require 'gnus-art) - (define-key gnus-summary-mode-map ";" 'org-contacts-gnus-article-from-goto) - (add-hook 'gnus-article-prepare-hook 'org-contacts-gnus-check-mail-address) - (add-hook 'gnus-article-prepare-hook 'org-contacts-gnus-store-last-mail)) - -(when (boundp 'completion-at-point-functions) - (add-hook 'message-mode-hook - (lambda () - (add-to-list 'completion-at-point-functions - 'org-contacts-message-complete-function)))) - -(defun org-contacts-wl-get-from-header-content () - "Retrieve the content of the `From' header of an email. -Works from wl-summary-mode and mime-view-mode - that is while viewing email. -Depends on Wanderlust been loaded." - (with-current-buffer (org-capture-get :original-buffer) - (cond - ((eq major-mode 'wl-summary-mode) (when wl-summary-buffer-elmo-folder - (elmo-message-field - wl-summary-buffer-elmo-folder - (wl-summary-message-number) - 'from))) - ((eq major-mode 'mime-view-mode) (std11-narrow-to-header) - (prog1 - (std11-fetch-field "From") - (widen)))))) - -(defun org-contacts-wl-get-name-email () - "Get name and email address from wanderlust email. -See `org-contacts-wl-get-from-header-content' for limitations." - (let ((from (org-contacts-wl-get-from-header-content))) - (when from - (list (wl-address-header-extract-realname from) - (wl-address-header-extract-address from))))) - -(defun org-contacts-template-wl-name (&optional return-value) - "Try to return the contact name for a template from wl. -If not found return RETURN-VALUE or something that would ask the user." - (or (car (org-contacts-wl-get-name-email)) - return-value - "%^{Name}")) - -(defun org-contacts-template-wl-email (&optional return-value) - "Try to return the contact email for a template from wl. -If not found return RETURN-VALUE or something that would ask the user." - (or (cadr (org-contacts-wl-get-name-email)) - return-value - (concat "%^{" org-contacts-email-property "}p"))) - -(defun org-contacts-view-send-email (&optional ask) - "Send email to the contact at point. -If ASK is set, ask for the email address even if there's only one address." - (interactive "P") - (let ((marker (org-get-at-bol 'org-hd-marker))) - (org-with-point-at marker - (let ((emails (org-entry-get (point) org-contacts-email-property))) - (if emails - (let ((email-list (split-string emails))) - (if (and (= (length email-list) 1) (not ask)) - (compose-mail (org-contacts-format-email - (org-get-heading t) emails)) - (let ((email (completing-read "Send mail to which address: " email-list))) - (org-contacts-check-mail-address email) - (compose-mail (org-contacts-format-email (org-get-heading t) email))))) - (error (format "This contact has no mail address set (no %s property)." - org-contacts-email-property))))))) - -(defun org-contacts-get-icon (&optional pom) - "Get icon for contact at POM." - (setq pom (or pom (point))) - (catch 'icon - ;; Use `org-contacts-icon-property' - (let ((image-data (org-entry-get pom org-contacts-icon-property))) - (when image-data - (throw 'icon - (if (fboundp 'gnus-rescale-image) - (gnus-rescale-image (create-image image-data) - (cons org-contacts-icon-size org-contacts-icon-size)) - (create-image image-data))))) - ;; Next, try Gravatar - (when org-contacts-icon-use-gravatar - (let* ((gravatar-size org-contacts-icon-size) - (email-list (org-entry-get pom org-contacts-email-property)) - (gravatar - (when email-list - (loop for email in (split-string email-list) - for gravatar = (gravatar-retrieve-synchronously email) - if (and gravatar - (not (eq gravatar 'error))) - return gravatar)))) - (when gravatar (throw 'icon gravatar)))))) - -(defun org-contacts-irc-buffer (&optional pom) - "Get the IRC buffer associated with the entry at POM." - (setq pom (or pom (point))) - (let ((nick (org-entry-get pom org-contacts-nickname-property))) - (when nick - (let ((buffer (get-buffer nick))) - (when buffer - (with-current-buffer buffer - (when (eq major-mode 'erc-mode) - buffer))))))) - -(defun org-contacts-irc-number-of-unread-messages (&optional pom) - "Return the number of unread messages for contact at POM." - (when (boundp 'erc-modified-channels-alist) - (let ((number (cadr (assoc (org-contacts-irc-buffer pom) erc-modified-channels-alist)))) - (if number - (format (concat "%3d unread message" (if (> number 1) "s" " ") " ") number) - (make-string 21 ? ))))) - -(defun org-contacts-view-switch-to-irc-buffer () - "Switch to the IRC buffer of the current contact if it has one." - (interactive) - (let ((marker (org-get-at-bol 'org-hd-marker))) - (org-with-point-at marker - (switch-to-buffer-other-window (org-contacts-irc-buffer))))) - -(defun org-contacts-completing-read-nickname (prompt collection - &optional predicate require-match initial-input - hist def inherit-input-method) - "Like `completing-read' but reads a nickname." - (org-completing-read prompt (append collection (erc-nicknames-list)) predicate require-match - initial-input hist def inherit-input-method)) - -(defun erc-nicknames-list () - "Return all nicknames of all ERC buffers." - (if (fboundp 'erc-buffer-list) - (loop for buffer in (erc-buffer-list) - nconc (with-current-buffer buffer - (loop for user-entry in (mapcar 'car (erc-get-channel-user-list)) - collect (elt user-entry 1)))))) - -(add-to-list 'org-property-set-functions-alist - `(,org-contacts-nickname-property . org-contacts-completing-read-nickname)) - -(defun org-contacts-vcard-escape (str) - "Escape ; , and \n in STR for use in the VCard format. -Thanks to http://www.emacswiki.org/cgi-bin/wiki/bbdb-vcard-export.el for the regexp." - (when str - (replace-regexp-in-string "\n" "\\\\n" (replace-regexp-in-string "\\(;\\|,\\|\\\\\\)" "\\\\\\1" str)))) - -(defun org-contacts-vcard-encode-name (name) - "Try to encode NAME as VCard's N property. The N property expects FamilyName;GivenName;AdditionalNames;Prefix;Postfix. -Org-contacts does not specify how to encode the name. So we try to do our best." - (concat (replace-regexp-in-string "\\(\\w+\\) \\(.*\\)" "\\2;\\1" name) ";;;")) - -(defun org-contacts-vcard-format (contact) - "Formats CONTACT in VCard 3.0 format." - (let* ((properties (caddr contact)) - (name (org-contacts-vcard-escape (car contact))) - (n (org-contacts-vcard-encode-name name)) - (email (org-contacts-vcard-escape (cdr (assoc-string org-contacts-email-property properties)))) - (bday (org-contacts-vcard-escape (cdr (assoc-string org-contacts-birthday-property properties)))) - (addr (cdr (assoc-string org-contacts-address-property properties))) - (nick (org-contacts-vcard-escape (cdr (assoc-string org-contacts-nickname-property properties)))) - - (head (format "BEGIN:VCARD\nVERSION:3.0\nN:%s\nFN:%s\n" n name))) - (concat head - (when email (format "EMAIL:%s\n" email)) - (when addr - (format "ADR:;;%s\n" (replace-regexp-in-string "\\, ?" ";" addr))) - (when bday - (let ((cal-bday (calendar-gregorian-from-absolute (org-time-string-to-absolute bday)))) - (format "BDAY:%04d-%02d-%02d\n" - (calendar-extract-year cal-bday) - (calendar-extract-month cal-bday) - (calendar-extract-day cal-bday)))) - (when nick (format "NICKNAME:%s\n" nick)) - "END:VCARD\n\n"))) - -(defun org-contacts-export-as-vcard (&optional name file to-buffer) - "Export all contacts matching NAME as VCard 3.0. It TO-BUFFER is nil, the content is written to FILE or `org-contacts-vcard-file'. If TO-BUFFER is non-nil, the buffer is created and the VCard is written into that buffer." - (interactive) ; TODO ask for name? - (let* ((filename (or file org-contacts-vcard-file)) - (buffer (if to-buffer - (get-buffer-create to-buffer) - (find-file-noselect filename)))) - - (message "Exporting...") - - (set-buffer buffer) - (let ((inhibit-read-only t)) (erase-buffer)) - (fundamental-mode) - (org-install-letbind) - - (when (fboundp 'set-buffer-file-coding-system) - (set-buffer-file-coding-system coding-system-for-write)) - - (loop for contact in (org-contacts-filter name) - do (insert (org-contacts-vcard-format contact))) - - (if to-buffer - (current-buffer) - (progn (save-buffer) (kill-buffer))))) - -(defun org-contacts-show-map (&optional name) - "Show contacts on a map. Requires google-maps-el." - (interactive) - (unless (fboundp 'google-maps-static-show) - (error "org-contacts-show-map requires google-maps-el.")) - (google-maps-static-show - :markers - (loop - for contact in (org-contacts-filter name) - for addr = (cdr (assoc-string org-contacts-address-property (caddr contact))) - if addr - collect (cons (list addr) (list :label (string-to-char (car contact))))))) - -(provide 'org-contacts) diff --git a/.emacs.d/site-lisp/shift-indent.el b/.emacs.d/site-lisp/shift-indent.el deleted file mode 100644 index d6d6e76..0000000 --- a/.emacs.d/site-lisp/shift-indent.el +++ /dev/null @@ -1,33 +0,0 @@ -(require 'simple) - -(defun indent-shift-left (start end &optional count) - (interactive - (if mark-active - (list (region-beginning) (region-end) current-prefix-arg) - (list (line-beginning-position) (line-end-position) current-prefix-arg))) - (if count - (setq count (prefix-numeric-value count)) - (setq count tab-width)) - (when (> count 0) - (let ((deactivate-mark nil)) - (save-excursion - (goto-char start) - (while (< (point) end) - (if (and (< (current-indentation) count) - (not (looking-at "[ \t]*$"))) - (error "Can't shift all lines enough")) - (forward-line)) - (indent-rigidly start end (- count)))))) - -(add-to-list 'debug-ignored-errors "^Can't shift all lines enough") - -(defun indent-shift-right (start end &optional count) - (interactive - (if mark-active - (list (region-beginning) (region-end) current-prefix-arg) - (list (line-beginning-position) (line-end-position) current-prefix-arg))) - (let ((deactivate-mark nil)) - (if count - (setq count (prefix-numeric-value count)) - (setq count tab-width)) - (indent-rigidly start end count))) diff --git a/.emacs.d/site-lisp/xmodmap-mode.el b/.emacs.d/site-lisp/xmodmap-mode.el deleted file mode 100644 index 3002a49..0000000 --- a/.emacs.d/site-lisp/xmodmap-mode.el +++ /dev/null @@ -1,9 +0,0 @@ -(define-generic-mode 'xmodmap-mode - '(?!) - '("add" "clear" "keycode" "keysym" "pointer" "remove") - nil - '("[xX]modmap\\(rc\\)?\\'") - nil - "Simple mode for xmodmap files.") - -(provide 'xmodmap-mode) diff --git a/.emacs.d/startup/.dir-locals.el b/.emacs.d/startup/.dir-locals.el deleted file mode 100644 index eecb8a9..0000000 --- a/.emacs.d/startup/.dir-locals.el +++ /dev/null @@ -1 +0,0 @@ -((nil . ((eval . (git-auto-commit-mode))))) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a58a911 --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +modules = emacs +install-modules = $(addprefix install-,$(modules)) + +.PHONY: all install $(modules) $(install-modules) + +all: $(modules) +install: $(install-modules) + +$(modules): + $(MAKE) -C $@/ + +$(install-modules): install-%: + $(MAKE) -C $*/ install diff --git a/emacs/Makefile b/emacs/Makefile new file mode 100644 index 0000000..45151ef --- /dev/null +++ b/emacs/Makefile @@ -0,0 +1,24 @@ +EMACS = emacs + +files = init.el init.elc +install-files = $(addprefix install-,$(files)) +submodules = eshell +install-submodules = $(addprefix install-,$(submodules)) + +.PHONY: all $(submodules) install $(install-submodules) $(install-files) + +all: $(files) $(submodules) + +$(submodules): + $(MAKE) -C $@/ + +$(filter %.elc,$(files)): %.elc: %.el + $(EMACS) -batch -eval "(byte-compile-file \"$^\")" + +install: $(install-files) $(install-submodules) + +$(install-files): install-%: + install -Dm 444 $* ${HOME}/.emacs.d/$* + +$(install-submodules): install-%: + $(MAKE) -C $*/ install diff --git a/emacs/eshell/Makefile b/emacs/eshell/Makefile new file mode 100644 index 0000000..a28a794 --- /dev/null +++ b/emacs/eshell/Makefile @@ -0,0 +1,6 @@ +.PHONY: all install + +all: + +install: + install -Dm 444 alias ${HOME}/.emacs.d/eshell/alias diff --git a/.emacs.d/eshell/alias b/emacs/eshell/alias similarity index 100% rename from .emacs.d/eshell/alias rename to emacs/eshell/alias diff --git a/.emacs.d/gnus.el b/emacs/gnus.el similarity index 100% rename from .emacs.d/gnus.el rename to emacs/gnus.el diff --git a/emacs/init.el b/emacs/init.el new file mode 100644 index 0000000..9dadf1c --- /dev/null +++ b/emacs/init.el @@ -0,0 +1,1124 @@ +(eval-and-compile + (package-initialize) + + (mapc #'(lambda (directory) + (add-to-list 'load-path directory) + (let ((default-directory directory)) + (normal-top-level-add-subdirs-to-load-path))) + '("/usr/share/emacs/site-lisp" "~/.emacs.d/site-lisp"))) + +(eval-when-compile + (require 'org-contacts) + (require 'sauron)) + +(autoload 'identica-mode "identica-mode" nil t) +(autoload 'mu4e "mu4e" nil t) + +(defalias 'yes-or-no-p 'y-or-n-p) + +(defmacro oni:define-mailbox (name email &optional signature longname) + "Define a mailbox function." + `(defun ,(make-symbol (concat "oni:" name "-mailbox")) () + ,(concat "Settings for " name " mailbox") + (setq mu4e-mu-home ,(expand-file-name (concat "~/.mu/" name)) + mu4e-maildir ,(expand-file-name (concat "~/documents/mail/" + (or longname name))) + mu4e-get-mail-command ,(concat "offlineimap -oa " (or longname + name)) + mu4e~main-buffer-name ,(concat "*mu4e-" name "*") + user-mail-address ,email + message-sendmail-extra-arguments '("-a" ,name) + message-signature-file ,signature))) + +(defmacro oni:generic-outline (regex) + "Prepare for enabling `outline-minor-mode'." + `(progn + (outline-minor-mode) + (set (make-local-variable 'outline-regexp) ,regex) + (hide-body) + (local-set-key [C-tab] 'outline-toggle-children))) + +(defun oni:after-save-func () + "Function for `after-save-hook'." + (oni:compile-el) + (executable-make-buffer-file-executable-if-script-p)) + +(defun oni:before-save-func () + "Function for `before-save-hook'." + (if (eq major-mode 'html-mode) + (oni:replace-html-special-chars)) + (if (not (eq major-mode 'markdown-mode)) + (delete-trailing-whitespace))) + +(defun oni:c-mode-common-func () + "Function for `c-mode-common-hook'." + (setq hs-adjust-block-beginning 'hs-c-like-adjust-block-beginning) + (hs-minor-mode)) + +(defun oni:compile-el () + "Compile the current buffer file if it is an .el file." + (let* ((full-file-name (buffer-file-name)) + (file-name (file-name-nondirectory full-file-name)) + (suffix (file-name-extension file-name))) + (if (and (not (string-equal file-name ".dir-locals.el")) + (string-equal suffix "el")) + (byte-compile-file full-file-name)))) + +(defun oni:hs-minor-mode-func () + "Function for `hs-minor-mode-hook'." + (local-set-key [C-tab] 'hs-toggle-hiding) + (hs-hide-all)) + +(defun oni:jabber-chat-mode-func () + "Function for `jabber-chat-mode-hook'." + (visual-line-mode)) + +(defun oni:mini-fix-timestamp-string (date-string) + "A minimal version of Xah Lee's `fix-timestamp-string' + function, found at http://xahlee.org/emacs/elisp_parse_time.html" + (setq date-string (replace-regexp-in-string "Jan" "01" date-string) + date-string (replace-regexp-in-string "Feb" "02" date-string) + date-string (replace-regexp-in-string "Mar" "03" date-string) + date-string (replace-regexp-in-string "Apr" "04" date-string) + date-string (replace-regexp-in-string "May" "05" date-string) + date-string (replace-regexp-in-string "Jun" "06" date-string) + date-string (replace-regexp-in-string "Jul" "07" date-string) + date-string (replace-regexp-in-string "Aug" "08" date-string) + date-string (replace-regexp-in-string "Sep" "09" date-string) + date-string (replace-regexp-in-string "Oct" "10" date-string) + date-string (replace-regexp-in-string "Nov" "11" date-string) + date-string (replace-regexp-in-string "Dec" "12" date-string)) + (string-match + "^\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{4\\}\\)$" + date-string) + (format "%s-%s-%s" + (match-string 3 date-string) + (match-string 2 date-string) + (match-string 1 date-string))) + +(defun oni:myepisodes-formatter (plist) + "Format RSS items from MyEpisodes as org tasks." + (let ((str (plist-get plist :title))) + (string-match + "^\\[ \\([^\]]+\\) \\]\\[ \\([^\]]+\\) \\]\\[ \\([^\]]+\\) \\]\\[ \\([^\]]+\\) \\]$" + str) + (let* ((title (match-string 1 str)) + (episode (match-string 2 str)) + (name (match-string 3 str)) + (date (oni:mini-fix-timestamp-string (match-string 4 str)))) + (format "* ACQUIRE %s %s - %s <%s>" title episode name date)))) + +(defun oni:prog-mode-func () + "Function for `prog-mode-hook'." + (rainbow-delimiters-mode) + (fci-mode) + (pretty-symbols-mode)) + +(defun oni:replace-html-special-chars () + (oni:replace-occurrences "é" "é")) + +(defun oni:replace-occurrences (from to) + "Replace all occurrences of FROM with TO in the current buffer." + (save-excursion + (goto-char (point-min)) + (while (search-forward from nil t) + (replace-match to)))) + +(defun oni:required-packages-installed-p () + "Check if all the packages I need are installed." + (let ((tmp-packages oni:required-packages) + (result t)) + (while (and tmp-packages result) + (if (not (package-installed-p (car tmp-packages))) + (setq result nil)) + (setq tmp-packages (cdr tmp-packages))) + result)) + +(defun oni:view-mail () + "Show a menu with all mailbox options from `oni:mailbox-map' +for easy selection." + (interactive) + (require 'tmm) + (let* ((tmm-completion-prompt "Choose a mailbox\n") + (inbox (tmm-prompt oni:mailbox-map))) + (if inbox + (progn + (require 'mu4e) + (funcall (intern (concat "oni:" inbox "-mailbox"))) + (mu4e))))) + +(defvar oni:mailbox-map + '("top" ("menu" + ("ryulash.org" . "ryuslash") + ("ninthfloor" . "ninthfloor") + ("gmail" . "gmail") + ("aethon" . "aethon"))) + "A mailbox map for use with `tmm-prompt'.") + +(defvar oni:required-packages + '(graphviz-dot-mode htmlize magit rainbow-delimiters + rainbow-mode yasnippet markdown-mode flymake + flymake-cursor pony-mode sauron dispass + expand-region fill-column-indicator + git-auto-commit-mode idomenu magit smex) + "List of all the packages I have (want) installed") + +(eval-after-load "mu4e" + '(add-to-list + 'org-capture-templates + '("c" "Contact" entry (file "~/documents/org/misc/contacts.org") + (concat "* %(mu4e-view-snarf-from 'name)\n" + " :PROPERTIES:\n" + " :EMAIL: %(mu4e-view-snarf-from 'email)\n" + " :END:")))) + +(oni:define-mailbox + "aethon" "thomas@aethon.nl" + (expand-file-name "~/documents/work/aethon/signature.txt")) +(oni:define-mailbox "gmail" "ryuslash@gmail.com") +(oni:define-mailbox "ninthfloor" "ryuslash@ninthfloor.org") +(oni:define-mailbox "ryuslash" "tom@ryuslash.org" nil "ryuslash.org") + +(setq-default c-basic-offset 4) +(setq-default fci-rule-column 73) + +(setq fci-rule-color "darkred") +(setq inferior-lisp-program "sbcl") +(setq jabber-account-list '(("ryuslash@jabber.org"))) +(setq jabber-chat-buffer-format "*jabber:%n*") +(setq jabber-chat-buffer-show-avatar nil) +(setq jabber-chat-fill-long-lines nil) +(setq jabber-chat-foreign-prompt-format "[%t] < ") +(setq jabber-chat-local-prompt-format "[%t] > ") +(setq jabber-chatstates-confirm nil) +(setq jabber-history-dir "~/.emacs.d/jabber") +(setq jabber-roster-show-bindings nil) +(setq jabber-roster-show-offline-contacts nil) +(setq mail-header-separator "") +(setq mu4e-headers-date-format "%d-%m %H:%M") +(setq mu4e-headers-fields '((:date . 11) + (:flags . 6) + (:to . 22) + (:from . 22) + (:subject))) +(setq mu4e-headers-show-threads nil) +(setq mu4e-headers-sort-revert nil) +(setq package-archives + '(("melpa" . "http://melpa.milkbox.net/packages/") + ("ELPA" . "http://tromey.com/elpa/") + ("gnu" . "http://elpa.gnu.org/packages/") + ("marmalade" . "http://marmalade-repo.org/packages/"))) +(setq package-load-list '((htmlize "1.39") + all)) +(setq org-feed-alist + '(("MyEpisodes" + "http://www.myepisodes.com/rss.php?feed=mylist&uid=Slash&pwdmd5=04028968e1f0b7ee678b748a4320ac17" + "~/documents/org/org" "MyEpisodes" + :formatter oni:myepisodes-formatter))) +(setq send-mail-function 'smtpmail-send-it) +(setq sendmail-program "/usr/bin/msmtp") +(setq yas-prompt-functions '(yas-ido-prompt)) + +(add-hook 'after-save-hook 'oni:after-save-func) +(add-hook 'before-save-hook 'oni:before-save-func) +(add-hook 'c-mode-common-hook 'oni:c-mode-common-func) +(add-hook 'hs-minor-mode-hook 'oni:hs-minor-mode-func) +(add-hook 'jabber-chat-mode-hook 'oni:jabber-chat-mode-func) +(add-hook 'prog-mode-hook 'oni:prog-mode-func) + +(global-set-key (kbd "") 'jabber-switch-to-roster-buffer) +(global-set-key (kbd "M-n") 'idomenu) + +(unless (oni:required-packages-installed-p) + (message "%s" "Refreshing package database...") + (package-refresh-contents) + (message "%s" " done.") + (mapc #'(lambda (package) + (when (not (package-installed-p package)) + (package-install package))) + oni:required-packages)) + +(defconst oni:c-outline-regex + (eval-when-compile + (concat + "\\(?:static\\s +\\)?\\(?:\\sw+\\(?: \\|\t\\|\n\\)*?\\*?\\)" + "\\(?:\\s \\|\t\\|\n\\)\\(?:\\sw\\|_\\)+([^)]*)[^;\n]*$")) + "Regex for `outline-minor-mode' for `c-mode'.") + +(defun oni:c-mode-func () + "Function for `c-mode-hook'." + (local-set-key [f9] 'compile) + (local-set-key "\C-j" 'oni:newline-and-indent)) + +(add-hook 'c-mode-hook 'oni:c-mode-func) + +(defun oni:css-mode-func () + "Function for `css-mode-hook'." + (setq hs-adjust-block-beginning 'hs-c-like-adjust-block-beginning) + (hs-minor-mode) + (local-set-key "\C-j" 'oni:newline-and-indent) + (rainbow-mode)) + +(add-hook 'css-mode-hook 'oni:css-mode-func) + +(defun oni:emacs-lisp-mode-func () + "Function for `emacs-lisp-mode-hook'." + (eldoc-mode) + (when (buffer-file-name) + (hs-minor-mode))) + +(add-hook 'emacs-lisp-mode-hook 'oni:emacs-lisp-mode-func) + +(defun oni:go-mode-func () + "Function for `go-mode-hook'." + (setq indent-tabs-mode nil) + (local-set-key "\C-j" 'oni:newline-and-indent)) + +(add-hook 'go-mode-hook 'oni:go-mode-func) + +(defun oni:html-mode-func () + "Function for `html-mode-hook'." + (fci-mode)) + +(add-hook 'html-mode-hook 'oni:html-mode-func) + +(defconst oni:javascript-outline-regex "function \\(\\w\\|_\\)+(" + "Regex for `outline-minor-mode' for `js-mode'.") + +(defun oni:js-mode-func () + "Function for `js-mode-hook'." + (oni:generic-outline oni:javascript-outline-regex) + (rainbow-delimiters-mode) + (local-set-key "\C-j" 'oni:newline-and-indent)) + +(add-hook 'js-mode-hook 'oni:js-mode-func) + +(add-to-list 'auto-mode-alist '("\\.js\\(on\\)?$" . js-mode)) + +(defun oni:lisp-mode-func () + "Function for `lisp-mode-hook'." + (hs-minor-mode)) + +(add-hook 'lisp-mode-hook 'oni:lisp-mode-func) + +(defconst oni:python-outline-regex + (eval-when-compile + (concat "^[ \t]*\\(?:@[a-zA-Z0-9_]+\\(?:([a-zA-Z0-9_=, ]*)\\)?" + "\n\\)*[ \t]*\\(?:\\(class\\|def\\)[ \t]+\\(\\sw\\|\\s_\\)+" + "\\(([^)]*):\\)?\\|\\#[ a-zA-Z0-9]*\\#\\)")) + "Regex for `outline-minor-mode' for `python-mode'.") + +(defun oni:python-mode-func () + "Function for `python-mode-hook'." + (flymake-mode) + (local-set-key (kbd "C->") 'python-indent-shift-right) + (local-set-key (kbd "C-<") 'python-indent-shift-left) + (local-set-key [C-tab] 'outline-toggle-children) + (oni:generic-outline oni:python-outline-regex) + (set (make-local-variable 'electric-indent-chars) nil) + (rainbow-delimiters-mode) + (fci-mode)) + +(add-hook 'python-mode-hook 'oni:python-mode-func) + +(autoload 'pony-mode "pony-mode" nil t) + +(defconst oni:php-outline-regex + (eval-when-compile + (concat + "^ *\\(\\(?:namespace\\|interface\\) [a-zA-Z0-9_]\\|\\(\\(abstract" + "\\|final\\) \\)?class [a-zA-Z0-9_]+\\( extends [\\a-zA-Z0-9_]+\\)?" + "\\|\\(abstract \\)?\\(public\\|private\\|protected\\)?" + "\\( static\\)? function [a-zA-Z0-9_]+(\\|/\\*\\*\\)")) + "Regex for `outline-minor-mode' for `php-mode'.") + +(defun oni:php-mode-func () + "Function for `php-mode-hook'." + (flymake-mode) + ;; (oni:gtags-for-php) + (local-set-key "\C-j" 'oni:newline-and-indent) + (c-set-offset 'arglist-intro '+) + (c-set-offset 'arglist-close '0) + (rainbow-delimiters-mode) + (setq fci-rule-column 81)) + +(autoload 'php-mode "php-mode" nil t) + +(setq-default php-mode-warn-if-mumamo-off nil) + +(setq php-function-call-face 'font-lock-function-name-face + php-mode-force-pear t) + +(add-to-list 'auto-mode-alist '("\\.php[345]?$" . php-mode)) + +(add-hook 'php-mode-hook 'oni:php-mode-func) + +(add-to-list 'auto-mode-alist '("\\.tpl$" . html-mode)) + +(defun oni:scheme-mode-func () + "Function for `scheme-mode-hook'." + (hs-minor-mode)) + +(add-hook 'scheme-mode-hook 'oni:scheme-mode-func) + +(require 'geiser-install) + +(setq geiser-active-implementations '(guile) + geiser-repl-history-filename "~/.emacs.d/geiser-history") + +(defun oni:java-mode-func () + "Function for `java-mode-hook'." + (local-set-key "\C-j" 'oni:newline-and-indent)) + +(add-hook 'java-mode-hook 'oni:java-mode-func) + +(defun oni:close-client-window () + "Close a client's frames." + (interactive) + (server-save-buffers-kill-terminal nil)) + +(when (daemonp) + (global-set-key "\C-x\C-c" 'oni:close-client-window)) + +(defun oni:org-mode-func () + "Function for `org-mode-hook'." + (flyspell-mode) + (auto-fill-mode)) + +(add-hook 'org-mode-hook 'oni:org-mode-func) + +(global-set-key "\C-ca" 'org-agenda) +(global-set-key "\C-cc" 'org-capture) + +(eval-after-load "org" + '(progn + (require 'appt) + (require 'org-protocol) + (require 'org-habit) + (require 'org-contacts) + + (add-to-list 'org-modules 'habit) + + (org-indent-mode t) + + (org-agenda-to-appt) + (ad-activate 'org-agenda-redo))) + +(eval-after-load "org-crypt" + '(org-crypt-use-before-save-magic)) + +(setq org-hide-emphasis-markers t) + +(setq org-refile-allow-creating-parent-nodes t + org-refile-targets '((nil . (:maxlevel . 6))) + org-refile-use-outline-path 'file) + +(defadvice org-agenda-redo (after org-agenda-redo-add-appts) + "Pressing `r' on the agenda will also add appointments." + (progn + (setq appt-time-msg-list nil) + (org-agenda-to-appt))) + +(setq org-agenda-custom-commands + '(("b" "Bookmarks to look at." + todo "LOOKAT") + ("w" "Work todo." + tags-todo "CATEGORY=\"Work\""))) + +(setq org-directory (expand-file-name "~/documents/org")) + +(setq org-default-notes-file (concat org-directory "/org")) + +(setq org-agenda-files + `(,(concat org-directory "/org") + ,(concat org-directory "/misc/contacts.org") + ,(concat org-directory "/misc/bookmarks.org"))) + +(setq org-agenda-sorting-strategy ; How to sort my agenda. + '((agenda habit-down time-up priority-down category-keep) + (todo priority-down category-up) + (tags priority-down category-keep) + (search category-keep))) + +(setq org-capture-templates ; What to capture when. + '(("t" "Task" entry (file+headline "" "tasks") + "* TODO %^{Description}\n %u\n\n %?") + ("T" "Task with link" entry (file+headline "" "tasks") + "* TODO %^{Description}\n %u\n\n %a\n %?") + ("h" "Habit" entry (file+headline "" "tasks") + (concat "* TODO %^{Description}\n" + " SCHEDULED: %^T\n" + " :PROPERTIES:\n" + " :STYLE: habit\n" + " :END:") + :immediate-finish t) + ("l" "Log" entry (file+headline "" "notes") + (concat "* %n %<%d-%m-%Y %H:%M:%S>\n" + " %a\n\n" + " %?") + :prepend t :empty-lines 1) + ("a" "Appointment" entry (file+headline "" "appointments") + "* %^{Description} %^T" :immediate-finish t) + ("b" "Bookmark" entry (file "~/documents/org/misc/bookmarks.org") + "* %c\n\n %:initial"))) + +(setq org-export-htmlize-output-type 'css + org-outline-path-complete-in-steps t + org-return-follows-link t + org-src-fontify-natively t + org-tags-exclude-from-inheritance '("crypt") + org-use-fast-todo-selection t) + +(setq org-todo-keyword-faces + '(("TODO" :foreground "red") + ("IN PROGRESS" :foreground "yellow") + ("DONE" :foreground "forest green") + ("SUCCEEDED" :foreground "forest green") + ("WAITING" :foreground "orange") + ("CANCELLED" :foreground "orangered") + ("FAILED" :foreground "orangered"))) + +(setq org-todo-keywords + '((sequence "TODO(t)" "IN PROGRESS" "WAITING(@/!)" "|" + "DONE(!/!)" "CANCELLED(@/!)"))) + +(defun oni:diary-display-func () + "Function for `diary-display-hook'." + (diary-fancy-display)) + +(add-hook 'diary-display-hook 'oni:diary-display-func) + +(setq appt-display-diary nil) + +(defun oni:newline-and-indent () + (interactive) + (if (and (not (or (= (point) (point-max)) + (= (point) (point-min)))) + (or (and (char-equal (char-before) ?{) + (char-equal (char-after) ?})) + (and (char-equal (char-before) ?\() + (char-equal (char-after) ?\))))) + (save-excursion (newline-and-indent))) + (newline-and-indent)) + +(defun oni:emms-toggle-playing () + "Toggle between playing/paused states." + (interactive) + (if (eq emms-player-playing-p nil) + (emms-start) + (emms-pause))) + +(eval-after-load "emms-source-file" + '(progn + (require 'emms-setup) + + (emms-standard) + (require 'emms-player-mpd) + + (setq emms-player-mpd-server-name "localhost") + (setq emms-player-mpd-server-port "6600") + + (add-to-list 'emms-info-functions 'emms-info-mpd) + (add-to-list 'emms-player-list 'emms-player-mpd) + (setq emms-player-mpd-music-directory "/mnt/music/mp3"))) + +(setq emms-source-file-default-directory "/mnt/music/") + +(global-set-key [XF86AudioNext] 'emms-next) +(global-set-key [XF86AudioPlay] 'oni:emms-toggle-playing) +(global-set-key [XF86AudioPrev] 'emms-previous) +(global-set-key [XF86AudioStop] 'emms-stop) +(global-set-key [XF86Tools] 'emms) + +(defun oni:erc-mode-func () + "Function for `erc-mode-hook'." + (erc-fill-mode -1) + (visual-line-mode) + (setq truncate-lines nil)) + +(setq erc-autojoin-channels-alist + '(("freenode.net" "#herbstluftwm" "#ninthfloor" "#emacs" + "#dispass"))) + +(setq erc-nick "ryuslash") + +(add-hook 'erc-mode-hook 'oni:erc-mode-func) + +(setq erc-insert-timestamp-function 'erc-insert-timestamp-left + erc-timestamp-format "[%H:%M] " + erc-timestamp-only-if-changed-flag nil) + +(setq erc-hide-list '("JOIN" "PART" "QUIT")) + +(defun oni:eshell-mode-func () + "Function for `eshell-mode-hook'." + (setq truncate-lines nil)) + +(add-hook 'eshell-mode-hook 'oni:eshell-mode-func) + +(require 'cl) +(defun oni:shorten-dir (dir) + "Shorten a directory, (almost) like fish does it." + (let ((scount (1- (count ?/ dir)))) + (dotimes (i scount) + (string-match "\\(/\\.?.\\)[^/]+" dir) + (setq dir (replace-match "\\1" nil nil dir)))) + dir) + +(defun oni:eshell-prompt-function () + (let ((status (if (zerop eshell-last-command-status) ?+ ?-)) + (hostname (shell-command-to-string "hostname")) + (dir (abbreviate-file-name (eshell/pwd))) + (branch + (shell-command-to-string + "git branch --contains HEAD 2>/dev/null | sed -e '/^[^*]/d'")) + (userstatus (if (zerop (user-uid)) ?# ?$))) + (format "%c%s:%s@%s %c " + status + (substring hostname 0 -1) + (oni:shorten-dir dir) + (when (not (string= branch "")) + (substring branch 2 -1)) + userstatus))) + +(setq eshell-prompt-function 'oni:eshell-prompt-function) + +(defun oni:raise-eshell () + "Start or switch back to `eshell'. Also change directories to + current working directory." + (interactive) + (let ((dir (file-name-directory + (or (buffer-file-name) "~/"))) + (hasfile (not (eq (buffer-file-name) nil)))) + (eshell) + (if (and hasfile (eq eshell-process-list nil)) + (progn + (eshell/cd dir) + (eshell-reset))))) + +(global-set-key [f8] 'oni:raise-eshell) + +(eval-after-load "em-term" + '(add-to-list 'eshell-visual-commands + "unison")) + +(defun oni:flymake-mode-func () + "Function for `flymake-mode-hook'." + (local-set-key [M-P] 'flymake-goto-prev-error) + (local-set-key [M-N] 'flymake-goto-next-error)) + +(add-hook 'flymake-mode-hook 'oni:flymake-mode-func) + +(defun oni:flymake-pyflakes-init () + "Initialize function for flymake with pyflakes." + (let* ((temp-file (flymake-init-create-temp-buffer-copy + 'flymake-create-temp-inplace)) + (local-file (file-relative-name temp-file (file-name-directory + buffer-file-name)))) + (list "pyflakes" (list local-file)))) + +(eval-after-load "flymake" + '(progn + (require 'flymake-cursor) + + (add-to-list ; Make sure pyflakes is loaded + 'flymake-allowed-file-name-masks ; for python files. + '("\\.py\\'" oni:flymake-pyflakes-init)) + + (add-to-list ; Error line repexp for go + 'flymake-err-line-patterns ; compilation. + '("^\\([a-zA-Z0-9_]+\\.go\\):\\([0-9]+\\):\\(.*\\)$" + 1 2 nil 3)) + + (add-to-list ; Go uses makefiles, makes + 'flymake-allowed-file-name-masks ; flymaking 'easy'. + '("\\.go$" flymake-simple-make-init)))) + +(setq flymake-log-file-name (expand-file-name "~/.emacs.d/flymake.log") + flymake-log-level 0 + flymake-gui-warnings-enabled nil) + +(autoload 'gtags-mode "gtags" nil t) + +(defun oni:gtags-create-or-update () + "Create or update the GNU Global tag file" + (interactive) + (if (not (= 0 (call-process "global" nil nil nil " -p"))) + (let ((olddir default-directory) + (topdir (read-directory-name + "gtags: top of source tree:" default-directory))) + (cd topdir) + (shell-command "~/bin/create_gtags") + (cd olddir)) + ;; Tagfile already exists; update it + (shell-command "~/bin/update_gtags"))) + +(defun oni:gtags-for-php () + "Setup gtags for `php-mode'." + (let* ((file-name (buffer-file-name)) + (fext (if (not (eq nil file-name)) + (file-name-extension (buffer-file-name)) + nil))) + (if (equal fext "php") + (progn + (gtags-mode) + (oni:gtags-create-or-update))))) + +(defun oni:gtags-mode-func () + "Function for `gtags-mode-hook'." + (local-set-key "\M-," 'gtags-find-tag) + (local-set-key "\M-." 'gtags-find-rtag)) + +(add-hook 'gtags-mode-hook 'oni:gtags-mode-func) + +(setq gtags-auto-update t) + +(require 'newcomment) + +(defun oni:kill-region-or-backward-char () + "Kill either the active region, or delete the character left of + the cursor" + (interactive) + (if (region-active-p) + (kill-region (region-beginning) (region-end)) + (backward-delete-char-untabify 1))) + +(global-set-key "\C-w" 'oni:kill-region-or-backward-char) + +(defun oni:kill-region-or-forward-char () + "Kill either the active region, or delete the character right + of the cursor" + (interactive) + (if (region-active-p) + (kill-region (region-beginning) (region-end)) + (delete-forward-char 1))) + +(global-set-key "\C-d" 'oni:kill-region-or-forward-char) + +(defun oni:kill-region-or-line () + "Kill either the active region, or the rest of the line, + depending on whether or not `region-active-p' is t" + (interactive) + (if (region-active-p) + (kill-region (region-beginning) (region-end)) + (kill-line))) + +(global-set-key "\C-k" 'oni:kill-region-or-line) + +(defun oni:move-beginning-of-dwim () + "Move to the beginning of line, either after the indentatoin of + before." + (interactive) + (let ((start (point))) + (back-to-indentation) + (if (= start (point)) + (beginning-of-line)))) + +(global-set-key "\C-a" 'oni:move-beginning-of-dwim) + +(defun oni:move-end-of-dwim () + "Move to the end of line, either before any comments or after + them." + (interactive) + (let ((start (point)) + (eolpos (line-end-position))) + (beginning-of-line) + (if (and comment-start + (comment-search-forward eolpos t)) + (progn + (search-backward-regexp (concat "[^ \t" comment-start "]")) + (forward-char) + + (when (or (bolp) + (= start (point))) + (end-of-line))) + (end-of-line)))) + +(global-set-key "\C-e" 'oni:move-end-of-dwim) + +(defun oni:self-insert-dwim () + "Execute self insert, but when the region is active call self + insert at the end of the region and at the beginning." + (interactive) + (if (region-active-p) + (let ((electric-pair-mode nil) + (beginning (region-beginning)) + (end (region-end))) + (goto-char end) + (self-insert-command 1) + (save-excursion + (goto-char beginning) + (self-insert-command 1))) + (self-insert-command 1))) + +(global-set-key "'" 'oni:self-insert-dwim) +(global-set-key "\"" 'oni:self-insert-dwim) + +(global-set-key [f7] 'magit-status) + +(defun oni:magit-log-edit-mode-func () + "Function for `magit-log-edit-mode-hook'." + (auto-fill-mode) + (font-lock-add-keywords + nil + '(("\\`\\(.\\{,50\\}\\)\\(.*\\)\n?\\(.*\\)$" + (1 'git-commit-summary-face) + (2 'git-commit-overlong-summary-face) + (3 'git-commit-nonempty-second-line-face)) + ("`\\([^']+\\)'" 1 font-lock-constant-face)) + t)) + +(add-hook 'magit-log-edit-mode-hook 'oni:magit-log-edit-mode-func) + +(defun oni:markdown-mode-func () + "Function for `markdown-mode-hook'." + (auto-fill-mode) + (whitespace-mode)) + +(add-hook 'markdown-mode-hook 'oni:markdown-mode-func) + +(add-to-list 'auto-mode-alist '("\\.m\\(ark\\)?do?wn$" . markdown-mode)) + +(setq whitespace-style '(face trailing)) + +(defun oni:message-mode-func () + "Function for `message-mode-hook'." + (auto-fill-mode) + (flyspell-mode) + (ispell-change-dictionary (read-string "New dictionary: "))) + +(setq message-send-mail-function 'message-send-mail-with-sendmail) + +(add-hook 'message-mode-hook 'oni:message-mode-func) + +(require 'w3m-load) + +(require 'uniquify) + +(setq uniquify-buffer-name-style 'post-forward) + +(defun oni:raise-scratch (&optional mode) + "Show the *scratch* buffer. If called with a universal +argument, ask the user which mode to use. If MODE is not nil, +open a new buffer with the name *MODE-scratch* and load MODE as +its major mode." + (interactive (list (if current-prefix-arg + (read-string "Mode: ") + nil))) + (let* ((bname (if mode + (concat "*" mode "-scratch*") + "*scratch*")) + (buffer (get-buffer bname)) + (mode-sym (intern (concat mode "-mode")))) + + (unless buffer + (setq buffer (generate-new-buffer bname)) + (with-current-buffer buffer + (when (fboundp mode-sym) + (funcall mode-sym)))) + + (switch-to-buffer buffer))) + +(setq initial-major-mode 'emacs-lisp-mode + initial-scratch-message nil) + +(global-set-key [XF86HomePage] 'oni:raise-scratch) + +(defun oni:reload-buffer () + "Reload current buffer." + (interactive) + (revert-buffer nil t nil)) + +(global-set-key [f5] 'oni:reload-buffer) + +(defun oni:term-mode-func () + "Function for `term-mode-hook'." + (setq truncate-lines nil)) + +(add-hook 'term-mode-hook 'oni:term-mode-func) + +(defun oni:texinfo-mode-func () + "Function for `texinfo-mode-hook'." + (auto-fill-mode)) + +(add-hook 'texinfo-mode-hook 'oni:texinfo-mode-func) + +(autoload 'xmodmap-mode "xmodmap-mode" nil t) +(add-to-list 'auto-mode-alist '("^\\.Xmodmap$" . xmodmap-mode)) + +(defun oni:indent-shift-left (start end &optional count) + (interactive + (if mark-active + (list (region-beginning) (region-end) current-prefix-arg) + (list (line-beginning-position) + (line-end-position) + current-prefix-arg))) + (if count + (setq count (prefix-numeric-value count)) + (setq count tab-width)) + (when (> count 0) + (let ((deactivate-mark nil)) + (save-excursion + (goto-char start) + (while (< (point) end) + (if (and (< (current-indentation) count) + (not (looking-at "[ \t]*$"))) + (error "Can't shift all lines enough")) + (forward-line)) + (indent-rigidly start end (- count)))))) + +(add-to-list 'debug-ignored-errors "^Can't shift all lines enough") + +(defun oni:indent-shift-right (start end &optional count) + (interactive + (if mark-active + (list (region-beginning) (region-end) current-prefix-arg) + (list (line-beginning-position) + (line-end-position) + current-prefix-arg))) + (let ((deactivate-mark nil)) + (if count + (setq count (prefix-numeric-value count)) + (setq count tab-width)) + (indent-rigidly start end count))) + +(global-set-key (kbd "C-<") 'indent-shift-left) +(global-set-key (kbd "C->") 'indent-shift-right) + +(autoload 'po-mode "po-mode" nil t) +(add-to-list 'auto-mode-alist '("\\.po\\'\\|\\.po\\." . po-mode)) + +(autoload 'sawfish-mode "sawfish" nil t) + +(add-to-list 'auto-mode-alist '("\\.jl$" . sawfish-mode)) + +(electric-indent-mode) +(electric-pair-mode) +(show-paren-mode) +(savehist-mode) + +(blink-cursor-mode -1) +(menu-bar-mode -1) +(scroll-bar-mode -1) +(tool-bar-mode -1) +(tooltip-mode -1) + +(defun oni:write-file-func () + "Function for `write-file-hooks'." + (time-stamp)) + +(add-hook 'write-file-hooks 'oni:write-file-func) + +(setq time-stamp-active t) +(setq time-stamp-format "%04y-%02m-%02d %02H:%02M:%02S (%u)") + +(ido-mode) + +(setq ido-auto-merge-delay-time 1000000) + +(setq ido-save-directory-list-file nil) + +(eval-after-load "ido" + '(setq ido-ignore-buffers `(,@ido-ignore-buffers + "^\\*.*\\*$" "^irc\\." "^\\#"))) + +(setq smex-save-file "~/.emacs.d/smex-items") + +(smex-initialize) + +(eval-after-load "smex" + '(progn + (global-set-key (kbd "M-x") 'smex) + (global-set-key (kbd "C-M-x") 'smex-major-mode-commands))) + +(require 'iso-transl) + +(setq-default bidi-paragraph-direction 'left-to-right) + +(setq-default gac-automatically-push-p t) + +(setq-default indent-tabs-mode nil + tab-width 4) + +(setq-default require-final-newline t) + +(setq-default truncate-lines t) + +(add-to-list 'auto-mode-alist '("^PKGBUILD$" . shell-script-mode)) + +(setq auto-mode-case-fold nil) + +(setq auto-save-file-name-transforms + `((".*" ,temporary-file-directory t)) + + backup-directory-alist + `((".*" . ,temporary-file-directory))) + +(setq browse-url-browser-function 'browse-url-generic + browse-url-generic-program (getenv "BROWSER")) + +(setq custom-file "~/.emacs.d/custom.el") + +(setq custom-theme-directory "~/.emacs.d/themes") +(add-to-list 'custom-theme-load-path + (concat custom-theme-directory "/naquadah-theme")) +(load-theme 'naquadah t) + +(setq + default-frame-alist + `((border-width . 0) + (internal-border-width . 0) + (vertical-scroll-bars . nil) + (menu-bar-lines . nil) + (tool-bar-lines . nil) + (font . "DejaVu Sans Mono:pixelsize=18") + (left-fringe . 0))) + +(setq frame-title-format '(:eval (concat "emacs: " (buffer-name)))) + +(setq help-at-pt-display-when-idle t) +(help-at-pt-set-timer) + +(setq sauron-max-line-length 189) + +(eval-after-load "sauron" + '(setq sauron-modules (append '(sauron-identica sauron-jabber) + sauron-modules))) + + (setq sauron-column-alist ; I don't need as much + '((timestamp . 6) ; information as the default. + (message))) + +(setq sauron-hide-mode-line t) +(setq sauron-timestamp-format "%H:%M") +(setq sauron-watch-nicks '("ryuslash")) +(setq sauron-watch-patterns '("ryuslash")) +(setq special-display-buffer-names '("*Sauron*")) +(setq special-display-frame-alist + '((minibuffer . nil) + (right-fringe . 0))) + +(setq inhibit-default-init t) + +(setq inhibit-local-menu-bar-menus t) + +(setq inhibit-startup-message t) + +(setq jit-lock-defer-time 0.2) + +(setq message-log-max 1000) + +(setq org-blog-directory "~/code/projects/orgweb/blog" + org-blog-unfinished-directory "~/documents/blog/drafts") + +(setq org-contacts-files '("~/documents/org/misc/contacts.org")) + +(setq rainbow-delimiters-max-face-count 12) + +(setq redisplay-dont-pause t) + +(put 'upcase-region 'disabled nil) +(put 'downcase-region 'disabled nil) +(put 'narrow-to-region 'disabled nil) + +(global-set-key (kbd "C-@") 'er/expand-region) + +(defface oni:mode-line-modified + '((t (:inherit font-lock-warning-face))) + "Face for the modified state in the mode-line" + :group 'local) + +(defface oni:mode-line-mode + '((t (:inherit font-lock-string-face))) + "Face for the major mode in the mode-line" + :group 'local) + +(defface oni:mode-line-buffer-position + '((t (:inherit font-lock-constant-face))) + "Face for the buffer position in the mode-line" + :group 'local) + +(defface oni:mode-line-buffer-line + '((t (:inherit font-lock-type-face))) + "Face for the line number in the mode-line" + :group 'local) + +(defface oni:mode-line-buffer-column + '((t (:inherit font-lock-type-face))) + "Face for the column number in the mode-line" + :group 'local) + +(defface oni:mode-line-buffer-state + '((t (:inherit font-lock-preprocessor-face))) + "Face for the state of the buffer in the mode-line" + :group 'local) + +(setq-default + mode-line-format + (list + '(:eval (if (and (buffer-modified-p) (buffer-file-name)) + (propertize "!" + 'face 'oni:mode-line-modified + 'help-echo "Buffer has been modified") + " ")) + + '(:eval (propertize "%m" + 'face 'oni:mode-line-mode + 'help-echo buffer-file-coding-system)) + + ": " + + '(:eval (propertize "%b " + 'face 'mode-line-buffer-id + 'help-echo (buffer-file-name))) + + "(" + (propertize "%p" 'face 'oni:mode-line-buffer-position) ":" + (propertize "%04l" 'face 'oni:mode-line-buffer-line) "," + (propertize "%02c" 'face 'oni:mode-line-buffer-column) + ") " + + "[" + '(:eval (propertize + (if buffer-read-only + "R" + (if overwrite-mode "O" "I")) + 'face 'oni:mode-line-buffer-state + 'help-echo (concat "Buffer is " + (if buffer-read-only + "read-only" + (if overwrite-mode + "in overwrite mode" + "in insert mode"))))) + + "] " + + '(:eval (propertize (format-time-string "%H:%M") + 'help-echo + (concat (format-time-string "%c; ") + (emacs-uptime "Uptime: %hh")))) + " --" + '(:eval global-mode-string))) + +(setq scroll-conservatively 101) + +(setq use-dialog-box nil) + +(setq user-full-name "Tom Willemsen") + +(define-key key-translation-map (kbd "C-j") (kbd "C-l")) +(define-key key-translation-map (kbd "C-l") (kbd "C-j")) + +(global-set-key "\C-x\C-b" 'electric-buffer-list) +(global-set-key "\C-\M-d" 'kill-word) +(global-set-key "\C-\M-w" 'backward-kill-word) +(global-set-key (kbd "C-S-k") 'kill-whole-line) +(global-set-key [XF86Mail] 'oni:view-mail) +(global-set-key "\C-cip" 'identica-update-status-interactive) + +(when (or window-system (daemonp)) + (global-unset-key "\C-z")) + +(load custom-file) +(load "rudel-loaddefs.el") +(load (expand-file-name "~/quicklisp/slime-helper.el"))