Skip to content

Instantly share code, notes, and snippets.

@hraban hraban/gist:3017681
Last active Aug 15, 2016

What would you like to do?
My .emacs (hraban)
(add-to-list 'load-path "~/.emacs.d/plugins")
;; cl-* functions and macros
(require 'cl)
(cl-defmacro if-exists ((var fname) &rest body)
`(let ((,var ,fname))
(when (file-exists-p ,var)
(if-exists (f "~/.emacs.d/nxhtml/autostart.el")
(load f))
(if-exists (f (expand-file-name "~/quicklisp/slime-helper.el"))
(load f))
(setq inferior-lisp-program "sbcl")
(setq-default indent-tabs-mode nil)
(global-linum-mode t)
(defun kill-to-start-of-line ()
"Kill from point to start of line."
(kill-line 0))
(global-set-key (kbd "C-c u") 'kill-to-start-of-line)
(setq mouse-wheel-progressive-speed nil)
(set-face-attribute 'default nil :height 140)
(show-paren-mode 1)
(delete-selection-mode t)
(set-scroll-bar-mode 'right)
(defun my-isearch-word-at-point ()
(call-interactively 'isearch-forward-regexp))
(defun my-isearch-yank-word-hook ()
(when (equal this-command 'my-isearch-word-at-point)
(let ((string (concat "\\<"
(progn (skip-syntax-backward "w_") (point))
(progn (skip-syntax-forward "w_") (point)))
(if (and isearch-case-fold-search
(eq 'not-yanks search-upper-case))
(setq string (downcase string)))
(setq isearch-string string
(concat isearch-message
(mapconcat 'isearch-text-char-description
string ""))
isearch-yank-flag t)
(add-hook 'isearch-mode-hook 'my-isearch-yank-word-hook)
(global-set-key (kbd "C-c 8") 'my-isearch-word-at-point)
(defadvice isearch-search (after isearch-no-fail activate)
(unless isearch-success
(ad-disable-advice 'isearch-search 'after 'isearch-no-fail)
(ad-activate 'isearch-search)
(isearch-repeat (if isearch-forward 'forward))
(ad-enable-advice 'isearch-search 'after 'isearch-no-fail)
(ad-activate 'isearch-search)))
;; Winner mode is for the C-c [left] binding (undo window changes)
(when (fboundp 'winner-mode)
(winner-mode 1))
;; From
(defun smart-beginning-of-line ()
"Move point to first non-whitespace character or beginning-of-line.
Move point to the first non-whitespace character on this line.
If point was already at that position, move point to beginning of line."
(interactive) ; Use (interactive "^") in Emacs 23 to make shift-select work
(let ((oldpos (point)))
(and (= oldpos (point))
(global-set-key [home] 'smart-beginning-of-line)
(destructuring-bind ((a . b) &rest c) '((1 . 2) (a . b) (i . ii))
(list a b c))
(defun httpsify-href (href)
(replace-regexp-in-string "^http://" "https://" href))
(defun map-alist-cdr (f alist)
"Map every value in the alist through a function f
(map-alist-cdr '1+ '((a . 1) (b . 3) (c . 9)))
=> ((a . 2) (b . 4) (c . 10))
(cl-loop for (a . b) in alist
collect (cons a (funcall f b))))
(defun httpsify-package-list (archives)
"Turn all http:// archives into https:// in the package-archives list"
(map-alist-cdr 'httpsify-href archives))
(when (>= emacs-major-version 24)
(require 'package)
(add-to-list 'package-archives '("melpa" . ""))
(setq package-archives (httpsify-package-list package-archives))
;; Run this to refresh package contents
;; VIM-mode if available
;; $ (cd ~/.emacs.d/; hg clone
(if-exists (f "~/.emacs.d/evil")
(add-to-list 'load-path f)
(require 'evil)
(evil-mode 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.