Skip to content

Instantly share code, notes, and snippets.

@toumorokoshi
Last active December 17, 2015 10:39
Show Gist options
  • Save toumorokoshi/5596276 to your computer and use it in GitHub Desktop.
Save toumorokoshi/5596276 to your computer and use it in GitHub Desktop.
Non-masochist version of my emacs no externals.
;; Load packages for emacs 24. Keep package-based stuff separate in loadpackages
;; someday I may want a "bare" emacs file
;;(load "~/.emacs.loadpackages")
;;(add-hook 'after-init-hook '(lambda ()
;; (load "~/.emacs.loadpackages")
;; (load "~/.emacs.methods")
;; (load "~/.emacs.elget")
;; (ad-activate 'isearch-search)))
(require 'cl)
;; don't add newline
(setq require-final-newline nil)
;; Remove GTK dialog boxes
(setq use-dialog-box nil)
;; Remove scrollbars, menu bars, and toolbars
(when (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(when (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(when (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
;; No splash screen
(setq inhibit-startup-message t)
;; uniquify (prefix names)
(require 'uniquify)
(setq
uniquify-buffer-name-style 'forward
)
;; Set font size
(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.
)
;; Adding in hideshow
(load-library "hideshow")
(add-hook 'python-mode-hook 'hs-minor-mode)
;; change the filename collisions in emacs
(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)
;; ido (listing of file in a directory in minibuffer)
(require 'ido)
(ido-mode 'both)
;; Keybindings
;; Whitespace mode
(global-set-key (kbd "C-c h") 'whitespace-mode)
;; Wind-move
(global-set-key (kbd "C-x C-l") 'windmove-right)
(global-set-key (kbd "C-x C-h") 'windmove-left)
(global-set-key (kbd "C-x C-k") 'windmove-up)
(global-set-key (kbd "C-x C-j") 'windmove-down)
;; better indenting
(setq-default indent-tabs-mode nil)
(setq-default tab-width 2)
;; Python-mode
(add-hook 'python-mode-hook '(lambda ()
(setq python-indent 4)))
;; Hippie-expand (haven't really used it yet)
(global-set-key (kbd "C-x C-;") 'hippie-expand)
;; File search, doesn't really work like I want it to
;; (global-set-key (kbd "C-x C-g") 'find-name-dired)
;; Start a terminal, also doesn't work perfectly
(global-set-key (kbd "C-c C-t") 'ansi-term)
;; Set octave major mode for m files
(add-to-list
'auto-mode-alist
'("\\.m$" . octave-mode))
;; Asks if you want emacs asked before closing
(defun ask-before-closing ()
"Ask whether or not to close, and then close if y was pressed"
(interactive)
(if (y-or-n-p (format "Are you sure you want to exit Emacs? "))
(if (< emacs-major-version 22)
(save-buffers-kill-terminal)
(save-buffers-kill-emacs))
(message "Canceled exit")))
(when window-system
(global-set-key (kbd "C-x C-c") 'ask-before-closing))
;; Associate .emacs files to lisp-mode
(add-to-list 'auto-mode-alist '("\\.emacs.*$" . lisp-mode))
;; mapping find files recursive to a key for now
(global-set-key (kbd "C-x g") 'find-name-dired)
;; Remap M-x to the proper command
(global-set-key (kbd "M-x") 'execute-extended-command)
;; sets a map for linum mode
;; also disables the annoying Ctrl Z which returns me to regular emacs from viper
;; (define-prefix-command 'toumorokoshi-custom-map)
;; (global-set-key (kbd "C-z") 'toumorokoshi-custom-map)
;; (global-set-key (kbd "C-z C-l") 'linum-mode)
(add-hook 'find-file-hook (lambda () (linum-mode 1)))
(global-linum-mode 1)
;; truncate long lines
(set-default 'truncate-lines t)
;; add whack whitespace
(global-set-key "\C-l" 'whack-whitespace)
;; cedet
;; (require 'cedet)
;; (global-semantic-idle-completions-mode t)
;; (global-semantic-decoration-mode t)
;; (global-semantic-highlight-func-mode t)
;; (global-semantic-show-unmatched-syntax-mode t)
;; Install emacs packages on load
;; defining the list of packages I want
;; this is a change.
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/") t)
(package-initialize)
(defvar mycustom-packages
'(
ace-jump-mode
) "A list of packages to ensure are installed at launch.")
(provide 'mycustom-packages)
;; http://stackoverflow.com/questions/10092322/how-to-automatically-install-emacs-packages-by-specifying-a-list-of-package-name
(setq url-http-attempt-keepalives nil)
(defun packages-installed-p ()
(loop for p in mycustom-packages
when (not (package-installed-p p)) do (return nil)
finally (return t)))
(unless (packages-installed-p)
;; check for new packages (package versions)
(message "%s" "Emacs is now refreshing its package database...")
(package-refresh-contents)
(message "%s" " done.")
;; install the missing packages
(dolist (p mycustom-packages)
(when (not (package-installed-p p))
(package-install p))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment