Startup related tasks/setup that might be used later on.
Duplicated from tangle.el just to make using org easier.
TODO: make this stuff work sanely in emacs org mode and via external tangling. Not tangled for now.
(defun tangle/yn (p) (if (bound-and-true-p p) "yes" "no")) (defun tangle/file (p file) (if (bound-and-true-p p) (concat "tmp/" file) "no"))
Setup the builtin emacs package manager.
(require 'package) (package-initialize)
Add in the standard package archive urls.
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/") t)
This configuration is using use-package extensively. Install it straight away.
(unless (package-installed-p 'use-package)
(progn
(package-refresh-contents)
(package-install 'use-package)
(package-initialize)))
(require 'use-package)
(setq use-package-verbose t)
(defun string/ends-with (string suffix)
"Return t if STRING ends with SUFFIX."
(and (string-match (rx-to-string `(: ,suffix eos) t)
string)
t)
)
Add a save hook to always tangle and byte compile emacs.org file when we save it.
(defun tangle-init ()
"If the current buffer is 'emacs.org' the code-blocks are
tangled, and the tangled file is compiled."
(when (string/ends-with (buffer-file-name) ".emacs.d/emacs.org")
(let ((prog-mode-hook nil))
(org-babel-tangle)
(byte-compile-file (concat user-emacs-directory "init.el")))
)
)
(add-hook 'after-save-hook 'tangle-init)
Not having to start emacs with –debug-init is useful.
(setq debug-on-error t)
Start up the emacs server if it isn't running.
(load "server") (unless (server-running-p) (server-start))
Solarized light is decent. I'll just use that. Note, to prevent flicker this is setup early in startup.
(use-package solarized-theme :ensure t :init (load-theme 'solarized-light 't))
Make it easier to determine what os we're running on.
(defvar on-mswindows (string-match "windows" (symbol-name system-type))
"Am I running under windows?")
(defvar on-osx (string-match "darwin" (symbol-name system-type))
"Am I running under osx?")
(defvar on-linux (string-match "gnu/linux" (symbol-name system-type))
"Am I running under linux?")
Like the startup screen and the echo hooey.
(custom-set-variables '(inhibit-startup-screen t) '(inhibit-startup-message t) '(inhibit-startup-echo-area-message t) )
Keep temporary stuff isolated from everyone else. It infects everything otherwise. As bad as the .DS_Store files on osx.
(custom-set-variables
'(temporary-file-directory "/tmp")
'(backup-directory-alist `((".*" . ,temporary-file-directory)))
'(auto-save-file-name-transforms `((".*" ,temporary-file-directory t)))
'(create-lockfiles nil)
'(make-backup-files nil)
'(auto-save-default nil)
'(backup-by-copying t)
'(auto-save-list-file-prefix temporary-file-directory)
'(backup-directory-alist `((".*" . ,temporary-file-directory)))
'(auto-save-file-name-transforms `((".*" ,temporary-file-directory t)))
)
Update files in open buffers as they're changed on disk, freaking annoying without this on.
(custom-set-variables '(global-auto-revert-mode t))
Use dired-x.
(add-hook 'dired-load-hook (function (lambda () (load "dired-x"))))
For those rare times I use it, make it a bit less derp on output.
(setq ediff-window-setup-function 'ediff-setup-windows-plain) (setq ediff-split-window-function 'split-window-horizontally)
Trailing whitespace is not normally useful. Remove it always on save in the before-save-hook.
(add-hook 'before-save-hook 'delete-trailing-whitespace)
Because its derp to have to chmod 755 stuff after I save. Honestly, do it for me kthxbai.
(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
Line wrapping is useful. Enable it globally for a start.
Need word-wrap so kill line kills the line, not the displayed line.
(global-visual-line-mode t) (custom-set-variables '(word-wrap t))
So if we don't know, call it text-mode.
(custom-set-variables '(default-major-mode 'text-mode))
utf8 is the best. Default to it.
(custom-set-variables '(locale-coding-system 'utf-8)) (set-terminal-coding-system 'utf-8) (set-keyboard-coding-system 'utf-8) (set-selection-coding-system 'utf-8) (prefer-coding-system 'utf-8)
If I selected text, delete the selection, I probably meant it emacs.
(delete-selection-mode 1)
80 char line columns not 72.
(custom-set-variables '(fill-column 80))
Double spacing after a line isn't needed. We aren't animals emacs, we have computers.
(set-default 'sentence-end-double-space nil)
Semi related to the above, make the sentence endings a bit more code-ish.
(custom-set-variables '(sentence-end "[.?!][]\"')]*\\($\\|\t\\| \\)[ \t\n]*") '(sentence-end-double-space nil) )
Two seems sensible, cause well, tabs are evil incarnate.
Lets use a tab width of 2 by default.
(custom-set-variables '(default-tab-width 2))
Customize whitespace mode to make tabs obvious as boxes, and to highlight lines over 80 characters in length.
(require 'whitespace)
(setq whitespace-style '(face tabs trailing))
(set-face-attribute 'whitespace-tab nil
:foreground "#2075c7"
:background "lightgrey")
(set-face-attribute 'whitespace-line nil
:foreground "#2075c7"
:background "lightgrey")
I have no idea how to label these.
Highlight parens.
(show-paren-mode)
Typing out yes or no is stupid.
(fset 'yes-or-no-p 'y-or-n-p)
On osx, don't ever display the gui dialog box. Taken from http://superuser.com/questions/125569/how-to-fix-emacs-popup-dialogs-on-mac-os-x
(when (and on-osx (window-system))
(defadvice yes-or-no-p (around prevent-dialog activate)
"Prevent yes-or-no-p from activating a dialog"
(let ((use-dialog-box nil))
ad-do-it))
(defadvice y-or-n-p (around prevent-dialog-yorn activate)
"Prevent y-or-n-p from activating a dialog"
(let ((use-dialog-box nil))
ad-do-it))
)
Command should be meta on cocoa emacs like the old carbon/macports version.
(when (and on-osx (window-system))
(custom-set-variables
'(mac-command-key-is-meta t)
'(mac-option-key-is-meta nil)
'(mac-command-key-is-meta t)
'(mac-command-modifier 'meta)
'(mac-option-modifier 'none)
)
)
Global key bindings.
(global-set-key (kbd "C-x ,") 'kill-whole-line) (global-set-key (kbd "C-x C-m") 'compile)
(when (and on-linux (window-system))
(progn
(setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
(setq x-select-enable-clipboard t)
)
)
When i'm running in a terminal emacs, most of this junk isn't needed. For that matter gui counts for most.
Basically, never show the tool bar or the scroll bar in gui or tty. In gui its ok to show the menu-bar.
Also have the scratch buffer be empty instead of have the derp message I never read anyway.
(tool-bar-mode -1)
(scroll-bar-mode -1)
(when (not window-system)
(menu-bar-mode -1))
(custom-set-variables '(initial-scratch-message nil))
List of fonts in order of preference.
(defvar my/gui-fonts
'(
"PragmataPro"
"Pragmata Pro" ;; Seems to register differently on osx than X
"Source Code Pro"
"Menlo"
"Monaco"
)
)
Set preferred font list when we're in a gui emacs session.
(with-no-warnings
(when window-system
(if (find-font (font-spec :name (car my/gui-fonts)))
(progn (set-frame-font (car my/gui-fonts))
(set-face-attribute 'default nil :height 180))
(progn (set-gui-font (cdr my/gui-fonts))))
)
)
Enable mouse mode for the console and use the mousewheel if possible.
(unless window-system
(require 'mouse)
(xterm-mouse-mode t)
(global-set-key [mouse-4] '(lambda ()
(interactive)
(scroll-down 1)))
(global-set-key [mouse-5] '(lambda ()
(interactive)
(scroll-up 1)))
(defun track-mouse (e))
)
All the packages I use.
(use-package tramp
:ensure t
:config (custom-set-variables '(tramp-default-method "ssh"))
)
Turns out that someone wrote this exact thing already. Yay get to drop my own crap.
(use-package exec-path-from-shell
:ensure t
:init (if on-osx (exec-path-from-shell-initialize))
)
(when on-osx
(use-package osx-clipboard
:ensure t
:config
(progn
(osx-clipboard-mode +1)
)
)
)
(use-package smart-mode-line
:ensure t
:config
(progn
(custom-set-variables '(sml/name-width 20)
'(sml/mode-width 'full)
'(sml/shorten-modes t)
'(sml/shorten-directory t)
'(sml/hidden-modes
'(" GitGutter"
" Fill"
" $"
" Wrap"
" MRev"
" Ind"
" Projectile"
" SP"
" Undo-Tree"
" yas"
" WSC"))
)
(sml/toggle-shorten-modes)
(add-to-list 'sml/replacer-regexp-list
'("^~/src/" ":src:"))
(sml/setup)
(column-number-mode)
)
)
(use-package semantic
:ensure t
:config
(progn
(custom-set-variables
'(global-semantic-decoration-mode t)
'(global-semantic-highlight-func-mode t)
'(global-semantic-idle-scheduler-mode t)
'(global-semantic-idle-local-symbol-highlight-mode t)
'(global-semantic-stickyfunc-mode f)
)
)
:init(semantic-mode t)
)
(use-package expand-region :ensure t :bind ("C-]" . er/expand-region))
Switching to ivy mode+swiper
(use-package counsel
:ensure t
:bind (("C-x C-f" . counsel-find-file)
("C-c g" . counsel-git)
("C-c j" . counsel-git-grep)
("C-c k" . counsel-ag)
("C-x l" . counsel-locate)
("C-S-o" . counsel-rhythmbox)
("C-c C-r" . ivy-resume))
:config (custom-set-variables '(counsel-find-file-at-point t)))
(use-package swiper
:ensure t
:diminish ivy-mode
:bind (("C-s" . swiper)
("M-x" . counsel-M-x))
:config (progn
(custom-set-variables
'(projectile-completion-system 'ivy)
'(magit-completing-read-function 'ivy-completing-read)
'(ivy-use-virtual-buffers t)
'(ivy-height 10)
'(ivy-count-format "(%d/%d) ")
)
(ivy-mode 1)
)
)
Make git not ass to use. At least in emacs. magit is the best git interface… in the world.
(use-package magit
:ensure t
:commands (magit-init
magit-status
magit-diff
magit-commit)
:bind ("C-x m" . magit-status)
:config
(progn
(custom-set-variables
'(magit-auto-revert-mode nil)
'(magit-last-seen-setup-instructions "1.4.0")
)
(defadvice magit-status (around magit-fullscreen activate)
(window-configuration-to-register :magit-fullscreen)
ad-do-it
(delete-other-windows))
(defadvice magit-quit-window (around magit-restore-screen activate)
ad-do-it
(jump-to-register :magit-fullscreen)))
)
Save workgroup layouts. Similar..ish to desktop-save.
(use-package workgroups2
:ensure t
:diminish (workgroups-mode . "")
:config
(progn
(custom-set-variables
'(wg-session-file "~/.emacs.d/workgroups")
'(wg-prefix-key (kbd "C-c C-w"))
'(wg-mode-line-display-on nil)
)
)
:init (workgroups-mode 1)
)
Highlight matching ()'s []'s etc…
(use-package autopair
:ensure t
:config
(progn (custom-set-variables '(autopair-blink 'nil)))
)
foo
bar
Org-mode keybindings and settings, pretty sparse really.
(use-package org
:ensure org-plus-contrib
:bind (("C-c a" . org-agenda)
("C-c b" . org-iswitchb)
("C-c c" . org-capture)
("C-c l" . org-store-link)
("C-c p" . org-latex-export-to-pdf))
:init (use-package org-bullets
:config
(progn
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))))
:config
(progn
(custom-set-variables
'(org-log-done t)
'(org-hide-leading-stars t)
'(org-hide-emphasis-markers t)
)
(font-lock-add-keywords 'org-mode
'(("^ +\\([-*]\\) "
(0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•"))))))
(let* ((variable-tuple (cond ((x-list-fonts "Source Sans Pro") '(:font "Source Sans Pro"))
((x-list-fonts "Lucida Grande") '(:font "Lucida Grande"))
((x-list-fonts "Verdana") '(:font "Verdana"))
((x-family-fonts "Sans Serif") '(:family "Sans Serif"))
(nil (warn "Cannot find a Sans Serif Font. Install Source Sans Pro."))))
(base-font-color (face-foreground 'default nil 'default))
(headline `(:inherit default :weight bold :foreground ,base-font-color)))
(custom-theme-set-faces 'user
`(org-level-8 ((t (,@headline ,@variable-tuple))))
`(org-level-7 ((t (,@headline ,@variable-tuple))))
`(org-level-6 ((t (,@headline ,@variable-tuple))))
`(org-level-5 ((t (,@headline ,@variable-tuple))))
`(org-level-4 ((t (,@headline ,@variable-tuple :height 1.1))))
`(org-level-3 ((t (,@headline ,@variable-tuple :height 1.25))))
`(org-level-2 ((t (,@headline ,@variable-tuple :height 1.5))))
`(org-level-1 ((t (,@headline ,@variable-tuple :height 1.75))))
`(org-document-title ((t (,@headline ,@variable-tuple :height 1.5 :underline nil))))))
(org-reload)
)
)
Flycheck for on the fly checking of code.
(use-package flycheck
:ensure t
:init
(custom-set-variables '(flycheck-indication-mode 'left-fringe))
:config
(add-hook 'prog-mode-hook 'flycheck-mode)
)
Need to vet this, used it more when I did more c. But its handy for non standard pkg-config setups.
Not tangled into the config intentionally.
(defun pkg-config-add-lib-cflags (pkg-config-lib)
"This function will add necessary header file path of a
specified by `pkg-config-lib' to `flycheck-clang-include-path', which make it
completionable by auto-complete-clang"
(interactive "spkg-config lib: ")
(if (executable-find "pkg-config")
(if (= (shell-command
(format "pkg-config %s" pkg-config-lib))
0)
(setq flycheck-clang-include-path
(append flycheck-clang-include-path
(split-string
(shell-command-to-string
(format "pkg-config --cflags-only-I %s"
pkg-config-lib)))))
(message "Error, pkg-config lib %s not found." pkg-config-lib))
(message "Error: pkg-config tool not found.")))
Auto complete functionality is nice to have.
(use-package auto-complete
:ensure t
:init (progn (require 'auto-complete-config)
(ac-config-default)
(global-auto-complete-mode t)
))
Helpfully inserts matching parens, can be a pita too.
(use-package smartparens
:ensure t
:config
(add-hook 'prog-mode-hook 'smartparens-mode)
)
Makes matching parens easier.
(use-package rainbow-delimiters
:ensure t
:config
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
)
Make buffer names unique based on their directory and not have <N> or other nonsense.
(require 'uniquify) (custom-set-variables '(uniquify-buffer-name-style 'post-forward))
Desktop saving of session information handy to keep the same buffers between sessions.
(require 'desktop)
(desktop-save-mode 1)
(custom-set-variables
'(desktop-restore-eager 5)
'(desktop-path '("~/.emacs.d"))
'(desktop-dirname "~/.emacs.d")
'(desktop-base-file-name "desktop")
)
(defun local-desktop-save ()
(interactive)
(if (eq (desktop-owner) (emacs-pid))
(desktop-save desktop-dirname)))
(add-hook 'auto-save-hook 'desktop-save-in-desktop-dir)
Highlight TODO/FIXME type messages in comments.
(use-package fic-mode
:ensure t
:init
(add-hook 'prog-mode-hook 'turn-on-fic-mode)
)
(use-package projectile
:ensure t
:init (projectile-global-mode)
)
(use-package git-gutter
:ensure t
:config
(progn (global-git-gutter-mode t))
)
(use-package clang-format
:ensure t
:bind (([C-M-tab] . clang-format-region))
)
(use-package hideshow
:ensure t
:bind ("C-c s" . hs-toggle-hiding)
)
(use-package ggtags :ensure t)
Completion tips.
(use-package company-mode
:ensure t
:config
(progn (add-hook 'after-init-hook 'global-company-mode))
)
For.. yaml
(use-package yaml-mode :ensure t)
So I write gooder. Me fail English? Thats unpossible.
(use-package writegood-mode :ensure t)
Compress down python configuration a bit.
(use-package python
:commands python-mode
:mode ("\\.py\\'" . python-mode)
:ensure t
:init
(progn
(use-package jedi
:ensure t
:init
(progn
(jedi:install-server)
)
:config
(progn
(custom-set-variables
'(jedi:complete-on-dot t)
'(jedi:install-imenu t)
)
)
:bind
(("M-." . jedi:goto-definition)
("M-," . jedi:goto-definition-pop-marker)
)
)
(use-package company-anaconda
:ensure t
:config
(progn
(add-to-list 'company-backends 'company-anaconda)
(add-hook 'python-mode-hook 'anaconda-mode)
)
)
(use-package pytest
:ensure t
:bind ("C-c t" . pytest-one)
)
(use-package pymacs :ensure t)
)
:config
(progn
(add-hook 'python-mode-hook'
(lambda ()
(jedi:setup)
(push '("lambda" . ?λ) prettify-symbols-alist)
(push '("<=" . ?≤) prettify-symbols-alist)
(push '(">=" . ?≥) prettify-symbols-alist)
(push '("==" . ?≡) prettify-symbols-alist)
(push '("/=" . ?≢) prettify-symbols-alist)
(push '("&&" . ?∧) prettify-symbols-alist)
(push '("||" . ?∨) prettify-symbols-alist)
(push '("not" . ?¬) prettify-symbols-alist)
(push '("None" . ?⊥) prettify-symbols-alist)
(prettify-symbols-mode)
)
))
)
Need to make haskell source be all pretty.
(use-package haskell-mode
:ensure t
:config
(progn
(use-package hindent
:if (executable-find "hindent")
:ensure t
:config
(progn
(add-hook 'haskell-mode-hook #'hindent-mode)
)
)
(use-package flycheck-haskell :ensure t)
(use-package flycheck-hdevtools
:ensure t
:config
(progn
(add-hook 'haskell-mode-hook 'flycheck-mode)
)
)
(use-package ghc
:if (executable-find "ghc-mod")
:ensure t
:config
(progn
(autoload 'ghc-init "ghc" nil t)
(autoload 'ghc-debug "ghc" nil t)
(add-hook 'haskell-mode-hook (lambda ()
(ghc-init)
)
)
)
)
(add-hook 'haskell-mode-hook 'interactive-haskell-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
(custom-set-variables
'(haskell-program-name "ghci")
'(haskell-process-type 'cabal-repl)
'(haskell-tags-on-save t)
)
(add-to-list 'completion-ignored-extensions ".hi")
(add-hook 'haskell-mode-hook'
(lambda ()
(push '("()" . ?∅) prettify-symbols-alist)
(push '("\\" . ?λ) prettify-symbols-alist)
(push '("pi" . ?π) prettify-symbols-alist)
(push '("=>" . ?⇒) prettify-symbols-alist)
(push '("->" . ?→) prettify-symbols-alist)
(push '("<-" . ?←) prettify-symbols-alist)
(push '("<=" . ?≤) prettify-symbols-alist)
(push '(">=" . ?≥) prettify-symbols-alist)
(push '("==" . ?≡) prettify-symbols-alist)
(push '("/=" . ?≢) prettify-symbols-alist)
(push '("!!" . "‼") prettify-symbols-alist)
(push '("&&" . ?∧) prettify-symbols-alist)
(push '("||" . ?∨) prettify-symbols-alist)
(push '("~>" . ?⇝) prettify-symbols-alist)
(push '("-<" . ?↢) prettify-symbols-alist)
(push '("not" . ?¬) prettify-symbols-alist)
(push '("forall" . ?∀) prettify-symbols-alist)
(push '("sqrt" . ?√) prettify-symbols-alist)
(push '("undefined" . ?⊥) prettify-symbols-alist)
(push '("sqrt" . ?√) prettify-symbols-alist)
(prettify-symbols-mode)
)
)
)
)
Make undo more useful, and treelike.
(use-package undo-tree
:ensure t
:init
(progn (global-undo-tree-mode))
:config
(progn (defadvice undo-tree-visualize (around undo-tree-split-side-by-side activate)
"Split undo-tree side-by-side"
(let ((split-height-threshold nil)
(split-width-threshold 0))
ad-do-it)
)
)
:bind
("C-x u" . undo-tree-visualize)
)
Color variables for easy identification, its like a rainbow puked over everything opened in prog-mode-hook.
(use-package color-identifiers-mode
:ensure t
:config
(add-hook 'prog-mode-hook 'color-identifiers-mode)
)
Instead of text might as well get a decent mode hook going here.
(use-package nix-mode :ensure t)
Common mode defaults I think are sensible.
(add-hook 'prog-mode-hook
'(lambda ()
(auto-complete-mode) ;; can't get this to work with use-package easily
(interactive)
(hl-line-mode)
(whitespace-mode)
(visual-line-mode)
(flyspell-prog-mode)
(custom-set-variables
'(indent-tabs-mode nil)
'(tab-width 2)
)
)
)
(add-to-list 'auto-mode-alist '("\\.[chm]\\'" . c-mode))
(add-hook 'c-mode-common-hook
'(lambda ()
(global-set-key "\C-x\C-m" 'compile)
(setq flycheck-clang-language-standard "c11")
(setq flycheck-idle-change-delay 2)
(setq flycheck-highlighting-mode 'symbols)
;; later...
;; (add-hook 'before-save-hook 'clang-format-buffer nil t)
(c-toggle-auto-state 1)
(setq-default c-basic-offset 2
tab-width 2
indent-tabs-mode nil
c-electric-flag t
indent-level 2
c-default-style "bsd"
backward-delete-function nil)
))
TODO: fixme
(add-hook 'emacs-lisp-hook
(lambda ()
(define-key emacs-lisp-map
"\C-x\C-e" 'pp-eval-last-sexp)
(define-key emacs-lisp-map
"\r" 'reindent-then-newline-and-indent)))
(add-hook 'python-mode-hook
'(lambda ()
(flycheck-select-checker 'python-flake8)
(flycheck-select-checker 'python-pylint)
)
)
(autoload 'sh--mode "sh-mode" "mode for shell stuff" t)
(add-to-list 'auto-mode-alist '("\\.sh$\\'" . sh-mode))
(add-to-list 'auto-mode-alist '("\\.[zk]sh$\\'" . sh-mode))
(add-to-list 'auto-mode-alist '("\\.bash$\\'" . sh-mode))
(add-to-list 'auto-mode-alist '("\\[.].*shrc$\\'" . sh-mode))
(add-to-list 'auto-mode-alist '("sourceme$\\'" . sh-mode))
(add-hook 'sh-mode-hook
'(lambda ()
(setq sh-basic-offset 2 sh-indentation 4
sh-indent-for-case-label 0 sh-indent-for-case-alt '+)))
(fset 'perl-mode 'cperl-mode)
(add-hook 'cperl-mode-hook
'(lambda ()
(setq indent-tabs-mode t)
(setq tab-width 8)
(setq cperl-indent-level 4)
(setq tab-stop-list (number-sequence 4 200 4))
(setq cperl-tab-always-indent t)
(setq cperl-indent-parens-as-block t)
)
)
Use auto-insert-mode to insert in templates for blank files.
So first up, add auto-insert to find-file-hooks so we insert straight away. Also setup the copyright bit to minimally put in name.
(add-hook 'find-file-hooks 'auto-insert) (defvar auto-insert-copyright (user-full-name))
Create auto-insert-alist so all the mode lists are the same
(defvar auto-insert-alist '(()))
(setq auto-insert-alist
(append
'(
((c-mode . "c")
nil
"/*\n"
"File: " (file-name-nondirectory buffer-file-name) "\n"
"Copyright: " (substring (current-time-string) -4) " " auto-insert-copyright "\n"
"Description: " _ "\n"
"*/\n"
"#include <stdio.h>\n"
"#include <stdlib.h>\n\n"
"int main(int argc, char **argv) {\n"
" return 0;\n"
"}\n"
)
)
auto-insert-alist)
)
(setq auto-insert-alist
(append
'(
((emacs-lisp-mode . "elisp")
nil
";;-*-mode: emacs-lisp; coding: utf-8;-*-\n"
";; File: " (file-name-nondirectory buffer-file-name) "\n"
";; Copyright: " (substring (current-time-string) -4) " " auto-insert-copyright "\n"
";; Description: " _ "\n"
)
)
auto-insert-alist)
)
(setq auto-insert-alist
(append
'(((python-mode . "python")
nil
"#!/usr/bin/env python\n"
"# -*-mode: Python; coding: utf-8;-*-\n"
"# File: " (file-name-nondirectory buffer-file-name) "\n"
"# Copyright: " (substring (current-time-string) -4) " " auto-insert-copyright "\n"
"# Description: " _ "\n\n"
)
)
auto-insert-alist)
)
(setq auto-insert-alist
(append
'(
((sh-mode . "sh")
nil
"#!/usr/bin/env sh\n"
"#-*-mode: Shell-script; coding: utf-8;-*-\n"
"# File: " (file-name-nondirectory buffer-file-name) "\n"
"# Copyright: " (substring (current-time-string) -4) " " auto-insert-copyright "\n"
"# Description: " _ "\n"
"export script=$(basename \"$0\")\n"
"export dir=$(cd \"$(dirname \"$0\")\"; pwd)\n"
"export iam=${dir}/${script}\n"
)
)
auto-insert-alist)
)
Load this up last to allow for local customization if needed and to keep from custom writing to the init.el file.
(setq custom-file "~/.emacs.d/custom.el") (load custom-file 'noerror)