summaryrefslogtreecommitdiffstats
path: root/emacs
diff options
context:
space:
mode:
authorGravatar Tom Willemse2015-12-17 00:58:26 +0100
committerGravatar Tom Willemse2015-12-17 00:58:26 +0100
commit168bcf9c5804532f4017ccca4d83200cedb7c6b3 (patch)
treeb7fb8b4132cfa79e75f1ab2d0e03adcf964c2ff7 /emacs
parentf65c03208b289bbaf71302279c4a8342896c0f8a (diff)
downloaddotfiles-168bcf9c5804532f4017ccca4d83200cedb7c6b3.tar.gz
dotfiles-168bcf9c5804532f4017ccca4d83200cedb7c6b3.zip
Move editing functions to separate library
Diffstat (limited to 'emacs')
-rw-r--r--emacs/.emacs.d/init.el33
-rw-r--r--emacs/.emacs.d/site-lisp/oni-editing.el66
2 files changed, 66 insertions, 33 deletions
diff --git a/emacs/.emacs.d/init.el b/emacs/.emacs.d/init.el
index ebc59b5..0c0310e 100644
--- a/emacs/.emacs.d/init.el
+++ b/emacs/.emacs.d/init.el
@@ -137,21 +137,6 @@ MODE1 is enabled and vice-versa."
;;;; Functions
-(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)))
- (save-excursion
- (delete-region (car bounds) (cdr bounds))
- (insert num))))
-
-(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:current-jabber-status ()
"Return a string representing the current jabber status."
(or (and (not *jabber-connected*) "Offline")
@@ -159,19 +144,10 @@ MODE1 is enabled and vice-versa."
*jabber-current-status*)
"Online"))
-(defun oni:decrease-number-at-point ()
- "Take the number at `point' and replace it with it decreased by 1."
- (interactive)
- (oni:change-number-at-point #'1-))
-
(defun oni:diary-display-func ()
"Function for `diary-display-hook'."
(diary-fancy-display))
-(defun oni:downcase-prev (num)
- (interactive "p")
- (oni:change-prev-case num 'down))
-
(defun oni:enable (functions)
"Set the `disabled' property for each item in FUNCTIONS to nil."
(mapc #'(lambda (f) (put f 'disabled nil)) functions))
@@ -193,11 +169,6 @@ MODE1 is enabled and vice-versa."
"Function for `haskell-mode-hook'."
(turn-on-haskell-indentation))
-(defun oni:increase-number-at-point ()
- "Take the number at `point' and replace it with it increased by 1."
- (interactive)
- (oni:change-number-at-point #'1+))
-
(defun indent-defun ()
"Indent the current defun."
(interactive)
@@ -657,10 +628,6 @@ If no direction is given, don't split."
"Function for `term-mode-hook'."
(setq truncate-lines nil))
-(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))
diff --git a/emacs/.emacs.d/site-lisp/oni-editing.el b/emacs/.emacs.d/site-lisp/oni-editing.el
new file mode 100644
index 0000000..ff8a155
--- /dev/null
+++ b/emacs/.emacs.d/site-lisp/oni-editing.el
@@ -0,0 +1,66 @@
+;;; oni-editing.el --- General editing commands and functions -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2015 Tom Willemse
+
+;; Author: Tom Willemse <tom@ryuslash.org>
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Here are some general editing functions and commands.
+
+;;; Code:
+
+(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)))
+ (save-excursion
+ (delete-region (car bounds) (cdr bounds))
+ (insert num))))
+
+(defun oni:change-prev-case (num dir)
+ "Change the case of the region or previous word."
+ (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))))
+
+;;;###autoload
+(defun oni:decrease-number-at-point ()
+ "Take the number at `point' and replace it with it decreased by 1."
+ (interactive)
+ (oni:change-number-at-point #'1-))
+
+;;;###autoload
+(defun oni:downcase-prev (num)
+ (interactive "p")
+ (oni:change-prev-case num 'down))
+
+;;;###autoload
+(defun oni:increase-number-at-point ()
+ "Take the number at `point' and replace it with it increased by 1."
+ (interactive)
+ (oni:change-number-at-point #'1+))
+
+;;;###autoload
+(defun oni:upcase-prev (num)
+ (interactive "p")
+ (oni:change-prev-case num 'up))
+
+(provide 'oni-editing)
+;;; oni-editing.el ends here