Skip to content

Latest commit

 

History

History
873 lines (835 loc) · 31.5 KB

init.org

File metadata and controls

873 lines (835 loc) · 31.5 KB

General

Automatically byte-compile

Compile files that have already been compiled before.

(defun auto-byte-recompile ()
  "If the current buffer is in emacs-lisp-mode and there already exists an `.elc'
  file corresponding to the current buffer file, then recompile the file."
  (interactive)
  (when (and (eq major-mode 'emacs-lisp-mode)
             (file-exists-p (byte-compile-dest-file buffer-file-name)))
    (byte-compile-file buffer-file-name)))
  (add-hook 'after-save-hook 'auto-byte-recompile)

Start emacs server for emacsclient

(server-start)
(autoload 'server-edit "server" nil t)
(server-edit)

Set up ELPA

    (setq package-archives '(("org" . "https://orgmode.org/elpa/")
                             ("ELPA" . "http://tromey.com/elpa/") 
                             ("gnu" . "http://elpa.gnu.org/packages/")
                             ("melpa" . "https://melpa.org/packages/")))
(require 'use-package)

Notifications

(use-package notify)

Internet

Tramp

;; Set tramp variables
(setq tramp-default-method "ssh")
;; have tramp save temps locally...
(setq auto-save-file-name-transforms
      '(("\\`/[^/]*:\\([^/]*/\\)*\\([^/]*\\)\\'" "/tmp/\\2" t)
	("\\`/?\\([^/]*/\\)*\\([^/]*\\)\\'" "~/.emacs.d/auto-save/" t)))

ERC

(defun erc-libera ()
  (interactive)
  (erc :server "irc.libera.chat"
	 :port "6697"))

Email

(setq mail-user-agent 'gnus-user-agent)

Editing

Emacs Interface editing

Move emacs “backup” files to a directory

(push '("." . "~/.emacs.d/backups") backup-directory-alist)

Unique buffer names

(setq 
  uniquify-buffer-name-style 'forward
  uniquify-separator ":")

Make sentences end with one space instead of two spaces

(setq sentence-end-double-space nil)

EVIL

 (use-package evil-leader
   :ensure t
   :config
   (global-evil-leader-mode)
   (evil-leader/set-leader ",")
   (evil-leader/set-key
     "m" #'compile
     "l" #'linum-mode))
 (use-package evil
   :ensure t
   :config (evil-mode t)
   (fset 'evil-visual-update-x-selection 'ignore)
   (define-key evil-normal-state-map (kbd "C-k") #'evil-scroll-up)
   (define-key evil-normal-state-map (kbd "C-j") #'evil-scroll-down)
   (define-key evil-normal-state-map (kbd "M-.") nil)
   (define-key evil-normal-state-map (kbd "M-,") nil)
   (evil-define-key 'normal org-mode (kbd "<tab>") #'org-cycle)
   (evil-define-key 'normal ednc-view-mode-map (kbd "<tab>") #'ednc-toggle-expanded-view)
   (evil-define-key 'normal ednc-view-mode-map (kbd "d") #'ednc-dismiss-notifications)
   (evil-define-key 'normal ednc-view-mode-map (kbd "<mouse-1>") #'ednc-invoke-action)
   (evil-define-key 'normal ednc-view-mode-map (kbd "<ret>") #'ednc-invoke-action)
   (setq evil-undo-system 'undo-redo)

   (mapc (lambda (mode-map)
	    (evil-add-hjkl-bindings mode-map 'emacs)) 
	  '(ibuffer-mode-map
	    jabber-roster-mode-map
	    gnus-group-mode-map
	    gnus-server-mode-map
	    gnus-browse-mode-map
	    gnus-summary-mode-map
	    gnus-article-mode-map
	    package-menu-mode-map))
   (defun evil-visual-update-x-selection (&optional buffer)
   "Update the X selection with the current visual region."
   (with-current-buffer (or buffer (current-buffer))
     (when (and (evil-visual-state-p)
		 (fboundp 'x-set-selection)   
		 (or (not (boundp 'ns-initialized))
		     (with-no-warnings ns-initialized))
		 (not (eq evil-visual-selection 'block)))
	(x-set-selection 'PRIMARY (buffer-substring-no-properties
				   evil-visual-beginning
				   evil-visual-end))
	(setq x-last-selected-text-primary nil))))
   (evil-define-motion evil-little-word (count)
     :type exclusive
     (let* ((case-fold-search nil)
	     (count (if count count 1)))
	(while (> count 0)
	  (forward-char)
	  (search-forward-regexp "[_A-Z]\\|\\W" nil t)
	  (backward-char)
	  (decf count))))
   (define-key evil-operator-state-map (kbd "lw") #'evil-little-word))
 (use-package evil-collection
   :after evil
   :ensure t
   :config
   (remove 'info evil-collection-mode-list)
   (evil-collection-init))
 (use-package evil-surround
   :ensure t
   :config (global-evil-surround-mode 1))
 (use-package evil-numbers
   :ensure t
   :config
   (define-key evil-normal-state-map (kbd "C-a") 'evil-numbers/inc-at-pt)
   (define-key evil-normal-state-map (kbd "M-a") 'evil-numbers/dec-at-pt))
 (use-package evil-smartparens
   :ensure t
   :config
   (add-hook 'smartparens-enabled-hook #'evil-smartparens-mode))
 (use-package evil-commentary
   :ensure t
   :config (evil-commentary-mode))
 (use-package evil-tutor
   :ensure t)

Dired customizations

 (global-auto-revert-mode t)
 (defun dired-copy-filename ()
   "Get filename+path and copy it to kill ring in dired"
   (interactive)
   (message "Slurped %s " (kill-new (dired-get-filename))))
 (add-hook 'dired-load-hook
	    (lambda ()
	      (load "dired-x")
	      ;; Set dired-x global variables here.  For example:
	      ))
 (add-hook 'dired-mode-hook
	    (lambda ()
	      ;; Set dired-x buffer-local variables here.  For example:
	      (define-key dired-mode-map "c" 'dired-copy-filename)))
 (setq dired-guess-shell-alist-user '(("\\.djvu$" "xpdf")
				       ("\\.pdf$" "xpdf")
				       ("\\.ps$" "xpdf")
				       ("\\.odt$" "soffice")
				       ("\\.odp$" "soffice")
				       ("\\.doc$" "soffice")
				       ("\\.docx$" "soffice")
				       ("\\.ppt$" "soffice")
				       ("\\.pptx$" "soffice"))
	dired-listing-switches "-alh"
	dired-omit-files "^\\.?#\\|^\\.?~\\|^\\.[A-Za-z0-9]"
	dired-recursive-copies 'always
	dired-recursive-deletes 'top
	dired-dwim-target t
	global-auto-revert-non-file-buffers t
	auto-revert-verbose nil)

Disable UI elements

(scroll-bar-mode -1)
(when (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(when (fboundp 'menu-bar-mode) (menu-bar-mode -1))

Hi-line mode

(global-hl-line-mode t)
(set-face-underline 'hl-line nil)

Custom rebinds for better productivity

(global-set-key "\C-w" #'backward-kill-word)
(global-set-key "\C-x\C-k" #'kill-region)
(global-set-key "\C-c\C-k" #'kill-region)

(global-set-key (kbd "C-M-=") #'indent-region)
(global-set-key (kbd "M-j") (lambda () (interactive) (join-line -1)))

Toggle-Map

Taken from here

“The manual recommends C-c for user keys, but I (Artur Malabarba) like using C-x for global keys and using C-c for mode-specific keys.” (I (Dave) agree with this philosophy, so the comment stays.)

(define-prefix-command 'endless/toggle-map)
(define-key ctl-x-map "t" 'endless/toggle-map)
(define-key endless/toggle-map "c" #'column-number-mode)
(define-key endless/toggle-map "d" #'toggle-debug-on-error)
(define-key endless/toggle-map "e" #'toggle-debug-on-error)
(define-key endless/toggle-map "f" #'auto-fill-mode)
(define-key endless/toggle-map "l" #'toggle-truncate-lines)
(define-key endless/toggle-map "q" #'toggle-debug-on-quit)
(define-key endless/toggle-map "r" #'read-only-mode)
(define-key endless/toggle-map "t" #'toggle-themes)
(define-key endless/toggle-map "w" #'whitespace-mode)

Launch-Map

(define-prefix-command 'launcher-map)
(define-key ctl-x-map "l" 'launcher-map)
;; (global-set-key (kbd "s-l") 'launcher-map)
(define-key launcher-map "c" #'calc)
(define-key launcher-map "C" #'calendar)
(define-key launcher-map "d" #'ediff-buffers)
(define-key launcher-map "f" #'find-dired)
(define-key launcher-map "g" #'lgrep)
(define-key launcher-map "G" #'rgrep)
(define-key launcher-map "h" #'man) ; Help
(define-key launcher-map "i" #'package-install-from-buffer)
(define-key launcher-map "p" #'list-packages)
(define-key launcher-map "s" #'shell)
(define-key launcher-map "t" #'proced) ; top

Narrow-widen DWIM

This Gem from here.

(defun narrow-or-widen-dwim (p)
  "If the buffer is narrowed, it widens. Otherwise, it narrows intelligently.
  Intelligently means: region, org-src-block, org-subtree, or defun,
  whichever applies first.
  Narrowing to org-src-block actually calls `org-edit-src-code'.
  
  With prefix P, don't widen, just narrow even if buffer is already
  narrowed."
  (interactive "P")
  (declare (interactive-only))
  (cond ((and (buffer-narrowed-p) (not p)) (widen))
        ((region-active-p)
         (narrow-to-region (region-beginning) (region-end)))
        ((derived-mode-p 'org-mode)
         ;; `org-edit-src-code' is not a real narrowing command.
         ;; Remove this first conditional if you don't want it.
         (cond ((org-in-src-block-p)
                (org-edit-src-code)
                (delete-other-windows))
               ((org-at-block-p)
                (org-narrow-to-block))
               (t (org-narrow-to-subtree))))
        (t (narrow-to-defun))))
(define-key ctl-x-map "n" #'narrow-or-widen-dwim)
(eval-after-load 'org-src
  '(define-key org-src-mode-map
     "\C-x\C-s" #'org-edit-src-exit))

Ibuffer Mode

Turn on the infamous ibuffer mode

(global-set-key (kbd "C-x C-b") 'ibuffer) ;; Use Ibuffer for Buffer List
(setq ibuffer-saved-filter-groups
      '(("home"
         ("Diary" (or (mode . Diary)
                      (name . "diary")
                      (name . "\*Calendar\*")))
         ("emacs-config" (or (filename . ".emacs.d")
                             (filename . ".emacs-lisp")
                             (filename . ".emacs")
                             (filename . "emacs-config")))
         ("Org" (or (mode . org-mode)
                    (filename . "*.org")))
         ("LaTeX" (or (mode . LaTeX-mode)
                      (mode . latex-mode)))
         ("C Family" (or (mode . c-mode)
                         (mode . c++-mode)))
         ("XML" (or (filename . "xml")
                    (mode . nXML)))
         ("Lisp" (or (filename . "lisp")
                     (mode . lisp-mode)))
         ("Python" (or (filename . "py")
                       (mode . Python)
                       (mode . python)))
         ("Chat" (or (mode . erc-mode)
                     (mode . jabber-chat-mode)
                     (name . "\*-jabber-roster-\*")))
         ("Music" (or (mode . EMMS-mode)
                      (mode . Emms-Browser-mode)
                      (name . "\*Music\*")
                      (mode . Emms-Browser)))
         ("Dired" (or (mode . dired-mode)
                      (mode . dired+-mode)))
         ("Shell Scripts" (or (mode . shell-script-mode)
                      (filename . "sh")))
         ("Gnus" (or (mode . Group)
                     (mode . Summary)
                     (mode . Article)
                     (name . "\*Group\*")
                     (name . "\*Summary nn.*")
                     (name . "\*Article nn.*")
                     (name . "\*Gnus.*")
                     (name . "\*Server\*")
                     (name . ".*sent.*")))
         ("BBDB" (or (mode . BBDB)
                     (name . "\.bbdb")))
         ("Help" (or (name . "\*Help\*")
                     (name . "\*Apropos\*")
                     (mode . Help)
                     (name . "\*info\*")))
         ("TRAMP" (name . "\*tramp/.*"))
         ("Calculator" (or (name . "\*Calc*\*")
                           (mode . Calculator)))
         ("Ruby" (or (mode . Ruby)
                     (filename . "rb")))
         ("Shells" (or (mode . EShell)
                       (name . "\*eshell\**")
                       (mode . Term)
                       (name . "\**term*\*"))))))

(add-hook 'ibuffer-mode-hook 
          '(lambda ()
             (ibuffer-auto-mode 1)
             (ibuffer-switch-to-saved-filter-groups "home")))
(setq ibuffer-expert t
      ibuffer-show-empty-filter-groups nil)

Eval and replace

(defun fc-eval-and-replace ()
  "Replace the preceding sexp with its value."
  (interactive)
  (backward-kill-sexp)
  (condition-case nil
      (prin1 (eval (read (current-kill 0)))
             (current-buffer))
    (error (message "Invalid expression")
           (insert (current-kill 0)))))
(global-set-key (kbd "C-c e") 'fc-eval-and-replace)

Mode-line customization

This works fairly well, its very minimal. The only thing “missing” is the vc status which I can’t quite get right.

 (setq-default mode-line-format
	(list
	 " " mode-line-modified
	 " %[" mode-line-buffer-identification " %l%] %6 "
	 mode-line-misc-info
	 mode-line-end-spaces))
 (setq global-mode-string '("" (vc-mode vc-mode)
			     evil-mode-line-tag
			     display-time-string
			     appt-mode-string))

Custom scratch message

(setq scratch-msgs '("Curiosity is Life."
                     "All things come to him who waits."
                     "Your skills will accomplish what the force of many cannot."
                     "To combat a sour attitude use kind words."
                     "A good memory is fine but the ability to forget is the one true test of greatness."
                     "A leader is powerful to the degree he empowers others."
                     "If you have hope, you have everything."
                     "Nothing in the world can take the place of persistence."
                     "Teamwork makes the dream work."
                     "Simplicity of character is the natural result of profound thought."
                     "Now is the time to set your sights high and \"Go for it\". "
                     "Do it because you love it."
                     "A new venture will be a success."
                     "He who seeks will find."
                     "If you have no critics you'll likely have no success."
                     "Hope is the best stimulant of life."
                     "There is but one cause of human failure. And that is man's lack of faith in his true self."
                     "A hunch is creativity trying to tell you something."
                     "Write injuries in dust, benefits in marble."
                     "You are strong and brave, use these qualities to pull through."
                     "Do not let what you do not have, prevent you from using what you do have. "
                     "Discipline is the refining fire by which talent becomes ability."
                     "Good books are friends who are always ready to talk to us."
                     "Not all closed eye is sleeping, nor open eye seeing."
                     "Success is never final and failure never fatal. Its courage that counts."
                     "Emotion hinders your true self."
                     "Experience is reflective like a still pond."
                     "The speed of the leader determines the rate of the pack."
                     "We need to attract people who create more light than heat."
                     "Patience is bitter, but its fruit is sweet."
                     "You will find your solution where you least expect it."
                     "In the end all things will be known."
                     "Opportunity will soon knock.  When it does, answer the door!"
                     "In the eyes of lovers, everything is beautiful."
                     "Enjoy what you have, hope for what you lack."
                     "With every deed you are sowing a seed, though the harvest you may not see."
                     "The most valuable of all talents is that of never using two words when one will do."
                     "Softening your attitude opens your heart."
                     "Success is failure turned inside out."
                     "A person with a determined heart frightens problems away."
                     "Do you see difficulty behind every opportunity, or opportunity behind every difficulty?"
                     "Better to do something imperfectly than to do nothing perfectly."
                     "Enjoy what you have! Never mind fame and power."))
(setq initial-scratch-message 
      (concat ";; Remember: "(nth (random (length scratch-msgs)) scratch-msgs ) "\n"))
(with-current-buffer "*scratch*"
  (goto-char (point-min))
  (fill-paragraph nil)
  (goto-char (point-max)))

Whitespace visualization

(use-package whitespace
  :config
  (setq whitespace-style '(face empty tabs lines-tail trailing)))

VC Options

See manual for other options, ‘nil’ means display a warning but visit anyway.

(setq vc-follow-symlinks nil)

Literature stuff

Unfill region

(defun unfill-region (begin end)
 "Remove all linebreaks in a region but leave paragraphs, 
 indented text (quotes,code) and lines starting with an asterix (lists) intact."
 (interactive "r")
 (replace-regexp "\\([^\n]\\)\n\\([^ *\n]\\)" "\\1 \\2" nil begin end))

Aspell spell checking on the fly

(setq ispell-program-name "aspell"
  ispell-extra-args '("--sug-mode=ultra"))
(dolist (hook '(LaTeX-mode-hook
                tex-mode-hook
                text-mode-hook
                jabber-chat-mode-hook
                erc-mode-hook))
  (add-hook hook (lambda () (flyspell-mode 1))))
(dolist (hook '(c-mode-hook lisp-mode-hook c++-mode-hook python-mode-hook))
  (add-hook hook (lambda () (flyspell-prog-mode))))

LaTeX and friends

(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq TeX-PDF-mode t)
(setq-default TeX-master nil)

(add-hook 'LaTeX-mode-hook 'auto-fill-mode)
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)

(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)

Code Editing

subword mode for non-lispy languages

(add-hook 'c-mode-hook 'subword-mode)
(mapc (lambda (mode)
          (add-hook mode 'subword-mode))
        '(c-mode-hook
          c++-mode-hook
          python-mode-hook
          java-mode-hook))

Copy paste with X fix

(setq x-select-enable-clipboard t)
(when (functionp #'x-cut-buffer-or-selection-value)
    (setq interprogram-paste-function #'x-cut-buffer-or-selection-value))

Compilation Mode

(setq compilation-scroll-output 'first-error)

Comments

(defun comment-or-uncomment-line-or-region ()
  "(Un)comment line. If region is active, (un)comment region."
  (interactive)
  (if (region-active-p)
      (comment-or-uncomment-region (region-beginning) (region-end))
    (comment-or-uncomment-region (line-beginning-position) (line-end-position))))
(define-key global-map (kbd "C-c C-/") 'comment-or-uncomment-line-or-region)

Delimiters (parens and family)

Smartparens

(use-package smartparens
  :ensure t
  :config 
  (smartparens-global-mode t)
  (show-smartparens-global-mode t)
  (require 'smartparens-config)
  (require 'smartparens-ruby)
  (sp-with-modes '(rhtml-mode)
    (sp-local-pair "<" ">")
    (sp-local-pair "<%" "%>"))
  (sp-with-modes '(org-mode)
    (sp-local-pair "$" "$"))
  (mapc (lambda (mode)
	    (add-hook mode (lambda ()
			     (setq sp-pair-list
				   (remove '("'" . "'") sp-pair-list)))))
	  '(Latex-mode-hook
	    org-mode-hook
	    tex-mode-hook
	    text-mode-hook)))

SLIME

Load slime for clisp hacking

(setq inferior-lisp-program "sbcl")
(load (expand-file-name "~/quicklisp/slime-helper.el"))
(require 'slime-autoloads)
(add-hook 'lisp-mode-hook (lambda () (slime-mode t)))
(add-hook 'inferior-lisp-mode-hook (lambda () (inferior-slime-mode t)))
(slime-setup '(slime-fancy)) ; almost everything

CLHS

(add-to-list 'load-path "~/.emacs-lisp/gcl-info")
(require 'get-gcl-info)

Misc

Color Theme

(use-package flexoki-themes
  :ensure t  ;; or :straight t if using straight.el
  :config (load-theme 'flexoki-themes-dark t))

(setq current-theme 'flexoki-themes-dark)
(setq dark-theme 'flexoki-themes-dark)
(setq light-theme 'flexoki-themes-light)

(load-theme current-theme t)
(defun toggle-themes ()
  (interactive)
  (cond ((eq current-theme light-theme) 
	   (setq current-theme dark-theme)
	   (shell-command "xrdb -load ~/dotfiles/Xresources-dark"))
	  ((eq current-theme dark-theme)
	   (setq current-theme light-theme)
	   (shell-command "xrdb -load ~/dotfiles/Xresources-light")))
  (load-theme current-theme))

Default font

;(add-to-list 'default-frame-alist '(font . "Fira Code-12"))
(add-to-list 'default-frame-alist '(font . "Berkeley Mono-12"))

Diary

(setq diary-file "~/.emacs-lisp/diary")

Markdown mode

(use-package markdown-mode
  :ensure t)

Hydra

(use-package hydra
:ensure t)
  (defhydra hydra-zoom (global-map "<f2>")
    "zoom"
    ("g" text-scale-increase "in")
    ("l" text-scale-decrease "out"))

 (defhydra hydra-org-template (:color blue :hint nil)
    "
 _c_enter  _q_uote     _e_macs-lisp    _L_aTeX:
 _l_atex   _E_xample   _p_erl          _i_ndex:
 _a_scii   _v_erse     _P_erl tangled  _I_NCLUDE:
 _s_rc     _n_ote      plant_u_ml      _H_TML:
 _h_tml    ^ ^         ^ ^             _A_SCII:
"
    ("s" (hot-expand "<s"))
    ("E" (hot-expand "<e"))
    ("q" (hot-expand "<q"))
    ("v" (hot-expand "<v"))
    ("n" (hot-expand "<not"))
    ("c" (hot-expand "<c"))
    ("l" (hot-expand "<l"))
    ("h" (hot-expand "<h"))
    ("a" (hot-expand "<a"))
    ("L" (hot-expand "<L"))
    ("i" (hot-expand "<i"))
    ("e" (hot-expand "<s" "emacs-lisp"))
    ("p" (hot-expand "<s" "perl"))
    ("u" (hot-expand "<s" "plantuml :file CHANGE.png"))
    ("P" (hot-expand "<s" "perl" ":results output :exports both :shebang \"#!/usr/bin/env perl\"\n"))
    ("I" (hot-expand "<I"))
    ("H" (hot-expand "<H"))
    ("A" (hot-expand "<A"))
    ("<" self-insert-command "ins")
    ("o" nil "quit"))

  (require 'org-tempo) ; Required from org 9 onwards for old template expansion
  ;; Reset the org-template expnsion system, this is need after upgrading to org 9 for some reason
  (setq org-structure-template-alist (eval (car (get 'org-structure-template-alist 'standard-value))))
  (defun hot-expand (str &optional mod header)
    "Expand org template.

STR is a structure template string recognised by org like <s. MOD is a
string with additional parameters to add the begin line of the
structure element. HEADER string includes more parameters that are
prepended to the element after the #+HEADER: tag."
    (let (text)
      (when (region-active-p)
        (setq text (buffer-substring (region-beginning) (region-end)))
        (delete-region (region-beginning) (region-end))
        (deactivate-mark))
      (when header (insert "#+HEADER: " header) (forward-line))
      (insert str)
      (org-tempo-complete-tag)
      (when mod (insert mod) (forward-line))
      (when text (insert text))))

  (define-key org-mode-map "<"
    (lambda () (interactive)
      (if (or (region-active-p) (looking-back "^"))
          (hydra-org-template/body)
        (self-insert-command 1))))

  (eval-after-load "org"
    '(cl-pushnew
    '("not" . "note")
      org-structure-template-alist))

Info tweaks

(add-to-list 'Info-directory-list "~/local/share/info")
(add-to-list 'Info-directory-list "~/.local/share/info")

Calc Tweaks

(setq math-additional-units
      '((bit    nil           "Bit")
        (byte   "8 * bit"     "Byte")
        (bps    "bit / s"     "Bit per second"))
        math-units-table nil)

Org-inits

Custom Latex Classes

First setup the export process to use latexmk and pdflatex, remove “fixltx2e” package since it conflicts with some of the custom classes, allow org files to bind local variables, and prepare org-latex-classes for adding templates.

(require 'ox-latex)
(setq org-latex-pdf-process
      '("latexmk -bibtex -pdflatex='pdflatex --shell-escape -interaction nonstopmode' -pdf -f %f"))

(setf org-latex-default-packages-alist
      (remove '("" "fixltx2e" nil) org-latex-default-packages-alist))
(setq org-export-allow-bind-keywords t
      org-latex-with-hyperref nil)
(unless (boundp 'org-latex-classes)
  (setq org-latex-classes nil))

Tufte Latex

(add-to-list 'org-latex-classes
                 '("tufte-book"
                   "
\\documentclass[]{tufte-book}
\\usepackage{booktabs}
\\usepackage{tikz}
\\usepackage{pgfplots}
\\usepackage{amsmath}
\\usepackage{graphicx}
\\setkeys{Gin}{width=\\linewidth,totalheight=\\textheight,keepaspectratio}
\\graphicspath{{graphics\/}}
\\usepackage{fancyvrb}
\\fvset{fontsize=\\normalsize}
\\usepackage{xspace}
\\usepackage{units}
\\usepackage{makeidx}
" 
                   ("\\chapter{%s}" . "\\chapter*{%s}") 
                   ("\\section{%s}" . "\\section{%s}") 
                   ("\\subsection{%s}" . "\\subsection{%s}") 
                   ("\\subsubsection{%s}" . "\\subsubsection{%s}") 
                   ("\\paragraph{%s}" . "\\paragraph{%s}")
                   ("\\subparagraph{%s}" . "\\subparagraph{%s}")))

Org Ref

(use-package org-ref 
    :ensure t
    :config 
    (setq reftex-default-bibliography '("~/Dropbox/org/research/papers/bibliography.bib")
      org-ref-bibliography-notes "~/Dropbox/org/research/papers/bibliography.org"
      org-ref-default-bibliography '("~/Dropbox/org/research/papers/bibliography.bib")
      org-ref-pdf-directory "~/Dropbox/org/research/papers/bibtex-pdfs/"
      bibtex-completion-pdf-open-function #'org-open-file))

Agenda Files

Appointment Notifications

Set appropriate variables for appointment pop-ups 5mins before they happen.

 (setq appt-message-warning-time 5
	appt-display-mode-line t
	appt-display-format 'window)
 (appt-activate 1)
 (add-hook 'org-finalize-agenda-hook 'org-agenda-to-appt)

Misc Org Inits

 (add-to-list 'org-latex-classes 
	       '("memoir"
		 "\\documentclass[12pt]{memoir}" 
		 ("\\section{%s}" . "\\section*{%s}") 
		 ("\\subsection{%s}" . "\\subsection*{%s}") 
		 ("\\subsubsection{%s}" . "\\subsubsection*{%s}") 
		 ("\\paragraph{%s}" . "\\paragraph*{%s}")
		 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))


 (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
 (setq help-at-pt-display-when-idle t
	org-export-copy-to-kill-ring nil
	org-export-allow-bind-keywords t)

 (global-set-key "\C-cl" 'org-store-link)
 (global-set-key "\C-ca" 'org-agenda)
 (global-set-key "\C-cb" 'org-iswitchb)

 (define-key mode-specific-map [?a] 'org-agenda)
 (setcdr (assoc "\\.pdf\\'" org-file-apps) "xpdf %s")

 (add-hook 'org-agenda-mode-hook
	    (lambda ()
	      (define-key org-agenda-mode-map "\C-n" 'next-line)
	      (define-key org-agenda-keymap "\C-n" 'next-line)
	      (define-key org-agenda-mode-map "\C-p" 'previous-line)
	      (define-key org-agenda-keymap "\C-p" 'previous-line)))
 (eval-after-load "org"
   '(progn
      (define-prefix-command 'org-todo-state-map)
      (define-key org-mode-map "\C-cx" 'org-todo-state-map)
      (define-key org-todo-state-map "x"
	 #'(lambda nil (interactive) (org-todo "CANCELLED")))
      (define-key org-todo-state-map "d"
	 #'(lambda nil (interactive) (org-todo "DONE")))
      (define-key org-todo-state-map "f"
	 #'(lambda nil (interactive) (org-todo "DEFERRED")))
      (define-key org-todo-state-map "l"
	 #'(lambda nil (interactive) (org-todo "DELEGATED")))
      (define-key org-todo-state-map "s"
	 #'(lambda nil (interactive) (org-todo "STARTED")))
      (define-key org-todo-state-map "w"
	 #'(lambda nil (interactive) (org-todo "WAITING")))))

Org-mode static site publishing

The HEP guide

(setq org-html-metadata-timestamp-format "%m/%d/%Y"
 org-publish-project-alist
 '(("thhg-orgfiles"
    :base-directory "~/hitchhikers-guide-to-hep/"
    :base-extension "org"
    :publishing-directory "~/public/the-guide/"
    :recursive t
    :publishing-function org-html-publish-to-html
    :headline-levels 5
    :auto-preamble t
    :section-numbers nil
    :table-of-contents t
    :style-include-default nil
    :html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"./css/style.css\" />"
    :html-preamble t
    :html-postamble "<p class=\"postamble\"><hr/> Written by: %a. Last updated %d. </p>")
   ("thhg-images"
    :base-directory "~/hitchhikers-guide-to-hep/images/"
    :base-extension "jpg\\|gif\\|png"
    :publishing-directory "~/public/the-guide/images/"
    :recursive t
    :publishing-function org-publish-attachment)

   ("thhg-css"
    :base-directory "~/hitchhikers-guide-to-hep/css/"
    :base-extension "css\\|el"
    :recursive t
    :publishing-directory "~/public/the-guide/"
    :publishing-function org-publish-attachment)
   ("thhg-website" :components ("thhg-orgfiles" "thhg-images" "thhg-css"))

   ("stumpwm-files"
    :base-directory "~/stumpwm.github.io/"
    :base-extension "org"
    :publishing-directory "~/stumpwm.github.io/"
    :recursive t
    :publishing-function org-html-publish-to-html
    :headline-levels 5
    :auto-preamble t
    :section-numbers nil
    :table-of-contents t
    :style-include-default nil
    :html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"./style.css\" />"
    :html-preamble t
    :html-postamble "<p></p>")
   ("stumpwm-website" :components ("stumpwm-files"))
   ))

Babel

Active babel langugages

(org-babel-do-load-languages
 'org-babel-load-languages
 '((scheme . t)
   (C . t)
   (ruby . t)
   (python . t)
   (gnuplot .t )
   (lisp . t)))

Interface tweaks

(font-lock-add-keywords 'org-mode
			    '(("^ +\\([-*]\\) "
			       (0 (prog1 () (compose-region 
					     (match-beginning 1)
					     (match-end 1) ""))))))
(let* (
	   (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 ))))
			      `(org-level-7 ((t (,@headline ))))
			      `(org-level-6 ((t (,@headline ))))
			      `(org-level-5 ((t (,@headline ))))
			      `(org-level-4 ((t (,@headline  :height 1.1))))
			      `(org-level-3 ((t (,@headline  :height 1.25))))
			      `(org-level-2 ((t (,@headline  :height 1.5))))
			      `(org-level-1 ((t (,@headline  :height 1.75))))
			      `(org-document-title ((t (,@headline :height 1.5 :underline nil))))))

CD

(cd "~/")