Emacs Daily Snippets
From the interesting, to the useful all the way to the useless.
lorem ipsum
(defun lorem ()
"Insert a lorem ipsum."
(interactive)
(insert "Lorem ipsum dolor sit amet, consectetur adipisicing elit, "
"sed do eiusmod tempor incididunt ut labore et dolore "
"magnaaliqua. Ut enim ad minim veniam, quis nostrud "
"exercitation ullamco laboris nisi ut aliquip ex ea commodo "
"consequat. Duis aute irure dolor in reprehenderit in "
"voluptate velit esse cillum dolore eu fugiat nulla pariatur. "
"Excepteur sint occaecat cupidatat non proident, sunt in "
"culpa qui officia deserunt mollit anim id est laborum."))
Transparent background
(defun transparent ()
(interactive)
(if (not (eq (first (frame-parameter (selected-frame) 'alpha)) 75))
(progn
(set-frame-parameter (selected-frame) 'alpha '(75 85)))
(set-frame-parameter (selected-frame) 'alpha '(100 100))))
Night Theme
(defun load-theme-by-time (hour)
"""Load theme based on the HOUR provided"""
(if (> (nth 2 (decode-time (current-time))) hour)
(load-theme 'gruvbox-dark-hard t)
(load-theme 'gruvbox-dark-hard t))
Toggle Eshell
(defun toggle-eshell ()
"""Open a new ehsell session or close a opened one."""
(interactive)
(if (get-buffer-window "*eshell*")
(progn
(if (not (string= (buffer-name) "*eshell*")) (switch-to-buffer-other-window "*eshell*"))
(kill-buffer "*eshell*")
(delete-window))
(let ((w (split-window-below 40)))
(select-window w)
(eshell))
(switch-to-buffer "*eshell*")))