various improvements
[dot-emacs] / init.el
diff --git a/init.el b/init.el
index 5ba8428531ba7fe76d244bcc98e56f2947ab84e5..412b68dda5a8a93ec4bb3333f089990ef80ef53b 100644 (file)
--- a/init.el
+++ b/init.el
@@ -39,8 +39,8 @@
   ;; 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)
+  (require 'benchmark-init)
+  (add-hook 'after-init-hook 'benchmark-init/deactivate)
   ;;
 
   ;; these need to be done before the hook in order to satisfy the byte compiler or batch mode
@@ -218,7 +218,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,8 +249,6 @@ 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.
 
@@ -311,6 +309,7 @@ Fourth argument TYPE is the custom option type."
 
 
 
+
 ;;; abreviations
   ;; turn on abbrev mode globally
   (setq-default abbrev-mode t)
@@ -481,7 +480,7 @@ Fourth argument TYPE is the custom option type."
            ;; mu4e has a bug right now, undo breaks when saving drafts
            (not (string= (buffer-file-name) "*draft*"))
            (buffer-modified-p)
-           (not (org-src-edit-buffer-p)))
+           (not (and (boundp 'org-src-edit-buffer-p) (org-src-edit-buffer-p))))
       ;; serial is incremented on each save, so let's do a bit less of them
       (not (derived-mode-p 'dns-mode))
       (setq my-auto-save-last last)
@@ -955,21 +954,14 @@ 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"
      ;; 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
@@ -977,16 +969,7 @@ 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)
-        )
      ) ;; 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
@@ -1177,10 +1160,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)))
 
@@ -1433,7 +1416,7 @@ https://fsf.org | https://gnu.org
 
   (defun gtags-update-hook()
     "Update GTAGS file incrementally upon saving a file"
-    (when (and ggtags-mode ggtags-project-root)
+    (when (and (boundp 'ggtags-mode) ggtags-mode ggtags-project-root)
       (gtags-update-current-file)))
 
   (add-hook 'after-save-hook 'gtags-update-hook)
@@ -1506,7 +1489,7 @@ https://fsf.org | https://gnu.org
 
 
   ;; show the name of the current function definition in the modeline
-  (require 'which-func)
+  ;;(require 'which-func)
   (setq which-func-modes t)
   (which-function-mode 1)
 
@@ -1560,19 +1543,7 @@ https://fsf.org | https://gnu.org
     (define-key Info-mode-map [mouse-4]         nil)
     (define-key Info-mode-map [mouse-5]         nil))
 
-  (eval-after-load "info" '(my-info-init))
-
-  (require 'smooth-scroll)
-  ;; long gnus summary buffers lags too much with this,
-  ;; but I like it enough to leave it enabled by default
-  ;; and crank up the step size to be faster
-  ;; and it doesn't have a way to enable it only for certain modes etc.
-  ;; todo sometime, make it work for certain modes only
-  (smooth-scroll-mode t)
-  ;; its too slow with the default of 2
-  (setq smooth-scroll/vscroll-step-size 7)
-  ;; sublimity doesn't work as good going fast by default
-  ;; smooth-scrolling.el, does not do smooth scrolling. its about cursor location
+  (add-hook 'info-mode-hook 'my-info-init)
 
 
   (setq sh-here-document-word "'EOF'")
@@ -1671,6 +1642,18 @@ https://fsf.org | https://gnu.org
                 imenu-auto-rescan t
                 indicate-empty-lines t) ; mark end of buffer
 
+  (require 'smooth-scroll)
+  ;; long gnus summary buffers lags too much with this,
+  ;; but I like it enough to leave it enabled by default
+  ;; and crank up the step size to be faster
+  ;; and it doesn't have a way to enable it only for certain modes etc.
+  ;; todo sometime, make it work for certain modes only
+  (smooth-scroll-mode t)
+  ;; its too slow with the default of 2
+  (setq smooth-scroll/vscroll-step-size 7)
+  ;; sublimity doesn't work as good going fast by default
+  ;; smooth-scrolling.el, does not do smooth scrolling. its about cursor location
+
 
   (blink-cursor-mode '(-4))
   (menu-bar-mode -1)
@@ -1850,6 +1833,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
@@ -2224,7 +2208,9 @@ indent yanked text (with prefix arg don't indent)."
 
   ;; todo, testout these mode specific settings from graphene.
   ;; Ruby-specific pairs and handlers
-  (require 'smartparens-ruby)
+
+  (eval-after-load "ruby"
+    '(require 'smartparens-ruby))
 
   ;; Markdown
   (sp-local-pair '(markdown-mode gfm-mode) "*" "*"
@@ -2235,13 +2221,8 @@ indent yanked text (with prefix arg don't indent)."
   (sp-local-pair 'html-mode "\"" nil :unless '(:rem sp-point-after-word-p))
 
 
-;;; smex
-  ;;  todo; check out smex-show-unbound-commands shows frequently used commands that have no key bindings.
-                                        ; these must be before smex-initialize
-  (setq
-   smex-save-file "~/.emacs.d/.smex-items")
 
-  (smex-initialize)
+
 ;;; spell correction
   (setq
    ispell-program-name "hunspell"
@@ -2337,7 +2318,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
+   erc-modules
+     '(autojoin button completion irccontrols list match menu move-to-prompt netsplit networks noncommands readonly ring stamp track)
+   )
 
 
 ;;; named commands
@@ -2363,6 +2348,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,9 +2358,34 @@ 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
+
+  (define-prefix-command 'terminal-key-map)
+  (global-set-key (kbd "\e[") 'terminal-key-map)
+
+
+
   (global-set-key (kbd "C-x C-b") 'ibuffer)
 
 
@@ -2806,8 +2817,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)
@@ -2984,15 +2997,22 @@ 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
 
   (global-set-key (kbd "C-s") 'kill-region)
 
-;;;;; M-x - smex
+;;;;; M-x - counsel-m-x
+
+
+  ;;  todo; check out smex-show-unbound-commands shows frequently used commands that have no key bindings.
+  ;; this must be before smex-initialize
+  (setq
+   smex-save-file "~/.emacs.d/.smex-items")
 
-  (global-set-key (kbd "M-x") 'smex)
+  ;; this uses smex
+  (global-set-key (kbd "M-x") 'counsel-M-x)
 
 ;;;;; C-M-x - cut-to-register
 
@@ -3126,6 +3146,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 ()
@@ -3196,7 +3219,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)
@@ -3233,9 +3257,10 @@ modes like org-mode which have their own yank function."
         (org-show-context 'mark-goto)))
 
   (global-set-key (kbd "C-j") 'my-pop-to-mark-command)
-  (define-key ido-common-completion-map (kbd "C-j") 'ido-select-text)
   (add-hook 'ido-setup-hook
-            (lambda () (define-key ido-common-completion-map (kbd "C-j") 'ido-select-text)))
+            (lambda ()
+              (define-key ido-common-completion-map (kbd "C-j") 'ido-select-text)
+              ))
   (add-hook 'lisp-interaction-mode-hook
             (lambda ()
               (define-key lisp-interaction-mode-map (kbd "C-j") nil)))
@@ -3286,13 +3311,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)))
 
@@ -3325,6 +3353,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)))
@@ -3340,6 +3369,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
 
@@ -3426,6 +3456,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
   (global-set-key (kbd "<C-S-kp-enter>") 'smex-major-mode-commands)
 
 ;;;;; C-lbracket - ----
@@ -3459,15 +3490,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
@@ -3545,9 +3567,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
 
@@ -3555,7 +3577,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)
@@ -3566,7 +3588,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")
@@ -3618,7 +3640,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)))
 
@@ -3659,7 +3681,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)