summaryrefslogtreecommitdiffstats
path: root/.emacs.d/site-lisp/oni.el
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2013-02-15 15:37:42 +0100
committerGravatar Tom Willemsen2013-02-15 15:37:42 +0100
commit934d02bcacaa5d0aef64a8edf7677f3b0c198666 (patch)
treeedfc842025b5f8569973567b44ad62aa662f548f /.emacs.d/site-lisp/oni.el
parent06ff316f7f3b098504a6342651a79017cfb80ae7 (diff)
parentee34dfcc2c2fec53731b64afca03bb34dd80b2ba (diff)
downloaddotfiles-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/oni.el')
-rw-r--r--.emacs.d/site-lisp/oni.el222
1 files changed, 88 insertions, 134 deletions
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