Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

118 lines (97 sloc) 3.15 kb
;;; config-defuns.el --- Functionality used in my configuration.
;;
;; Copyright (C) 2011 Yesudeep Mangalapilly
;;
;; Author: Yesudeep Mangalapilly <yesudeep@gmail.com>
;; Keywords: convenience
;;
;; This file is not a part of GNU Emacs.
;;
;;; License:
;;
;; 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 GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Code:
;; Kill entire line with C-k and use C-S-backspace for killing from beginning
(defun kill-and-join-forward (&optional arg)
"If at end of line, join with following; otherwise kill line.
Deletes whitespace at join."
(interactive "P")
(if (and (eolp) (not (bolp)))
(delete-indentation t)
(kill-line arg)))
;; Line movement --- http://www.emacswiki.org/emacs/MoveLine -- Joe Smith
;; (Paredit breaks line movement. Use autopair.el)
(defun move-line (n)
"Move the current line up or down by N lines."
(interactive "p")
(setq col (current-column))
(beginning-of-line) (setq start (point))
(end-of-line) (forward-char) (setq end (point))
(let ((line-text (delete-and-extract-region start end)))
(forward-line n)
(insert line-text)
;; restore point to original column in moved line
(forward-line -1)
(forward-char col)))
(defun move-line-up (n)
"Move the current line up by N lines."
(interactive "p")
(move-line (if (null n) -1 (- n))))
(defun move-line-down (n)
"Move the current line down by N lines."
(interactive "p")
(move-line (if (null n) 1 n)))
;; Line insertion
(defun insert-empty-line-below ()
(interactive)
(move-end-of-line nil)
(open-line 1)
(next-line 1))
(defun insert-empty-line-above ()
(interactive)
(previous-line 1)
(move-end-of-line nil)
(open-line 1)
(next-line 1)
)
(defun insert-empty-line-below-next-line ()
(interactive)
(next-line 1)
(move-end-of-line nil)
(open-line 1)
(next-line 1)
)
;; Cleaning up indentation and whitespace.
(defun untabify-buffer ()
"Untabify the entire buffer."
(interactive)
(untabify (point-min) (point-max)))
(defun tabify-buffer ()
"Tabify the entire buffer."
(interactive)
(tabify (point-min) (point-max)))
(defun indent-buffer ()
"Properly indent the entire buffer."
(interactive)
(indent-region (point-min) (point-max)))
(defun tidy-buffer ()
"Indent, untabify, and clean up trailing whitespace from a buffer."
(interactive)
(indent-buffer)
(untabify-buffer)
(delete-trailing-whitespace))
(provide 'config-defuns)
;;; config-defuns.el ends here
Jump to Line
Something went wrong with that request. Please try again.