summaryrefslogtreecommitdiffstats
path: root/emacs/site-lisp
diff options
context:
space:
mode:
Diffstat (limited to 'emacs/site-lisp')
-rw-r--r--emacs/site-lisp/Makefile2
-rw-r--r--emacs/site-lisp/dzen.el1
-rw-r--r--emacs/site-lisp/ext.el7
-rw-r--r--emacs/site-lisp/oni.el165
-rw-r--r--emacs/site-lisp/org-init.el9
5 files changed, 71 insertions, 113 deletions
diff --git a/emacs/site-lisp/Makefile b/emacs/site-lisp/Makefile
index bf452e9..91ee32e 100644
--- a/emacs/site-lisp/Makefile
+++ b/emacs/site-lisp/Makefile
@@ -1,4 +1,4 @@
-DESTDIR:=$(DESTDIR)/site-lisp
+SUBDIR=site-lisp
objects=dzen.elc dzen.el eltuki.elc eltuki.el ext.elc ext.el \
metalexpress.elc metalexpress.el mu4e-init.elc mu4e-init.el \
oni.elc oni.el org-init.elc org-init.el quick-edit-mode.elc \
diff --git a/emacs/site-lisp/dzen.el b/emacs/site-lisp/dzen.el
index d946458..da83099 100644
--- a/emacs/site-lisp/dzen.el
+++ b/emacs/site-lisp/dzen.el
@@ -25,6 +25,7 @@
;;; Code:
(require 'newst-backend)
+(require 'sawfish)
(defvar dzen-process nil
"Dzen2's process.")
diff --git a/emacs/site-lisp/ext.el b/emacs/site-lisp/ext.el
index eb84a3f..9bfbe34 100644
--- a/emacs/site-lisp/ext.el
+++ b/emacs/site-lisp/ext.el
@@ -38,6 +38,13 @@
buffer-file-name))))
(list "pycheck.sh" (list local-file))))
+(defun ext:indent-defun ()
+ "Indent the current defun."
+ (interactive)
+ (save-excursion
+ (mark-defun)
+ (indent-region (region-beginning) (region-end))))
+
(defun ext:reload-buffer ()
"Reload current buffer."
(interactive)
diff --git a/emacs/site-lisp/oni.el b/emacs/site-lisp/oni.el
index cf73ac1..b90bd4a 100644
--- a/emacs/site-lisp/oni.el
+++ b/emacs/site-lisp/oni.el
@@ -34,6 +34,15 @@ DOT are intentionally being skipped."
(concat (symbol-name user) "@" (symbol-name host) "."
(symbol-name com)))
+(defmacro oni:eval-after-init (&rest body)
+ "Defer execution of BODY until after Emacs init.
+
+ Some functionality is dependent on code loaded by package.el.
+ Instead of requiring package.el to load very early on, have some
+ functionality deferred to a point after Emacs has initialized and
+ package.el is loaded anyway."
+ `(add-hook 'emacs-startup-hook #'(lambda () ,@body)))
+
(defun oni:after-save-func ()
"Function for `after-save-hook'."
(oni:compile-el)
@@ -66,6 +75,13 @@ DOT are intentionally being skipped."
(local-set-key [f9] 'compile)
(local-set-key "\C-j" 'oni:newline-and-indent))
+(defun oni:change-prev-case (num dir)
+ (let ((regfunc (if (eq dir 'up) 'upcase-region 'downcase-region))
+ (wordfunc (if (eq dir 'up) 'upcase-word 'downcase-word)))
+ (if (> num 1)
+ (funcall regfunc (point) (- (point) num))
+ (funcall wordfunc -1))))
+
(defun oni:close-client-window ()
"Close a client's frames."
(interactive)
@@ -86,8 +102,7 @@ DOT are intentionally being skipped."
(defun oni:css-mode-func ()
"Function for `css-mode-hook'."
- (local-set-key "\C-j" 'oni:newline-and-indent)
- (rainbow-mode))
+ (local-set-key "\C-j" 'oni:newline-and-indent))
(defun oni:current-jabber-status ()
"Return a string representing the current jabber status."
@@ -100,9 +115,9 @@ DOT are intentionally being skipped."
"Function for `diary-display-hook'."
(diary-fancy-display))
-(defun oni:emacs-lisp-mode-func ()
- "Function for `emacs-lisp-mode-hook'."
- (eldoc-mode))
+(defun oni:downcase-prev (num)
+ (interactive "p")
+ (oni:change-prev-case num 'down))
(defun oni:emacs-startup-func ()
"Function for `emacs-init-hook'."
@@ -123,11 +138,9 @@ DOT are intentionally being skipped."
"Function for `haskell-mode-hook'."
(turn-on-haskell-indentation))
-(defun oni:html-mode-func ()
- "Function for `html-mode-hook'."
- (yas-minor-mode)
- (fci-mode)
- (flycheck-mode))
+(defun oni:hostname ()
+ "Get the current machine's hostname."
+ (substring (shell-command-to-string "hostname") 0 -1))
(defun oni:indent-shift-left (start end &optional count)
"Rigidly indent region.
@@ -174,10 +187,6 @@ If COUNT has been specified indent by that much, otherwise look at
(notifications-notify :title title
:body text))
-(defun oni:jabber-chat-mode-func ()
- "Function for `jabber-chat-mode-hook'."
- (visual-line-mode))
-
(defun oni:jabber-roster-mode-func ()
"Function for `jabber-roster-mode-hook'."
(setq mode-line-format
@@ -189,68 +198,22 @@ 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))
(defun oni:js2-mode-func ()
"Function for `js2-mode-hook'."
- (oni:prog-mode-func)
(oni:js-mode-func)
- (local-set-key (kbd "<f5>") #'slime-js-reload)
- (slime-js-minor-mode))
-
-(defun oni:kill-region-or-backward-char ()
- "Either `kill-region' or `backward-delete-char-untabify'."
- (interactive)
- (if (region-active-p)
- (kill-region (region-beginning) (region-end))
- (backward-delete-char-untabify 1)))
-
-(defun oni:kill-region-or-forward-char ()
- "Either `kill-region' or `delete-forward-char'."
- (interactive)
- (if (region-active-p)
- (kill-region (region-beginning) (region-end))
- (delete-forward-char 1)))
-
-(defun oni:kill-region-or-line ()
- "Either `kill-region' or `kill-line'."
- (interactive)
- (if (region-active-p)
- (kill-region (region-beginning) (region-end))
- (kill-line)))
+ (local-set-key (kbd "<f5>") #'slime-js-reload))
(defun oni:lua-mode-func()
"Function for `lua-mode-hook'."
(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'."
- (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))
+ (local-unset-key (kbd "}")))
(defun oni:markdown-mode-func ()
"Function for `markdown-mode-hook'."
- (setq-local comment-auto-fill-only-comments nil)
- (setq-local whitespace-style '(face trailing))
- (auto-fill-mode)
- (whitespace-mode))
-
-(defun oni:message-mode-func ()
- "Function for `message-mode-hook'."
- (setq-local comment-auto-fill-only-comments nil)
- (auto-fill-mode)
- (flyspell-mode))
+ (setq-local whitespace-style '(face trailing)))
(defun oni:mini-fix-timestamp-string (date-string)
"A minimal version of Xah Lee's `fix-timestamp-string'.
@@ -276,6 +239,20 @@ code. Found at http://xahlee.org/emacs/elisp_parse_time.html"
(match-string 2 date-string)
(match-string 1 date-string)))
+(defun oni:mode-line-current-song ()
+ "Extract current song information from a path.
+
+EMMS only shows me the absolute path of a song, this function
+extracts the parts I want to know about."
+ (let* ((song (emms-track-name (emms-playlist-current-selected-track)))
+ (matchp (string-match "\\([^/]+\\)/\\([0-9]\\{4\\}\\) - \\(.+\\)/\\([0-9]\\{2,3\\}\\) - \\(.+\\)\\..\\{3,4\\}$" song))
+ (band (substring song (match-beginning 1) (match-end 1)))
+ (year (substring song (match-beginning 2) (match-end 2)))
+ (album (substring song (match-beginning 3) (match-end 3)))
+ (track (substring song (match-beginning 4) (match-end 4)))
+ (title (substring song (match-beginning 5) (match-end 5))))
+ (format "[%s - %s]" band title)))
+
(defun oni:move-beginning-of-dwim ()
"Move to beginning of line either after indentation or before."
(interactive)
@@ -328,44 +305,25 @@ When dealing with braces, add another line and indent that too."
(save-excursion (newline-and-indent)))
(newline-and-indent))
-(defun oni:org-mode-func ()
- "Function for `org-mode-hook'."
- (auto-fill-mode)
- (yas-minor-mode)
- (set (make-local-variable 'comment-auto-fill-only-comments) nil))
-
(defun oni:php-mode-func ()
"Function for `php-mode-hook'."
(local-set-key "\C-j" 'oni:newline-and-indent)
(c-set-offset 'arglist-intro '+)
(c-set-offset 'arglist-close '0)
- (rainbow-delimiters-mode)
- (setq-local fci-rule-column 80)
- (flycheck-mode))
+ (setq-local fci-rule-column 80))
(defun oni:prog-mode-func ()
"Function for `prog-mode-hook'."
- (rainbow-delimiters-mode)
- (fci-mode)
- (yas-minor-mode)
- (auto-fill-mode))
+ (setq-local comment-auto-fill-only-comments t))
(defun oni:python-mode-func ()
"Function for `python-mode-hook'."
- (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)
- (rainbow-delimiters-mode)
(setq fci-rule-column 79
fill-column 72)
- (setq-local whitespace-style '(tab-mark))
- (fci-mode)
- (whitespace-mode))
-
-(defun oni:rainbow-mode-init ()
- "Initialization function for rainbow-mode."
- (diminish 'rainbow-mode))
+ (setq-local whitespace-style '(tab-mark)))
(defun oni:raise-ansi-term (arg)
"Create or show an `ansi-term' buffer."
@@ -437,10 +395,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:rst-mode-func ()
- "Function for `rst-mode-hook'."
- (auto-fill-mode))
-
(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."
@@ -472,10 +426,12 @@ insert at the end of the region and at the beginning."
(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:skip-ex-tag ()
+ (let ((tags (org-entry-get (point) "TAGS")))
+ (when (and tags (string-match-p ":ex:" tags))
+ (save-excursion
+ (org-forward-element)
+ (point)))))
(defun oni:split-window-interactive (dir)
"Split windows in direction DIR.
@@ -515,10 +471,13 @@ If no direction is given, don't split."
"Function for `term-mode-hook'."
(setq truncate-lines nil))
-(defun oni:texinfo-mode-func ()
- "Function for `texinfo-mode-hook'."
- (setq-local comment-auto-fill-only-comments nil)
- (auto-fill-mode))
+(defun oni:upcase-prev (num)
+ (interactive "p")
+ (oni:change-prev-case num 'up))
+
+(defun oni:vala-mode-func ()
+ "Function for `vala-mode-hook'."
+ (setq indent-tabs-mode nil))
(defun oni:write-file-func ()
"Function for `write-file-hooks'."
@@ -530,18 +489,6 @@ If no direction is given, don't split."
(define-key yas-minor-mode-map [(tab)] nil)
(define-key yas-minor-mode-map (kbd "C-\\") 'yas-expand))
-(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")
diff --git a/emacs/site-lisp/org-init.el b/emacs/site-lisp/org-init.el
index 3c698d2..ca822aa 100644
--- a/emacs/site-lisp/org-init.el
+++ b/emacs/site-lisp/org-init.el
@@ -101,10 +101,10 @@
(search . " %i %-12:c")))
(setq org-agenda-sorting-strategy
'((agenda habit-down time-up priority-down category-keep)
- (todo user-defined-down)
+ (todo priority-down user-defined-down)
(tags priority-down category-keep)
(search category-keep)))
-(setq org-agenda-tags-column -101)
+(setq org-agenda-tags-column (1+ (- (window-width))))
(setq org-directory (expand-file-name "~/documents/org"))
(setq org-default-notes-file (concat org-directory "/org"))
(setq org-capture-templates
@@ -112,6 +112,8 @@
"* TODO %?")
("T" "Linked task" entry (file "~/documents/org/tasks")
"* TODO %?\n\n %a")
+ ("a" "Appointment" entry (file "~/documents/org/tasks")
+ "* %?\n SCHEDULED: %^T\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"))
@@ -132,7 +134,7 @@
(setq org-refile-use-outline-path 'file)
(setq org-return-follows-link t)
(setq org-src-fontify-natively t)
-(setq org-tags-column -101)
+(setq org-tags-column (- 70))
(setq org-tags-exclude-from-inheritance '("crypt"))
(setq org-todo-keyword-faces
'(("TODO" :foreground "#ff756e" :background "#171719" :box (:width 1 :color "#282830"))
@@ -146,6 +148,7 @@
("ACQUIRE" :foreground "#ff756e" :background "#171719" :box (:width 1 :color "#282830"))
("IGNORED" :foreground "#999999" :background "#222224" :box (:width 1 :color "#333335"))))
(setq org-use-fast-todo-selection t)
+(setq org-agenda-skip-function-global 'oni:skip-ex-tag)
(setq org-use-property-inheritance '("slug"))
(add-hook 'org-agenda-mode-hook 'org-agenda-to-appt)