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.
This commit is contained in:
parent
cce4cd35ea
commit
9786d89c93
1 changed files with 36 additions and 0 deletions
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue