optimize startup
[dot-emacs] / init.el
diff --git a/init.el b/init.el
index 85c7fb2ec81d16487769b9918e7ab812cc6a0dc2..021fc6c9ccfdcfd3cc8a34779c92a442ee4d39c3 100644 (file)
--- a/init.el
+++ b/init.el
 (add-hook 'after-init-hook
           `(lambda ()
              (setq file-name-handler-alist file-name-handler-alist-old
-                   gc-cons-threshold 800000
-                   gc-cons-percentage 0.1)
-             (garbage-collect)) t)
+                   ;; 100 mb
+                   gc-cons-threshold 100000000))
+          ;; taken from wiegley, dunno why the t is there.
+          t)
 
 ;; 2019-6-26, 1.26s
 ;; ; to profile init:
 ;; ; uncomment the following block
-;; (require 'benchmark-init)
-;; (add-hook 'after-init-hook 'benchmark-init/deactivate)
+ (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
   :unless noninteractive
   :config
   (save-place-mode 1))
+;; find file at point
 (use-package ffap)
 
-;; from jwiegley
-(use-package recentf
-  :defer 10
-  :commands (recentf-mode
-             recentf-add-file
-             recentf-apply-filename-handlers)
-  :config
-  (recentf-mode 1))
 
 (setq package-archives
       (quote
 
 ;; keep our init.el clean, by moving customization elisp to it's own file
 (setq custom-file "~/.emacs.d/custom.el")
-(load custom-file 'noerror)
+;; empty atm
+;;(load custom-file 'noerror)
 
 
 ;;; auto-complete
@@ -635,54 +630,37 @@ A non-nil CURRENT-ONLY argument means save only current buffer."
 
 ;;; cross session settings
 
-;; Save a list of recent files visited.
-(recentf-mode 1)
-(setq recentf-max-saved-items 400
-      recentf-max-menu-items 15)
-
-
-(setq save-place t
-      save-place-version-control 'nospecial
-      save-place-limit 40000
-      save-place-file "~/.emacs.d/places")
-
-
-
-;; savehist keeps track of some history
-;; search entries
-(setq savehist-additional-variables '(kill-ring search-ring regexp-search-ring)
-      ;; save every minute
-      savehist-autosave-interval 60
-      ;; keep the home clean
-      savehist-file "~/.emacs.d/.savehist")
-(savehist-mode 1)
-
-
-;;; ediff
-;; ediff-buffers is the main command to use
-
-;; ediff - don't start another frame for the control panel
-;; unfortunately, this doesn't allow me to use 2 frames for the diff buffers
-;; so disable this temporarily with the next line if you want that
-;; sometime I should setup 2 functions to explicitly do each type
-(setq ediff-window-setup-function 'ediff-setup-windows-plain)
-;;(setq ediff-window-setup-function 'ediff-setup-windows-default)
+(use-package recentf
+  ;; defer & commands from jwiegley
+  :defer 10
+  :commands (recentf-mode
+             recentf-add-file
+             recentf-apply-filename-handlers)
+  :config
+  (recentf-mode 1)
+  (setq recentf-max-saved-items 400
+        recentf-max-menu-items 15)
+  )
 
-;; do side by side diffs
-(setq ediff-split-window-function 'split-window-horizontally)
+(use-package saveplace
+  :unless noninteractive
+  :config
+  save-place-version-control 'nospecial
+  save-place-limit 4000
+  save-place-file "~/.emacs.d/places"
+  (save-place-mode 1))
 
 
-;; Things I tried which didn't work, which intuitively I think should
-;; work better: I can open the second diff buffer in a new frame, and
-;; close it's window in the first frame after starting ediff, but when I
-;; hit n to go to the next diff, it restores the window in the first
-;; frame. Another thing I tried is to open 2 new frames and set them up
-;; as I want. However, if I try to open the *Ediff Control Panel* buffer
-;; in a different window from its original one, my mouse jumps to one of
-;; the diff frames, or if that isn't visible, the buffer just hangs
-;; until I select the original ediff control panel window. This seems
-;; like a bug to me. I am using a very recent development version of
-;; emacs.
+;; savehist keeps track of some history search entries
+(use-package savehist
+  :unless noninteractive
+  :config
+  (setq savehist-additional-variables '(kill-ring search-ring regexp-search-ring)
+        ;; save every minute
+        savehist-autosave-interval 60
+        ;; keep the home clean
+        savehist-file "~/.emacs.d/.savehist")
+  (savehist-mode 1))
 
 ;;; dired
 
@@ -701,6 +679,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer."
 ;; (setq mu4e-headers-results-limit 2000)
 
 
+
 (defun my-mu4e-init ()
   (setq mu4e-headers-fields (delq (assoc :mailing-list mu4e-headers-fields) mu4e-headers-fields))
   ;; it's implemented in mu4e, but not in the actions list for
@@ -739,6 +718,11 @@ A non-nil CURRENT-ONLY argument means save only current buffer."
 (eval-after-load "mu4e" '(my-mu4e-init))
 
 (setq
+ ;; message mode prompted me on first message.
+ ;; a function which describes options then sets this
+ ;; the other options were to use smtp directly or pass to another mail client
+ ;; here we use the standard sendmail interface. This applies for gnus too.
+ send-mail-function (quote sendmail-send-it)
  ;; 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.
@@ -1014,10 +998,38 @@ and Ian Kelling as the name"
 
 ;;; modes with little configuration needed
 
-;; disabled temporarily
+(setq outline-minor-mode-prefix "\ 3\ 1"
+      css-indent-offset 2
+      ;; auto indent shell script comments
+      sh-indent-comment t
+      sh-here-document-word "'EOF'"
+      tramp-default-method "ssh"
+      ;; ediff-buffers is the main command to use
+      ;; don't start another frame for the control panel
+      ;; unfortunately, this doesn't allow me to use 2 frames for the diff buffers
+      ;; so disable this temporarily with the next line if you want that
+      ;; sometime I should setup 2 functions to explicitly do each type
+      ediff-window-setup-function 'ediff-setup-windows-plain
+      ;;(setq ediff-window-setup-function 'ediff-setup-windows-default)
+      ;; do side by side diffs
+      ediff-split-window-function 'split-window-horizontally
+      ;; ediff things I tried which didn't work, which intuitively I think should
+      ;; work better: I can open the second diff buffer in a new frame, and
+      ;; close it's window in the first frame after starting ediff, but when I
+      ;; hit n to go to the next diff, it restores the window in the first
+      ;; frame. Another thing I tried is to open 2 new frames and set them up
+      ;; as I want. However, if I try to open the *Ediff Control Panel* buffer
+      ;; in a different window from its original one, my mouse jumps to one of
+      ;; the diff frames, or if that isn't visible, the buffer just hangs
+      ;; until I select the original ediff control panel window. This seems
+      ;; like a bug to me. I am using a very recent development version of
+      ;; emacs.
+
+      )
+
+;; disabled temporarily. todo, look into it
 ;;(add-hook 'outline-minor-mode-hook 'outshine-mode)
 
-(setq css-indent-offset 2)
 
 (when (file-exists-p "/a/h/iank-mod.el")
   (load-file "/a/h/iank-mod.el"))
@@ -1038,9 +1050,9 @@ and Ian Kelling as the name"
 
 (ws-butler-global-mode)
 
-
-
-(require 'nginx-mode)
+;; disabled because i dont edit nginx files enough
+;; to have this loaded at startup
+;;(use-package nginx-mode)
 ;;The mode should automatically activate for files called nginx.conf and files under /etc/nginx - if not, you can add something like this to your init file:
 ;;(add-to-list 'auto-mode-alist '("/etc/nginx/sites-available/.*" . nginx-mode))
 
@@ -1060,23 +1072,12 @@ and Ian Kelling as the name"
   (setq-local prev-auto-revert-max (point-max)))
 
 
-;; message mode prompted me on first message.
-;; a function which describes options then sets this
-;; the other options were to use smtp directly or pass to another mail client
-;; here we use the standard sendmail interface, which I use postfix for
-(setq send-mail-function (quote sendmail-send-it))
-
 ;; delete active selection with self-insert commands
 (delete-selection-mode t)
 
 ;; Transparently open compressed files
 (auto-compression-mode t)
 
-;; not documented, but looking at the source, I find this
-;; stops me from being asked what command on every C-c-c
-;; when doing a latex document.
-(setq TeX-command-force "LaTeX")
-
 ;; dot mode, repeats last action
 (require 'dot-mode)
 (add-hook 'find-file-hooks 'dot-mode-on)
@@ -1090,7 +1091,6 @@ and Ian Kelling as the name"
 
 
 ;; show the name of the current function definition in the modeline
-;;(require 'which-func)
 (setq which-func-modes t)
 (which-function-mode 1)
 
@@ -1123,10 +1123,6 @@ and Ian Kelling as the name"
 ;;(add-hook 'text-mode-hook 'turn-on-auto-fill)
 (add-hook 'text-mode-hook 'turn-on-flyspell)
 
-
-;; auto indent shell script comments
-(setq sh-indent-comment t)
-
 ;; random extra highlights
 (require 'volatile-highlights)
 (volatile-highlights-mode t)
@@ -1146,11 +1142,22 @@ and Ian Kelling as the name"
 (add-hook 'info-mode-hook 'my-info-init)
 
 
-(setq sh-here-document-word "'EOF'")
-
-(setq tramp-default-method "ssh")
 ;;; misc general settings
 
+
+;; I tried to look for a function that would set this that is
+;; not part of the emacs interactive customize stuff, but didn't see one
+;; in the faces documentation.
+
+(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.
+ '(header-line ((t (:background "default" :foreground "default" :overline nil :underline nil))))
+ '(region ((t nil))))
+
+
 ;; 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)
@@ -1662,7 +1669,8 @@ Go to the next directory based on where the cursor is."
   ;; this says do autofilling using newcomment.el. The "only" is a misnomer.
   (set (make-local-variable 'comment-auto-fill-only-comments) t)
   (column-number-mode t)
-  (turn-on-smartparens-mode)
+  ;; trying without
+  ;; (turn-on-smartparens-mode)
 
   ;; prettify lambdas
   (font-lock-add-keywords
@@ -1761,62 +1769,13 @@ indent yanked text (with prefix arg don't indent)."
     (shell)))
 
 (add-hook 'shell-mode-hook 'track-shell-directory/procfs)
-;;; smartparens
-;; the melpa git version had a catastrophic bug I reported.
-;; downgraded to marmalade version and everything is working fine.
-(require 'smartparens-config)
-(show-smartparens-global-mode t)
-
-
-(defun gp/sp/pair-on-newline-and-indent (id action context)
-  "Open a new brace or bracket expression, with relevant newlines and indent. "
-  (save-excursion
-    (newline)
-    (indent-according-to-mode))
-  (indent-according-to-mode))
-
-;; 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 "RET"))))
-(sp-pair "[" nil :post-handlers
-         '(:add ((lambda (id action context)
-                   (gp/sp/pair-on-newline-and-indent id action context)) (kbd "RET"))))
-
-
-;; in my version, this is not a pairing.
-;; not sure if it is in a future version since I reverted to marmalade
-;; Don't need c-comments in strings -- they frustrate filename globs
-;; (sp-pair "/*" nil :unless '(sp-in-string-p))
-
-;; Don't need quotes to pair next to words
-(sp-pair "\"" nil :unless '(sp-point-before-word-p sp-point-after-word-p))
-(sp-pair "'" nil :unless '(sp-point-before-word-p sp-point-after-word-p))
-
-
-;; todo, testout these mode specific settings from graphene.
-;; Ruby-specific pairs and handlers
-
-(eval-after-load "ruby"
-  '(require 'smartparens-ruby))
-
-;; Markdown
-(sp-local-pair '(markdown-mode gfm-mode) "*" "*"
-               :unless '(sp-in-string-p)
-               :actions '(insert wrap))
-
-;; Except in HTML
-(sp-local-pair 'html-mode "\"" nil :unless '(:rem sp-point-after-word-p))
-
-
-
-
 ;;; spell correction
 (setq
  ispell-program-name "hunspell"
  ispell-silently-savep t) ; don't prompt to save personal dictionary
 
-(require 'rw-hunspell)
+(use-package rw-hunspell
+  :defer t)
 ;; rw-hunspell sets up hunspell dictionary automagically.
 
 
@@ -1831,25 +1790,24 @@ indent yanked text (with prefix arg don't indent)."
 
 ;;; tex
 (setq-default TeX-PDF-mode t) ; use pdf
-
-                                        ; more sensible defaults based on info manual quickstart
-(setq TeX-auto-save t)
-(setq TeX-parse-self t)
-
-
+;; more sensible defaults based on info manual quickstart
+(setq TeX-auto-save t
+      TeX-parse-self t
+      ;; not documented, but looking at the source, I find this
+      ;; stops me from being asked what command on every C-c-c
+      ;; when doing a latex document.
+      TeX-command-force "LaTeX"
+      )
 
 ;;; visible mark mode
 
 ;; since it is not easy to change the mark overlay priority, I change this one.
 (setq show-paren-priority 999)
 
-
 (defface visible-mark-active
   '((((type tty) (class mono)))
     (t (:background "magenta"))) "")
 
-
-
 (defface mouse-cursor-face
   '((((type tty) (class mono)))
     (t (:background "DeepPink1"))) "")
@@ -1857,15 +1815,14 @@ indent yanked text (with prefix arg don't indent)."
 
 (require 'visible-mark)
 
-(setq visible-mark-faces '(visible-mark-face1 visible-mark-face2))
-(setq visible-mark-forward-faces '(visible-mark-forward-face1))
-
-
-                                        ; highlight the last 2 marks
-(setq visible-mark-max 2)
-                                        ; highlight 1 forward mark
-(setq visible-mark-forward-max 1)
-                                        ; globally activate visible-mark-mode
+(setq
+ visible-mark-faces '(visible-mark-face1 visible-mark-face2)
+ visible-mark-forward-faces '(visible-mark-forward-face1)
+ ;; highlight the last 2 marks
+ visible-mark-max 2
+ ;; highlight 1 forward mark
+ visible-mark-forward-max 1)
+;; globally activate visible-mark-mode
 (global-visible-mark-mode +1)
 
 
@@ -1873,9 +1830,7 @@ indent yanked text (with prefix arg don't indent)."
 ;; if I could define overlay faces to use inverse foreground color
 
 
-;;; znc
-
-(setq erc-fill-prefix "")
+;;; znc/erc
 (defun chirp()
   (interactive)
   (setq vol 50)
@@ -1898,27 +1853,27 @@ indent yanked text (with prefix arg don't indent)."
      ;; We must return nil. See help for `erc-server-PRIVMSG-functions'
      nil)))
 
-(add-hook 'erc-server-PRIVMSG-functions
-          'erc-my-privmsg-sound)
-
 (defun erc-sound-if-not-server (match-type nickuserhost msg)
   (unless (string-match "Server:[0-9]+" nickuserhost)
     (chirp)))
-(add-hook 'erc-text-matched-hook 'erc-sound-if-not-server)
-
-(eval-after-load "erc"
-  '(erc-track-mode 1))
-(setq
- ;; 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
- ;; 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)
- )
-
 
+(use-package erc
+  :defer t
+  :init
+  (setq erc-fill-prefix ""
+        ;; 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
+        ;; 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)
+        ) ; end setq
+  :config
+  (add-hook 'erc-server-PRIVMSG-functions
+            'erc-my-privmsg-sound)
+  (add-hook 'erc-text-matched-hook 'erc-sound-if-not-server)
+  (erc-track-mode 1))
 ;;; named commands
 (defun rm-file-and-buffer ()
   "Removes file connected to current buffer and kills buffer."
@@ -1960,19 +1915,22 @@ indent yanked text (with prefix arg don't indent)."
 
 ;; 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)
+(use-package undo-tree
+  :config
+  ;; more resilient undo-tree-history if we have its location set up front.
+  (setq undo-tree-history-directory-alist '(("." . "~/.undo-tree-history"))
+        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
+        undo-tree-enable-undo-in-region nil)
+  ;; disabled due to bug, something like unknown entry in undo tree canary
+  ;; (setq undo-tree-auto-save-history t)
+
+  ;; todo, send patch undo-tree-visualize should scroll with the scroll key, instead of just pgup pgdn (aka next/prior)
+  (global-undo-tree-mode)
+  ;; simple way to fix that enable undo-tree starts out disabled in org-mode
+  (defun undo-tree-overridden-undo-bindings-p() nil))
 
 ;;; keybinds
 
@@ -2271,7 +2229,7 @@ modes like org-mode which have their own yank function."
 (add-hook 'org-mode-hook
           (lambda ()
             (define-key org-mode-map (kbd "<S-right>") nil)))
-;;;;; esc
+;;;;; esc --- terminal dup
 ;; todo, test out if this can be used
 ;;;;; return - new line