spacemacs/my-funcs.el

64 lines
2 KiB
EmacsLisp

(defun syl-python-compile ()
"Use compile to run python programs"
(interactive)
(compile (concat "python " (buffer-name))))
(setq compilation-scroll-output t)
;; from https://gist.github.com/3402786
(defun toggle-maximize-buffer () "Maximize buffer"
(interactive)
(if (= 1 (length (window-list)))
(jump-to-register '_)
(progn
(set-register '_ (list (current-window-configuration)))
(delete-other-windows))))
;; from http://stackoverflow.com/questions/2905575/emacs-pass-arguments-to-inferior-python-shell-during-buffer-evaluation
(defun python-send-buffer-with-args (args)
(interactive "sArguments: ")
(let ((source-buffer (current-buffer)))
(with-temp-buffer
(insert "import sys; sys.argv = '" args "'.split()\n")
(insert-buffer-substring source-buffer)
(python-shell-send-buffer))))
(defun z:set-transparency (value)
"Sets the transparency of the frame window. 0=transparent/100=opaque"
(interactive "nTransparency Value 0 - 100 opaque:")
(set-frame-parameter (selected-frame) 'alpha value))
(defun z:switch-to-next-frame ()
"Select the next frame on current display, and raise it."
(interactive)
(other-frame 1))
(defun z:switch-to-previous-frame ()
"Select the previous frame on current display, and raise it."
(interactive)
(other-frame -1))
;; http://emacswiki.org/emacs/TransposeWindows
(defun z:rotate-windows ()
"Rotate your windows"
(interactive)
(cond
((not (> (count-windows) 1))
(message "You can't rotate a single window!"))
(t
(let ((i 1)
(num-windows (count-windows)))
(while (< i num-windows)
(let* ((w1 (elt (window-list) i))
(w2 (elt (window-list) (+ (% i num-windows) 1)))
(b1 (window-buffer w1))
(b2 (window-buffer w2))
(s1 (window-start w1))
(s2 (window-start w2)))
(set-window-buffer w1 b2)
(set-window-buffer w2 b1)
(set-window-start w1 s2)
(set-window-start w2 s1)
(setq i (1+ i))))))))
(provide 'my-funcs)