Skip to content

Instantly share code, notes, and snippets.

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

Embed
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)
,@body)))
(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."
(interactive)
(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)
(column-number-mode)
(defun my-isearch-word-at-point ()
(interactive)
(call-interactively 'isearch-forward-regexp))
(defun my-isearch-yank-word-hook ()
(when (equal this-command 'my-isearch-word-at-point)
(let ((string (concat "\\<"
(buffer-substring-no-properties
(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
isearch-message
(concat isearch-message
(mapconcat 'isearch-text-char-description
string ""))
isearch-yank-flag t)
(isearch-search-and-update))))
(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 http://stackoverflow.com/a/145359
(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)))
(back-to-indentation)
(and (= oldpos (point))
(beginning-of-line))))
(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)
(package-initialize)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(setq package-archives (httpsify-package-list package-archives))
;; Run this to refresh package contents
;(package-refresh-contents)
)
;; VIM-mode if available
;;
;; $ (cd ~/.emacs.d/; hg clone https://bitbucket.org/lyro/evil)
(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.