From 9786d89c93a1657c715fca0c8e10f09f19b4469d Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Wed, 3 Apr 2013 01:54:52 +0200 Subject: [PATCH] Emacs: Add case functions, vala-mode change Add some functions that may help me managing case for enums and such. For some reason vala-mode really likes having indent-tabs-mode turned on, but I prefer it off anyway. --- emacs/init.org | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/emacs/init.org b/emacs/init.org index db69785..a127d78 100644 --- a/emacs/init.org +++ b/emacs/init.org @@ -552,6 +552,42 @@ buffer hanging around. (kill-buffer (current-buffer))))) #+END_SRC +I don't have a capslock key on my keyboard, and sometimes it's +annoying to have to hold my shift key for long enums and such. The +idea is to type everything except regular caps in lower case and then +use these functions to fix them. + +#+BEGIN_SRC emacs-lisp + (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:upcase-prev (num) + (interactive "p") + (oni:change-prev-case num 'up)) + + (defun oni:downcase-prev (num) + (interactive "p") + (oni:change-prev-case num 'down)) + + (global-set-key (kbd "C-c u") 'oni:upcase-prev) + (global-set-key (kbd "C-c d") 'oni:downcase-prev) +#+END_SRC + +For some reason, =vala-mode= turns on =indent-tabs-mode=, I don't like +that. + +#+BEGIN_SRC emacs-lisp + (defun oni:vala-mode-func () + "Function for `vala-mode-hook'." + (setq indent-tabs-mode nil)) + + (add-hook 'vala-mode-hook 'oni:vala-mode-func) +#+END_SRC + #+BEGIN_SRC emacs-lisp (eval-after-load "rainbow-mode" '(oni:rainbow-mode-init)) (eval-after-load "smex" '(oni:smex-init))