From b55e180c1f5e3f46badf6d237bee92998e64602a Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 31 Dec 2013 03:19:05 +0100 Subject: Rename functions --- .emacs.d/init.el | 147 +++++++++++++++++++++++++++---------------------------- 1 file changed, 72 insertions(+), 75 deletions(-) (limited to '.emacs.d/init.el') diff --git a/.emacs.d/init.el b/.emacs.d/init.el index bb57d6c..05f4058 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -113,7 +113,7 @@ MODE1 is enabled and vice-versa." (defmacro oni:stumpwm (&rest body) "Execute BODY in stumpwm." (declare (indent 0)) - `(call-process oni:init-stumpish-program nil nil nil + `(call-process oni:stumpish-program nil nil nil ,(format "eval '%S'" `(progn ,@body)))) (defmacro oni:turn-off (&rest modes) @@ -123,7 +123,7 @@ MODE1 is enabled and vice-versa." ;;;; Variables -(defvar oni:init-stumpish-program +(defvar oni:stumpish-program (expand-file-name "~/.local/share/quicklisp/local-projects/stumpwm/contrib/stumpish") "The location of the stumpish executable.") @@ -159,7 +159,7 @@ MODE1 is enabled and vice-versa." new-time appt-msg min-to-app) nil) (appt-disp-window min-to-app new-time appt-msg)) -(defun init-augment-sql-prompt () +(defun oni:augment-sql-prompt () "Add the MariaDB prompt to the `sql-prompt-regexp'." (if (eq sql-product 'mysql) (setq sql-prompt-regexp @@ -180,7 +180,7 @@ MODE1 is enabled and vice-versa." (local-set-key [f9] 'compile) (local-set-key "\C-j" 'oni:newline-and-indent)) -(defun change-number-at-point (change-func) +(defun oni:change-number-at-point (change-func) "Use CHANGE-FUNC to change the number at `point'." (let ((num (number-to-string (funcall change-func (number-at-point)))) (bounds (bounds-of-thing-at-point 'word))) @@ -228,10 +228,10 @@ MODE1 is enabled and vice-versa." *jabber-current-status*) "Online")) -(defun decrease-number-at-point () +(defun oni:decrease-number-at-point () "Take the number at `point' and replace it with it decreased by 1." (interactive) - (change-number-at-point #'1-)) + (oni:change-number-at-point #'1-)) (defun oni:diary-display-func () "Function for `diary-display-hook'." @@ -241,7 +241,7 @@ MODE1 is enabled and vice-versa." (interactive "p") (oni:change-prev-case num 'down)) -(defun enable (functions) +(defun oni:enable (functions) "Set the `disabled' property for each item in FUNCTIONS to nil." (mapc #'(lambda (f) (put f 'disabled nil)) functions)) @@ -254,7 +254,7 @@ MODE1 is enabled and vice-versa." 'action (lambda (button) (browse-url (button-label button))))))) -(defun oni-eshell-prompt () +(defun oni:eshell-prompt () "Show a pretty shell prompt." (let ((status (if (zerop eshell-last-command-status) ?+ ?-))) (concat @@ -273,10 +273,10 @@ MODE1 is enabled and vice-versa." "Function for `haskell-mode-hook'." (turn-on-haskell-indentation)) -(defun increase-number-at-point () +(defun oni:increase-number-at-point () "Take the number at `point' and replace it with it increased by 1." (interactive) - (change-number-at-point #'1+)) + (oni:change-number-at-point #'1+)) (defun indent-defun () "Indent the current defun." @@ -326,7 +326,7 @@ If COUNT has been specified indent by that much, otherwise look at (setq count tab-width)) (indent-rigidly start end count))) -(defun init-eshell-C-d () +(defun oni:eshell-C-d () "Either call `delete-char' interactively or quit." (interactive) (condition-case err @@ -348,12 +348,12 @@ If COUNT has been specified indent by that much, otherwise look at "Function for `js2-mode-hook'." (oni:js-mode-func)) -(defun level (lst) +(defun oni:level (lst) "Reduce a 2-level list LST to a flat list." (let ((lsts (mapcar (lambda (l) (if (listp l) l (list l))) lst))) (apply #'append lsts))) -(defun init-locally-enable-double-spaces () +(defun oni:locally-enable-double-spaces () "Specify that two spaces end a sentence in the current buffer." (setq-local sentence-end-double-space t)) @@ -363,7 +363,7 @@ If COUNT has been specified indent by that much, otherwise look at (local-unset-key (kbd "]")) (local-unset-key (kbd "}"))) -(defun init-make-readable () +(defun oni:make-readable () "Make non-programming buffers a little more readable." (setq line-spacing .2)) @@ -371,7 +371,7 @@ If COUNT has been specified indent by that much, otherwise look at "Function for `markdown-mode-hook'." (setq-local whitespace-style '(face trailing))) -(defun init-maybe-fci-mode () +(defun oni:maybe-fci-mode () "Turn on `fci-mode' if there is a filename for the buffer." (when (buffer-file-name) (fci-mode))) @@ -417,7 +417,7 @@ extracts the parts I want to know about." (format "[%s - %s]" band title)) song))) -(defun move-beginning-of-dwim () +(defun oni:move-beginning-of-dwim () "Move to beginning of line either after indentation or before." (interactive) (let ((start (point))) @@ -498,7 +498,7 @@ When dealing with braces, add another line and indent that too." (switch-to-buffer buffer) (ansi-term (getenv "SHELL"))))) -(defun raise-eshell () +(defun oni:raise-eshell () "Start or switch back to `eshell'. Also change directories to current working directory." @@ -536,7 +536,7 @@ use. If MODE is not nil, open a new buffer with the name (select-window (display-buffer buffer)))) -(defun reload-buffer () +(defun oni:reload-buffer () "Reload current buffer." (interactive) (revert-buffer nil t nil)) @@ -624,11 +624,11 @@ insert at the end of the region and at the beginning." (self-insert-command 1))) (self-insert-command 1))) -(defun set-emacs-lisp-keys () +(defun oni:set-emacs-lisp-keys () "Set some keys for `emacs-lisp-mode'." (local-set-key (kbd "C-.") 'find-function)) -(defun init-set-emacs-lisp-symbols () +(defun oni:set-emacs-lisp-symbols () "Set a few extra UTF-8 symbols for use in emacs-lisp." (when (boundp 'prettify-symbols-alist) (setq prettify-symbols-alist @@ -638,34 +638,34 @@ insert at the end of the region and at the beginning." ("sqrt" . ?√)))))) -(defun init-set-keys-for-dired () +(defun oni:set-keys-for-dired () "Set somee keybindings for `dired'." (local-set-key (kbd "E") #'wdired-change-to-wdired-mode)) -(defun init-set-keys-for-eshell () +(defun oni:set-keys-for-eshell () "Set some keybindings for `eshell'." - (local-set-key (kbd "C-d") #'init-eshell-C-d)) + (local-set-key (kbd "C-d") #'oni:eshell-C-d)) -(defun init-set-keys-for-hy () +(defun oni:set-keys-for-hy () "Set some keybindings for `hy-mode'." (local-set-key (kbd "{") #'paredit-open-curly) (local-set-key (kbd "}") #'paredit-close-curly)) -(defun init-set-keys-for-jabber-chat () +(defun oni:set-keys-for-jabber-chat () "Set certain keys for `jabber-chat-mode'." (local-set-key (kbd "M-!") #'shell-command-with-command)) -(defun init-set-keys-for-tagedit () +(defun oni:set-keys-for-tagedit () "Set some keybindings for `tagedit-mode'." (local-set-key (kbd "M-k") #'tagedit-kill-attribute)) -(defun init-set-python-imenu-function () +(defun oni:set-python-imenu-function () "Set the `imenu-create-index-function' variable. For `python-mode' I prefer `python-imenu-create-flat-index'." (setq imenu-create-index-function #'python-imenu-create-flat-index)) -(defun init-set-python-symbols () +(defun oni:set-python-symbols () "Set a few extra UTF-8 symbols for use in python." (when (boundp 'prettify-symbols-alist) (setq prettify-symbols-alist @@ -674,7 +674,7 @@ For `python-mode' I prefer `python-imenu-create-flat-index'." (">=" . ?≥) ("!=" . ?≠))))) -(defun set-smartparens-keys () +(defun oni:set-smartparens-keys () "Set some keys for `smartparens-mode'." (local-set-key [remap backward-delete-char] 'sp-backward-delete-char) (local-set-key [remap delete-char] 'sp-delete-char) @@ -685,7 +685,7 @@ For `python-mode' I prefer `python-imenu-create-flat-index'." (local-set-key (kbd "M-J") 'sp-join-sexp) (local-set-key (kbd "M-S") 'sp-split-sexp)) -(defun init-set-tab-maybe-toggle-outline () +(defun oni:set-tab-maybe-toggle-outline () "Wrap the current function mapped to `TAB'." (let ((func (or (lookup-key (current-local-map) (kbd "TAB")) (lookup-key (current-global-map) (kbd "TAB"))))) @@ -700,17 +700,17 @@ For `python-mode' I prefer `python-imenu-create-flat-index'." (let ((theme (if (equal system-name "drd") 'yoshi 'leuven))) (let ((setp (not (daemonp)))) - (defun init-set-theme (frame) + (defun oni:set-theme (frame) "Try to set the theme for the current (first) frame." (ignore frame) (unless setp (run-at-time .1 nil (lambda () (setq setp (load-theme theme t))))))) (if (daemonp) - (add-hook 'after-make-frame-functions #'init-set-theme) + (add-hook 'after-make-frame-functions #'oni:set-theme) (oni:eval-after-init (load-theme theme t)))) -(defun shell-command-with-command (command &optional output-buffer) +(defun oni:shell-command-with-command (command &optional output-buffer) "Print both COMMAND and the output into OUTPUT-BUFFER." (interactive (list (read-shell-command "Shell command: " nil nil) current-prefix-arg)) @@ -734,7 +734,7 @@ For `python-mode' I prefer `python-imenu-create-flat-index'." (interactive) (find-file "~/documents/org/index.org")) -(defun sort-imports () +(defun oni:sort-imports () "Sort python multiline imports using `()'." (interactive) (save-excursion @@ -775,11 +775,11 @@ If no direction is given, don't split." (interactive) (kill-process "python-test-mail-server")) -(defun stumpwm-command (cmd) +(defun oni:stumpwm-command (cmd) "Execute CMD in stumpwm." - (call-process oni:init-stumpish-program nil nil nil cmd)) + (call-process oni:stumpish-program nil nil nil cmd)) -(defun init-switch-to-other-buffer () +(defun oni:switch-to-other-buffer () "Switch to the most recently viewed buffer." (interactive) (switch-to-buffer (other-buffer))) @@ -788,7 +788,7 @@ If no direction is given, don't split." "Function for `term-mode-hook'." (setq truncate-lines nil)) -(defun turn-on-compilation-shell-for-pony () +(defun oni:turn-on-compilation-shell-for-pony () "Turn on option `compilation-shell-minor-mode' for `pony-minor-mode'." (add-hook 'pony-minor-mode-hook 'compilation-shell-minor-mode nil t)) @@ -813,16 +813,12 @@ If no direction is given, don't split." ;;;;; Macro support (eval-and-compile - (defun loadpath-add-and-autoload (path) + (defun oni:loadpath-add-and-autoload (path) "Add PATH to `load-path' and load a `loaddefs.el' if it exists." (add-to-list 'load-path path) (let ((loaddefs (concat path "/loaddefs.el"))) (when (file-exists-p loaddefs) - (load loaddefs)))) - - (defun make-mode-hook-name (mode) - "Get the hook name for MODE." - (intern (concat (symbol-name mode) "-mode-hook")))) + (load loaddefs))))) ;;;;; Advice @@ -837,11 +833,12 @@ If no direction is given, don't split." (kill-buffer (current-buffer))) (defadvice windmove-do-window-select - (around init-windmove-stumpwm activate) + (around oni:windmove-stumpwm activate) "If no window can be moved to, move stumpwm." (condition-case err ad-do-it - (error (stumpwm-command (format "move-focus %s" (ad-get-arg 0)))))) + (error (oni:stumpwm-command + (format "move-focus %s" (ad-get-arg 0)))))) ;;;; Aliases @@ -851,7 +848,7 @@ If no direction is given, don't split." ;;;; Load path (eval-and-compile - (mapc #'loadpath-add-and-autoload + (mapc #'oni:loadpath-add-and-autoload '("~/.emacs.d/site-lisp" "~/projects/emacs/pony-mode/src" "~/.emacs.d/vendor-lisp/org/lisp" "~/.emacs.d/vendor-lisp/org/contrib/lisp" @@ -973,7 +970,7 @@ If no direction is given, don't split." (add-to-list 'desktop-globals-to-clear 'desktop-dirname)) (stante-after dired - (add-hook 'dired-mode-hook #'init-set-keys-for-dired)) + (add-hook 'dired-mode-hook #'oni:set-keys-for-dired)) (stante-after eap (setq eap-music-library "/mnt/music") @@ -991,7 +988,7 @@ If no direction is given, don't split." (stante-after em-prompt (setq eshell-highlight-prompt nil) - (setq eshell-prompt-function 'oni-eshell-prompt) + (setq eshell-prompt-function 'oni:eshell-prompt) (setq eshell-prompt-regexp "^[+-]> ")) (stante-after em-term @@ -1213,15 +1210,15 @@ If no direction is given, don't split." (add-hook 'after-save-hook 'oni:after-save-func t) (add-hook 'before-save-hook 'oni:before-save-func) -(add-hook 'comint-mode-hook #'turn-on-compilation-shell-for-pony) +(add-hook 'comint-mode-hook #'oni:turn-on-compilation-shell-for-pony) (add-hook 'diary-display-hook 'oni:diary-display-func) (add-hook 'haskell-mode-hook 'oni:haskell-mode-func) (add-hook 'java-mode-hook 'oni:java-mode-func) (add-hook 'org-mode-hook #'yas-minor-mode) -(add-hook 'outline-minor-mode-hook #'init-set-tab-maybe-toggle-outline) +(add-hook 'outline-minor-mode-hook #'oni:set-tab-maybe-toggle-outline) (add-hook 'slime-mode-hook #'set-up-slime-ac) -(add-hook 'smartparens-mode-hook #'set-smartparens-keys) -(add-hook 'sql-interactive-mode-hook #'init-augment-sql-prompt) +(add-hook 'smartparens-mode-hook #'oni:set-smartparens-keys) +(add-hook 'sql-interactive-mode-hook #'oni:augment-sql-prompt) (add-hook 'term-mode-hook 'oni:term-mode-func) (add-hook 'vala-mode-hook #'oni:vala-mode-func) (add-hook 'write-file-hooks 'oni:write-file-func) @@ -1231,7 +1228,7 @@ If no direction is given, don't split." 'perl-mode-hook 'rst-mode-hook 'ruby-mode-hook 'rust-mode-hook 'sh-mode-hook) -(oni:add-function-to-hooks #'init-make-readable +(oni:add-function-to-hooks #'oni:make-readable 'Info-mode-hook 'gnus-article-mode-hook 'gnus-group-mode-hook 'gnus-summary-mode-hook 'org-agenda-mode-hook) @@ -1246,27 +1243,27 @@ If no direction is given, don't split." #'oni:css-mode-func #'rainbow-mode) (oni:add-hooks 'emacs-lisp-mode-hook - #'init-locally-enable-double-spaces #'init-set-emacs-lisp-symbols - #'paredit-mode #'flycheck-mode #'eldoc-mode #'set-emacs-lisp-keys) + #'oni:locally-enable-double-spaces #'oni:set-emacs-lisp-symbols + #'paredit-mode #'flycheck-mode #'eldoc-mode #'oni:set-emacs-lisp-keys) (oni:add-hooks 'eshell-mode-hook - #'buffer-disable-undo #'init-set-keys-for-eshell) + #'buffer-disable-undo #'oni:set-keys-for-eshell) (oni:add-hooks 'go-mode-hook #'oni:go-mode-func #'flycheck-mode) (oni:add-hooks 'html-mode-hook - #'flycheck-mode #'yas-minor-mode #'init-maybe-fci-mode #'tagedit-mode + #'flycheck-mode #'yas-minor-mode #'oni:maybe-fci-mode #'tagedit-mode #'turn-off-flyspell #'turn-off-auto-fill) (oni:add-hooks 'hy-mode-hook - #'paredit-mode #'init-set-keys-for-hy) + #'paredit-mode #'oni:set-keys-for-hy) (oni:add-hooks 'ielm-mode-hook - #'paredit-mode #'eldoc-mode #'set-emacs-lisp-keys) + #'paredit-mode #'eldoc-mode #'oni:set-emacs-lisp-keys) (oni:add-hooks 'jabber-chat-mode-hook - #'init-set-keys-for-jabber-chat #'init-make-readable) + #'oni:set-keys-for-jabber-chat #'oni:make-readable) (oni:add-hooks 'js-mode-hook #'moz-minor-mode #'oni:js-mode-func) @@ -1276,7 +1273,7 @@ If no direction is given, don't split." #'moz-minor-mode) (oni:add-hooks 'lisp-mode-hook - #'init-set-emacs-lisp-symbols #'paredit-mode) + #'oni:set-emacs-lisp-symbols #'paredit-mode) (oni:add-hooks 'lua-mode-hook #'oni:lua-mode-func #'flycheck-mode) @@ -1288,23 +1285,23 @@ If no direction is given, don't split." #'oni:php-mode-func #'flycheck-mode) (oni:add-hooks 'prog-mode-hook - #'oni:prog-mode-func #'yas-minor-mode #'init-maybe-fci-mode + #'oni:prog-mode-func #'yas-minor-mode #'oni:maybe-fci-mode #'rainbow-delimiters-mode #'oni:maybe-prettify-symbols-mode) (oni:add-hooks 'python-mode-hook - #'init-set-python-symbols #'oni:python-mode-func #'flycheck-mode + #'oni:set-python-symbols #'oni:python-mode-func #'flycheck-mode #'smartparens-strict-mode #'whitespace-mode - #'init-set-python-imenu-function #'jedi:setup #'subword-mode) + #'oni:set-python-imenu-function #'jedi:setup #'subword-mode) (oni:add-hooks 'slime-repl-mode-hook #'paredit-mode #'set-up-slime-ac) (oni:add-hooks 'tagedit-mode-hook #'tagedit-add-experimental-features - #'tagedit-add-paredit-like-keybindings #'init-set-keys-for-tagedit) + #'tagedit-add-paredit-like-keybindings #'oni:set-keys-for-tagedit) (oni:add-hooks 'text-mode-hook - #'auto-fill-mode #'flyspell-mode #'init-make-readable) + #'auto-fill-mode #'flyspell-mode #'oni:make-readable) ;;;; Keybindings @@ -1312,13 +1309,13 @@ If no direction is given, don't split." (global-set-key (kbd "") 'oni:raise-scratch) (global-set-key (kbd "") 'gnus) (global-set-key (kbd "") 'git-project-show-files) -(global-set-key (kbd "") 'reload-buffer) +(global-set-key (kbd "") #'oni:reload-buffer) (global-set-key (kbd "") 'magit-status) -(global-set-key (kbd "") 'raise-eshell) +(global-set-key (kbd "") #'oni:raise-eshell) (global-set-key (kbd "") 'oni:show-org-index) (global-set-key (kbd "") 'oni:scroll-up-or-next-page) (global-set-key (kbd "") 'oni:scroll-down-or-prev-page) -(global-set-key (kbd "C-. C-.") #'init-switch-to-other-buffer) +(global-set-key (kbd "C-. C-.") #'oni:switch-to-other-buffer) (global-set-key (kbd "C-<") 'oni:indent-shift-left) (global-set-key (kbd "C->") 'oni:indent-shift-right) (global-set-key (kbd "C-M-4") 'split-window-vertically) @@ -1328,8 +1325,8 @@ If no direction is given, don't split." (global-set-key (kbd "C-M-x") 'smex-major-mode-commands) (global-set-key (kbd "C-M-z") 'indent-defun) (global-set-key (kbd "C-S-k") 'kill-whole-line) -(global-set-key (kbd "C-c +") #'increase-number-at-point) -(global-set-key (kbd "C-c -") #'decrease-number-at-point) +(global-set-key (kbd "C-c +") #'oni:increase-number-at-point) +(global-set-key (kbd "C-c -") #'oni:decrease-number-at-point) (global-set-key (kbd "C-c Q") #'delete-other-windows) (global-set-key (kbd "C-c R") #'delete-window) (global-set-key (kbd "C-c S") #'split-window-right) @@ -1362,7 +1359,7 @@ If no direction is given, don't split." (global-set-key (kbd "M-o") 'other-window) (global-set-key (kbd "M-x") 'smex) (global-set-key (kbd "\"") 'oni:self-insert-dwim) -(global-set-key [remap move-beginning-of-line] 'move-beginning-of-dwim) +(global-set-key [remap move-beginning-of-line] #'oni:move-beginning-of-dwim) (if (daemonp) (global-set-key "\C-x\C-c" 'oni:close-client-window)) @@ -1372,8 +1369,8 @@ If no direction is given, don't split." ;;;; Misc modes -(enable '(downcase-region narrow-to-page narrow-to-region scroll-left - upcase-region)) +(oni:enable '(downcase-region narrow-to-page narrow-to-region scroll-left + upcase-region)) (oni:turn-off menu-bar-mode scroll-bar-mode tool-bar-mode blink-cursor-mode -- cgit v1.2.3-54-g00ecf