]> git.donarmstrong.com Git - lib.git/commitdiff
update configuration; outdent, use more demand and defer
authorDon Armstrong <don@donarmstrong.com>
Mon, 24 Jul 2023 23:55:48 +0000 (16:55 -0700)
committerDon Armstrong <don@donarmstrong.com>
Mon, 24 Jul 2023 23:55:48 +0000 (16:55 -0700)
emacs_el/configuration/don-configuration.org

index 28cd9532b0d5ad70f2d1c127fe9112f72a1dc997..a081d6d7dc2b08042344502d255ea411214b5c04 100644 (file)
 ** package repositories and package manager
 #+BEGIN_SRC emacs-lisp
 (require 'use-package)
+(setq use-package-always-ensure t)
 (require 'gnutls)
 (add-to-list 'gnutls-trustfiles "/etc/ssl/ca-global/ca-certificates.crt")
 (use-package package
   :init
 (setq package-enable-at-startup nil)
 (setq package--init-file-ensured t)
-; (setq package-user-dir "~/var/emacs/elpa")
 (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
                         ("melpa" . "https://melpa.org/packages/")
                         ("org" . "http://orgmode.org/elpa/")))
 #+END_SRC
 ** Paradox
 #+BEGIN_SRC emacs-lisp
-  (use-package paradox
-    :ensure paradox
-    :commands (paradox-upgrade-packages paradox-list-packages)
-    :config
-    (setq paradox-execute-asynchronously t)
-    (setq paradox-github-token t) ; I don't want to be prompted about this integration
-    )
+(use-package paradox
+  :ensure paradox
+  :commands (paradox-upgrade-packages paradox-list-packages)
+  :config
+  (setq paradox-execute-asynchronously t)
+  (setq paradox-github-token t) ; I don't want to be prompted about this integration
+  )
 #+END_SRC
 * Disable custom-vars
 #+BEGIN_SRC emacs-lisp
-  ;; Set the custom file to /dev/null and don't bother to load it
-  (setq custom-file "/dev/null")
+;; Set the custom file to /dev/null and don't bother to load it
+(setq custom-file "/dev/null")
 #+END_SRC
 * Misc functions
 ** with-library
 #+END_SRC
 * Memory
 #+BEGIN_SRC emacs-lisp
-  (setq global-mark-ring-max 128
-        mark-ring-max 128
-        kill-ring-max 128)
+(setq global-mark-ring-max 128
+      mark-ring-max 128
+      kill-ring-max 128)
 
-  (defun don/minibuffer-setup-hook ()
-    (setq gc-cons-threshold most-positive-fixnum))
+(defun don/minibuffer-setup-hook ()
+  (setq gc-cons-threshold most-positive-fixnum))
 
-  (defun don/minibuffer-exit-hook ()
-    (setq gc-cons-threshold 1048576))
+(defun don/minibuffer-exit-hook ()
+  (setq gc-cons-threshold 1048576))
 
-  (add-hook 'minibuffer-setup-hook #'don/minibuffer-setup-hook)
-  (add-hook 'minibuffer-exit-hook #'don/minibuffer-exit-hook)
+(add-hook 'minibuffer-setup-hook #'don/minibuffer-setup-hook)
+(add-hook 'minibuffer-exit-hook #'don/minibuffer-exit-hook)
 #+END_SRC
 * Modules
 ** Tree sitter
 #+BEGIN_SRC emacs-lisp
 (use-package tree-sitter
-  :ensure t
-  :defer 1
+  :defer t
   :config
   (global-tree-sitter-mode)
   )
 #+END_SRC
 ** Hippie Expand
 #+BEGIN_SRC emacs-lisp
-  (use-package hippie-exp
-    :bind* (("M-<SPC>" . hippie-expand))
-    )
+(use-package hippie-exp
+  :bind* (("M-<SPC>" . hippie-expand))
+  )
 #+END_SRC
 ** Flyspell πŸ 
 #+BEGIN_SRC emacs-lisp
-  (use-package flyspell
-    :ensure t
-    :delight flyspell-mode πŸ
-    :config
-    (add-hook 'text-mode-hook 'turn-on-flyspell)
-    (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
-    (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
-    (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
-    :init
-    (setq ispell-program-name "ispell")
-    )
+(use-package flyspell
+  :delight flyspell-mode πŸ
+  :config
+  (add-hook 'text-mode-hook 'turn-on-flyspell)
+  (add-hook 'c-mode-common-hook 'flyspell-prog-mode)
+  (add-hook 'cperl-mode-hook 'flyspell-prog-mode)
+  (add-hook 'tcl-mode-hook 'flyspell-prog-mode)
+  :init
+  (setq ispell-program-name "ispell")
+  )
 
 #+END_SRC
 
 #+end_src  
 
 ** Flymake
-#+begin_src emacs-lisp :tangle yes
+#+BEGIN_SRC emacs-lisp
   (use-package flymake
     :delight "Ξ¦")
-#+end_src
+#+END_SRC
 
 ** Winnermode
 #+BEGIN_SRC emacs-lisp
@@ -377,16 +375,10 @@ value, scrolling continues until there is no more output.
 #+END_SRC
 
 ** Mode line cleaning
-*** Delight
-#+BEGIN_SRC emacs-lisp
-  (use-package delight
-    :ensure t)
-#+END_SRC
-
 *** Delight 
 #+BEGIN_SRC emacs-lisp
-  (use-package delight
-    :ensure t)
+(use-package delight
+  :demand t)
 #+END_SRC
 
 ** Jumping
@@ -447,30 +439,29 @@ value, scrolling continues until there is no more output.
 #+END_SRC
 *** Auto-YASnippet
 #+BEGIN_SRC emacs-lisp
-  (use-package auto-yasnippet
-    :ensure t
-    :bind (("H-w" . aya-create)
-           ("H-y" . aya-expand)
-           )
-    )
+(use-package auto-yasnippet
+  :ensure t
+  :bind (("H-w" . aya-create)
+         ("H-y" . aya-expand)
+         )
+  )
 #+END_SRC
 ** Treemacs: Tree file viewer
 #+BEGIN_SRC emacs-lisp
 ;; Provides workspaces with file browsing (tree file viewer)
 ;; and project management when coupled with `projectile`.
 
-(use-package treemacs
-  :ensure t
-  :defer t
-  :config
-  (setq treemacs-no-png-images t
-         treemacs-width 24)
-  :bind ("C-c t" . treemacs))
+(use-package treemacs
+  :ensure t
+  :defer t
+  :config
+  (setq treemacs-no-png-images t
+;        treemacs-width 24)
+  :bind ("C-c t" . treemacs))
 #+END_SRC
 ** LSP mode
 #+BEGIN_SRC emacs-lisp
 (use-package lsp-mode
-  :ensure t
   :defer t
   :commands (lsp lsp-deferred)
   :init (setq lsp-keymap-prefix "C-c l")
@@ -496,7 +487,6 @@ value, scrolling continues until there is no more output.
 ;; For example definitions on hover. 
 ;; The `imenu` lets me browse definitions quickly.
 (use-package lsp-ui
-  :ensure t
   :defer t
   :config
   (setq lsp-ui-sideline-enable nil
@@ -507,15 +497,14 @@ value, scrolling continues until there is no more output.
 ;; Language server for Python 
 ;; Read the docs for the different variables set in the config.
 (use-package lsp-pyright
-  :ensure t
   :defer t
   :config
-  (setq lsp-clients-python-library-directories '("/usr/" "~/miniconda3/pkgs"))
+  (setq lsp-clients-python-library-directories '("/usr/"))
   (setq lsp-pyright-disable-language-service nil
        lsp-pyright-disable-organize-imports nil
        lsp-pyright-auto-import-completions t
        lsp-pyright-use-library-code-for-types t
-       lsp-pyright-venv-path "~/miniconda3/envs")
+       lsp-pyright-venv-path "venv")
   :hook ((python-mode . (lambda () 
                           (require 'lsp-pyright) (lsp-deferred)))))
 #+END_SRC
@@ -523,6 +512,7 @@ value, scrolling continues until there is no more output.
 #+BEGIN_SRC emacs-lisp
 (use-package corfu
   :ensure t
+  :demand t
   ;; Optional customizations
   :custom
   (corfu-cycle t)                ;; Enable cycling for `corfu-next/previous'
@@ -535,15 +525,7 @@ value, scrolling continues until there is no more output.
   (corfu-on-exact-match nil)     ;; Configure handling of exact matches
   (corfu-scroll-margin 5)        ;; Use scroll margin
 
-  ;; Enable Corfu only for certain modes.
-  ;; :hook ((prog-mode . corfu-mode)
-  ;;        (shell-mode . corfu-mode)
-  ;;        (eshell-mode . corfu-mode))
-
-  ;; Recommended: Enable Corfu globally.
-  ;; This is recommended since Dabbrev can be used globally (M-/).
-  ;; See also `corfu-exclude-modes'.
-  :init
+  :config
   (global-corfu-mode))
 #+END_SRC
 ** Dabbrv
@@ -569,9 +551,8 @@ value, scrolling continues until there is no more output.
 #+END_SRC
 
 ** Magit
-#+BEGIN_SRC emacs-lisp :tangle don-configuration.el
+#+BEGIN_SRC emacs-lisp
 (use-package magit
-  :ensure t
   :defer t
   :bind (("C-x g" . magit-status)
          ("C-x C-g" . magit-status))
@@ -580,12 +561,10 @@ value, scrolling continues until there is no more output.
   (setq magit-diff-refine-hunk nil)
   )
 (use-package magit-annex
-  :ensure t
   :defer t
   :load-path "~/lib/emacs_el/magit-annex/"
   )
 (use-package magit-vcsh
-  :ensure t
   :defer t
   )
 #+END_SRC
@@ -593,100 +572,98 @@ value, scrolling continues until there is no more output.
 *** Forge (github/gitlab)
 #+BEGIN_SRC emacs-lisp
 (use-package forge
-  :ensure t
   :after magit
   )
 #+END_SRC
 
 ** Perl
 #+BEGIN_SRC emacs-lisp
-  (use-package cperl-mode
-    :ensure t
-    :config
-    (progn
-      ;; Use c-mode for perl .xs files
-      (add-to-list 'auto-mode-alist '("\\.xs\\'" . c-mode))
-      (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
-      (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
-      (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
-      (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
-      (setq cperl-hairy t
-            cperl-indent-level 4
-            cperl-auto-newline nil
-            cperl-auto-newline-after-colon nil
-            cperl-continued-statement-offset 4
-            cperl-brace-offset -1
-            cperl-continued-brace-offset 0
-            cperl-label-offset -4
-            cperl-highlight-variables-indiscriminately t
-            cperl-electric-lbrace-space nil
-            cperl-indent-parens-as-block nil
-            cperl-close-paren-offset -1
-            cperl-tab-always-indent t)
-      ;;(add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
-  ))
+(use-package cperl-mode
+  :ensure t
+  :config
+  (progn
+    ;; Use c-mode for perl .xs files
+    (add-to-list 'auto-mode-alist '("\\.xs\\'" . c-mode))
+    (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
+    (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
+    (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
+    (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
+    (setq cperl-hairy t
+          cperl-indent-level 4
+          cperl-auto-newline nil
+          cperl-auto-newline-after-colon nil
+          cperl-continued-statement-offset 4
+          cperl-brace-offset -1
+          cperl-continued-brace-offset 0
+          cperl-label-offset -4
+          cperl-highlight-variables-indiscriminately t
+          cperl-electric-lbrace-space nil
+          cperl-indent-parens-as-block nil
+          cperl-close-paren-offset -1
+          cperl-tab-always-indent t)
+    (setq cperl-lazy-help-time nil)
+    ;;(add-hook 'cperl-mode-hook (lambda () (cperl-set-style "PerlStyle")))
+))
 #+END_SRC
 
 ** Markdown mode
 #+BEGIN_SRC emacs-lisp
-  (use-package markdown-mode
-    :ensure t
-    :mode (("\\.md\\'" . markdown-mode)
-           ("\\.mdwn\\'" . markdown-mode)
-           ("README\\.md\\'" . gfm-mode)
-           )
-    :config
-    (setq markdown-enable-math t)
-    (setq markdown-follow-wiki-link-on-enter nil)
-    (bind-key "M-." #'markdown-jump markdown-mode-map)
-    (add-hook 'markdown-mode-hook #'flyspell-mode)
-    (add-hook 'markdown-mode-hook #'outline-minor-mode)
-    (bind-key "C-<tab>" #'outline-cycle markdown-mode-map)
-  )
+(use-package markdown-mode
+  :ensure t
+  :defer t
+  :mode (("\\.md\\'" . markdown-mode)
+         ("\\.mdwn\\'" . markdown-mode)
+         ("README\\.md\\'" . gfm-mode)
+         )
+  :config
+  (setq markdown-enable-math t)
+  (setq markdown-follow-wiki-link-on-enter nil)
+  (bind-key "M-." #'markdown-jump markdown-mode-map)
+  (add-hook 'markdown-mode-hook #'flyspell-mode)
+  (add-hook 'markdown-mode-hook #'outline-minor-mode)
+  (bind-key "C-<tab>" #'outline-cycle markdown-mode-map)
+)
 
 #+END_SRC
 ** SQL mode
 #+BEGIN_SRC emacs-lisp
 ; load sql-indent when sql is loaded
 (use-package sql-indent
-  :ensure t
+  :defer t
   :hook sql-mode
   )
 (use-package sql
-  :ensure t
+  :defer t
   :mode (("\\.sql\\'" . sql-mode))
   )
 #+END_SRC
 ** Ediff
 #+BEGIN_SRC emacs-lisp
-  (use-package ediff
-    :commands ediff ediff3
-    :ensure f
-    :config
-    ;; ediff configuration
-    ;; don't use the multi-window configuration
-    (setq ediff-window-setup-function 'ediff-setup-windows-plain)
-  )
+(use-package ediff
+  :defer t
+  :commands ediff ediff3
+  :config
+  ;; ediff configuration
+  ;; don't use the multi-window configuration
+  (setq ediff-window-setup-function 'ediff-setup-windows-plain)
+)
 #+END_SRC
 ** Do the Right Thing Indenting
 Attempts to automatically identify the right indentation for a file
 #+BEGIN_SRC emacs-lisp
 (use-package dtrt-indent
-  :ensure t
 )  
 #+END_SRC
 ** VCL --editing varnish configuration files
 #+BEGIN_SRC emacs-lisp
-  (use-package vcl-mode
-    :ensure t
-    :mode "\\.vcl\\'"
-    )
-  
+(use-package vcl-mode
+  :mode "\\.vcl\\'"
+  )
+
 #+END_SRC
 ** Vertico
 #+BEGIN_SRC emacs-lisp
 (use-package vertico
-  :ensure t
   :demand t
   :config
   (vertico-mode)
@@ -709,43 +686,57 @@ Attempts to automatically identify the right indentation for a file
   :custom
   (vertico-grid-separator "       ")
   (vertico-grid-lookahead 50)
+  :config
+  (require 'vertico-multiform)
+  (setq vertico-multiform-categories
+     '((file reverse)
+       (consult-grep buffer)
+       (consult-location)
+       (imenu buffer)
+       (library reverse indexed)
+       (org-roam-node reverse indexed)
+       ; (t reverse)
+       )
+     )
+  (setq vertico-multiform-commands
+        '(("flyspell-correct-*" grid reverse)
+          (org-refile grid reverse indexed)
+          (consult-yank-pop indexed)
+          (consult-flycheck)
+          (consult-lsp-diagnostics)
+          )
+        )
+  (vertico-multiform-mode)
   )
-(use-package vertico-multiform
+(use-package vertico-grid
+  :ensure nil
+  :after vertico
+  )
+(use-package vertico-reverse
+  :ensure nil
+  :after vertico
+  )
+(use-package vertico-indexed
+  :ensure nil
+  :after vertico
+  )
+(use-package vertico-buffer
+  :ensure nil
   :after vertico
-  :config
-  ;(vertico-multiform-mode)
-  :custom
-    (vertico-multiform-categories
-   '((file reverse)
-     (consult-grep buffer)
-     (consult-location)
-     (imenu buffer)
-     (library reverse indexed)
-     (org-roam-node reverse indexed)
-     (t reverse)
-     ))
-  (vertico-multiform-commands
-   '(("flyspell-correct-*" grid reverse)
-     (org-refile grid reverse indexed)
-     (consult-yank-pop indexed)
-     (consult-flycheck)
-     (consult-lsp-diagnostics)
-     ))
   )
-  
 
 ;; Persist history over Emacs restarts. Vertico sorts by history position.
 (use-package savehist
-  :ensure t
-  :init
+  :demand t
+  :config
   (savehist-mode))
 
 #+END_SRC
 ** Orderless: advanced completion style
 #+begin_src emacs-lisp
 (use-package orderless
-  :ensure t
-  :init
+  :demand t
+  :config
   ;; Configure a custom style dispatcher (see the Consult wiki)
   ;; (setq orderless-style-dispatchers '(+orderless-dispatch)
   ;;       orderless-component-separator #'orderless-escapable-split-on-space)
@@ -756,18 +747,16 @@ Attempts to automatically identify the right indentation for a file
 ** Marginalia: Rich annotations in the minibuffer
 #+begin_src emacs-lisp
 (use-package marginalia
-  :ensure t
+  :demand t
   :bind (:map minibuffer-local-map
          ("M-A" . marginalia-cycle))
-  :init
+  :config
   (marginalia-mode)
   )
 #+end_src
 ** Embark: Minibuffer actions and context menu
 #+begin_src emacs-lisp
 (use-package embark
-  :ensure t
-
   :bind
   (("C-." . embark-act)         ;; pick some comfortable binding
    ("C-;" . embark-dwim)        ;; good alternative: M-.
@@ -787,7 +776,6 @@ Attempts to automatically identify the right indentation for a file
                  (window-parameters (mode-line-format . none)))))
 
 (use-package embark-consult
-  :ensure t
   :hook
   (embark-collect-mode . consult-preview-at-point-mode))
 #+end_src
@@ -882,7 +870,7 @@ Attempts to automatically identify the right indentation for a file
   (consult-customize
    consult-theme :preview-key '(:debounce 0.2 any)
    consult-ripgrep consult-git-grep consult-grep
-   consult-bookmark consult-recent-file consult-xref
+   consult-bookmark consult-recent-file consult-xref
    consult--source-bookmark consult--source-file-register
    consult--source-recent-file consult--source-project-recent-file
    ;; :preview-key "M-."
@@ -914,19 +902,16 @@ Attempts to automatically identify the right indentation for a file
 ** Projectile -- Project management
 #+begin_src emacs-lisp
 (use-package projectile
-  :ensure t
   :bind (("<f5>" . projectile-compile-project)
          ("<f6>" . next-error))
-  :config (progn
-            (use-package magit :ensure t)
-            (projectile-global-mode)))
+  :config (projectile-global-mode))
 #+end_src
 
 ** Zap to char
 #+BEGIN_SRC emacs-lisp
-  (use-package avy-zap
-    :ensure t
-    :bind ("M-z" . avy-zap-up-to-char-dwim))
+(use-package avy-zap
+  :ensure t
+  :bind ("M-z" . avy-zap-up-to-char-dwim))
 #+END_SRC
 ** Hydra
 #+BEGIN_SRC emacs-lisp
@@ -999,34 +984,33 @@ Attempts to automatically identify the right indentation for a file
 
 ** Tramp
 #+BEGIN_SRC emacs-lisp
-  (use-package tramp
-    :config
-    (add-to-list 'tramp-methods '("vcsh"
-                                  (tramp-login-program "vcsh")
-                                  (tramp-login-args
-                                   (("enter")
-                                    ("%h")))
-                                  (tramp-remote-shell "/bin/sh")
-                                  (tramp-remote-shell-args
-                                   ("-c")))))
+(use-package tramp
+  :config
+  (add-to-list 'tramp-methods '("vcsh"
+                                (tramp-login-program "vcsh")
+                                (tramp-login-args
+                                 (("enter")
+                                  ("%h")))
+                                (tramp-remote-shell "/bin/sh")
+                                (tramp-remote-shell-args
+                                 ("-c")))))
 #+END_SRC
 ** Reftex
 #+BEGIN_SRC emacs-lisp
-  (use-package reftex
-    :ensure t
-    :config
-    (setq-default reftex-default-bibliography
-                    '("~/projects/research/references.bib")))
+(use-package reftex
+  :config
+  (setq-default reftex-default-bibliography
+                  '("~/projects/research/references.bib")))
 #+END_SRC
 ** BibTex
 #+BEGIN_SRC emacs-lisp
-  (use-package bibtex
-    :config (setq bibtex-user-optional-fields
-                  (quote (("annote" "Personal annotation (ignored)")
-                          ("abstract" "")
-                  ("pmid" "")
-                  ("doi" ""))))
-    )
+(use-package bibtex
+  :config (setq bibtex-user-optional-fields
+                (quote (("annote" "Personal annotation (ignored)")
+                        ("abstract" "")
+                ("pmid" "")
+                ("doi" ""))))
+  )
 
 #+END_SRC
 ** LaTeX
@@ -1140,88 +1124,83 @@ Attempts to automatically identify the right indentation for a file
 #+END_SRC
 ** ESS
 #+BEGIN_SRC emacs-lisp
-  (use-package ess
-    :ensure t
-    :commands R
-    :mode ("\\.R\\'" . ess-r-mode)
-    :bind (:map ess-mode-map
-                ("C-c C-R" . dla/ess-region-remote-eval))
-    :init
-    (autoload 'ess-r-mode "ess-site" nil t)
-    (autoload 'R "ess-site" nil t)
-    :config
-    ; actually load the rest of ess
-    (require 'ess-site)
-    (defun ess-change-directory (path)
-      "Set the current working directory to PATH for both *R* and Emacs."
-      (interactive "Directory to change to: ")
-    
-      (when (file-exists-p path)
-        (ess-command (concat "setwd(\"" path "\")\n"))
-        ;; use file-name-as-directory to ensure it has trailing /
-        (setq default-directory (file-name-as-directory path))))
-    (add-hook 'ess-mode-hook 'flyspell-prog-mode)
-    ;; outlining support for ess modes
-    (add-hook
-     'ess-mode-hook
-     '(lambda ()
-        (outline-minor-mode)
-        (setq outline-regexp "\\(^#\\{4,5\\} \\)\\|\\(^[a-zA-Z0-9_\.]+ ?<- ?function\\)")
-        (defun outline-level ()
-          (cond ((looking-at "^##### ") 1)
-                ((looking-at "^#### ") 2)
-                ((looking-at "^[a-zA-Z0-9_\.]+ ?<- ?function(.*{") 3)
-                (t 1000)))
-        ))
-    (defun dla/ess-region-remote-eval (start end)
-      "Evaluate region in a remote ESS instance"
-      (interactive "r")
-      (shell-command-on-region start end "eval_r" (get-buffer-create "***essregionremoteeval***") nil nil nil)
-      (kill-buffer "***essregionremoteeval***"))
-    ;; Don't restore history or save workspace image
-    '(inferior-R-args "--no-restore-history --no-save")
-    )
+(use-package ess
+  :commands R
+  :mode ("\\.R\\'" . ess-r-mode)
+  :bind (:map ess-mode-map
+              ("C-c C-R" . dla/ess-region-remote-eval))
+  :init
+  (autoload 'ess-r-mode "ess-site" nil t)
+  (autoload 'R "ess-site" nil t)
+  :config
+  ; actually load the rest of ess
+  (require 'ess-site)
+  (defun ess-change-directory (path)
+    "Set the current working directory to PATH for both *R* and Emacs."
+    (interactive "Directory to change to: ")
+
+    (when (file-exists-p path)
+      (ess-command (concat "setwd(\"" path "\")\n"))
+      ;; use file-name-as-directory to ensure it has trailing /
+      (setq default-directory (file-name-as-directory path))))
+  (add-hook 'ess-mode-hook 'flyspell-prog-mode)
+  ;; outlining support for ess modes
+  (add-hook
+   'ess-mode-hook
+   '(lambda ()
+      (outline-minor-mode)
+      (setq outline-regexp "\\(^#\\{4,5\\} \\)\\|\\(^[a-zA-Z0-9_\.]+ ?<- ?function\\)")
+      (defun outline-level ()
+        (cond ((looking-at "^##### ") 1)
+              ((looking-at "^#### ") 2)
+              ((looking-at "^[a-zA-Z0-9_\.]+ ?<- ?function(.*{") 3)
+              (t 1000)))
+      ))
+  (defun dla/ess-region-remote-eval (start end)
+    "Evaluate region in a remote ESS instance"
+    (interactive "r")
+    (shell-command-on-region start end "eval_r" (get-buffer-create "***essregionremoteeval***") nil nil nil)
+    (kill-buffer "***essregionremoteeval***"))
+  ;; Don't restore history or save workspace image
+  '(inferior-R-args "--no-restore-history --no-save")
+  )
 #+END_SRC
 
 ** Rainbowmode
 From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colorizes color strings
 
 #+BEGIN_SRC emacs-lisp
-  (use-package rainbow-mode
-    ;; add ess to the x major mode
-    :config (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
-    (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
-  )
+(use-package rainbow-mode
+  ;; add ess to the x major mode
+  :config (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[S])
+  (add-to-list 'rainbow-x-colors-major-mode-list 'ESS[R])
+)
 #+END_SRC
 
 ** YAML Mode
 #+BEGIN_SRC emacs-lisp
-  (use-package yaml-mode
-    ;; add ess to the x major mode
-    :mode ("\\.\\(yaml|yml\\)\\'" . yaml-mode)
-  )
+(use-package yaml-mode
+  ;; add ess to the x major mode
+  :mode ("\\.\\(yaml|yml\\)\\'" . yaml-mode)
+)
 #+END_SRC
 
 ** Polymode
 #+BEGIN_SRC emacs-lisp
 (use-package poly-noweb
-  :ensure t
   :after polymode
 
   )
 (use-package poly-markdown
-  :ensure t
   :after polymode
   )
 (use-package poly-R
-  :ensure t
   :after (:all polymode poly-markdown poly-noweb)
-  :mode ("\\.Snw" . poly-noweb+r-mode)
-  :mode ("\\.Rnw" . poly-noweb+r-mode)
-  :mode ("\\.Rmd" . poly-markdown+r-mode)
+  :mode ("\\.Snw" . poly-noweb+r-mode)
+  :mode ("\\.Rnw" . poly-noweb+r-mode)
+  :mode ("\\.Rmd" . poly-markdown+r-mode)
   )
 (use-package polymode
-  :ensure t
   )
 
 #+END_SRC
@@ -1243,86 +1222,83 @@ From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colori
 #+END_SRC
 ** Writeroom Mode
 #+BEGIN_SRC emacs-lisp
-  (use-package writeroom-mode
-    :config
-    (defun my/writing-mode ()
-      "Start my writing mode; enable visual-line-mode and auto-fill-mode"
-      (interactive)
-      (if writeroom-mode
-          (progn
-            (writeroom-mode -1)
-            (visual-line-mode -1)
-            (auto-fill-mode -1)
-            (visual-fill-column-mode -1)
-            )
-        (visual-line-mode 1)
-        (auto-fill-mode 1)
-        (visual-fill-column-mode 1)
-        (writeroom-mode 1))
-      )
+(use-package writeroom-mode
+  :config
+  (defun my/writing-mode ()
+    "Start my writing mode; enable visual-line-mode and auto-fill-mode"
+    (interactive)
+    (if writeroom-mode
+        (progn
+          (writeroom-mode -1)
+          (visual-line-mode -1)
+          (auto-fill-mode -1)
+          (visual-fill-column-mode -1)
+          )
+      (visual-line-mode 1)
+      (auto-fill-mode 1)
+      (visual-fill-column-mode 1)
+      (writeroom-mode 1))
     )
+  )
 #+END_SRC
 ** GhostText/Atomic Chrome
 #+BEGIN_SRC emacs-lisp
-  (use-package atomic-chrome
-    :config
-    (ignore-errors (atomic-chrome-start-server))
-    (setq atomic-chrome-buffer-open-style 'full)
-    )
+(use-package atomic-chrome
+  :config
+  (ignore-errors (atomic-chrome-start-server))
+  (setq atomic-chrome-buffer-open-style 'full)
+  )
 #+END_SRC
 ** Edit Server
 #+BEGIN_SRC emacs-lisp
-  (use-package edit-server
-    :ensure t
-    :commands edit-server-start
-    :init (if after-init-time
-              (edit-server-start)
-            (add-hook 'after-init-hook
-                      #'(lambda() (edit-server-start))))
-    :config (setq edit-server-new-frame-alist
-                  '((name . "Edit with Emacs FRAME")
-                    (top . 200)
-                    (left . 200)
-                    (width . 80)
-                    (height . 25)
-                    (minibuffer . t)
-                    (menu-bar-lines . t)
-                    (window-system . x)))
-    )
+(use-package edit-server
+  :commands edit-server-start
+  :init (if after-init-time
+            (edit-server-start)
+          (add-hook 'after-init-hook
+                    #'(lambda() (edit-server-start))))
+  :config (setq edit-server-new-frame-alist
+                '((name . "Edit with Emacs FRAME")
+                  (top . 200)
+                  (left . 200)
+                  (width . 80)
+                  (height . 25)
+                  (minibuffer . t)
+                  (menu-bar-lines . t)
+                  (window-system . x)))
+  )
 #+END_SRC
 ** Multiple Cursors
 [[https://github.com/magnars/multiple-cursors.el][Multiple Cursors]]
 #+BEGIN_SRC emacs-lisp
-  (use-package multiple-cursors
-    :bind* (("C-;" . mc/mark-all-dwim)
-            ("C-<" . mc/mark-previous-like-this)
-            ("C->" . mc/mark-next-like-this)
-            ("C-S-c C-S-c" . mc/edit-lines))
-    )
+(use-package multiple-cursors
+  :bind* (("C-;" . mc/mark-all-dwim)
+          ("C-<" . mc/mark-previous-like-this)
+          ("C->" . mc/mark-next-like-this)
+          ("C-S-c C-S-c" . mc/edit-lines))
+  )
 #+END_SRC
 ** Web Mode
 #+BEGIN_SRC emacs-lisp
-  (use-package web-mode
-    :load-path "/home/don/projects/web-mode/"
-    :mode ("\\.\\(tx|tmpl\\)\\'" . web-mode)
-    :config
-    (add-to-list 'auto-mode-alist '("\\.tmpl\\'" . web-mode))
-    (setq web-mode-enable-engine-detection t)
-    (setq web-mode-engines-alist
-          '(("template-toolkit" . "\\.tmpl\\'")))
-    )
+(use-package web-mode
+  :load-path "/home/don/projects/web-mode/"
+  :mode ("\\.\\(tx|tmpl\\)\\'" . web-mode)
+  :config
+  (add-to-list 'auto-mode-alist '("\\.tmpl\\'" . web-mode))
+  (setq web-mode-enable-engine-detection t)
+  (setq web-mode-engines-alist
+        '(("template-toolkit" . "\\.tmpl\\'")))
+  )
 #+END_SRC
 ** Spamassassin Mode
 #+BEGIN_SRC emacs-lisp
-  (use-package spamassassin-mode
-    :commands spamassassin-mode
-    :ensure t
-    )
+(use-package spamassassin-mode
+  :commands spamassassin-mode
+  )
 #+END_SRC
 ** Password Store
 #+BEGIN_SRC emacs-lisp
 (use-package password-store
-  :ensure t
   :commands password-store-edit password-store-generate
   :config
   (defun dla/password-store-edit (entry)
@@ -1334,37 +1310,36 @@ From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colori
 #+END_SRC
 ** CSS mode
 #+BEGIN_SRC emacs-lisp
-  (use-package css
-    :mode "\\.css'"
-    :config
-    ;; fix up css mode to not be silly
-    ;; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
-    (setq cssm-indent-level 4)
-    (setq cssm-newline-before-closing-bracket t)
-    (setq cssm-indent-function #'cssm-c-style-indenter)
-    (setq cssm-mirror-mode nil))
+(use-package css
+  :mode "\\.css'"
+  :config
+  ;; fix up css mode to not be silly
+  ;; from http://www.stokebloke.com/wordpress/2008/03/21/css-mode-indent-buffer-fix/
+  (setq cssm-indent-level 4)
+  (setq cssm-newline-before-closing-bracket t)
+  (setq cssm-indent-function #'cssm-c-style-indenter)
+  (setq cssm-mirror-mode nil))
 #+END_SRC
 ** Abbrev Mode
 #+BEGIN_SRC emacs-lisp
-  (use-package abbrev
-    :delight abbrev-mode
-    :config
-    ;; load abbreviations from 
-    (setq abbrev-file-name       
-          "~/.emacs_abbrev_def")
+(use-package abbrev
+  :delight abbrev-mode
+  :config
+  ;; load abbreviations from 
+  (setq abbrev-file-name       
+        "~/.emacs_abbrev_def")
 
-    ;; read the abbrev file if it exists
-    (if (file-exists-p abbrev-file-name)
-        (quietly-read-abbrev-file))
+  ;; read the abbrev file if it exists
+  (if (file-exists-p abbrev-file-name)
+      (quietly-read-abbrev-file))
 
-    ;; for now, use abbrev mode everywhere
-    (setq default-abbrev-mode t))
+  ;; for now, use abbrev mode everywhere
+  (setq default-abbrev-mode t))
 #+END_SRC
 
 ** Debugging (realgud)
 #+BEGIN_SRC emacs-lisp
 (use-package realgud
-  :ensure t
   )
 #+END_SRC
 ** Python Programming
@@ -1378,24 +1353,15 @@ From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colori
   (python-mode . yas-minor-mode)
   (python-mode . anaconda-mode)
   )
-(use-package pyenv
-  :ensure t
+(use-package pyenv-mode
+  :after python-mode
   )
 (use-package blacken
   :delight βš‘
-  :init
+  :after python-mode
+  :config
   (setq-default blacken-fast-unsafe t)
-  ; (setq-default blacken-line-length 80)
-  :ensure t)
-(use-package anaconda-mode
-  :ensure t
-  )
-
-(use-package elpy
-  :ensure t
-  :init
-  (elpy-enable)
-  )
+)
 #+END_SRC
 *** Black
 #+begin_src emacs-lisp :tangle yes
@@ -1459,15 +1425,14 @@ From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colori
 *** Message-mode
 #+BEGIN_SRC emacs-lisp
 (use-package message
-  :ensure f
   :delight (message "βœ‰")
+  :delight (message-mode "βœ‰")
   :mode ("muttng-[a-z0-9]+-[0-9]+-" . message-mode)
   :mode ("mutt-[a-z0-9]+-[0-9]+-" . message-mode)
   :hook 'my/message-mode-settings
   :hook 'turn-on-flyspell
   :bind (:map message-mode-map
       ("C-c C-a" . my/post-attach-file))
-  :delight (message-mode "βœ‰")
   :config
   (defun my/message-mode-settings ()
     (font-lock-add-keywords nil
@@ -1505,11 +1470,23 @@ From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colori
 #+END_SRC
 *** Muttrc mode
 #+BEGIN_SRC emacs-lisp
-  (use-package muttrc-mode
-    :mode "muttngrc"
-    :mode "muttrc"
-  )
-
+(use-package muttrc-mode
+  :mode "muttngrc"
+  :mode "muttrc"
+)
+#+END_SRC
+*** Set mail User agent
+#+BEGIN_SRC emacs-lisp
+(setq mail-user-agent (quote sendmail-user-agent))
+#+END_SRC
+*** Mail aliases
+#+BEGIN_SRC emacs-lisp
+(use-package
+  :straight t
+  :hook message
+  :config
+  (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
+)
 #+END_SRC
 * Base emacs
 ** Reverting buffers
@@ -1526,12 +1503,12 @@ From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colori
 ** Use-package and load things
 #+BEGIN_SRC emacs-lisp
 
-  (use-package org
-    :delight (org-mode "ΓΈ")
-    :mode ("\\.\\(org\\|org_archive\\|txt\\)\\'" . org-mode)
-    :bind (("C-c l"  . org-store-link)
-           ("C-c a"  . org-agenda)
-           ("C-c b"  . org-iswitchb))
+(use-package org
+  :delight (org-mode "ΓΈ")
+  :mode ("\\.\\(org\\|org_archive\\|txt\\)\\'" . org-mode)
+  :bind (("C-c l"  . org-store-link)
+         ("C-c a"  . org-agenda)
+         ("C-c b"  . org-iswitchb))
 #+END_SRC
 ** Agenda Configuration
 #+BEGIN_SRC emacs-lisp
@@ -1825,7 +1802,7 @@ do not already have one."
 ** Org ID locations
 #+BEGIN_SRC emacs-lisp
 (use-package find-lisp
-  :ensure t)
+  :demand t)
 (setq org-agenda-text-search-extra-files
       (append '(agenda-archives)
               (find-lisp-find-files "~/projects/org-notes" "\.org$")
@@ -2073,10 +2050,13 @@ Maildir, or by Message-ID."
 #+END_SRC
 ** LaTeX configuration
 #+BEGIN_SRC emacs-lisp
-(use-package ox-extra
+(use-package org-plus-contrib
+  :no-require t
+  :after org
   :config
-  (ox-extras-activate '(ignore-headlines)))
-(require 'ox-latex)
+  (require 'ox-extra)
+  (ox-extras-activate '(latex-header-blocks ignore-headlines))
+  (require 'ox-latex)
 (add-to-list 'org-latex-classes
          '("memarticle"
        "\\documentclass[11pt,oneside,article]{memoir}\n"
@@ -2194,6 +2174,7 @@ Maildir, or by Message-ID."
 ;; keep latex logfiles
 
 (setq org-latex-remove-logfiles nil)
+)
 
 ;; Resume clocking task when emacs is restarted
 (org-clock-persistence-insinuate)
@@ -2555,18 +2536,11 @@ same directory as the org-buffer and insert a link to this file."
   (setq calendar-longitude -121.5)
   (setq case-fold-search t)
   (setq confirm-kill-emacs (quote y-or-n-p))
-  (setq cperl-lazy-help-time nil)
+
 #+END_SRC
-** Turn on fontlock and icomplete
+** Turn on fontlock
 #+BEGIN_SRC emacs-lisp
   (global-font-lock-mode 1)
-  (icomplete-mode 1)
-  (setq log-edit-keep-buffer t)
-#+END_SRC
-** Set mail User agent
-#+BEGIN_SRC emacs-lisp
-  (setq mail-user-agent (quote sendmail-user-agent))
-  (setq mutt-alias-file-list (quote ("~/.mutt/aliases" "~/.mail_aliases")))
 #+END_SRC
 ** PS Printing
 #+BEGIN_SRC emacs-lisp
@@ -2598,56 +2572,48 @@ same directory as the org-buffer and insert a link to this file."
 #+END_SRC
 ** Use primary selection on unix machines
 #+BEGIN_SRC emacs-lisp
-  ;; switch back to the old primary selection method
-  (if (or (string-equal system-type "darwin")
-          (string-equal system-type "windows")
-          )
-      (progn
-        (setq select-enable-clipboard t)
-        (setq select-enable-primary nil)
+;; switch back to the old primary selection method
+(if (or (string-equal system-type "darwin")
+        (string-equal system-type "windows")
         )
     (progn
-      (setq select-enable-clipboard nil)
-      (setq select-enable-primary t)
-      ))
-  ; (setq mouse-drag-copy-region t)
-
-  ;; tramp configuration
-  (setq tramp-use-ssh-controlmaster-options nil)
-
-  (setq-default c-indent-level 4)
-  (setq-default c-brace-imaginary-offset 0)
-  (setq-default c-brace-offset -4)
-  (setq-default c-argdecl-indent 4)
-  (setq-default c-label-offset -4)
-  (setq-default c-continued-statement-offset 4)
-  ; tabs are annoying
-  (setq-default indent-tabs-mode nil)
-  (setq-default tab-width 4)
-
-
-  ;; (autoload 'php-mode "php-mode" "PHP editing mode" t)
-  ;; (add-to-list 'auto-mode-alist '("\\.php3?\\'" . php-mode))
-  ;; (add-to-list 'auto-mode-alist '("\\.phtml?\\'" . php-mode))
-  ;; (add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode))
-  ;; (add-to-list 'auto-mode-alist '("\\.php4?\\'" . php-mode))
-
+      (setq select-enable-clipboard t)
+      (setq select-enable-primary nil)
+      )
+  (progn
+    (setq select-enable-clipboard nil)
+    (setq select-enable-primary t)
+    ))
+; (setq mouse-drag-copy-region t)
+
+;; tramp configuration
+(setq tramp-use-ssh-controlmaster-options nil)
+
+(setq-default c-indent-level 4)
+(setq-default c-brace-imaginary-offset 0)
+(setq-default c-brace-offset -4)
+(setq-default c-argdecl-indent 4)
+(setq-default c-label-offset -4)
+(setq-default c-continued-statement-offset 4)
+; tabs are annoying
+(setq-default indent-tabs-mode nil)
+(setq-default tab-width 4)
+
+(defun insert-date ()
+  "Insert date at point."
+  (interactive)
+  (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
+(global-set-key "\C-[d" 'insert-date)
+
+(defun unfill-paragraph (arg)
+  "Pull this whole paragraph up onto one line."
+  (interactive "*p")
+  (let ((fill-column 10000))
+    (fill-paragraph arg))
+  )
 
-  (defun insert-date ()
-    "Insert date at point."
-    (interactive)
-    (insert (format-time-string "%A, %B %e, %Y %k:%M:%S %Z")))
-  (global-set-key "\C-[d" 'insert-date)
-
-  (defun unfill-paragraph (arg)
-    "Pull this whole paragraph up onto one line."
-    (interactive "*p")
-    (let ((fill-column 10000))
-      (fill-paragraph arg))
-    )
+(column-number-mode t)
 
-  (column-number-mode t)
 #+END_SRC
 ** Desktop-save-mode
 If the envvar EMACS_SERVER_NAME is set, consider this a separate
@@ -2676,152 +2642,138 @@ emacs, and use a different desktop file to restore history
 #+END_SRC
 ** Misc (Uncharacterized)
 #+BEGIN_SRC emacs-lisp
-  '(icomplete-mode on)
-  (custom-set-faces
-   ;; custom-set-faces 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.
-   '(menu ((((type x-toolkit)) (:background "black" :foreground "grey90")))))
-
-
-  (put 'upcase-region 'disabled nil)
-  (put 'downcase-region 'disabled nil)
-  (put 'narrow-to-region 'disabled nil)
-
-  ; (defun turn-on-flyspell ()
-  ;    "Force flyspell-mode on using a positive arg.  For use in hooks."
-  ;    (interactive)
-  ;    (flyspell-mode 1))
-
-
-   ; Outline-minor-mode key map
-   (define-prefix-command 'cm-map nil "Outline-")
-   ; HIDE
-   (define-key cm-map "q" 'outline-hide-sublevels)    ; Hide everything but the top-level headings
-   (define-key cm-map "t" 'outline-hide-body)         ; Hide everything but headings (all body lines)
-   (define-key cm-map "o" 'outline-hide-other)        ; Hide other branches
-   (define-key cm-map "c" 'outline-hide-entry)        ; Hide this entry's body
-   (define-key cm-map "l" 'outline-hide-leaves)       ; Hide body lines in this entry and sub-entries
-   (define-key cm-map "d" 'outline-hide-subtree)      ; Hide everything in this entry and sub-entries
-   ; SHOW
-   (define-key cm-map "a" 'outline-show-all)          ; Show (expand) everything
-   (define-key cm-map "e" 'outline-show-entry)        ; Show this heading's body
-   (define-key cm-map "i" 'outline-show-children)     ; Show this heading's immediate child sub-headings
-   (define-key cm-map "k" 'outline-show-branches)     ; Show all sub-headings under this heading
-   (define-key cm-map "s" 'outline-show-subtree)      ; Show (expand) everything in this heading & below
-   ; MOVE
-   (define-key cm-map "u" 'outline-up-heading)                ; Up
-   (define-key cm-map "n" 'outline-next-visible-heading)      ; Next
-   (define-key cm-map "p" 'outline-previous-visible-heading)  ; Previous
-   (define-key cm-map "f" 'outline-forward-same-level)        ; Forward - same level
-   (define-key cm-map "b" 'outline-backward-same-level)       ; Backward - same level
-   (global-set-key "\M-o" cm-map)
-  ; fix up tmux xterm keys
-  ; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
-  (defun fix-up-tmux-keys ()
-      "Fix up tmux xterm keys"
-      (if (getenv "TMUX")
-          (progn
-            (let ((x 2) (tkey ""))
-              (while (<= x 8)
-                ;; shift
-                (if (= x 2)
-                    (setq tkey "S-"))
-                ;; alt
-                (if (= x 3)
-                    (setq tkey "M-"))
-                ;; alt + shift
-                (if (= x 4)
-                    (setq tkey "M-S-"))
-                ;; ctrl
-                (if (= x 5)
-                    (setq tkey "C-"))
-                ;; ctrl + shift
-                (if (= x 6)
-                    (setq tkey "C-S-"))
-                ;; ctrl + alt
-                (if (= x 7)
-                    (setq tkey "C-M-"))
-                ;; ctrl + alt + shift
-                (if (= x 8)
-                    (setq tkey "C-M-S-"))
-
-                ;; arrows
-                (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
-                (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
-                (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
-                (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
-                ;; home
-                (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
-                ;; end
-                (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
-                ;; page up
-                (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
-                ;; page down
-                (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
-                ;; insert
-                (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
-                ;; delete
-                (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
-                ;; f1
-                (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
-                ;; f2
-                (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
-                ;; f3
-                (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
-                ;; f4
-                (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
-                ;; f5
-                (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
-                ;; f6
-                (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
-                ;; f7
-                (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
-                ;; f8
-                (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
-                ;; f9
-                (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
-                ;; f10
-                (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
-                ;; f11
-                (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
-                ;; f12
-                (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
-                ;; f13
-                (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
-                ;; f14
-                (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
-                ;; f15
-                (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
-                ;; f16
-                (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
-                ;; f17
-                (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
-                ;; f18
-                (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
-                ;; f19
-                (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
-                ;; f20
-                (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
-
-                (setq x (+ x 1))
-                ))
-            )
-        )
+
+(put 'upcase-region 'disabled nil)
+(put 'downcase-region 'disabled nil)
+(put 'narrow-to-region 'disabled nil)
+
+; Outline-minor-mode key map
+(define-prefix-command 'cm-map nil "Outline-")
+; HIDE
+(define-key cm-map "q" 'outline-hide-sublevels)    ; Hide everything but the top-level headings
+(define-key cm-map "t" 'outline-hide-body)         ; Hide everything but headings (all body lines)
+(define-key cm-map "o" 'outline-hide-other)        ; Hide other branches
+(define-key cm-map "c" 'outline-hide-entry)        ; Hide this entry's body
+(define-key cm-map "l" 'outline-hide-leaves)       ; Hide body lines in this entry and sub-entries
+(define-key cm-map "d" 'outline-hide-subtree)      ; Hide everything in this entry and sub-entries
+; SHOW
+(define-key cm-map "a" 'outline-show-all)          ; Show (expand) everything
+(define-key cm-map "e" 'outline-show-entry)        ; Show this heading's body
+(define-key cm-map "i" 'outline-show-children)     ; Show this heading's immediate child sub-headings
+(define-key cm-map "k" 'outline-show-branches)     ; Show all sub-headings under this heading
+(define-key cm-map "s" 'outline-show-subtree)      ; Show (expand) everything in this heading & below
+; MOVE
+(define-key cm-map "u" 'outline-up-heading)                ; Up
+(define-key cm-map "n" 'outline-next-visible-heading)      ; Next
+(define-key cm-map "p" 'outline-previous-visible-heading)  ; Previous
+(define-key cm-map "f" 'outline-forward-same-level)        ; Forward - same level
+(define-key cm-map "b" 'outline-backward-same-level)       ; Backward - same level
+(global-set-key "\M-o" cm-map)
+; fix up tmux xterm keys
+; stolen from http://unix.stackexchange.com/questions/24414/shift-arrow-not-working-in-emacs-within-tmux
+(defun fix-up-tmux-keys ()
+    "Fix up tmux xterm keys"
+    (if (getenv "TMUX")
+        (progn
+          (let ((x 2) (tkey ""))
+            (while (<= x 8)
+              ;; shift
+              (if (= x 2)
+                  (setq tkey "S-"))
+              ;; alt
+              (if (= x 3)
+                  (setq tkey "M-"))
+              ;; alt + shift
+              (if (= x 4)
+                  (setq tkey "M-S-"))
+              ;; ctrl
+              (if (= x 5)
+                  (setq tkey "C-"))
+              ;; ctrl + shift
+              (if (= x 6)
+                  (setq tkey "C-S-"))
+              ;; ctrl + alt
+              (if (= x 7)
+                  (setq tkey "C-M-"))
+              ;; ctrl + alt + shift
+              (if (= x 8)
+                  (setq tkey "C-M-S-"))
+
+              ;; arrows
+              (define-key key-translation-map (kbd (format "M-[ 1 ; %d A" x)) (kbd (format "%s<up>" tkey)))
+              (define-key key-translation-map (kbd (format "M-[ 1 ; %d B" x)) (kbd (format "%s<down>" tkey)))
+              (define-key key-translation-map (kbd (format "M-[ 1 ; %d C" x)) (kbd (format "%s<right>" tkey)))
+              (define-key key-translation-map (kbd (format "M-[ 1 ; %d D" x)) (kbd (format "%s<left>" tkey)))
+              ;; home
+              (define-key key-translation-map (kbd (format "M-[ 1 ; %d H" x)) (kbd (format "%s<home>" tkey)))
+              ;; end
+              (define-key key-translation-map (kbd (format "M-[ 1 ; %d F" x)) (kbd (format "%s<end>" tkey)))
+              ;; page up
+              (define-key key-translation-map (kbd (format "M-[ 5 ; %d ~" x)) (kbd (format "%s<prior>" tkey)))
+              ;; page down
+              (define-key key-translation-map (kbd (format "M-[ 6 ; %d ~" x)) (kbd (format "%s<next>" tkey)))
+              ;; insert
+              (define-key key-translation-map (kbd (format "M-[ 2 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
+              ;; delete
+              (define-key key-translation-map (kbd (format "M-[ 3 ; %d ~" x)) (kbd (format "%s<delete>" tkey)))
+              ;; f1
+              (define-key key-translation-map (kbd (format "M-[ 1 ; %d P" x)) (kbd (format "%s<f1>" tkey)))
+              ;; f2
+              (define-key key-translation-map (kbd (format "M-[ 1 ; %d Q" x)) (kbd (format "%s<f2>" tkey)))
+              ;; f3
+              (define-key key-translation-map (kbd (format "M-[ 1 ; %d R" x)) (kbd (format "%s<f3>" tkey)))
+              ;; f4
+              (define-key key-translation-map (kbd (format "M-[ 1 ; %d S" x)) (kbd (format "%s<f4>" tkey)))
+              ;; f5
+              (define-key key-translation-map (kbd (format "M-[ 15 ; %d ~" x)) (kbd (format "%s<f5>" tkey)))
+              ;; f6
+              (define-key key-translation-map (kbd (format "M-[ 17 ; %d ~" x)) (kbd (format "%s<f6>" tkey)))
+              ;; f7
+              (define-key key-translation-map (kbd (format "M-[ 18 ; %d ~" x)) (kbd (format "%s<f7>" tkey)))
+              ;; f8
+              (define-key key-translation-map (kbd (format "M-[ 19 ; %d ~" x)) (kbd (format "%s<f8>" tkey)))
+              ;; f9
+              (define-key key-translation-map (kbd (format "M-[ 20 ; %d ~" x)) (kbd (format "%s<f9>" tkey)))
+              ;; f10
+              (define-key key-translation-map (kbd (format "M-[ 21 ; %d ~" x)) (kbd (format "%s<f10>" tkey)))
+              ;; f11
+              (define-key key-translation-map (kbd (format "M-[ 23 ; %d ~" x)) (kbd (format "%s<f11>" tkey)))
+              ;; f12
+              (define-key key-translation-map (kbd (format "M-[ 24 ; %d ~" x)) (kbd (format "%s<f12>" tkey)))
+              ;; f13
+              (define-key key-translation-map (kbd (format "M-[ 25 ; %d ~" x)) (kbd (format "%s<f13>" tkey)))
+              ;; f14
+              (define-key key-translation-map (kbd (format "M-[ 26 ; %d ~" x)) (kbd (format "%s<f14>" tkey)))
+              ;; f15
+              (define-key key-translation-map (kbd (format "M-[ 28 ; %d ~" x)) (kbd (format "%s<f15>" tkey)))
+              ;; f16
+              (define-key key-translation-map (kbd (format "M-[ 29 ; %d ~" x)) (kbd (format "%s<f16>" tkey)))
+              ;; f17
+              (define-key key-translation-map (kbd (format "M-[ 31 ; %d ~" x)) (kbd (format "%s<f17>" tkey)))
+              ;; f18
+              (define-key key-translation-map (kbd (format "M-[ 32 ; %d ~" x)) (kbd (format "%s<f18>" tkey)))
+              ;; f19
+              (define-key key-translation-map (kbd (format "M-[ 33 ; %d ~" x)) (kbd (format "%s<f19>" tkey)))
+              ;; f20
+              (define-key key-translation-map (kbd (format "M-[ 34 ; %d ~" x)) (kbd (format "%s<f20>" tkey)))
+
+              (setq x (+ x 1))
+              ))
+          )
       )
-  ; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
-
-  (defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
-    "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
-    (if (or (buffer-modified-p)
-            (verify-visited-file-modtime)
-            (< (* 8 1024 1024) (buffer-size))
-            (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
-        ad-do-it
-      (clear-visited-file-modtime)
-      (not-modified)))
-  (ad-activate 'ask-user-about-supersession-threat)
+    )
+; (add-hook 'tty-setup-hook 'fix-up-tmux-keys)
+
+(defadvice ask-user-about-supersession-threat (around ask-user-about-supersession-threat-if-necessary)
+  "Call ask-user-about-supersession-threat only if the buffer is actually obsolete."
+  (if (or (buffer-modified-p)
+          (verify-visited-file-modtime)
+          (< (* 8 1024 1024) (buffer-size))
+          (/= 0 (call-process-region 1 (+ 1 (buffer-size)) "diff" nil nil nil "-q" (buffer-file-name) "-")))
+      ad-do-it
+    (clear-visited-file-modtime)
+    (not-modified)))
+(ad-activate 'ask-user-about-supersession-threat)
 #+END_SRC
 
 * Start Server
@@ -2836,8 +2788,6 @@ emacs, and use a different desktop file to restore history
       (server-start)))
 #+END_SRC
 
-
-
 * END
 #+BEGIN_SRC emacs-lisp
 (provide 'don-configuration)