Skip to content

Instantly share code, notes, and snippets.

@rplacd
Last active December 15, 2015 02:49
Show Gist options
  • Save rplacd/5190140 to your computer and use it in GitHub Desktop.
Save rplacd/5190140 to your computer and use it in GitHub Desktop.
.init.el
; Setup packaging...
(require 'package)
(add-to-list 'package-archives
'("marmalade" .
"http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives
'("melpa" .
"http://melpa.milkbox.net/packages/"))
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
(defvar my-packages '(starter-kit starter-kit-lisp starter-kit-bindings zenburn-theme ecb minimap evil highlight-80+ lua-mode helm)
"A list of packages to ensure are installed at launch.")
(dolist (p my-packages)
(when (not (package-installed-p p))
(package-install p)))
;; Setup the cc-modes:
(setq c-default-style "bsd")
;; Setup Haskell's major mode...
(load "~/.emacs.d/haskell-mode/haskell-site-file.el")
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
(add-to-list 'load-path "~/.emacs.d/ghc-mod/")
(autoload 'ghc-init "ghc" nil t)
(add-hook 'haskell-mode-hook (lambda () (ghc-init) (flymake-mode)))
;; Setup Lisp interaction...
(setq inferior-lisp-program "wx86cl")
(add-to-list 'load-path "~/.emacs.d/slime/" )
(require 'slime)
(slime-setup '(slime-fancy))
;; Setup CEDET and friends.
(setq semantic-load-turn-useful-things-on 't)
;; Aesthetic customization.
(load-theme 'zenburn t)
(set-face-attribute 'default nil :font "Andika 10")
;; Print-here functionality.
(defvar mode-specific-eval-backends
'((emacs-lisp-mode . (lambda (text)
(condition-case elisp-eval-error
(format "%s" (eval (read text)))
(error (error-message-string elisp-eval-error)))))
(lisp-mode . (lambda (text)
(slime-eval `(swank:eval-and-grab-output ,text)
(lambda (result)
result))))))
(defun eval-backend-for-major-mode ()
"Gets the function that maps input text -> output text as per the buffer's current major mode."
(let ((callback (cdr (assoc major-mode mode-specific-eval-backends))))
(if (null callback)
(error "Print-here doesn't know how to eval in the major mode %s" major-mode)
callback)))
(defun print-range-here (beginning-point end-point)
"Backend printing function, handling eval and output insertion."
(let ((evaled-text (funcall (eval-backend-for-major-mode)
(buffer-substring beginning-point end-point))))
(set-mark-command nil)
; "Go to the end of the region, and add output there."
(goto-char end-point)
; IDIOSYNCRASY:
; Why add output padding here instead of goto-char (end-point + 1)?
; Because goto-char clamps positions exceeding the end of the
; buffer to the end of the buffer - so if we're print-it-ing at
; the end of a buffer, we won't get the extra space required.
(if (string-match-p "\n" evaled-text)
(insert "\n" evaled-text)
(insert " " evaled-text))
; And now select the region for easy deleting.
(push-mark end-point)
(set mark-active t)))
(defun print-region-here ()
"Print the eval'd output of a region."
(interactive)
(when (use-region-p)
(print-range-here (region-beginning) (region-end))))
(defun print-line-here ()
"Print the eval'd output of the current line from its beginning to the point."
(interactive)
(print-range-here (line-beginning-position) (point)))
"interlocution lessons lessen\n illegibility and lesions at leisure"
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(gdb-many-windows t))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment