Skip to content

Instantly share code, notes, and snippets.

@SupermanScott
Created January 11, 2014 17:58
Show Gist options
  • Save SupermanScott/8374336 to your computer and use it in GitHub Desktop.
Save SupermanScott/8374336 to your computer and use it in GitHub Desktop.
personal.el
;;; personal.el -- personal modifications
;;; Commentary:
;;; provide personal modifications
;;; Code:
(set-face-attribute 'default nil :height 140)
(prelude-require-packages '(color-theme-sanityinc-tomorrow paredit ac-geiser
geiser))
(provide 'personal)
(load-theme 'sanityinc-tomorrow-bright)
(add-hook 'clojure-mode-hook 'paredit-mode)
(scroll-bar-mode -1)
(setq scheme-program-name "guile")
;alist of 'buffer-name / timer' items
(defvar buffer-tail-alist nil)
(defun buffer-tail (name)
"Follow buffer tails NAME buffer."
(cond ((or (equal (buffer-name (current-buffer)) name)
(string-match "^ \\*Minibuf.*?\\*$" (buffer-name (current-buffer)))))
((get-buffer name)
(with-current-buffer (get-buffer name)
(goto-char (point-max))
(let ((windows (get-buffer-window-list (current-buffer) nil t)))
(while windows (set-window-point (car windows) (point-max))
(with-selected-window (car windows) (recenter -3)) (setq windows (cdr windows))))))))
(defun toggle-buffer-tail (name &optional force)
"Toggle tailing of buffer NAME. When called non-interactively, a FORCE arg of 'on' or 'off' can be used to to ensure a given state for buffer NAME."
(interactive (list (cond ((if name name) (read-from-minibuffer
(concat "buffer name to tail"
(if buffer-tail-alist (concat " (" (caar buffer-tail-alist) ")") "") ": ")
(if buffer-tail-alist (caar buffer-tail-alist)) nil nil
(mapcar '(lambda (x) (car x)) buffer-tail-alist)
(if buffer-tail-alist (caar buffer-tail-alist)))) nil)))
(let ((toggle (cond (force force) ((assoc name buffer-tail-alist) "off") (t "on")) ))
(if (not (or (equal toggle "on") (equal toggle "off")))
(error "Invalid 'force' arg. Required 'on'/'off'")
(progn
(while (assoc name buffer-tail-alist)
(cancel-timer (cdr (assoc name buffer-tail-alist)))
(setq buffer-tail-alist (remove* name buffer-tail-alist :key 'car :test 'equal)))
(if (equal toggle "on")
(add-to-list 'buffer-tail-alist (cons name (run-at-time t 1 'buffer-tail name))))
(message "toggled 'tail buffer' for '%s' %s" name toggle)))))
(defun tail-nrepl-server ()
"Start tailing the nrepl server buffer."
(toggle-buffer-tail "*nrepl-server*" "on"))
;;; personal ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment