remove obsolete/useless stuff
[dot-emacs] / init.el
diff --git a/init.el b/init.el
index 6b9094f3983550ebbb26f913042eacc58772cff5..b7119d027ce22f39a4ff15a8e4fd022e708acb6b 100644 (file)
--- a/init.el
+++ b/init.el
   (setq gc-cons-threshold 100000000)
 
   ;; 2019-6-26, 1.26s
-  ;; to profile init:
-  ;; emacs -f benchmark-init/show-durations-tabulated
-  ;; emacs -f benchmark-init/show-durations-tree
-  ;; to catch things post-init
-  ;; emacs -f benchmark-init/deactivate
-  (require 'benchmark-init)
-  (add-hook 'after-init-hook 'benchmark-init/deactivate)
-  ;;
+  ;;; to profile init:
+  ;;; uncomment the following block
+  ;; (require 'benchmark-init)
+  ;; (add-hook 'after-init-hook 'benchmark-init/deactivate)
+  ;;; Then run:
+  ;;; emacs -f benchmark-init/show-durations-tabulated
+  ;;; emacs -f benchmark-init/show-durations-tree
+  ;;; to catch things post-init
+  ;;; emacs -f benchmark-init/deactivate
+
 
   ;; these need to be done before the hook in order to satisfy the byte compiler or batch mode
 
   (add-to-list 'load-path "~/.emacs.d/src/visible-mark")
 
 
-  ;; git version of gnus
-  ;; (add-to-list 'load-path "~/.emacs.d/src/gnus/lisp")
-  ;; (eval-after-load "info"
-  ;; (quote (add-to-list 'Info-default-directory-list "~/.emacs.d/src/gnus/texi")))
-
-
-  ;; needed for git version
-  ;;(add-to-list 'load-path "~/.emacs.d/src/haskell-mode")
-  ;;(require 'haskell-mode-autoloads)
-  ;;(add-to-list 'Info-default-directory-list "~/.emacs.d/src/haskell-mode")
-
-  ;; for using custom/upstream bbdb
-  ;;(require 'bbdb-loaddefs "~/.emacs.d/src/bbdb/lisp/bbdb-loaddefs.el")
-  ;;(setq bbdb-print-tex-path "~/.emacs.d/src/bbdb/tex")
-
-
-  ;; iank: dunno what this was about
-  ;;(add-hook 'server-visit-hook 'raise-frame)
 
   (setq init-dir (file-name-directory load-file-name))
   ;; previously, i was doing byte-recompile-directory, but
   ;; now i just have one init file
   (unless (equal (user-uid) 0) ; don't make root owned files
     (byte-recompile-file (expand-file-name "init.el" init-dir) nil 0)
-    (byte-recompile-file "/p/c/mymu4e.el" nil 0)
+    (when (file-exists-p "/p/c/mymu4e.el")
+      (byte-recompile-file "/p/c/mymu4e.el" nil 0))
     )
 
-  ;; load init in `after-init-hook' so all packages are loaded. However, disabled because
-  ;; there seems to be no need.
-  ;; todo, learn about the weird evaluation order of this hook that requires the quoting.
-  ;; adapted from starter-kit
-  ;; (add-hook 'after-init-hook
-  ;;           `(lambda ()
-  ;;              (load-file (expand-file-name "myinit.el" init-dir))
-  ;;              ))
-
-
-;;; Weird package bug workaround
-
-
-  ;; without this, when installing a package, this message happens
-  ;;
-  ;; custom-handle-keyword: Unknown keyword :group
-  ;;
-  ;; but when i lookup the function, i get the following, and if
-  ;; I evaluate it, the error goes away. so I think the real
-  ;; definition is happening somewhere else
-
-  (defun custom-handle-keyword (symbol keyword value type)
-    "For customization option SYMBOL, handle KEYWORD with VALUE.
-Fourth argument TYPE is the custom option type."
-    (if purify-flag
-        (setq value (purecopy value)))
-    (cond ((eq keyword :group)
-          (custom-add-to-group value symbol type))
-         ((eq keyword :version)
-          (custom-add-version symbol value))
-         ((eq keyword :package-version)
-          (custom-add-package-version symbol value))
-         ((eq keyword :link)
-          (custom-add-link symbol value))
-         ((eq keyword :load)
-          (custom-add-load symbol value))
-         ((eq keyword :tag)
-          (put symbol 'custom-tag value))
-         ((eq keyword :set-after)
-          (custom-add-dependencies symbol value))
-         (t
-          (error "Unknown keyword %s" keyword))))
-
-
 ;;; misc emacs documentation
 
 ;;;; how to find auto-saved files that need recovering
@@ -218,7 +159,7 @@ Fourth argument TYPE is the custom option type."
   ;; nnfolder-generate-active-file
 
   ;; to reset things, when changing mail group. I duno all the proper way, but it works to delete
-  ;; ~/Mail ~/.newsrc.eld ~/.dribble (or something)
+  ;; ~/Mail ~/.newsrc.eld ~/.newsrc-dribble
 
 
 ;;;;; mail sources vs select methods background
@@ -249,33 +190,7 @@ Fourth argument TYPE is the custom option type."
 
 
 ;;; things that should be at the beginning
-  ;; todo, evaluating this manually disables debug on error instead of toggling it
-  (toggle-debug-on-error) ;uncomment to help debug and catch errors
-
-  ;; packages installed from package manager: i pretty much prioritize repos this way: gnu, then melpa, then marmalade.
-
-  ;; package-activated-list:
-  ;; ac-dabbrev ac-haskell-process ack-and-a-half alect-themes auctex bash-completion bbdb csv-mode cyberpunk-theme dot-mode expand-region f find-file-in-project flycheck foreign-regexp ggtags ghc gnuplot-mode goto-chg haskell-mode heroku-theme highlight-indentation highlight-symbol htmlize inf-ruby info+ inkpot-theme jedi auto-complete jedi-core epc ctable concurrent key-chord leuven-theme logstash-conf magit git-commit magit-popup misc-fns mouse+ naquadah-theme nginx-mode occidental-theme org paredit pcsv php-mode pkg-info epl popup py-autopep8 python-environment deferred python-info python-mode rainbow-mode rust-mode rw-hunspell s smartparens smex smooth-scroll sr-speedbar strings swiper ivy tabulated-list tangotango-theme thingatpt+ undo-tree vimrc-mode volatile-highlights web-mode with-editor dash async ws-butler yasnippet
-
-;;;; alternate keyboards
-  ;; todo, figure out an easy way to disable this when using external keyboard
-  (if (display-graphic-p)
-      (setq
-       enter-key (kbd "<return>")
-       s-enter-key (kbd "<S-return>")
-       c-m-enter-key (kbd "<C-M-return>")
-       m-enter (kbd "<M-return>")
-       c-enter (kbd "<C-return>"))
-    (setq
-     enter-key (kbd "C-m")
-     s-enter-key (kbd "C-8")
-     c-m-enter-key (kbd "C-M-8")
-     m-enter (kbd "M-m")
-     c-enter (kbd "C-8")))
 
-  (setq tp (string= (system-name) "tp"))
-  (setq x200 (string= (system-name) "x2"))
-  (setq laptop-keyboard (or tp x200))
 
   ;; Ubiquitous Packages which should be loaded on startup rather than
   ;;   autoloaded on demand since they are likely to be used in every
@@ -283,8 +198,6 @@ Fourth argument TYPE is the custom option type."
   (require 'saveplace)
   (require 'ffap)
   (require 'uniquify)
-  ;; iank: dunno why this was here
-  ;;(require 'ansi-color)
   (require 'recentf)
 
   ;; Better to have a list of packages in here vs installed manually.
@@ -300,9 +213,9 @@ Fourth argument TYPE is the custom option type."
   ;;             '("marmalade" .
   ;;               "http://marmalade-repo.org/packages/"))
 
-  (add-to-list 'package-archives
-               '("melpa" . "http://melpa.milkbox.net/packages/") t)
-  (add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
+  (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
+  ;; down atm 2020-08-30
+  ;;(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
 
 
   ;; keep our init.el clean, by moving customization elisp to it's own file
@@ -311,6 +224,7 @@ Fourth argument TYPE is the custom option type."
 
 
 
+
 ;;; abreviations
   ;; turn on abbrev mode globally
   (setq-default abbrev-mode t)
@@ -358,7 +272,8 @@ Fourth argument TYPE is the custom option type."
   (define-key ac-completing-map (kbd "<down>") nil)
   (define-key ac-completing-map (kbd "<S-return>") 'ac-expand)
   (define-key ac-completing-map "\t" 'ac-complete)
-  (define-key ac-completing-map (kbd "<tab>") 'ac-complete)
+  ;;(define-key ac-completing-map (kbd "<tab>") 'ac-complete)
+  (define-key ac-completing-map (kbd "TAB") 'ac-complete)
 
 
 
@@ -403,12 +318,14 @@ Fourth argument TYPE is the custom option type."
 
   (add-hook 'shell-mode-hook
             (lambda ()
-              (define-key shell-mode-map (kbd "<tab>") 'auto-complete)))
+              ;;(define-key shell-mode-map (kbd "<tab>") 'auto-complete)
+              (define-key shell-mode-map (kbd "TAB") 'auto-complete)
+              ))
 
 
 ;;; readline complete fix
 
-  ;; I need this function here, where INSIDE_EMACS is replaced with RLC_INSIDE_EMACS.
+  ;; I need this function here, where INSIDE_EMACS is replaced with LC_INSIDE_EMACS.
   ;; ian: last update 2017-1-7. update this periodically from upstream
   ;; like when we do a major emacs update
   (defun comint-exec-1 (name buffer command switches)
@@ -427,7 +344,7 @@ Fourth argument TYPE is the custom option type."
                      (format "COLUMNS=%d" (window-width)))
              (list "TERM=emacs"
                    (format "TERMCAP=emacs:co#%d:tc=unknown:" (window-width))))
-           (list (format "RLC_INSIDE_EMACS=%s,comint" emacs-version))
+           (list (format "LC_INSIDE_EMACS=%s,comint" emacs-version))
            process-environment))
          (default-directory
            (if (file-accessible-directory-p default-directory)
@@ -668,6 +585,8 @@ A non-nil CURRENT-ONLY argument means save only current buffer."
     (load-theme arg t))
   (setq color-theme-is-global t)
 
+  ;; temporary, make night be default
+
   (defun toggle-night ()
     (interactive)
     (cond  ((equal (car custom-enabled-themes) 'naquadah)
@@ -752,7 +671,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer."
 
   ;; Save a list of recent files visited.
   (recentf-mode 1)
-  (setq recentf-max-saved-items 200
+  (setq recentf-max-saved-items 400
         recentf-max-menu-items 15)
 
 
@@ -855,6 +774,8 @@ A non-nil CURRENT-ONLY argument means save only current buffer."
   (eval-after-load "mu4e" '(my-mu4e-init))
 
   (setq
+   ;; https://github.com/djcb/mu/issues/1025
+   mail-user-agent 'mu4e-user-agent
    ;; common to gnus. default sendmail-query-once asks us, then sets this via customize.
    send-mail-function (quote sendmail-send-it)
    ;; use the standard imap folders
@@ -880,6 +801,12 @@ A non-nil CURRENT-ONLY argument means save only current buffer."
    mu4e-cache-maildir-list t
    ;; default is 8, way too small for my big monitors
    mu4e-headers-visible-lines 50
+   message-sendmail-envelope-from 'header
+   ;; trying this out
+   ;;mu4e-view-use-gnus t
+   ;; had problems where mu4e and gnus would hang verifying signatures, gnus man
+   ;; said this should help, but it didnt work. they still got verified.
+   ;; mm-verify-option 'never
    )
 
   ;; fucks up reading unread bookmark. when that is fixed, enable it
@@ -891,7 +818,8 @@ A non-nil CURRENT-ONLY argument means save only current buffer."
   ;; mu4e-user-mail-address-list
   ;; and a function
   ;; inspired by mu4e info manual, search for mu4e-compose-pre-hook.
-  (load "/p/c/mymu4e.el")
+  (when (file-exists-p "/p/c/mymu4e.el")
+    (load "/p/c/mymu4e.el"))
 
   (defun my-decrypt ()
     ;; use for decrypting in mu4e
@@ -905,7 +833,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer."
         )))
   (add-hook 'mu4e-view-mode-hook 'my-decrypt)
 
-  (defun mu-set-from-name (regexes)
+  (defun iank-set-from-name (regexes)
     "If we find an address matching regex, then set that address as the to,
 and whatever was used"
     (when mu4e-compose-parent-message
@@ -915,17 +843,25 @@ and whatever was used"
                 regexes (cdr regexes)
                 found (mu4e-message-contact-field-matches
                        mu4e-compose-parent-message :to re)))
-        (when found (setq user-mail-address (cdr found)
-                          user-full-name (car found)))
+        (when found
+          (setq user-full-name (car found))
+          ;; we get an error unless we do this. that is a bug. I could
+          ;; send a patch...  also a bug: setting message-from-style nil
+          ;; doesnt work in mu4e unless user-full-name is also nil.
+          (unless user-full-name
+            (setq message-from-style nil))
+          (setq user-mail-address (cdr found)
+                mail-signature nil))
         found)))
-  (defun mu-set-from (regexes)
+  (defun iank-set-from (regexes)
     "If we find an address matching regex, then set that address as the to,
 and Ian Kelling as the name"
     (when mu4e-compose-parent-message
       (let ((found nil))
         (while (and regexes (not found))
           (setq re (car regexes)
-                regexes (cdr regexes)
+                sig (cadr regexes)
+                regexes (cddr regexes)
                 found (cdr (mu4e-message-contact-field-matches
                             mu4e-compose-parent-message :to re))))
         (when found (setq user-mail-address found
@@ -933,16 +869,6 @@ and Ian Kelling as the name"
         found)))
 
 
-  (defun my-mu4e-to-fsf ()
-    "inspired by mu4e info manual, search for mu4e-compose-pre-hook."
-    (cond
-     ((mu-set-from '("iank@fsf.org"
-                     "iank@gnu.org")))
-     ((setq user-mail-address "iank@fsf.org"
-            user-full-name "Ian Kelling"))))
-
-
-  ;; on first run   mkdir -p /nocow/user/.mufsf; mu index --maildir=/nocow/user/fsfmd
   (defun mu-exit-wait ()
     (interactive)
     ;; taken from the mu source
@@ -955,41 +881,16 @@ and Ian Kelling as the name"
 
   (defun fsf-mu4e ()
     (interactive)
-    (require 'mu4e)
-    (unless (equal mu4e-maildir "/nocow/user/fsfmd") (mu-exit-wait))
+    (my-mu4e-commmon)
     (setq
-     ;; fsf monitor is smaller
-     mu4e-headers-visible-lines 15
-     mu4e-maildir "/nocow/user/fsfmd"
-     mu4e-refile-folder "/Spam"
-     mu4e-index-lazy-check nil
-     mu4e-get-mail-command "true"
      user-mail-address "iank@fsf.org"
+     iank-user-mail-address user-mail-address
      ;; WARNING: be careful editing this, there needs to be a space after --, and my editor
      ;; and git will automatically remove it unless i manually disable it.
-     mail-signature "
-
--- 
-Ian Kelling | Senior Systems Administrator, Free Software Foundation
-GPG Key: B125 F60B 7B28 7FF6 A2B7  DF8F 170A F0E2 9542 95DF
-https://fsf.org | https://gnu.org
-"
-
-     mu4e-user-mail-address-list '("iank@fsf.org"
-                                   "iank@gnu.org")
-     mu4e-maildir-shortcuts
-     '( ("/INBOX"     . ?i)
-        ("/sysadmin" . ?a)
-        ("/sec"  . ?x)
-        ("/rtcc"  . ?c)
-        ("/Drafts"     . ?d)
-        ("/Sent"     . ?s)
-        )
+     mail-signature fsf-sig
      ) ;; end setq
-    (call-process "/a/exe/lnf" nil nil nil "-T" "/nocow/user/.mufsf" (concat (getenv "HOME") "/.mu"))
-    (add-hook 'mu4e-compose-pre-hook 'my-mu4e-to-fsf)
-    (remove-hook 'mu4e-compose-pre-hook 'my-mu4e-to)
-    (mu4e)) ;; end defun fsf-mu4e
+    (add-hook 'mu4e-compose-pre-hook 'my-mu4e-to)
+    (mu4e))
 
 
 
@@ -1177,10 +1078,10 @@ https://fsf.org | https://gnu.org
 
   (add-hook 'haskell-mode-hook
             (lambda () (define-key haskell-mode-map (kbd "C-(")
-                    (lambda () (interactive)
-                      (basic-save-buffer)
-                      (haskell-compile)
-                      (run-with-timer .3 nil 'repeat-shell)))))
+                         (lambda () (interactive)
+                           (basic-save-buffer)
+                           (haskell-compile)
+                           (run-with-timer .3 nil 'repeat-shell)))))
   (add-hook 'haskell-cabal-mode-hook
             (lambda () (define-key haskell-cabal-mode-map (kbd "C-(") 'haskell-compile)))
 
@@ -1189,7 +1090,8 @@ https://fsf.org | https://gnu.org
   (add-hook 'haskell-interactive-mode-hook
             (lambda ()
               (define-key haskell-interactive-mode-map "\r" nil)
-              (define-key haskell-interactive-mode-map (kbd "<return>") 'haskell-interactive-mode-return)))
+              (define-key haskell-interactive-mode-map (kbd "RET")
+                'haskell-interactive-mode-return)))
   (add-hook 'haskell-indentation-mode-hook (lambda () (define-key haskell-indentation-mode-map "\r" nil)))
 
 
@@ -1353,7 +1255,8 @@ https://fsf.org | https://gnu.org
   ;;(require 'csv-mode)
   ;;(add-to-list 'auto-mode-alist '("\\.[Cc][Ss][Vv]\\'" . csv-mode))
 
-  (add-hook 'outline-minor-mode-hook 'outshine-mode)
+  ;; disabled temporarily
+  ;;(add-hook 'outline-minor-mode-hook 'outshine-mode)
 
   (setq org-caldav-url "https://cal.iankelling.org"
         org-caldav-calendar-id "ian"
@@ -1366,7 +1269,8 @@ https://fsf.org | https://gnu.org
 
   (setq css-indent-offset 2)
 
-  (load-file "/a/h/iank-mod.el")
+  (when (file-exists-p "/a/h/iank-mod.el")
+    (load-file "/a/h/iank-mod.el"))
 
   ;; from when i was running my own patches
   ;;(add-to-list 'load-path "/a/opt/ws-butler")
@@ -1568,8 +1472,15 @@ https://fsf.org | https://gnu.org
   (setq tramp-default-method "ssh")
 ;;; misc general settings
 
+  ;; from tramp manual, use the same ssh controlmaster. I was having problems with
+  ;; tramp prompting me for a username and pass.
+  (customize-set-variable 'tramp-use-ssh-controlmaster-options nil)
+
   (setq
    auto-revert-interval 2
+   ;; fix eof end of file newline
+   mode-require-final-newline t
+   require-final-newline t
    auto-revert-verbose nil
    auto-revert-remote-files t)
 
@@ -1592,8 +1503,6 @@ https://fsf.org | https://gnu.org
   ;; give us a shell to start instead of scratch
   ;;(setq initial-buffer-choice (lambda () (new-shell)))
 
-  ;; disable this nasty function, as I always use a gui
-  (defun suspend-frame() (interactive))
 
   ;; Seed the random-number generator
   (random t)
@@ -1601,6 +1510,14 @@ https://fsf.org | https://gnu.org
   ;; easier to remember than keybinds
   (defalias 'scrypt 'mml-secure-message-encrypt-pgpmime)
   (defalias 'sign 'mml-secure-message-sign-pgpmime)
+  ;; otherwise we get error on sending:
+  ;; mml-secure-epg-sign: Couldn’t find any signer names; try setting `mml-secure-smime-sign-with-sender'.
+  ;; i dunno why sign+encrypt doesnt cause this, seems kinda dumb,
+  ;;
+  (setq mml-secure-openpgp-sign-with-sender t)
+  ;; i dun use smime, the smime signing fails complaining it doesnt have
+  ;; my key. todo: learn about smime
+  (setq mml-secure-smime-sign-with-sender t)
   (defun encrypt ()
     (interactive)
     (mml-secure-message-encrypt-pgpmime 'dontsign))
@@ -1850,6 +1767,7 @@ Go to the next directory based on where the cursor is."
       (dot-mode . "")
       (yas-global-mode . "")
       (yas-minor-mode . "")
+      (undo-tree-mode . "")
       (volatile-highlights-mode . "")
       (highlight-symbol-mode . "")
       ;; Major modes
@@ -1972,6 +1890,8 @@ Go to the next directory based on where the cursor is."
         org-extend-today-until 0
         org-startup-truncated nil
         org-clock-persist t
+        org-use-sub-superscripts "{}"
+        org-export-with-sub-superscripts nil
         org-clock-mode-line-total 'today
         ;; global STYLE property values for completion
         org-global-properties (quote (("STYLE_ALL" . "habit")))
@@ -2086,7 +2006,8 @@ Go to the next directory based on where the cursor is."
   (defun prog-mode-defaults ()
     "Default coding hook, useful with any programming language."
     ;; so that I can do completion before the dialog pops up
-    (local-set-key (kbd "<tab>") 'auto-complete)
+    ;;(local-set-key (kbd "<tab>") 'auto-complete)
+    (local-set-key (kbd "TAB") 'auto-complete)
     ;; todo, this is causing error message on loading file, prolly not working
     ;;(flycheck-mode +1)
     (setq ac-sources (delq 'ac-source-dictionary ac-sources))
@@ -2151,6 +2072,12 @@ indent yanked text (with prefix arg don't indent)."
 
 
 ;;; shell mode
+
+
+  ;;  # eval: (outline-minor-mode)
+  ;; # outline-regexp: "\\( *\\)# [*]\\{1,8\\} "
+
+
   ;; avoid stupid git crap like "warning, terminal not fully functional"
   (setenv "PAGER" "cat")
   ;; don't store successive duplicates in comint command history
@@ -2206,10 +2133,10 @@ indent yanked text (with prefix arg don't indent)."
   ;; when opening a pair, and then inserting a newline, push the closing pair to another newline
   (sp-pair "{" nil :post-handlers
            '(:add ((lambda (id action context)
-                     (gp/sp/pair-on-newline-and-indent id action context)) (kbd "<return>"))))
+                     (gp/sp/pair-on-newline-and-indent id action context)) (kbd "RET"))))
   (sp-pair "[" nil :post-handlers
            '(:add ((lambda (id action context)
-                     (gp/sp/pair-on-newline-and-indent id action context)) (kbd "<return>"))))
+                     (gp/sp/pair-on-newline-and-indent id action context)) (kbd "RET"))))
 
 
   ;; in my version, this is not a pairing.
@@ -2308,9 +2235,16 @@ indent yanked text (with prefix arg don't indent)."
   (defun chirp()
     (interactive)
     (setq vol 50)
-    (when (string= (system-name) "tp") (setq vol 40))
-    (start-process-shell-command "ignoreme" nil (format "mpv --no-terminal --vo=null --volume=%d /a/bin/data/bird.mp3" vol)))
+    (when (string= (system-name) "kd") (setq vol 80))
+    ;; speed is there so i can adjust and make it go slow so it plays long enough to adjust in pavucontrol
+    (start-process-shell-command "ignoreme" nil (format "mpv --speed=1 --no-terminal --vo=null --volume=%d /a/bin/data/bird.mp3" vol)))
   ;; from https://www.emacswiki.org/emacs/ErcSound
+  (defun chirp-slow()
+    (interactive)
+    (setq vol 50)
+    (when (string= (system-name) "tp") (setq vol 80))
+    ;; speed is there so i can adjust and make it go slow so it plays long enough to adjust in pavucontrol
+    (start-process-shell-command "ignoreme" nil (format "mpv --speed=.2 --no-terminal --vo=null --volume=%d /a/bin/data/bird.mp3" vol)))
 
   (defun erc-my-privmsg-sound (proc parsed)
     (let* ((tgt (car (erc-response.command-args parsed)))
@@ -2334,7 +2268,11 @@ indent yanked text (with prefix arg don't indent)."
    ;; consider invisible frames to be unseen. seems like an obvious default
    erc-track-visibility 'visible
    ;; switch to buffer where i've been mentioned, etc instead of oldest
-   erc-track-switch-direction 'importance)
+   erc-track-switch-direction 'importance
+   ;; defaults minus fill. todo: modify the list instead of specifying it explicitly in case the defaults change
+   erc-modules
+   '(autojoin button completion irccontrols list match menu move-to-prompt netsplit networks noncommands readonly ring stamp track)
+   )
 
 
 ;;; named commands
@@ -2360,8 +2298,11 @@ indent yanked text (with prefix arg don't indent)."
   (dolist
       (r `(
            (?i (file . ,"~/.emacs.d/init.el"))
-           (?w (file . ,"/a/work.org"))
+           (?o (file . ,"/a/work.org"))
            (?t (file . ,"/a/t.org"))
+           (?s (file . ,"/usr/share/doc/exim4-base/spec.txt.gz"))
+           (?w (file . ,"/p/w.org"))
+           (?k (file . ,"/a/bin/ds/Arduino/Model01-Firmware/Model01-Firmware.ino"))
            (?x (file . ,"/a/x.txt"))
            ))
     (set-register (car r) (cadr r)))
@@ -2370,6 +2311,25 @@ indent yanked text (with prefix arg don't indent)."
         undo-limit 500000000 ; undo history limit
         undo-strong-limit 600000000) ; undo history limit plus some extra
 
+
+;;; undo tree mode
+
+  ;; note, this has weird errors when it was before recentf-mode
+
+  ;; more resilient undo-tree-history if we have its location set up front.
+  (setq undo-tree-history-directory-alist '(("." . "~/.undo-tree-history")))
+
+
+  ;; todo, send patch undo-tree-visualize should scroll with the scroll key, instead of just pgup pgdn (aka next/prior)
+  (global-undo-tree-mode)
+  ;; disabled due to bug, something like unknown entry in undo tree canary
+  ;; (setq undo-tree-auto-save-history t)
+  (setq undo-outer-limit 100000000 ; per undo command
+        undo-limit 500000000 ; undo history limit
+        undo-strong-limit 600000000) ; undo history limit plus some extra
+  ;; Undo in region just happens accidentally, and throws me off
+  (setq undo-tree-enable-undo-in-region nil)
+
 ;;; keybinds
 
 ;;;; misc
@@ -2411,7 +2371,9 @@ indent yanked text (with prefix arg don't indent)."
 
 ;;;; single/special keys
 ;;;;; tab - isearch
-  (define-key isearch-mode-map (kbd "<tab>") 'isearch-query-replace)
+  ;; todo: this doesnt work. needs <tab>, which doesnt work in terminal. fix that.
+  ;; (define-key isearch-mode-map (kbd "TAB") 'isearch-query-replace)
+  (define-key isearch-mode-map (kbd "M-f") 'isearch-query-replace)
 
 ;;;;; f12 - isearch-forward
   ;; explained in http://stackoverflow.com/questions/7411920/how-to-bind-search-and-search-repeat-to-c-f-in-emacs
@@ -2465,7 +2427,10 @@ indent yanked text (with prefix arg don't indent)."
   (global-set-key (kbd "<home>") 'back-to-indentation-or-beginning)
 
 ;;;;; s-tab - indent-buffer
+  ;; graphical
   (global-set-key (kbd "<S-iso-lefttab>") 'indent-buffer)
+  ;; terminal
+  (global-set-key (kbd "<backtab>") 'indent-buffer)
 ;;;;; s-delete - send-shell
 
   (global-set-key (kbd "<S-delete>") 'send-shell)
@@ -2649,11 +2614,12 @@ modes like org-mode which have their own yank function."
   ;; stop splitting windows verticallly when I open a buffer or shell
   (setq split-height-threshold nil)
 
-;;;;; s-left arrow - shell
-  (global-set-key (kbd "<S-left>") 'shell-wrap)
-  (add-hook 'org-mode-hook
-            (lambda ()
-              (define-key org-mode-map (kbd "<S-left>") nil)))
+;;;;; s-left arrow - ---
+  ;; cant be used in terminal
+  ;; When I had a binding, i did this so org-mode wouldnt clobber it
+  ;; (add-hook 'org-mode-hook
+  ;;           (lambda ()
+  ;;             (define-key org-mode-map (kbd "<S-left>") nil)))
 
 ;;;;; s-right arrow - keyboard-yank-primary
   (defun keyboard-yank-primary ()
@@ -2687,7 +2653,7 @@ modes like org-mode which have their own yank function."
   (add-hook 'comint-mode-hook
             (lambda ()
               (define-key comint-mode-map "\r" nil)
-              (define-key comint-mode-map (kbd "<return>") 'comint-send-input)))
+              (define-key comint-mode-map (kbd "RET") 'comint-send-input)))
 
   (add-hook 'comint-mode-hook
             (lambda ()
@@ -2699,7 +2665,7 @@ modes like org-mode which have their own yank function."
   ;; kp-enter is shift return in terminal
   (global-set-key (kbd "<kp-enter>") 'flyspell-auto-correct-previous-word)
 
-;;;;; s-down arrow - my-contract-region
+;;;;; s-up arrow - my-contract-region
   (global-set-key (kbd "<S-up>") 'my-contract-region)
 ;;;;; c-up/down move 8 lines
 
@@ -2758,16 +2724,6 @@ modes like org-mode which have their own yank function."
 
 ;;;; left primary
 
-;;;;; C-2 copy-symbol
-
-  (global-unset-key (kbd "C-2"))
-  (defun copy-symbol (&optional arg)
-    "Copy symbol at point into kill-ring"
-    (interactive "P")
-    (kill-new (thing-at-point 'symbol)))
-
-  (global-set-key (kbd "C-2") 'copy-symbol)
-
 ;;;;; M-2 shell-cd-to-file
 
 
@@ -2781,13 +2737,18 @@ modes like org-mode which have their own yank function."
         (message "%s" "shell-cd-to-file: buffer has no file name"))))
   (global-set-key (kbd "M-2") 'shell-cd-to-file)
 
-;;;;; C-M-2 ---
-                                        ; todo. whats going on here?
+;;;;; C-M-2 copy-symbol
   (global-unset-key (kbd "C-M-2"))
+  (defun copy-symbol (&optional arg)
+    "Copy symbol at point into kill-ring"
+    (interactive "P")
+    (kill-new (thing-at-point 'symbol)))
 
-;;;;; C-3 dot-mode-execute
+  (global-set-key (kbd "C-M-2") 'copy-symbol)
 
-  (global-set-key (kbd "C-3") 'dot-mode-execute)
+;;;;; M-3 dot-mode-execute
+
+  (global-set-key (kbd "M-3") 'dot-mode-execute)
 
 ;;;;; C-M-3 recenter-top-bottom
 
@@ -2810,13 +2771,13 @@ modes like org-mode which have their own yank function."
 
   (global-set-key (kbd "C-M-q") 'quoted-insert)
 
-;;;;; C-w
+;;;;; C-w counsel-find-file
 
   (global-set-key (kbd "C-w") 'counsel-find-file)
 
-;;;;; M-w org-clock-in
+;;;;; M-w shell
 
-  (global-set-key (kbd "M-w") 'org-clock-in)
+  (global-set-key (kbd "M-w") 'shell-wrap)
 
 ;;;;; C-e copy-line
 
@@ -2918,6 +2879,11 @@ modes like org-mode which have their own yank function."
   (global-set-key (kbd "C-M-s") 'split-window-vertically)
 
 ;;;;; C-d - C-c prefix
+
+;;;;; M-d - run
+
+  (global-set-key (kbd "M-d") 'run)
+
 ;;;;; C-M-d - swap buffer across windows
   ;; from http://www.emacswiki.org/emacs/TransposeWindows
 
@@ -2947,7 +2913,7 @@ modes like org-mode which have their own yank function."
 
   (global-set-key (kbd "C-M-d") 'swap-buffers-in-windows)
 
-;;;;; C-f] - kill-whole-line
+;;;;; C-f - kill-whole-line
 
   (global-set-key (kbd "C-f") 'kill-whole-line-wrapper)
   (defun kill-whole-line-wrapper (&optional arg)
@@ -2976,10 +2942,7 @@ modes like org-mode which have their own yank function."
               (define-key org-mode-map (kbd "C-M-f") 'org-kill-line)))
 
   (global-set-key (kbd "C-M-f") 'kill-line)
-;;;;; C-g - cancel / other window
-
-  (global-set-key (kbd "C-g") 'other-window)
-
+;;;;; C-g - keyboard-quit
 ;;;;; M-g - abort-recursive-edit
 
   (global-set-key (kbd "M-g") 'abort-recursive-edit)
@@ -2989,8 +2952,12 @@ modes like org-mode which have their own yank function."
   (global-set-key (kbd "C-M-g") 'mu4e)
 
 ;;;;; C-z - undo-only
-
-  (global-set-key (kbd "C-z") 'undo-only)
+  (global-set-key (kbd "C-z") 'undo-tree-undo)
+;;;;; C-M-z - suspend-frame
+  (global-set-key (kbd "C-M-z") 'suspend-frame)
+  ;; this is never good in a gui
+  (when (window-system)
+    (defun suspend-frame() (interactive)))
 
 ;;;;; C-x - kill-region
 
@@ -3035,9 +3002,10 @@ modes like org-mode which have their own yank function."
               (define-key c-mode-base-map (kbd "<deletechar>") 'c-electric-delete-forward)))
 
 
-;;;;; M-c - org-capture
+;;;;; M-c - delete-other-windows
 
-  (define-key global-map "\M-c" 'org-capture)
+  ;; todo, consider binding/using org-capture
+  (define-key global-map "\M-c" 'delete-other-windows)
 
 ;;;;; C-M-c - copy-to-register
 
@@ -3074,9 +3042,9 @@ modes like org-mode which have their own yank function."
 
   (global-set-key (kbd "C-M-v") 'yank-pop)
 
-;;;;; C-b - delete-other-windows
+;;;;; C-b - other-window
 
-  (global-set-key (kbd "C-b") 'delete-other-windows)
+  (global-set-key (kbd "C-b") 'other-window)
 
 ;;;;; M-b - isearch-backward-current-symbol
 
@@ -3155,17 +3123,9 @@ modes like org-mode which have their own yank function."
   (global-set-key (kbd "<C-M-backspace>") 'backward-kill-sexp)
 
 ;;;; right primary
-;;;;; C-* - split-window-horizontally
+;;;;; M-8 - delete-window-or-exit
 
-  (global-set-key (kbd "C-*") 'split-window-horizontally)
-
-;;;;; C-M-* - calc-dispatch
-
-  (global-set-key (kbd "C-M-*") 'calc-dispatch)
-
-;;;;; C-9 - delete-window-or-exit
-
-  (global-set-key (kbd "C-9") 'delete-window-or-exit)
+  (global-set-key (kbd "M-8") 'delete-window-or-exit)
 
   (defun delete-window-or-exit ()
     "Delete window or exit emacs."
@@ -3175,6 +3135,12 @@ modes like org-mode which have their own yank function."
             (progn (basic-save-buffer) (delete-frame))
           (save-buffers-kill-terminal t))))
 
+;;;;; C-* - split-window-horizontally
+  (global-set-key (kbd "C-*") 'split-window-horizontally)
+;;;;; C-M-* - calc-dispatch
+
+  (global-set-key (kbd "C-M-*") 'calc-dispatch)
+
 ;;;;; M-9 - kill-buffer
 
   (defun kill-buffer-no-ido ()
@@ -3213,7 +3179,15 @@ modes like org-mode which have their own yank function."
       ))
 
 ;;;;; C-i -
-  (define-key input-decode-map [?\C-i] [C-i])
+  ;; todo: try making use
+  ;; this is the key in terminal
+  ;;M-[ 4 d is undefined
+
+  ;; previously had this for enhancing graphical keybinds,
+  ;; but afaik its no help since i want terminal to work
+  ;; the same.
+  ;;  (define-key input-decode-map [?\C-i] [C-i])
+
 ;;;;; C-M-i - query-replace-regexp
 
   (global-set-key (kbd "C-M-i") 'query-replace-regexp)
@@ -3304,15 +3278,17 @@ modes like org-mode which have their own yank function."
     (move-beginning-of-line 2))
   (global-set-key (kbd "C-M-;") 'comment-current-line-dwim)
 
-;;;;; C-m
-(define-key input-decode-map [?\C-m] [C-m])
+;;;;; C-m - ---
+  ;; terminal/console needs this. otherwise, we could do this
+  ;; to make C-m be a valid key in graphical mode.
+  ;;  (define-key input-decode-map [?\C-m] [C-m])
 ;;;;; C-M-m - recursive grep
 
   (define-key global-map (kbd "C-M-m") 'rgrep)
 
 ;;;;; C-, - ---
-;; not recognized by terminal, can't get konsole keydef file to recognize comma,
-;; todo: dig into konsole sources, or try newer version than t8
+  ;; not recognized by terminal, can't get konsole keydef file to recognize comma,
+  ;; todo: dig into konsole sources, or try newer version than t8
 
   (add-hook 'flyspell-mode-hook
             (lambda () (define-key flyspell-mode-map (kbd "C-,") nil)))
@@ -3322,32 +3298,12 @@ modes like org-mode which have their own yank function."
   (global-set-key (kbd "C-M-,") 'find-file-in-project)
 
 ;;;;; C-. - find recent file
-  ;;  Taken from starter kit.
-
-  (defun recentf-ido-find-file ()
-    "Find a recent file using Ido."
-    (interactive)
-    (let* ((file-assoc-list
-            (mapcar (lambda (x)
-                      (cons (file-name-nondirectory x)
-                            x))
-                    recentf-list))
-           (filename-list
-            (remove-duplicates (mapcar #'car file-assoc-list)
-                               :test #'string=))
-           (filename (ido-completing-read "Choose recent file: "
-                                          filename-list
-                                          nil
-                                          t)))
-      (when filename
-        (find-file (cdr (assoc filename
-                               file-assoc-list))))))
 
   (add-hook 'flyspell-mode-hook
             (lambda () (define-key flyspell-mode-map (kbd "C-.") nil)))
   (define-key dot-mode-map (kbd "C-.") nil)
-  (define-key terminal-key-map (kbd "4c") 'recentf-ido-find-file)
-  (global-set-key (kbd "C-.") 'recentf-ido-find-file)
+  (define-key terminal-key-map (kbd "4c") 'counsel-recentf)
+  (global-set-key (kbd "C-.") 'counsel-recentf)
   (add-hook 'php-mode-hook
             (lambda () (define-key php-mode-map (kbd "C-.") nil)))
 
@@ -3362,6 +3318,7 @@ modes like org-mode which have their own yank function."
     (interactive)
     (join-line '(4)))
   (global-set-key (kbd "C-/") 'vim-style-join-line)
+  (define-key undo-tree-map (kbd "C-/") nil)
 
 ;;;;; C-M-/ - copy-buffer-file-name
 
@@ -3399,10 +3356,6 @@ modes like org-mode which have their own yank function."
 
 
 
-;;;;; C-8 - calc-embedded-word
-
-  (global-set-key (kbd "C-8") 'calc-embedded-word)
-
 ;;;;; C-up-arrow - org prev headline
 
   ;; disabled just because i don't want to accidentally hit it
@@ -3448,7 +3401,7 @@ modes like org-mode which have their own yank function."
 
 ;;;;; C-S-down-arrow - m-x for major mode
 
-;; todo, update this for ivy
+  ;; todo, update this for ivy
   (global-set-key (kbd "<C-S-kp-enter>") 'smex-major-mode-commands)
 
 ;;;;; C-lbracket - ----
@@ -3471,6 +3424,7 @@ modes like org-mode which have their own yank function."
     (interactive)
     (end-of-line)
     (newline-and-indent))
+  ;; todo use alternate keybind make this work for terminal
   (global-set-key (kbd "<C-return>") 'newline-anywhere)
 
 
@@ -3479,7 +3433,7 @@ modes like org-mode which have their own yank function."
   (defun plain-newline ()
     (interactive)
     (insert "\n"))
-  (global-set-key (kbd "<M-return>") 'plain-newline)
+  (global-set-key (kbd "M-RET") 'plain-newline)
 
 
 ;;;;; C-space - org-edit-special
@@ -3559,9 +3513,9 @@ modes like org-mode which have their own yank function."
 ;;;;; C-home - start of buffer
 ;;;;; C-end - end of buffer
 ;;;; right secondary
-;;;;; C-6 - save-buffers-kill-emacs
+;;;;; C-^ - save-buffers-kill-emacs
 
-  (global-set-key (kbd "C-6") 'save-buffers-kill-emacs)
+  (global-set-key (kbd "C-^") 'save-buffers-kill-emacs)
 
 ;;;;; C-M-6 - insert-small-copyright
 
@@ -3569,18 +3523,22 @@ modes like org-mode which have their own yank function."
     (interactive)
     (beginning-of-line)
     (let ((beg (point)))
-      (insert "Copyright (C) 2017 Ian Kelling\nThis program is under GPL v. 3 or later, see <http://www.gnu.org/licenses/>")
+      (insert "Copyright (C) 2019 Ian Kelling\nThis program is under GPL v. 3 or later, see <http://www.gnu.org/licenses/>")
       (comment-region beg (point))))
 
   (global-set-key (kbd "C-M-6") 'insert-small-copyright)
 
+;;;;; M-7 - calc-embedded-word
+
+  (global-set-key (kbd "M-7") 'calc-embedded-word)
+
 ;;;;; C-M-7 - insert-full-copyright
 
   (defun insert-full-copyright ()
     (interactive)
     (beginning-of-line)
     (let ((beg (point)))
-      (insert "Copyright (C) 2017 Ian Kelling\n")
+      (insert "Copyright (C) 2019 Ian Kelling\n")
       (insert "\n")
       (insert "This program is free software: you can redistribute it and/or modify\n")
       (insert "it under the terms of the GNU General Public License as published by\n")
@@ -3632,7 +3590,7 @@ modes like org-mode which have their own yank function."
 ;;;;; C-M-- - org-edit-src-exit
 ;;;;; C-y - undo
 
-  (global-set-key (kbd "C-y") 'undo)
+  (global-set-key (kbd "C-y") 'undo-tree-redo)
   (add-hook 'org-mode-hook
             (lambda () (define-key org-mode-map (kbd "C-y") nil)))
 
@@ -3673,7 +3631,9 @@ modes like org-mode which have their own yank function."
 ;;;;; C-escape - find-tag
 
   (global-set-key (kbd "<C-escape>") 'find-tag)
-  ) ;; end let
+
+;;; end let from start of file
+  )
 
 ;; Local Variables:
 ;; eval: (outline-minor-mode)