Skip to content

Instantly share code, notes, and snippets.

@matthew-ball
Created May 27, 2012 04:30
Show Gist options
  • Save matthew-ball/2802182 to your computer and use it in GitHub Desktop.
Save matthew-ball/2802182 to your computer and use it in GitHub Desktop.
;; FILE: /home/chu/Programming/lisp/elisp/simple-dot-emacs.el
;; AUTHOR: Matthew Ball (copyleft 2012)
;; TIME: Wed 23 May 2012 15:27:03 EST
;; COMMENT:
;; The *Simple GNU Emacs* configuration.
;; Primarily designed for "modern" users:
;; - Completely new fundamental key design.
;; - Simplistic interface design.
;; This is an attempt to "bring GNU Emacs to the masses", so to speak.
;;; COMMENT: package management
;; SOURCE: `http://emacswiki.org/emacs/ELPA'
(message "package management")
(autoload 'package "package" "GNU Emacs lisp package management." t)
;; NOTE: set download repositories
(setq package-archives '(("elpa" . "http://tromey.com/elpa/")
("gnu" . "http://elpa.gnu.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")))
;; TODO: set download packages
;;; COMMENT: cosmetics
(message "cosmetics")
(when (fboundp 'menu-bar-mode) (menu-bar-mode -1)) ;; NOTE: hide the menu bar
;; (when (fboundp 'tool-bar-mode) (tool-bar-mode -1)) ;; NOTE: hide the tool bar
;; (when (fboundp 'scroll-bar-mode) (scroll-bar-mode -1)) ;; NOTE: hide the scroll bar
;; (when (fboundp 'blink-cursor-mode) (blink-cursor-mode -1)) ;; NOTE: turn off blinking cursor
(when (fboundp 'tooltip-mode) (tooltip-mode -1)) ;; NOTE: turn off tooltip
(when (fboundp 'fringe-mode) (set-fringe-mode '(1 . 0))) ;; NOTE: set fringe to 1px on left side only
(setq mode-line-format nil) ;; NOTE: clear the mode-line from the screen
(add-hook 'find-file-hook (lambda () (linum-mode 1))) ;; NOTE: turn on linum mode if in a file
;;; COMMENT: default variable values
(message "default variable values")
(setq inhibit-startup-message t ;; turn off startup message
inhibit-startup-echo-area-message t ;; turn off startup echo area message
initial-scratch-message (concat ";; For information about "
(substring (emacs-version) 0 16)
" and the GNU system, type C-h C-a.\n\n") ;; initial scratch message
completion-ignore-case t ;; ignore case in auto-completing text
read-file-name-completion-ignore-case t ;; ignore cases in filenames
auto-compression-mode 1 ;; automatically parse an archive
message-log-max 2000 ;; maximum number of lines to keep in the message log buffer (default is 100)
show-trailing-whitespace 1 ;; show trailing whitespace
scroll-margin 0 ;; use smooth scrolling
scroll-conservatively 100000 ;; ... the defaults
scroll-up-aggressively 0 ;; ... are very
scroll-down-aggressively 0 ;; ... annoying
scroll-preserve-screen-position t ;; preserve screen position with C-v/M-v
auto-save-interval 1000 ;; change auto-save interval from 300 to 1000 keystrokes
sentence-end-double-space 'nil ;; sentences end with a single space
echo-keystrokes 0.1 ;; see what you are typing
suggest-key-bindings nil) ;; do not show respective key-bindings
;;; COMMENT: code folding
;; SOURCE: `http://emacswiki.org/emacs/HideShow'
(message "code folding")
(autoload 'hs-minor-mode "hideshow" "Fold code with GNU Emacs." t)
;; TODO: add custom modes
;; (defvar hs-special-modes-alist
;; (mapcar 'purecopy
;; '((c-mode "{" "}" "/[*/]" nil nil)
;; (c++-mode "{" "}" "/[*/]" nil nil)
;; (bibtex-mode ("@\\S(*\\(\\s(\\)" 1))
;; (java-mode "{" "}" "/[*/]" nil nil)
;; (js-mode "{" "}" "/[*/]" nil))))
(setq hs-hide-comments nil) ;; NOTE: hide the comments too when you do a 'hs-hide-all'
(setq hs-isearch-open 't) ;; NOTE: set isearch opens folded comments; where x is code, comments, t (both), or nil (neither)
(defun toggle-selective-display (column)
(interactive "P")
(set-selective-display
(or column
(unless selective-display
(1+ (current-column))))))
(defun toggle-hiding (column)
(interactive "P")
(if hs-minor-mode
(if (condition-case nil
(hs-toggle-hiding)
(error t))
(hs-show-all))
(toggle-selective-display column)))
;; (add-hook 'lisp-mode-hook 'hs-minor-mode)
;; (add-hook 'emacs-lisp-mode-hook 'hs-minor-mode)
;; (add-hook 'shell-script-mode 'hs-minor-mode)
;; (add-hook 'haskell-mode-hook 'hs-minor-mode)
(add-hook 'latex-mode-hook 'hs-minor-mode)
;;; COMMENT: ido
;; TODO: you want `smex' from ELPA
(message "ido")
(ido-mode 'both) ;; NOTE: turn on interactive mode (files and buffers)
(setq ido-enable-flex-matching t ;; NOTE: enable fuzzy matching
ido-everywhere t ;; NOTE: enable ido everywhere
ido-create-new-buffer 'always ;; NOTE: create new buffers (if name does not exist)
ido-ignore-extensions t ;; NOTE: ignore extentions
ido-ignore-buffers '("\\` " "^\*Mess" "^\*Back" ".*Completion" "^\*Ido" "^\*trace" "^\*compilation" "^\*GTAGS" "^session\.*" "^\*")
ido-case-fold t ;; NOTE: enable case-insensitivity
ido-enable-last-directory-history t ;; NOTE: enable directory history
ido-max-work-directory-list 30 ;; NOTE: remember last used directories ...
ido-max-work-file-list 50 ;; NOTE: ... and files
ido-max-prospects 8 ;; NOTE: don't spam the mini buffer
confirm-nonexistent-file-or-buffer nil) ;; NOTE: the confirmation is rather annoying
;;; COMMENT: cuda mode
;; TODO: work this out
;;; COMMENT: global key bindings
(message "global key bindings")
;; (global-set-key (kbd "C-s") 'save-buffer)
;; (global-set-key (kbd "C-f") 'isearch-forward)
;; (global-set-key (kbd "C-x") 'cut)
;; (global-set-key (kbd "C-c") 'copy)
;; (global-set-key (kbd "C-v") 'paste)
(global-set-key (kbd "C-+") 'toggle-hiding)
(global-set-key (kbd "C-M-+") 'toggle-selective-display)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment