Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: 59dc636a0d
Fetching contributors…

Cannot retrieve contributors at this time

174 lines (143 sloc) 5.49 KB
;; Auto-indent on Paste
(dolist (command '(yank yank-pop))
(eval `(defadvice ,command (after indent-region activate)
(and (not current-prefix-arg)
(member major-mode '(emacs-lisp-mode lisp-mode
clojure-mode scheme-mode
haskell-mode ruby-mode
rspec-mode python-mode
c-mode c++-mode
objc-mode latex-mode
(let ((mark-even-if-inactive transient-mark-mode))
(indent-region (region-beginning) (region-end) nil))))))
;; Insert Hash
(defun insert-hash()
"Inserts a hash into the buffer. Useful for UK keyboard layout users."
(insert "#"))
;; Duplicate Line
;; From:
(defun duplicate-current-line-or-region (arg)
"Duplicates the current line or region ARG times.
If there's no region, the current line will be duplicated. However, if
there's a region, all lines that region covers will be duplicated."
(interactive "p")
(let (beg end (origin (point)))
(if (and mark-active (> (point) (mark)))
(setq beg (line-beginning-position))
(if mark-active
(setq end (line-end-position))
(let ((region (buffer-substring-no-properties beg end)))
(dotimes (i arg)
(goto-char end)
(insert region)
(setq end (point)))
(goto-char (+ origin (* (length region) arg) arg)))))
;; Align Equal Signs
(defun align-region-to-equals (begin end)
"Align region to equal signs"
(interactive "r")
(align-regexp begin end "\\(\\s-*\\)=" 1 1 ))
;; Yank Pop Forwards
(defun yank-pop-forwards (arg)
(interactive "p")
(yank-pop (- arg)))
;; Window Switching
(defun other-window-reverse ()
"Switch to the previous window"
(other-window -1))
;; Window Re-sizing
(defun enlarge-window-down () (interactive) (enlarge-window 1))
(defun enlarge-window-up () (interactive) (enlarge-window -1))
(defun enlarge-window-left () (interactive) (enlarge-window -1 t))
(defun enlarge-window-right () (interactive) (enlarge-window 1 t))
;; Window Swapping
;; - from
(defun swap-with (dir)
(let ((other-window (windmove-find-other-window dir)))
(when other-window
(let* ((this-window (selected-window))
(this-buffer (window-buffer this-window))
(other-buffer (window-buffer other-window))
(this-start (window-start this-window))
(other-start (window-start other-window)))
(set-window-buffer this-window other-buffer)
(set-window-buffer other-window this-buffer)
(set-window-start this-window other-start)
(set-window-start other-window this-start)))))
(defun swap-with-down () (interactive) (swap-with 'down))
(defun swap-with-up () (interactive) (swap-with 'up))
(defun swap-with-left () (interactive) (swap-with 'left))
(defun swap-with-right () (interactive) (swap-with 'right))
;; Transparency
(defun transparency-set-initial-value ()
"Set initial value of alpha parameter for the current frame"
(if (equal (frame-parameter nil 'alpha) nil)
(set-frame-parameter nil 'alpha 100)))
(defun transparency-set-value (numb)
"Set level of transparency for the current frame"
(interactive "nEnter transparency level in range 0-100: ")
(if (> numb 100)
(message "Error! The maximum value for transparency is 100!")
(if (< numb 0)
(message "Error! The minimum value for transparency is 0!")
(set-frame-parameter nil 'alpha numb))))
(defun transparency-increase ()
"Increase level of transparency for the current frame"
(if (> (frame-parameter nil 'alpha) 0)
(set-frame-parameter nil 'alpha (+ (frame-parameter nil 'alpha) -1))
(message "This is a minimum value of transparency!")))
(defun transparency-decrease ()
"Decrease level of transparency for the current frame"
(if (< (frame-parameter nil 'alpha) 100)
(set-frame-parameter nil 'alpha (+ (frame-parameter nil 'alpha) +1))
(message "This is a minimum value of transparency!")))
;; Escreen Helper
;; - from
(defun escreen-get-active-screen-numbers-with-emphasis ()
"what the name says"
(let ((escreens (escreen-get-active-screen-numbers))
(emphased ""))
(dolist (s escreens)
(setq emphased
(concat emphased (if (= escreen-current-screen-number s)
(propertize (number-to-string s)
;;'face 'custom-variable-tag) " ")
;;'face 'info-title-3)
'face 'font-lock-warning-face)
;;'face 'secondary-selection)
(number-to-string s))
" ")))
(message "escreen: active screens: %s" emphased)))
Jump to Line
Something went wrong with that request. Please try again.