use undo tree again, minor improvements
[dot-emacs] / init.el
diff --git a/init.el b/init.el
index d2411eb0ee0fd6f7f9c8be6f79d0645074ff1dbc..247ecfff95d7611ad6a7f60796fa6d37363b8469 100644 (file)
--- a/init.el
+++ b/init.el
@@ -311,6 +311,22 @@ Fourth argument TYPE is the custom option type."
 
 
 
+;;; undo tree 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)
+
 ;;; abreviations
   ;; turn on abbrev mode globally
   (setq-default abbrev-mode t)
@@ -969,7 +985,7 @@ and Ian Kelling as the name"
      ;; 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
@@ -1177,10 +1193,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)))
 
@@ -1850,6 +1866,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
@@ -2360,6 +2377,7 @@ indent yanked text (with prefix arg don't indent)."
   (dolist
       (r `(
            (?i (file . ,"~/.emacs.d/init.el"))
+           (?w (file . ,"/a/work.org"))
            (?t (file . ,"/a/t.org"))
            (?x (file . ,"/a/x.txt"))
            ))
@@ -2372,6 +2390,12 @@ indent yanked text (with prefix arg don't indent)."
 ;;; keybinds
 
 ;;;; misc
+
+  (define-prefix-command 'terminal-key-map)
+  (global-set-key (kbd "\e[") 'terminal-key-map)
+
+
+
   (global-set-key (kbd "C-x C-b") 'ibuffer)
 
 
@@ -2803,8 +2827,10 @@ modes like org-mode which have their own yank function."
 
   (global-set-key (kbd "C-M-q") 'quoted-insert)
 
-;;;;; C-w ---
-  ;; in terminal, it's ctrl-backspace, duplicate keybind.
+;;;;; C-w
+
+  (global-set-key (kbd "C-w") 'counsel-find-file)
+
 ;;;;; M-w org-clock-in
 
   (global-set-key (kbd "M-w") 'org-clock-in)
@@ -2981,7 +3007,7 @@ modes like org-mode which have their own yank function."
 
 ;;;;; C-z - undo-only
 
-  (global-set-key (kbd "C-z") 'undo-only)
+  (global-set-key (kbd "C-z") 'undo-tree-undo)
 
 ;;;;; C-x - kill-region
 
@@ -3130,6 +3156,9 @@ modes like org-mode which have their own yank function."
 
 ;;;;; C-backspace - backward-kill-symbol
 
+  (define-key terminal-key-map (kbd "4b") 'backward-kill-symbol) ;c-backspace in my konsole
+
+  ;; c-w is duplicate in terminal
   (global-set-key (kbd "<C-backspace>") 'backward-kill-symbol)
   (add-hook 'comint-mode-hook
             (lambda ()
@@ -3200,7 +3229,8 @@ modes like org-mode which have their own yank function."
       (delete-windows-on "*Help*")
       ))
 
-;;;;; C-i - -----
+;;;;; C-i -
+  (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)
@@ -3291,13 +3321,16 @@ 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-m - recursive grep
 
   (define-key global-map (kbd "C-M-m") 'rgrep)
 
-;;;;; C-, - counsel-find-file
+;;;;; 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
 
-  (global-set-key (kbd "C-,") 'counsel-find-file)
   (add-hook 'flyspell-mode-hook
             (lambda () (define-key flyspell-mode-map (kbd "C-,") nil)))
 
@@ -3330,6 +3363,7 @@ modes like org-mode which have their own yank function."
   (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)
   (add-hook 'php-mode-hook
             (lambda () (define-key php-mode-map (kbd "C-.") nil)))
@@ -3345,6 +3379,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
 
@@ -3431,7 +3466,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 - ----
@@ -3465,15 +3500,6 @@ modes like org-mode which have their own yank function."
   (global-set-key (kbd "<M-return>") 'plain-newline)
 
 
-;;;;; C-M-return - newline-anywhere-previous
-  (defun newline-anywhere-previous ()
-    "Add a newline from anywhere in the line."
-    (interactive)
-    (forward-line -1)
-    (end-of-line)
-    (newline-and-indent))
-  (global-set-key (kbd "<C-M-return>") 'newline-anywhere-previous)
-
 ;;;;; C-space - org-edit-special
 
   ;; commented due to new keyboard needing ctrl-space for mark
@@ -3551,9 +3577,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
 
@@ -3561,7 +3587,7 @@ 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)
@@ -3572,7 +3598,7 @@ modes like org-mode which have their own yank function."
     (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")
@@ -3624,7 +3650,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)))