diff options
author | Tom Willemsen | 2013-02-15 15:37:42 +0100 |
---|---|---|
committer | Tom Willemsen | 2013-02-15 15:37:42 +0100 |
commit | 934d02bcacaa5d0aef64a8edf7677f3b0c198666 (patch) | |
tree | edfc842025b5f8569973567b44ad62aa662f548f /.emacs.d/site-lisp | |
parent | 06ff316f7f3b098504a6342651a79017cfb80ae7 (diff) | |
parent | ee34dfcc2c2fec53731b64afca03bb34dd80b2ba (diff) | |
download | dotfiles-934d02bcacaa5d0aef64a8edf7677f3b0c198666.tar.gz dotfiles-934d02bcacaa5d0aef64a8edf7677f3b0c198666.zip |
Merge remote-tracking branch 'ryuslash/master' into phoenix
Conflicts:
.config/awesome/rc.lua
.emacs.d/init.el
.emacs.d/init.org
.emacs.d/site-lisp/oni.el
Diffstat (limited to '.emacs.d/site-lisp')
-rw-r--r-- | .emacs.d/site-lisp/dzen.el | 4 | ||||
-rw-r--r-- | .emacs.d/site-lisp/oni.el | 222 | ||||
-rw-r--r-- | .emacs.d/site-lisp/org-init.el | 83 |
3 files changed, 161 insertions, 148 deletions
diff --git a/.emacs.d/site-lisp/dzen.el b/.emacs.d/site-lisp/dzen.el index 2d43f95..6cc3eae 100644 --- a/.emacs.d/site-lisp/dzen.el +++ b/.emacs.d/site-lisp/dzen.el @@ -39,7 +39,9 @@ (defun dzen-update () (let ((strl "") - (strc metal-express-radio-currently-playing) + (strc (if (boundp 'metal-express-radio-currently-playing) + metal-express-radio-currently-playing + "")) (strr (format "jabber: %s ryu: %d gm: %d aet: %d 9n: %d rss: %d\n" (oni:current-jabber-status) diff --git a/.emacs.d/site-lisp/oni.el b/.emacs.d/site-lisp/oni.el index 979e804..ea64d3f 100644 --- a/.emacs.d/site-lisp/oni.el +++ b/.emacs.d/site-lisp/oni.el @@ -27,22 +27,6 @@ (autoload 'notifications-notify "notifications") (autoload 'jabber-send-message "jabber-chat") -(defmacro oni:define-mailbox (name email &optional signature longname) - "Define a mailbox function for mailbox NAME with address EMAIL. -Optionally set signature to SIGNATURE and use LONGNAME as the -actual account name." - `(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:email (user at host dot com) "Turn arguments into an email address. The resulting email address will look like: USER@HOST.COM, AT and @@ -50,20 +34,6 @@ DOT are intentionally being skipped." (concat (symbol-name user) "@" (symbol-name host) "." (symbol-name com))) -(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 sauron expand-region - fill-column-indicator git-auto-commit-mode idomenu magit smex) - "List of all the packages I have (want) installed.") - (defun oni:after-save-func () "Function for `after-save-hook'." (oni:compile-el) @@ -81,7 +51,9 @@ DOT are intentionally being skipped." nil (format "%s%s (in %s minutes)" new-time appt-msg min-to-app) nil) (appt-disp-window min-to-app new-time appt-msg)) - +;; (jabber-send-message (car jabber-connections) +;; "aethon@muc.ryuslash.org" nil "Hi, I'm a programmatic message; this +;; upens up possibilities :)" "groupchat") (defun oni:before-save-func () "Function for `before-save-hook'." (if (eq major-mode 'html-mode) @@ -99,6 +71,10 @@ DOT are intentionally being skipped." (interactive) (server-save-buffers-kill-terminal nil)) +(defun oni:color-for (object) + "Generate a hex color by taking the first 6 characters of OBJECT's MD5 sum." + (format "#%s" (substring (md5 object) 0 6))) + (defun oni:compile-el () "Compile the current buffer file if it is an .el file." (let* ((full-file-name (buffer-file-name)) @@ -128,12 +104,10 @@ DOT are intentionally being skipped." "Function for `emacs-lisp-mode-hook'." (eldoc-mode)) -(defun oni:emms-toggle-playing () - "Toggle between playing/paused states." - (interactive) - (if (eq emms-player-playing-p nil) - (emms-start) - (emms-pause))) +(defun oni:emacs-startup-func () + "Function for `emacs-init-hook'." + (require 'auto-complete-config) + (ac-config-default)) (defun oni:erc-mode-func () "Function for `erc-mode-hook'." @@ -141,44 +115,6 @@ DOT are intentionally being skipped." (visual-line-mode) (setq truncate-lines nil)) -(defun oni:eshell-mode-func () - "Function for `eshell-mode-hook'." - (setq truncate-lines nil)) - -(defun oni:eshell-prompt-function () - "Show a pretty shell prompt." - (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)) ?# ?$))) - (concat - (propertize (char-to-string status) - 'face `(:foreground ,(if (= status ?+) - "green" - "red"))) - " " - (propertize (substring hostname 0 -1) 'face 'mode-line-buffer-id) - " " - (propertize (oni:shorten-dir dir) 'face 'font-lock-string-face) - " " - (when (not (string= branch "")) - (propertize - ;; Cut off "* " and "\n" - (substring branch 2 -1) - 'face 'font-lock-function-name-face)) - " \n" - (propertize (char-to-string userstatus) - 'face `(:foreground "blue")) - "> "))) - -(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)) - (defun oni:go-mode-func () "Function for `go-mode-hook'." (setq indent-tabs-mode nil) @@ -189,9 +125,28 @@ DOT are intentionally being skipped." (local-set-key "\M-," 'gtags-find-tag) (local-set-key "\M-." 'gtags-find-rtag)) +(defun oni:haskell-mode-func () + "Function for `haskell-mode-hook'." + (turn-on-haskell-indentation)) + (defun oni:html-mode-func () "Function for `html-mode-hook'." - (fci-mode)) + (yas-minor-mode) + (fci-mode) + (flycheck-mode)) + +(defun oni:ido-init () + "Initialization functionn for ido." + (setq ido-ignore-buffers + (list "^\\` " "^irc\\." "^\\#" "^\\*Customize Option:" + (eval-when-compile + (regexp-opt + '("*-jabber-roster-*" + "*Messages*" + "*fsm-debug*" + "*magit-process*" + "*magit-edit-log*" + "*Backtrace*")))))) (defun oni:indent-shift-left (start end &optional count) "Rigidly indent region. @@ -245,6 +200,10 @@ If COUNT has been specified indent by that much, otherwise look at '(global-mode-string)) header-line-format nil)) +(defun oni:jabber-init () + "Initialization function for jabber." + (remove-hook 'jabber-alert-presence-hooks 'jabber-presence-echo)) + (defun oni:jabber-roster-mode-func () "Function for `jabber-roster-mode-hook'." (setq mode-line-format @@ -257,8 +216,7 @@ If COUNT has been specified indent by that much, otherwise look at (defun oni:js-mode-func () "Function for `js-mode-hook'." (rainbow-delimiters-mode) - (local-set-key "\C-j" 'oni:newline-and-indent) - (pretty-symbols-mode -1)) + (local-set-key "\C-j" 'oni:newline-and-indent)) (defun oni:js2-mode-func () "Function for `js2-mode-hook'." @@ -292,7 +250,8 @@ If COUNT has been specified indent by that much, otherwise look at "Function for `lua-mode-hook'." (local-unset-key (kbd ")")) (local-unset-key (kbd "]")) - (local-unset-key (kbd "}"))) + (local-unset-key (kbd "}")) + (flycheck-mode)) (defun oni:magit-log-edit-mode-func () "Function for `magit-log-edit-mode-hook'." @@ -403,29 +362,30 @@ When dealing with braces, add another line and indent that too." (defun oni:php-mode-func () "Function for `php-mode-hook'." - (flymake-mode) (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 80)) + (setq-local fci-rule-column 80) + (flycheck-mode)) (defun oni:pretty-control-l-function (win) - "Just make a string of either `fci-rule-colum' or `fill-column' -length -1. Use the `-' character. WIN is ignored." + "Just make a string of either `fci-rule-column' or +`fill-column' length -1. Use the `-' character. WIN is ignored." (make-string - (1- (if (boundp 'fci-rule-column) fci-rule-column fill-column)) ?-)) + (1- (if (boundp 'fci-rule-column) + fci-rule-column fill-column)) ?-)) (defun oni:prog-mode-func () "Function for `prog-mode-hook'." (rainbow-delimiters-mode) (fci-mode) - (pretty-symbols-mode) + (yas-minor-mode) (auto-fill-mode)) (defun oni:python-mode-func () "Function for `python-mode-hook'." - (flymake-mode) + (flycheck-mode) (local-set-key (kbd "C->") 'python-indent-shift-right) (local-set-key (kbd "C-<") 'python-indent-shift-left) (set (make-local-variable 'electric-indent-chars) nil) @@ -436,6 +396,10 @@ length -1. Use the `-' character. WIN is ignored." (fci-mode) (whitespace-mode)) +(defun oni:rainbow-mode-init () + "Initialization function for rainbow-mode." + (diminish 'rainbow-mode)) + (defun oni:raise-ansi-term (arg) "Create or show an `ansi-term' buffer." (interactive "P") @@ -444,19 +408,6 @@ length -1. Use the `-' character. WIN is ignored." (switch-to-buffer buffer) (call-interactively 'ansi-term)))) -(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))))) - (defun oni:raise-scratch (&optional mode) "Show the *scratch* buffer. If called with a universal argument, ask the user which mode to @@ -519,16 +470,6 @@ use. If MODE is not nil, open a new buffer with the name default-directory "' request-pull " (when patchp "-p ") from " " url " " 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:rst-mode-func () "Function for `rst-mode-hook'." (auto-fill-mode)) @@ -559,6 +500,16 @@ insert at the end of the region and at the beginning." (interactive) (message (format "%d:%d" (line-number-at-pos) (current-column)))) +(defun oni:show-org-index () + "Show the index of my org files." + (interactive) + (find-file "~/documents/org/index.org")) + +(defun oni:smex-init () + "Initialization function for smex." + (global-set-key (kbd "M-x") 'smex) + (global-set-key (kbd "C-M-x") 'smex-major-mode-commands)) + (defun oni:split-window-interactive (dir) "Split windows in direction DIR. @@ -582,13 +533,16 @@ If no direction is given, don't split." ((?h) (split-window-horizontally)) (t window)))) -(defun oni:start-emms () - "Check to see if the function `emms' exists, if not call -`emms-player-mpd-connect' and assume that will have loaded it." +(defun oni:start-python-test-mail-server () + "Run the python test mailserver." (interactive) - (unless (fboundp 'emms) - (emms-player-mpd-connect)) - (emms)) + (start-process "python-test-mail-server" "*py-mail-server*" "python" "-m" + "smtpd" "-n" "-c" "DebuggingServer" "localhost:1025")) + +(defun oni:stop-python-test-mail-server () + "Stop the python test mailserver." + (interactive) + (kill-process "python-test-mail-server")) (defun oni:term-mode-func () "Function for `term-mode-hook'." @@ -599,20 +553,6 @@ If no direction is given, don't split." (setq-local comment-auto-fill-only-comments nil) (auto-fill-mode)) -(defun oni:view-mail (inbox) - "Show a menu with all mailbox options from `oni:mailbox-map' -for easy selection." - (interactive - (list (progn - (require 'tmm) - (let ((tmm-completion-prompt "Choose a mailbox\n")) - (tmm-prompt oni:mailbox-map))))) - (if inbox - (progn - (require 'mu4e) - (funcall (intern (concat "oni:" inbox "-mailbox"))) - (mu4e)))) - (defun oni:write-file-func () "Function for `write-file-hooks'." (time-stamp)) @@ -623,11 +563,25 @@ for easy selection." (define-key yas-minor-mode-map [(tab)] nil) (define-key yas-minor-mode-map (kbd "C-\\") 'yas-expand)) -(define-skeleton html-tag - "Testing creation of an html tag" - "Tagname:" - "<" str ("Attribute: " " " str "=\"" (skeleton-read "Value: ") "\"") ">\n" - "</" str ">\n") +(defun oni:yasnippet-init () + "Initialization function for yasnippet." + (diminish 'yas-minor-mode)) + +(defvar oni:auto-save-name-transforms + `((".*" ,temporary-file-directory t)) + "Place all auto-save files in `temporary-file-directory'.") + +(defvar oni:backup-directory-alist + `((".*" . ,temporary-file-directory)) + "Palce all backup files in `temporary-file-directory'.") + +(defvar oni:mailbox-map + '("top" ("menu" + ("ryulash.org" . "ryuslash") + ("ninthfloor" . "ninthfloor") + ("gmail" . "gmail") + ("aethon" . "aethon"))) + "A mailbox map for use with `tmm-prompt'.") (provide 'oni) ;;; oni.el ends here diff --git a/.emacs.d/site-lisp/org-init.el b/.emacs.d/site-lisp/org-init.el index 23ae6a5..4033c30 100644 --- a/.emacs.d/site-lisp/org-init.el +++ b/.emacs.d/site-lisp/org-init.el @@ -30,16 +30,73 @@ (require 'org-habit) (require 'org-protocol) +(autoload 'org-clocking-p "org-clock") + (eval-after-load "org-crypt" '(org-crypt-use-before-save-magic)) +(defun oni:note-template () + (concat + "* %<%c>\n" + " :DIRECTORY: =" default-directory "=\n" + (when (buffer-file-name) " :FILE: [[file:%F][%F]]\n") + (when (org-clocking-p) " :TASK: %K\n") + "\n %?")) + +(defun oni:org-maybe-outline-path () + (let ((outline-path (org-format-outline-path (org-get-outline-path)))) + (unless (string= outline-path "") + (setq outline-path (concat "[ " outline-path " ] "))) + outline-path)) + +(defun oni:set-org-agenda-files () + "Set `org-agenda-files` according to the current time." + (interactive) + (let* ((current-time (decode-time)) + (current-hour (nth 2 current-time)) + (current-dow (nth 6 current-time))) + (if (or (= current-dow 6) (= current-dow 0) ; Saturday or Sunday + (< current-hour 9) (>= current-hour 17)) + (setq org-agenda-files + (append oni:personal-agenda-files oni:common-agenda-files)) + (setq org-agenda-files + (append oni:work-agenda-files oni:common-agenda-files))))) + +(defvar oni:personal-agenda-files + (list (expand-file-name "~/documents/org/tasks")) + "My personal agenda, should only show up at times I don't have + to work.") + +(defvar oni:work-agenda-files + (list (expand-file-name "~/documents/org/work")) + "My work agenda, should only show up at times I work.") + +(defvar oni:common-agenda-files + (list (expand-file-name "~/documents/org/dailies") + (expand-file-name "~/documents/org/misc/contacts.org") + (expand-file-name "~/documents/org/misc/bookmarks.org")) + "Agenda files that are work-agnostic, should always show up.") + (setq org-agenda-custom-commands - '(("w" "Work todo." tags-todo "work"))) + '(("P" . "Personal only") + ("Pa" "Personal agenda" agenda "" + ((org-agenda-files (append oni:personal-agenda-files + oni:common-agenda-files)))) + ("Pt" "Personal todo" todo "" + ((org-agenda-files (append oni:personal-agenda-files + oni:common-agenda-files)))) + ("W" . "Work only") + ("Wa" "Work agenda" agenda "" + ((org-agenda-files (append oni:work-agenda-files + oni:common-agenda-files)))) + ("Wt" "Work todo" todo "" + ((org-agenda-files (append oni:work-agenda-files + oni:common-agenda-files)))))) (setq org-agenda-prefix-format '((agenda . " %i %-12:c%?-12t% s") (timeline . " % s") - (todo . " %i %-12:c %(concat \"[ \"(org-format-outline-path (org-get-outline-path)) \" ]\") ") - (tags . " %i %-12:c %(concat \"[ \"(org-format-outline-path (org-get-outline-path)) \" ]\") ") + (todo . " %i %-12:c %(oni:org-maybe-outline-path)") + (tags . " %i %-12:c %(oni:org-maybe-outline-path)") (search . " %i %-12:c"))) (setq org-agenda-sorting-strategy '((agenda habit-down time-up priority-down category-keep) @@ -47,23 +104,19 @@ (tags priority-down category-keep) (search category-keep))) (setq org-agenda-tags-column -101) +(setq org-directory (expand-file-name "~/documents/org")) +(setq org-default-notes-file (concat org-directory "/org")) (setq org-capture-templates - '(("t" "Task" entry (file "~/documents/org/tasks") + `(("t" "Task" entry (file "~/documents/org/tasks") "* TODO %?") ("T" "Linked task" entry (file "~/documents/org/tasks") - "* TODO %?\n\n %a"))) + "* TODO %?\n\n %a") + ("n" "General note" entry (file ,org-default-notes-file) + (function oni:note-template)))) (setq org-contacts-files '("~/documents/org/misc/contacts.org")) -(setq org-directory (expand-file-name "~/documents/org")) -(setq org-agenda-files - (append - `(,(concat org-directory "/tasks") - ,(concat org-directory "/misc/contacts.org") - ,(concat org-directory "/misc/bookmarks.org")) - org-agenda-files)) (setq org-agenda-show-outline-path nil) (setq org-agenda-todo-ignore-deadlines 'far) (setq org-agenda-todo-ignore-scheduled t) -(setq org-default-notes-file (concat org-directory "/org")) (setq org-export-htmlize-output-type 'css) (setq org-feed-alist '(("MyEpisodes" @@ -103,5 +156,9 @@ (org-agenda-to-appt) (ad-activate 'org-agenda-redo) +(oni:set-org-agenda-files) +(run-at-time "09:01" (* 60 60 24) 'oni:set-org-agenda-files) +(run-at-time "17:01" (* 60 60 24) 'oni:set-org-agenda-files) + (provide 'org-init) ;;; org-init.el ends here |