ditch org for init, various improvements
[dot-emacs] / ian-notes.org
diff --git a/ian-notes.org b/ian-notes.org
new file mode 100644 (file)
index 0000000..e976bac
--- /dev/null
@@ -0,0 +1,1894 @@
+#+title: My Personal Init Customization
+#+OPTIONS: toc:nil num:nil ^:nil
+
+* python disabled due to long load time
+todo: get smart-operator to work
+todo, checkout https://github.com/python-rope/ropemacs refactoring python,
+todo, try py-autopep8, autoformatter
+todo, check out some python linting stuff. pychecker is one, others are in *packages*
+todo, finish reading through python-mode.el functions
+;; todo, figure out multi-line input in shell mode
+
+
+usefull m-x commands:
+m-x py-describe-mode: doc for mode which is extensive
+m-x py-sort-imports
+m-x py-guess-indent-offset: setup indent for code i didn't write
+
+possibly usefull commands:
+found via looking through python-mode.el, quit like 1/4 through, cuz its tedious, last spot was at:
+(defun py-comment-region (beg end &optional arg)
+after finding py-describe-mode, it seemed to do a good job of documenting all the most important stuff
+
+py-switch-to-python
+python-shell-completion-complete-or-indent may be usefull to get completion working in the shell
+py-insert-default-shebang
+py-electric-*
+py-indent-line-outmost
+py-newline-and-close-block
+py-indent-and-forward (indent line, move to next)
+py-fill-*
+py-which-function (for showing in the modeline)
+py-help-at-point
+py-execute-import-or-reload
+py-execute-def-or-class
+various pdb functions
+
+
+installing jedi
+#+begin_src sh :tangle no
+pi python-pip
+s pip install jedi virtualenv
+#+end_src
+then do m-x jedi:install-server
+
+
+
+disabled because it takes 152 ms to load,
+and I don't know how to do it conditioally
+#+begin_src emacs-lisp :tangle no
+
+;; change from default python3 to be compatibile with Pywikibot
+(setq py-shell-name "/usr/bin/python")
+(require 'python-mode)
+
+(setq py-autopep8-options '("--max-line-length=110"))
+
+(defun py-execute-block-or-clause-create-shell ()
+  (interactive)
+  (cond ((get-buffer "*Python*")
+         (py--execute-prepare "block-or-clause")
+         (py-execute-block-or-clause)
+         (call-interactively 'next-line))
+        (t
+         (py-shell)
+         ;; py-shell starts the shell but not display the buffer on the first run
+         ;; subsequent runs, it does. I grabbed this command from inside to
+         ;; do just the relevant part from the second run, as a hack.
+         ;; todo: report a bug on this
+         (py--shell-manage-windows py-buffer-name))))
+(setq py-tab-shifts-region-p t)
+(setq py-tab-indents-region-p t)
+
+(defun py-run ()
+  "default action to run the current buffer"
+  (basic-save-buffer)
+  (py-execute-buffer))
+
+
+(add-hook 'python-mode-hook
+          (lambda ()
+            (setq run-fun 'py-run)
+            (define-key python-mode-map (kbd "C-M-a") nil)
+            (define-key python-mode-map (kbd "C-M-d") nil)
+            (define-key python-mode-map (kbd "C-M-e") nil)
+            (define-key python-mode-map (kbd "C-M-h") nil)
+            (define-key python-mode-map (kbd "C-M-i") nil)
+            (define-key python-mode-map (kbd "C-M-u") nil)
+            (define-key python-mode-map (kbd "C-M-x") nil)
+            (define-key python-mode-map (kbd "<tab>") 'indent-for-tab-command)
+            (define-key python-mode-map (kbd "C-j") nil)
+            (define-key python-mode-map (kbd "<C-backspace>") nil)
+            ;;(define-key python-mode-map (kbd "C-(") (lambda () (interactive) (basic-save-buffer) (py-execute-buffer)))
+            ;; fix default return bindings
+            (define-key python-mode-map (kbd "C-j") nil)
+            (define-key python-mode-map (kbd "RET") nil)
+            (define-key python-mode-map (kbd "<return>") 'py-newline-and-indent)
+            (define-key python-mode-map (kbd "<M-tab>") 'py-indent-line)
+            (define-key python-mode-map (kbd "C-M-(") 'py-shift-left)
+            (define-key python-mode-map (kbd "C-M-)") 'py-shift-right)
+            (define-key python-mode-map (kbd "<home>") 'py-beginning-of-line)
+            (define-key python-mode-map (kbd "<end>") 'py-end-of-line)
+            (define-key python-mode-map (kbd "C-t") 'py-execute-block-or-clause-create-shell)
+            (define-key python-mode-map (kbd "<S-delete>") 'py-ian-execute-line-or-region)
+            ;; python mode adds these to this list, which is normally empty.
+            ;; it makes my send-python function not reuse an existing python shell window
+            ;; there are other ways to override this, but I don't know of any other value of
+            ;; having this set.
+            (setq same-window-buffer-names (delete "*Python*" same-window-buffer-names))
+            (setq same-window-buffer-names (delete "*IPython*" same-window-buffer-names))))
+
+;; i dunno, why, but this didn't work:
+;; and we can't eval-after-load cuz it is part of the greater python mode file
+(add-hook 'py-shell-hook
+          (lambda ()
+            (define-key py-shell-map "\r" nil)
+            (define-key py-shell-map (kbd "<return>") 'comint-send-input)
+            (define-key py-shell-map (kbd "C-t") 'py-shell-toggle-arrow-keys)
+            (define-key py-shell-map "\C-d" nil)
+            (define-key py-shell-map (kbd "<up>") 'my-comint-previous-input)
+            (define-key py-shell-map (kbd "<down>") 'my-comint-next-input)))
+
+
+(defun py-ian-execute-line-or-region ()
+  (interactive)
+  (cond ((get-buffer "*Python*")
+         (if mark-active
+             (py-execute-region)
+           (py-execute-statement))
+         (call-interactively 'next-line))
+        (t (py-shell))))
+
+;; http://tkf.github.io/emacs-jedi/latest/
+(add-hook 'python-mode-hook 'jedi:setup)
+(setq jedi:complete-on-dot t)
+
+(defun py-shell-toggle-arrow-keys ()
+  (interactive)
+  (toggle-arrow-keys py-shell-map))
+
+#+end_src
+
+
+;; py-shell window stuff
+;; it splits the window if the shell is in a different frame
+;; which seems to be a bug, but it can be fixed with this option
+;; (setq py-keep-windows-configuration 'force)
+;; however, with py-execute-block-or-clause, if the shell is in a different frame,
+;; you get errors "buffer is read only", when the point is near the beginning of a command
+;; todo: test with emacs -Q and file a bug
+;; if you execute py-execute-... without a python shell open,
+;; it starts one, doesn't display it, and subsequent py-execute commands
+;; give error "buffer is read only"
+;; these functions fix / improve these problems
+
+
+** initial python-mode setup
+
+python-mode seems to be the most canonical package, based on
+https://docs.python.org/devguide/emacs.html
+much more feature rich than the emacs built in one.
+
+getting it, it wants you to setup an account on launchpad by default,
+there is some way to get anonymous bzr access, but google didn't answer it right away,
+so fuck it, ill go the happy path.
+
+based on error messages,
+add public ssh key to https://launchpad.net/people/+me
+bzr launchpad-login iank
+cd  ~/.emacs.d/src/
+bzr branch lp:python-mode
+
+add lines from INSTALL to init
+
+
+** background on packages
+jedi appears most popular based on github stats
+pysmell appears dead
+ac-python appears dead
+https://github.com/proofit404/anaconda-mode seems to be kicking along
+
+
+** misc notes:
+
+python-mode has a TON of functions that are just aliases or verbatim wrappers of other functions.
+also has undocumented/unused vars all around. it is quite annoying.
+
+the dedicated argument to py-shell does nothing,
+and py-dedicated-shell just sets that, so it is a waste
+
+
+** background on sending to python shell
+
+using the builtin python execute shell functions, sending one line doesn't really work well.
+The bulit in functions don't wait for further input if a block is not closed.
+And doing a copy/paste thing gets messed up because of indents.
+With some hacking, I could probably do copy/paste and remove indents, only to a
+certain level if we have entered a block and are waiting to finish it.
+But just doing the builtin execute block is a decent work around.
+
+
+Here is the scrapped function for single line built in sending to shell.
+
+
+(setq w32-enable-num-lock nil)
+(global-set-key (kbd "<num_lock>") 'left-char)
+
+
+(defun sqlup-find-correct-keywords ()
+  "If emacs is handling the logic for syntax highlighting of SQL keywords, then we piggyback on top of that logic. If not, we use an sql-mode function to create a list of regular expressions and use that."
+    (mapcar 'car (sql-add-product-keywords sql-product '())))
+
+
+largest subarray sum, array of pos and neg ints.
+
+* disabled but saved for documentation purposes
+:PROPERTIES:
+:header-args: :tangle no
+:END:
+
+** ido keybinds
+*** C-j
+ido-find-file create file
+*** //]
+ido goto root
+*** C-k]
+ido kill buffer/file
+*** C-d]
+ido open dired buffer
+*** M-d]
+ido search within all subdirectories
+*** M-m]
+ido create subdirectory
+*** M-s]
+ido search recently used directories
+*** M-n/p]
+ido next/previous recently used directory
+*** C-s]
+**** TODO implement this keybind, normally ctrl-space
+ido use current pattern and start a new one
+
+
+** indent settings for git's perl code
+don't have a way to set this automatically or a good place to put this
+#+begin_src emacs-lisp
+(setq
+ perl-indent-level 8
+ perl-continued-statement-offset 8
+ perl-continued-brace-offset -8
+ perl-brace-offset 0
+ perl-brace-imaginary-offset 0
+ indent-tabs-mode t
+ )
+#+end_src
+** org mode website
+
+#+begin_src emacs-lisp
+;; use org-publish-current-project with a project file open
+(setq org-publish-project-alist
+      '(("org"
+         :base-directory "/a/h/src"
+         :publishing-directory "/a/h/output"
+         :base-extension "org"
+         ;;:publishing-function org-org-publish-to-org
+         :publishing-function org-html-publish-to-html
+         :preserve-breaks t
+         :html-postamble "Everything here is <a rel=\"license\"
+    href=\"http://creativecommons.org/licenses/by-sa/4.0/\"><img
+    alt=\"Creative Commons License\" style=\"border-width:0\"
+    src=\"http://i.creativecommons.org/l/by-sa/4.0/80x15.png\" /></a>"
+         :html-head "<link rel=\"stylesheet\"
+                               href=\"style.css\"
+                               type=\"text/css\"/>"
+         :htmlized-source t)
+        ("othersrc"
+         :base-directory "/a/h/src"
+         :base-extension "css\\|el\\|"
+         :publishing-directory "/a/h/output"
+         :publishing-function org-publish-attachment)
+        ("other"
+         :base-directory "/a/h/other"
+         :base-extension ".*"
+         :publishing-directory "/a/h/output"
+         :publishing-function org-publish-attachment)))
+;; default is xhtml-strict. don't really care, but this is more common
+(setq org-html-doctype "html4-strict")
+
+;; this is needed for worg
+;; todo: for my own site, I need to define the css in a separate file
+;; in order to use this setting. see the variable help for info
+(setq org-export-htmlize-output-type t)
+
+
+#+end_src
+
+** bash-completion
+#+begin_src emacs-lisp
+;; this eventually gets set in
+;; comint-dynamic-complete-functions
+;; (car comint-dynamic-complete-functions)
+(autoload 'bash-completion-dynamic-complete "bash-completion"
+  "BASH completion hook")
+(add-hook 'shell-dynamic-complete-functions
+          'bash-completion-dynamic-complete)
+
+;; this appears useless, but was in the recommended init code
+(add-hook 'shell-command-complete-functions
+          'bash-completion-dynamic-complete)
+
+(defun ac-rlc-setup-sources ()
+  "Add me to shell-mode-hook!"
+  (setq ac-sources '(ac-source-shell)))
+(add-hook 'shell-mode-hook 'ac-rlc-setup-sources)
+
+#+end_src
+
+** misc stuff
+  It is an awesome mode for keyboard navigation.
+  However, using the mouse takes less thought and works as well
+
+  #+begin_src emacs-lisp
+
+
+    ;; whitespace-mode config. minimal for bad whitespace
+                                            ;(setq whitespace-line-column 80) ; for style of lines-tail, but I have it disabled
+    (setq whitespace-style '(face tabs empty trailing))
+                                            ;to enable whitespace mode
+    (whitespace-mode +1)
+
+
+
+    (defun org-set-mark-command (arg)
+      "Do set-mark-command and then org-show-context if the point
+              moves to invisible text."
+      (interactive "P")
+      (let ((initial-point (point)))
+        (setq this-command 'set-mark-command)
+        (set-mark-command (arg))
+        (if (and (not (= (point) initial-point))
+                 (or (outline-invisible-p) (org-invisible-p2)))
+            (org-show-context 'mark-goto))))
+
+    (defun org-exchange-point-and-mark (&optional arg)
+      (interactive "P")
+      (let ((initial-point (point)))
+        (exchange-point-and-mark)
+        (if (and (not (= (point) initial-point))
+                 (or (outline-invisible-p) (org-invisible-p2)))
+            (org-show-context 'mark-goto))))
+
+
+    (defun toggle-mode-line ()
+      "Toggle mode line on and off."
+      (interactive)
+      (if mode-line-format
+          (progn (setq my-saved-mode-line-format mode-line-format)
+                 (setq mode-line-format nil))
+        (setq mode-line-format my-saved-mode-line-format))
+      (force-mode-line-update))
+    (toggle-mode-line)
+    (global-set-key (kbd "M-m") 'toggle-mode-line)
+    (add-hook 'after-change-major-mode-hook
+              (lambda () (setq my-saved-mode-line-format mode-line-format)
+                (setq mode-line-format nil)))
+
+
+  #+end_src
+
+** Copy mode-line to the top
+  #+begin_src emacs-lisp
+;; Copy mode-line to the top
+(setq-default header-line-format mode-line-format
+mode-line-format nil)
+;; copied the mode-line theme into the header theme, else it is unreadable
+;; this goes after loading the theme
+(let ((class '((class color) (min-colors 89))))
+(custom-theme-set-faces
+   'leuven
+     `(header-line ((,class (:box (:line-width 1 :color "#1A2F54") :foreground "#85CEEB" :background "#335EA8"))))))
+
+  #+end_src
+
+** tab bindings for when I wanted to make tab be for search
+#+begin_src emacs-lisp
+
+  (define-key emacs-lisp-mode-map (kbd "<tab>") nil)
+  (define-key button-buffer-map "\t" nil)
+  (define-key button-buffer-map (kbd "f") 'forward-button)
+  (define-key Info-mode-map "\t" nil)
+  (define-key widget-keymap "\t" nil)
+  (define-key widget-keymap (kbd "<tab>") nil)
+
+  (add-hook 'compilation-mode-hook (lambda ()
+                                     (define-key compilation-mode-map (kbd "<tab>") nil)
+                                     (define-key compilation-mode-map "\t" nil)))
+
+;; unbind c-i for yas. it already separately binds <tab>
+  (add-hook 'yas-minor-mode-hook (lambda ()
+                                     (define-key yas-minor-mode-map "\t" nil)))
+
+  (add-hook 'haskell-interactive-mode-hook
+            (lambda ()
+              (define-key haskell-interactive-mode-map "\t" nil)
+              (define-key haskell-interactive-mode-map (kbd "<tab>") 'haskell-interactive-mode-tab)))
+
+    (define-key minibuffer-local-must-match-map "\t" nil)
+  (define-key minibuffer-local-must-match-map (kbd "<tab>") 'minibuffer-complete)
+  (define-key minibuffer-local-completion-map (kbd "<tab>") 'minibuffer-complete)
+  (define-key minibuffer-local-completion-map "\t" 'minibuffer-complete)
+
+  (add-hook 'ido-setup-hook
+            (lambda()
+              (define-key ido-completion-map (kbd "<tab>") 'ido-complete)
+              (define-key ido-completion-map "\t" nil)))
+
+#+end_src
+
+** kill buffer and window
+#+begin_src emacs-lisp
+ (defun kill-buffer-and-window ()
+        "Close the current window and kill the buffer it's visiting."
+        (interactive)
+        (progn
+          (kill-buffer)
+          (delete-window)))
+#+end_src
+** sending multiple commands to a comint buffer
+without waiting for commands to finish is unreliable.
+seems like 1 in 100 times, an invisible command to restore prompt didn't work
+#+begin_src emacs-lisp
+(setq shell-unset-prompt "unset PROMPT_COMMAND; unset PS1")
+  (setq shell-set-prompt "PROMPT_COMMAND=prompt_command")
+
+(if (boundp 'shell-unset-prompt)
+              (send-invisible-string proc shell-unset-prompt))
+(if (boundp 'shell-set-prompt)
+              (send-invisible-string proc shell-set-prompt))
+
+
+  (defun send-invisible-string (proc string)
+    "Like send-invisible, but non-interactive"
+    (comint-snapshot-last-prompt)
+    (funcall comint-input-sender proc string))
+
+#+end_src
+
+
+
+
+** org-mode auto-complete source
+
+todo, someday take a look at this. it is broken.
+
+;(defvar ac-source-eshell-pcomplete
+;  '((candidates . (pcomplete-completions))))
+;(defun ac-complete-eshell-pcomplete ()
+;  (interactive)
+;  (auto-complete '(ac-source-eshell-pcomplete)))
+
+;(add-hook 'org-mode-hook (lambda () (setq ac-sources (cons 'ac-source-eshell-pcomplete ac-sources))))
+;(add-to-list 'ac-modes 'eshell-mode)
+
+
+** gnus nice unicode
+
+
+this looks nice, but it lags gnus just a bit
+#+begin_src emacs-lisp
+
+(defun gnus-pretty-chars-setup ()
+  (when window-system
+    (setq gnus-sum-thread-tree-indent "  "
+          gnus-sum-thread-tree-root "● "
+          gnus-sum-thread-tree-false-root "◯ "
+          gnus-sum-thread-tree-single-indent "◎ "
+          gnus-sum-thread-tree-leaf-with-other "├─► "
+          gnus-sum-thread-tree-vertical "│"
+          gnus-sum-thread-tree-single-leaf "╰─► ")))
+;; dunno why, but this didn't work just setting on startup
+(add-hook 'gnus-startup-hook 'gnus-pretty-chars-setup)
+
+#+end_src
+
+** misc
+#+begin_src emacs-lisp
+
+;; this makes more ergonomic sense, since our eyes are mostly on the left,
+;; but after using it a while, it's too much cognitive dissonance that
+;; every other program has it on the right
+;;(set-scroll-bar-mode 'left)
+
+
+
+; todo, is this require things necessary?
+;    (require 'flyspell)
+
+
+
+  ; whenever M-tab is completion, swap it with tab
+  ;(define-key emacs-lisp-mode-map (kbd "<tab>") 'completion-at-point)
+  ;(define-key emacs-lisp-mode-map (kbd "C-M-i") 'indent-for-tab-command)
+  ;(define-key lisp-interaction-mode-map (kbd "<tab>") 'completion-at-point)
+  ;(define-key lisp-interaction-mode-map (kbd "C-M-i") 'indent-for-tab-command)
+  ;the global tab keyind. for some reason this totally screws up mini-buffer tab.
+  ; disabled until I actually find myself using this, and find a fix for the above problem
+  ;(global-set-key (kbd "<tab>")  'complete-symbol)
+
+
+  ; todo, make my custom overlays have an underline if they are
+  ;  overriding a paren matching overlay
+  ; make right click set the mark
+  ; make search tab do completion instead of meta-tab
+  ; in isearch, move C-y to C-v
+  ; in isearch, move c-s to c-f
+
+  ;  some testing to figure out the underlining when paren highlight conflicts
+  ;      (let ((extra-overlays (overlays-at (1+ end-point))))
+  ;       (when extra-overlays (print extra-overlays)))
+
+
+
+
+  ; commented out because it messes up yank-pop.
+; todo, fix it someday
+  ; make yank linewise if it ends in a newline
+  ;(defadvice yank (before linewise-yank-advice activate)
+  ;  (let ((arg (ad-get-arg 0)))
+  ;  (when (string-match "\n[ \t]*$" (current-kill (cond
+  ;;                        ((listp arg) 0)
+  ;;                        ((eq arg '-) -2)
+  ;;                        (t (1- arg))) t))
+  ;; (move-beginning-of-line nil))))
+
+
+
+; todo, look into augmenting auto-complete with hippie expand.
+; starter kit has some hippie expand settings to look into:
+; (when (boundp 'hippie-expand-try-functions-list)
+;    (delete 'try-expand-line hippie-expand-try-functions-list)
+;    (delete 'try-expand-list hippie-expand-try-functions-list))
+
+
+;; hippie expand is dabbrev expand on steroids
+;(setq hippie-expand-try-functions-list '(try-expand-dabbrev
+;                                         try-expand-dabbrev-all-buffers
+;                                         try-expand-dabbrev-from-kill
+;                                         try-complete-file-name-partially
+;                                         try-complete-file-name
+;                                         try-expand-all-abbrevs
+;                                         try-expand-list
+;                                         try-expand-line
+;                                         try-complete-lisp-symbol-partially
+;                                         try-complete-lisp-symbol))
+;; use hippie-expand instead of dabbrev
+;(global-set-key (kbd "M-/") 'hippie-expand)
+
+
+; commented because i haven't had time to check it out yet
+;; shorter aliases for ack-and-a-half commands
+;(defalias 'ack 'ack-and-a-half)
+;(defalias 'ack-same 'ack-and-a-half-same)
+;(defalias 'ack-find-file 'ack-and-a-half-find-file)
+;(defalias 'ack-find-file-same 'ack-and-a-half-find-file-same)
+
+
+
+
+; todo. take a look at fixing this
+;delete-old-versions t ; fix description in http://www.emacswiki.org/emacs/ForceBackups
+
+
+
+
+;; prelude uses paredit mode.
+;; paredit has some useful stuff but also annoying stuff.
+;; if I ever do a ton of lisp coding, I should look into it
+
+
+
+
+
+
+  ; random notes and example code
+
+
+  ; usefull thing
+  ;(map 'list #'list tabSwapKeys (reverse (getBinds tabSwapKeys)))
+
+  ; example of getting keymap info
+  ;(car (car (minor-mode-key-binding (kbd "C-/") t)))
+  ;(cdr (car (minor-mode-key-binding (kbd "C-/") t)))
+  ;(global-key-binding (kbd "C-M-i") t)
+  ;(minor-mode-key-binding (kbd "<tab>") t)
+  ;(local-key-binding (kbd "C-M-i") t)
+  ;(current-minor-mode-maps)
+  ;(cdr (assq 'undo-tree-mode minor-mode-map-alist))
+
+
+  ; center on incremental search, instead of being at top or bottom of screen.
+  ; i'm hoping that setting Isearch Allow Scroll is good enough to fix this annoyance
+  ;from http://stackoverflow.com/questions/11052678/emacs-combine-iseach-forward-and-recenter-top-bottom
+
+  ;example of constant definition of an overlay and propreries
+  ;(defface mouse-flash-position '((t (:background "Yellow")))
+  ;  "*Face used to highlight mouse position temporarily."
+  ;  :group 'mouse)
+  ;(defface mouse-flash-position '((t (:background "Yellow")))
+  ;  "*Face used to highlight mouse position temporarily."
+  ;  :group 'mouse)
+  ;(defconst mouse-flash-posn-overlay
+  ;    ;; Create and immediately delete, to get "overlay in no buffer".
+  ;  (let ((ol  (make-overlay (point-min) (point-max))))
+  ;    ;(delete-overlay ol)
+  ;    ;(overlay-put ol 'face 'mouse-flash-position)
+  ;    (overlay-put ol 'mouse-face 'mouse-flash-position)
+  ;    (overlay-put ol 'priority 1000000)
+  ;    ol)
+  ;  "Overlay to highlight current mouse position.")
+
+
+  ;tip, put the last interactive command as elisp on the kill ring:
+  ;C-x <ESC> <ESC> C-a C-k C-g
+
+  ; example of overlay testing
+  ;(setq foo (make-overlay 2 3 nil t nil))
+  ;(setq foo2 (make-overlay 3 4 nil t nil))
+  ;(overlay-put foo 'face '(:background "red3" :foreground "black"))
+  ;(overlay-put foo2 'face '(:background "red1" :foreground "black"))
+  ;(overlay-put foo 'face 'visible-mark-face)
+  ;(overlay-put foo 'face visible-mark-face2)
+
+
+#+end_src
+
+
+** SQL
+
+disabled, as I haven't used it in a long time. I think it was good for learning some sql stuff.
+#+begin_src emacs-lisp :tangle no
+(require 'sqlup-mode)
+(add-hook 'sql-mode-hook 'sqlup-mode)
+(add-hook 'sql-interactive-mode-hook 'sqlup-mode)
+
+(setq sql-product 'postgres)
+#+end_src
+
+
+** icomplete
+#+begin_src emacs-lisp
+;; without this, on partial completion return would exit the minibuffer, and i had to
+;; keep typing out letters do a full completion before pressing enter.
+;; super annoying. So I picked ctrl-j as a free key to put exit,
+;; but in practice, I would just use ctrl-g to quit. Anyways,
+;; ivy is doing all the minibuffer stuff, so removed this as it's
+;; unused, so it can't cause any problems in future
+(when (boundp 'icomplete-minibuffer-map)
+  (define-key icomplete-minibuffer-map (kbd "C-j") 'exit-minibuffer)
+  (define-key icomplete-minibuffer-map (kbd "<return>")
+    'minibuffer-force-complete-and-exit))
+
+
+#+end_src
+
+** java eclim
+
+based on https://github.com/senny/emacs-eclim
+
+
+eclim: eclipse completion, searching, validation, etc inside emacs
+install:
+cd ~/opt
+git clone git://github.com/ervandew/eclim.git
+cd eclim
+pi ant
+ant -Declipse.home=/a/opt/eclipse
+
+
+currently makes emacs hang a bunch. dunno why. just using eclipse instead
+#+begin_src emacs-lisp :tangle no
+(require 'eclim)
+(global-eclim-mode)
+
+;; just do java
+(setq eclim-accepted-file-regexps
+ '("\\.java"))
+
+(custom-set-variables
+  '(eclim-eclipse-dirs '("/a/opt/eclipse"))
+  '(eclim-executable "/a/opt/eclipse/eclim"))
+
+(setq help-at-pt-display-when-idle t)
+(setq help-at-pt-timer-delay 0.1)
+(help-at-pt-set-timer)
+
+;; dunno if this line is needed
+(require 'eclimd)
+(setq eclimd-default-workspace "/a/bin/eclipse-workspace")
+
+;;add the emacs-eclim source
+(require 'ac-emacs-eclim-source)
+(add-hook 'java-mode-hook 'ac-emacs-eclim-java-setup)
+
+#+end_src
+
+#+RESULTS:
+| ac-emacs-eclim-java-setup |
+
+
+
+* broken & disabled mouse stuff
+
+all mouse stuff disabled till i have time to figure it out again.
+#+begin_src emacs-lisp :tangle no
+(defun xterm-mouse-translate-1 (&optional extension)
+  (save-excursion
+    (let* ((event (xterm-mouse-event extension))
+           (ev-command (nth 0 event))
+           (ev-data    (nth 1 event))
+           (ev-where   (nth 1 ev-data))
+           (vec (vector event))
+           (is-down (string-match "down-" (symbol-name ev-command))))
+
+      (cond
+       ((null event) nil)              ;Unknown/bogus byte sequence!
+       (is-down
+        (setf (terminal-parameter nil 'xterm-mouse-last-down) event)
+        vec)
+       (t
+        (let* ((down (terminal-parameter nil 'xterm-mouse-last-down))
+               (down-data (nth 1 down))
+               (down-where (nth 1 down-data)))
+          (setf (terminal-parameter nil 'xterm-mouse-last-down) nil)
+          (cond
+           ((null down)
+            ;; This is an "up-only" event.  Pretend there was an up-event
+            ;; right before and keep the up-event for later.
+            (push event unread-command-events)
+            (vector (cons (intern (replace-regexp-in-string
+                                   "\\`\\([ACMHSs]-\\)*" "\\&down-"
+                                   (symbol-name ev-command) t))
+                          (cdr event))))
+           ((equal ev-where down-where) vec)
+           (t
+            (let ((drag (if (symbolp ev-where)
+                            0          ;FIXME: Why?!?
+                          (list (intern (replace-regexp-in-string
+                                         "\\`\\([ACMHSs]-\\)*" "\\&drag-"
+                                         (symbol-name ev-command) t))
+                                down-data ev-data))))
+              (if (null track-mouse)
+                  (vector drag)
+                (push drag unread-command-events)
+                (vector (list 'mouse-movement ev-data))))))))))))
+
+#+end_src
+
+
+** cursor highlight
+disabled until fixed
+#+begin_src emacs-lisp :tangle no
+    (defun mouse-follow-cursor ()
+      ;(if (not (equal this-command last-command)) (print this-command))
+;debug
+ ;    (print this-command)
+      (when (and this-command (not (string= this-command "show-pointer")))
+        (let* ((pos (posn-col-row (posn-at-point)))
+               (x (1+ (car pos))) ; no idea why this is off by 1
+               (y (cdr pos)))
+      (setq ignore-mouse-visibility t)
+          (set-mouse-position (selected-frame) x y))
+    ;(sleep-for 0 100)
+        (frame-make-pointer-invisible)))
+
+    ;    (when this-command
+    ;      (if (string= this-command "show-pointer")
+    ;    (frame-make-pointer-visible)
+  ;))
+
+
+
+    (defun show-pointer ()
+      (interactive)
+      (if ignore-mouse-visibility
+          (setq ignore-mouse-visibility nil)
+;  (print "visible")
+      (frame-make-pointer-visible)))
+
+      (setq ignore-mouse-visibility t)
+; disabled
+ ;   (global-set-key (kbd "<mouse-movement>") 'show-pointer)
+
+ ;   (add-hook 'post-command-hook 'mouse-follow-cursor t)
+
+
+    ; status. working, except that all scroll wheel actions send a mouse-movement command before doing their actual command, which makes the pointer flicker.
+   ; this is just an artifact of xbindkeys. when i do my own mouse chip, it will fix this.
+
+; we could set track-mouse to nil, then do the command, then set it back. i like that idea a bit better.
+    ; we could do the same thing in the other case of ignore-mouse-visibility.
+
+    ; there are also other issues, it doesn't work with changing buffers on a split screen.
+   ; i think a good idea along with this would be for the cursor to follow the mouse all the time.
+   ; i have done code for that in my mouse 1 function,
+   ; i just need to read it again and try it out.
+
+
+
+
+    ; this does not take care of scrolling,
+    ; a post-command hook function below does,
+    ; but it breaks when the frame is split.
+    ; the bug is specifically in mouse-pixel-position
+    ; todo, fix this eventually
+    (defun mouse-highlight-event (event)
+      (interactive "e")
+      (when (or (not event) (mouse-movement-p event)
+                (memq (car-safe event) '(switch-frame select-window)))
+        (let ((pos (posn-point (event-end event))))
+          (if (eq (overlay-buffer mouse-hi-ov) (current-buffer))
+              (move-overlay mouse-hi-ov pos (1+ pos))
+            (delete-overlay mouse-hi-ov)
+            (setq mouse-hi-ov
+                  (make-overlay pos (1+ pos)))
+            (overlay-put mouse-hi-ov
+                         'insert-in-front-hooks (list 'mouse-hi-modification))
+            (overlay-put mouse-hi-ov 'priority 1001))
+          (cond ((save-excursion (goto-char pos) (eolp))
+                 (overlay-put mouse-hi-ov 'face nil)
+                 (overlay-put mouse-hi-ov 'before-string
+                              (propertize
+                               " "
+                               'cursor t
+                               'face 'mouse-cursor-face)))
+                (t
+                 (overlay-put mouse-hi-ov 'face 'mouse-cursor-face)
+                 (overlay-put mouse-hi-ov 'before-string nil))))))
+
+
+    ; overlay changed hook function
+    (defun mouse-hi-modification (ov timing beginning end &optional length)
+      "Make an overlay of length 1 not expand when text is inserted at the front."
+      (when timing
+        (let ((start (overlay-start ov)))
+          (move-overlay ov start (1+ start)))))
+
+
+
+
+    (defun mouse-hi-command-hook ()
+    ; not sure if I need to deal with case of a nil mouse position in some unforseen situation.
+      (let ((x-y (cdr (mouse-pixel-position))))
+        (when (wholenump (car x-y))
+          (let ((pos (posn-point (posn-at-x-y (car x-y) (cdr x-y) nil t))))
+            (when pos
+              (if (eq (overlay-buffer mouse-hi-ov) (current-buffer))
+                  (move-overlay mouse-hi-ov pos (1+ pos))
+                (delete-overlay mouse-hi-ov)
+                (setq mouse-hi-ov
+                      (make-overlay pos (1+ pos)))
+
+                (overlay-put mouse-hi-ov 'priority 1001))
+              (cond ((save-excursion (goto-char pos) (eolp))
+
+                     (overlay-put mouse-hi-ov 'face nil)
+                     (overlay-put mouse-hi-ov 'before-string
+                                  (propertize
+                                   " "
+                                   'cursor t
+                                   'face 'mouse-cursor-face)))
+                    (t
+                     (overlay-put mouse-hi-ov 'face 'mouse-cursor-face)
+                     (overlay-put mouse-hi-ov 'before-string nil))))))))
+    ; (pcase-let ((`(,_ ,x . ,y) (mouse-pixel-position)))
+    ;                   (posn-point (posn-at-x-y x y)))))
+    ; equivalent of above to find pos. todo, learn about the above syntax
+
+    (setq mouse-hi-ov (make-overlay 1 1))
+    (delete-overlay mouse-hi-ov)
+    ; initialized overlay
+    ; temporarily set to nil instead of t because it is broken and
+    ; also has a bug that makes emacs not remember the column when
+    ; doing  up and down movements.
+    ; it also messes up yas/insert-snippet, dunno why.
+; i should test out whether it is something in the post-command hook
+;    (setq track-mouse t)
+    ;(add-hook 'post-command-hook 'mouse-hi-command-hook)
+
+    ;(mouse-hi-command-hook)
+    ;(setq debug-on-error nil)
+
+  #+end_src
+** mouse 1 drag func
+
+disabled as it breaks in newer emacs versions with this error, when
+clicking on info links
+
+"and: Symbol's function definition is void: mouse--remap-link-click-p"
+
+#+begin_src emacs-lisp :tangle no
+
+  ; Copied from mouse.el and modified.
+  ; my modifications have comments prefaced by "ian"
+  (defun mouse-drag-track (start-event  &optional
+                                        do-mouse-drag-region-post-process)
+    "Track mouse drags by highlighting area between point and cursor.
+  The region will be defined with mark and point.
+  DO-MOUSE-DRAG-REGION-POST-PROCESS should only be used by
+  `mouse-drag-region'."
+    (mouse-minibuffer-check start-event)
+    (setq mouse-selection-click-count-buffer (current-buffer))
+  ; ian. removed as unneeded since I don't use TMM
+  ;(deactivate-mark)
+    (let* ((scroll-margin 0) ; Avoid margin scrolling (Bug#9541).
+           (original-window (selected-window))
+           ;; We've recorded what we needed from the current buffer and
+           ;; window, now let's jump to the place of the event, where things
+           ;; are happening.
+           (_ (mouse-set-point start-event))
+           (echo-keystrokes 0)
+           (start-posn (event-start start-event))
+           (start-point (posn-point start-posn))
+           (start-window (posn-window start-posn))
+           (start-window-start (window-start start-window))
+           (start-hscroll (window-hscroll start-window))
+           (bounds (window-edges start-window))
+           (make-cursor-line-fully-visible nil)
+           (top (nth 1 bounds))
+           (bottom (if (window-minibuffer-p start-window)
+                       (nth 3 bounds)
+                     ;; Don't count the mode line.
+                     (1- (nth 3 bounds))))
+           (on-link (and mouse-1-click-follows-link
+                         ;; Use start-point before the intangibility
+                         ;; treatment, in case we click on a link inside
+                         ;; intangible text.
+                         (mouse-on-link-p start-posn)))
+           (click-count (1- (event-click-count start-event)))
+           (remap-double-click (and on-link
+                                    (eq mouse-1-click-follows-link 'double)
+                                    (= click-count 1)))
+           ;; Suppress automatic hscrolling, because that is a nuisance
+           ;; when setting point near the right fringe (but see below).
+           (auto-hscroll-mode-saved auto-hscroll-mode)
+           (auto-hscroll-mode nil)
+           moved-off-start event end end-point)
+
+      (setq mouse-selection-click-count click-count)
+      ;; In case the down click is in the middle of some intangible text,
+      ;; use the end of that text, and put it in START-POINT.
+      (if (< (point) start-point)
+          (goto-char start-point))
+      (setq start-point (point))
+      (if remap-double-click
+          (setq click-count 0))
+
+      ;; Activate the region, using `mouse-start-end' to determine where
+      ;; to put point and mark (e.g., double-click will select a word).
+      (setq transient-mark-mode
+            (if (eq transient-mark-mode 'lambda)
+                '(only)
+              (cons 'only transient-mark-mode)))
+      (delete-overlay mouse-hi-ov) ; ian, added this.
+
+      (let ((range (mouse-start-end start-point start-point click-count)))
+        (push-mark (nth 0 range) t t)
+        (goto-char (nth 1 range)))
+
+      ;; Track the mouse until we get a non-movement event.
+      (track-mouse
+        (while (progn
+                 (setq event (read-event))
+                 (or (mouse-movement-p event)
+                     (memq (car-safe event) '(switch-frame select-window))))
+          (unless (memq (car-safe event) '(switch-frame select-window))
+            ;; Automatic hscrolling did not occur during the call to
+            ;; `read-event'; but if the user subsequently drags the
+            ;; mouse, go ahead and hscroll.
+            (let ((auto-hscroll-mode auto-hscroll-mode-saved))
+              (redisplay))
+            (setq end (event-end event)
+                  end-point (posn-point end))
+            ;; Note whether the mouse has left the starting position.
+            (unless (eq end-point start-point)
+              (setq moved-off-start t))
+            (if (and (eq (posn-window end) start-window)
+                     (integer-or-marker-p end-point))
+                (mouse--drag-set-mark-and-point start-point
+                                                end-point click-count)
+              (let ((mouse-row (cdr (cdr (mouse-position)))))
+                (cond
+                 ((null mouse-row))
+                 ((< mouse-row top)
+                  (mouse-scroll-subr start-window (- mouse-row top)
+                                     nil start-point))
+                 ((>= mouse-row bottom)
+                  (mouse-scroll-subr start-window (1+ (- mouse-row bottom))
+                                     nil start-point))))))
+          (visible-mark-move-overlays))) ; ian, added this
+
+
+      ;; Handle the terminating event if possible.
+      (when (consp event)
+        ;; Ensure that point is on the end of the last event.
+        (when (and (setq end-point (posn-point (event-end event)))
+                   (eq (posn-window end) start-window)
+                   (integer-or-marker-p end-point)
+                   (/= start-point end-point))
+          (mouse--drag-set-mark-and-point start-point
+                                          end-point click-count))
+
+        ;; Find its binding.
+        (let* ((fun (key-binding (vector (car event))))
+               (do-multi-click (and (> (event-click-count event) 0)
+                                    (functionp fun)
+                                    (not (memq fun '(mouse-set-point
+                                                     mouse-set-region))))))
+          (if (and (/= (mark) (point))
+                   (not do-multi-click))
+
+              ;; If point has moved, finish the drag.
+              (let* (last-command this-command)
+                (and mouse-drag-copy-region
+                     do-mouse-drag-region-post-process
+                     (let (deactivate-mark)
+                       (copy-region-as-kill (mark) (point)))))
+
+            ;; Otherwise, run binding of terminating up-event.
+            (if do-multi-click
+                (goto-char start-point)
+              (deactivate-mark)
+              (unless moved-off-start
+                ;; ian: poping the mark is a poor choice of behavior.
+                ;; we should delete the mark instead.
+                ;; The first way I found to delete it is to pop it first
+                (pop-mark)
+                (setq mark-ring (nbutlast mark-ring))))
+
+            (when (and (functionp fun)
+                       (= start-hscroll (window-hscroll start-window))
+                       ;; Don't run the up-event handler if the window
+                       ;; start changed in a redisplay after the
+                       ;; mouse-set-point for the down-mouse event at
+                       ;; the beginning of this function.  When the
+                       ;; window start has changed, the up-mouse event
+                       ;; contains a different position due to the new
+                       ;; window contents, and point is set again.
+                       (or end-point
+                           (= (window-start start-window)
+                              start-window-start)))
+
+              (when (and on-link
+                         (= start-point (point))
+                         (mouse--remap-link-click-p start-event event))
+
+                ;; If we rebind to mouse-2, reselect previous selected
+                ;; window, so that the mouse-2 event runs in the same
+                ;; situation as if user had clicked it directly.  Fixes
+                ;; the bug reported by juri@jurta.org on 2005-12-27.
+                (if (or (vectorp on-link) (stringp on-link))
+                    (setq event (aref on-link 0))
+                  (select-window original-window)
+                  (setcar event 'mouse-2)
+                  ;; If this mouse click has never been done by the
+                  ;; user, it doesn't have the necessary property to be
+                  ;; interpreted correctly.
+                  (put 'mouse-2 'event-kind 'mouse-click)))
+              (push event unread-command-events)))))))
+#+end_src
+
+** mouse 3
+#+begin_src emacs-lisp :tangle no
+
+
+  (defun mouse3-range-mark (start click click-count)
+    (let* ((range (mouse-start-end start click click-count))
+           (beg (nth 0 range))
+           (end (nth 1 range)))
+      (cond ((<= click start)
+             (set-mark beg))
+            (t
+             (set-mark end))))
+    (visible-mark-move-overlays))
+
+
+  (defun mouse3-set-mark (event)
+    "in development"
+    (interactive "e")
+    (mouse-minibuffer-check event)
+    ;; Use event-end in case called from mouse-drag-region.
+    ;; If EVENT is a click, event-end and event-start give same value.
+    (set-mark (posn-point (event-end event)))
+    (visible-mark-move-overlays))
+
+
+  (defun mouse3-func (start-event)
+    "in development"
+    (interactive "e")
+
+    (run-hooks 'mouse-leave-buffer-hook)
+
+    (mouse-minibuffer-check start-event)
+    (setq mouse-selection-click-count-buffer (current-buffer))
+    (push-mark (posn-point (event-end start-event)))
+
+    (let* ((scroll-margin 0) ; Avoid margin scrolling (Bug#9541).
+           (original-window (selected-window))
+           ;; We've recorded what we needed from the current buffer and
+           ;; window, now let's jump to the place of the event, where things
+           ;; are happening.
+  ;(_ (mouse-set-point start-event)) ; ian: commented, replaced
+           (echo-keystrokes 0)
+           (start-posn (event-start start-event))
+           (start-point (posn-point start-posn))
+           (start-window (posn-window start-posn))
+           (start-window-start (window-start start-window))
+           (start-hscroll (window-hscroll start-window))
+           (bounds (window-edges start-window))
+           (make-cursor-line-fully-visible nil)
+           (top (nth 1 bounds))
+           (bottom (if (window-minibuffer-p start-window)
+                       (nth 3 bounds)
+                     ;; Don't count the mode line.
+                     (1- (nth 3 bounds))))
+           (click-count (1- (event-click-count start-event)))
+           ;; Suppress automatic hscrolling, because that is a nuisance
+           ;; when setting point near the right fringe (but see below).
+           (auto-hscroll-mode-saved auto-hscroll-mode)
+           (auto-hscroll-mode nil)
+           moved-off-start event end end-point)
+
+      (setq mouse-selection-click-count click-count)
+      ;; In case the down click is in the middle of some intangible text,
+      ;; use the end of that text, and put it in START-POINT.
+      (if (< (mark) start-point) ; ian: change point to the mark
+          (set-mark start-point)
+        (visible-mark-move-overlays))
+      (setq start-point (mark))
+
+      (delete-overlay mouse-hi-ov) ; ian, added this.
+
+      ;; Activate the region, using `mouse-start-end' to determine where
+      ;; to put point and mark (e.g., double-click will select a word).
+      (let ((range (mouse-start-end start-point start-point click-count)))
+        (set-mark (nth 1 range)))
+      (visible-mark-move-overlays)
+
+
+      ;; Track the mouse until we get a non-movement event.
+      (track-mouse
+
+        (while (progn
+                 (setq event (read-event))
+                 (or (mouse-movement-p event)
+                     (memq (car-safe event) '(switch-frame select-window))))
+          (unless (memq (car-safe event) '(switch-frame select-window))
+
+            ;; Automatic hscrolling did not occur during the call to
+            ;; `read-event'; but if the user subsequently drags the
+            ;; mouse, go ahead and hscroll.
+            (let ((auto-hscroll-mode auto-hscroll-mode-saved))
+              (redisplay))
+            (setq end (event-end event)
+                  end-point (posn-point end))
+            ;; Note whether the mouse has left the starting position.
+
+            (unless (eq end-point start-point)
+              (setq moved-off-start t))
+            (if (and (eq (posn-window end) start-window)
+                     (integer-or-marker-p end-point))
+                (mouse3-range-mark start-point end-point click-count); ian, set mark
+
+  ; do scrolling if needed
+              (let ((mouse-row (cdr (cdr (mouse-position)))))
+                (cond
+                 ((null mouse-row))
+                 ((< mouse-row top)
+                  (mouse-scroll-subr start-window (- mouse-row top)
+                                     nil start-point))
+                 ((>= mouse-row bottom)
+                  (mouse-scroll-subr start-window (1+ (- mouse-row bottom))
+                                     nil start-point))))))))
+
+      ;; Handle the terminating event if possible.
+      (when (consp event)
+        ;; Ensure that point is on the end of the last event.
+        (when (and (setq end-point (posn-point (event-end event)))
+                   (eq (posn-window end) start-window)
+                   (integer-or-marker-p end-point)
+                   (/= start-point end-point))
+  ;(mouse--drag-set-mark-and-point start-point ; ian, set mark
+  ;end-point click-count))
+          (mouse3-range-mark start-point end-point click-count)); ian, set mark
+
+        ;; Find its binding.
+        (let* ((fun (key-binding (vector (car event))))
+               (do-multi-click (and (> (event-click-count event) 0)
+                                    (functionp fun)
+                                    (not (memq fun '(mouse3-set-mark))))))
+          (if (and (/= end-point start-point)
+                   (not do-multi-click))
+
+              ;; If point has moved, finish the drag.
+              (let* (last-command this-command)
+                (and mouse-drag-copy-region
+                     do-mouse-drag-region-post-process
+                     (let (deactivate-mark)
+                       (copy-region-as-kill (mark) (point)))))
+
+            ;; Otherwise, run binding of terminating up-event.
+            (when do-multi-click
+              (set-mark start-point)) ; ian, change this. why?
+            (visible-mark-move-overlays)
+
+
+            (when (and (functionp fun)
+                       (= start-hscroll (window-hscroll start-window))
+                       ;; Don't run the up-event handler if the window
+                       ;; start changed in a redisplay after the
+                       ;; mouse-set-point for the down-mouse event at
+                       ;; the beginning of this function.  When the
+                       ;; window start has changed, the up-mouse event
+                       ;; contains a different position due to the new
+                       ;; window contents, and point is set again.
+                       (or end-point
+                           (= (window-start start-window)
+                              start-window-start)))
+
+              (push event unread-command-events)))))))
+
+#+end_src
+
+
+
+
+
+* disabled planning to fix
+** speedbar
+(sr-speedbar-close)
+(sr-speedbar-open)
+
+      #+begin_src emacs-lisp :tangle no
+(require 'sr-speedbar)
+  (setq speedbar-hide-button-brackets-flag t ;; didn't notice a diff
+      speedbar-file-unshown-regexp "flycheck-.*"
+      sr-speedbar-width 40
+      sr-speedbar-width-x 40
+      sr-speedbar-auto-refresh nil
+      sr-speedbar-skip-other-window-p t
+      sr-speedbar-right-side nil
+speedbar-hide-button-brackets-flag nil)
+      #+end_src
+
+* TODO fix auto save to be reliable and not rely on idle time
+sometimes emacs or computer stays busy and idle never comes
+* TODO try out which key mode
+* TODO make installed emacs package declarative
+* TODO see if there are more cool functions in sh-script
+like sh-cd-here, and bind that to a key
+* TODO assign a key to append-next-kill
+* TODO keybinds to remember
+
+keys worth memorizing
+
+c-2
+c-m-3
+
+s-return
+
+in isearch, C-o
+isearch-occur
+
+org, C-c / t
+make just todo items visible
+
+C-mouse-1
+buffer list menu
+
+C-up/down
+move up/down fast
+
+M-right-scroll
+forward/back sexp
+
+C-M-right-scroll
+scroll
+
+C-S-scroll
+change text size
+
+how to control+left scroll on kinesis
+right shift = control
+
+C-left-scroll
+forward/backward word
+
+C-M-d
+swap buffers across windows
+
+shell-cd-to-file
+M-2
+
+* TODO add simpler keybind for make-frame-command
+current one is C-x 5 2.
+
+* TODO learn some more ivy mode stuff
+* TODO declarative package installations,
+with documentation.
+* TODO shell mode reverse search hides 2nd+ line of multi-line result
+* TODO figure out browsing files with broken nfs mount
+causes emacs to freeze until I kill -9 it.
+* TODO make a keybind to print var under cursor
+and actually, putting the start of it in th emodeline might be cool
+* TODO make recent files save periodically,
+normally it just saves on exit, but half the time I don't exit cleanly
+so they don't get saved, because I leave emacs running until it crashes
+* TODO fix undo tree outside visible buffer bug
+* TODO c-<delete> in shell mode should send over
+previous line if current line is empty
+* TODO make c-m-s be just a control key for easier use
+* TODO try out avy mode for laptop
+i used to have ace jump mode, but google says avy is better.
+* TODO bind a in group mode of gnus to c-u a,
+also, make a default for number of articles
+* TODO make auto-complete be on by default in sql-mode
+* TODO make an easy bind for open previous buffer
+* TODO i think my autosave for sudo-edit might be too fast
+it sometimes leaves #_asdfjasdf files littered
+* TODO readline-compleste doesn't work when you cat a file without a newline,
+and so the prompt is messed up. not sure exactly what needs to be in end, or if its anything
+* TODO figure out how to paste a path into find file
+probably have to use the old kind of find file
+* TODO readline-complete doesn't escape special chars in filenames
+* TODO readline-complete dev
+
+
+
+** misc fixes
+
+bad code, the comment this relates to was removed, but not the comment
+             /* If waiting for this channel, arrange to return as
+                soon as no more input to be processed.  No more
+                waiting.  */
+
+
+(status_notify): New arg WAIT_PROC. this is unused, this is a bug.
+The change in status_notify's return is just passing more information
+from what it did already. No changes at all inside this function.
+
+* TODO consider whether to bind indent-for-tab-command
+I removed it from m-tab for terminal compatibility.
+It's the default tab command, which yasnippet replaces.
+* TODO readline-complete: remove the hardcoded rlc-no-readline-hook
+* TODO isearch doesn't automatically wrap in info
+* TODO look into fixing shell mode reverse search
+and why auto-complete dies
+caveat is that it doesn't work well with certain unusual prompts, for example if $/# is not used at the end
+see if we can load history, or reverse search with history commands
+* TODO keybinds for s-delete/tab etc
+* TODO fix bbdb info packaging in melpa
+* TODO figure out why my emacs startup script doesn't work from dmenu
+* TODO post idea to make customize group show function var names so we can read doc strings
+* TODO report/fix bug that kill-whole-line doesn't work right with append kill
+* TODO make bash keybind for copy paste interoperate with x windows
+* TODO fix org stderr redirection
+make this produce output of "ok"
+#+begin_src sh
+echo ok >&2
+
+#+end_src
+* TODO make ido keybinds better
+* TODO fix indenting in org
+
+  (defun my-org-indent-region (start end)
+    "Indent region."
+    (interactive "r")
+    (save-excursion
+      (let ((line-end (org-current-line end)))
+        (goto-char start)
+        (while (< (org-current-line) line-end)
+          (cond ((org-in-src-block-p) (org-babel-do-in-edit-buffer (indent-according-to-mode)))
+                (t (call-interactively 'org-indent-line)))
+          (move-beginning-of-line 2)))))
+
+
+
+org-indent-region is broken for source blocks
+the above function works, but has several problems.
+first: it should not have separate logic from org-indent-line
+second: it runs way too slow, mainly the command
+ (org-babel-do-in-edit-buffer (indent-according-to-mode)))
+
+
+* TODO figure out newline in prompt shell issue
+setting this before readline-complete is loaded allows completion to work,
+but auto-completion still fails. Need to debug readline-complete to figure this out.
+(setq shell-prompt-pattern "^[^#$%>]*[#$]\n")
+* TODO setup bind for find tag / lisp function at point
+
+* TODO org-delete-char should also work for the delete/backspace keys!
+  fix and send patch
+
+* TODO checkout projectile / graphene's project settings
+
+* TODO check up on recent changes to 3rd party default configs
+- last checked apr 24
+  https://github.com/eschulte/emacs24-starter-kit/commits/master
+
+last checked mayish
+https://github.com/bbatsov/prelude
+- redefined mouse functions from this file
+
+* TODO figure out how to setup emacs to format text nicely like thunderbird
+* TODO it appears impossible make C-[ not be the same as escape
+* TODO movement within info buffer after opening a link doesn't cancel isearch
+leads to many frustrations
+* TODO fix org resolve clock message. it is innacurate
+  i is not the same, becuase it does not make org realize there is an active clock
+
+* TODO add apropos commands to help prefix, from
+  http://stackoverflow.com/questions/3124844/what-are-your-favorite-global-key-bindings-in-emacs
+* TODO my autosave goes into an endless prompting loop
+when running save buffer, and the buffer has been changed
+outside of emacs
+* TODO smart peren does not see ?\\) as a valid paren
+
+* TODO why does org-end-of-line not go all the way to the end on a closed headline?
+* TODO org makes random ... things, and delete right before them does ctrl-i
+* TODO try mark word, which might be a useful keybind
+* TODO fix org-cycle: it assumes which key it is bound to for its last alternative
+* TODO checkout lisp-complete-symbol to augment auto-complete
+* TODO emacs keylogger to optimize key binds
+* TODO remap/investigate find tag, find tag at point
+* TODO set key to cycle buffers by mode, example below
+
+(defun cycle-buffer-by-mode (p-mode)
+  "Cycle buffers by mode name"
+  (interactive)
+  (dolist (buffer (buffer-list))
+    (with-current-buffer buffer
+      (when (buffer-live-p buffer)
+        (if (string-match p-mode mode-name) ;(regexp-quote p-mode)
+            (setq switch2buffer buffer)))))
+  (when (boundp 'switch2buffer)
+    (switch-to-buffer switch2buffer)))
+
+And I have bound this to my F9 key
+
+(global-set-key [f9]             '(lambda () (interactive) (cycle-buffer-by-mode "Shell$")))
+
+* TODO test out usefulness of forward/back sexp in different languages
+
+* TODO major mode settings to check out in future
+** emacs24 starter kit
+- Nxhtml -- utilities for web development
+[[http://ourcomments.org/Emacs/nXhtml/doc/nxhtml.html][Nxhtml]] is a large package of utilities for web development and for
+embedding multiple major modes in a single buffer.
+
+Nxhtml is not installed in this version of the starter-kit by default,
+for information on installing nxhtml see [[http://www.emacswiki.org/emacs/NxhtmlMode][EmacsWiki-Nxhtml]].
+
+web-mode is competing package and actively developed, so i'm using that instead
+
+
+  (dolist (package '(yaml-mode js2-mode))
+    (unless (package-installed-p package)
+
+- Associate modes with file extensions
+
+(add-to-list 'auto-mode-alist '("COMMIT_EDITMSG$" . diff-mode))
+(add-to-list 'auto-mode-alist '("\\.css$" . css-mode))
+(require 'yaml-mode)
+(add-to-list 'auto-mode-alist '("\\.ya?ml$" . yaml-mode))
+(add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode))
+(add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
+(add-to-list 'auto-mode-alist '("\\.js\\(on\\)?$" . js2-mode))
+;; (add-to-list 'auto-mode-alist '("\\.xml$" . nxml-mode))
+
+- clojure in starter-kit-lisp.org
+
+- others = gnus, js, publish, perl, python, perl, ruby
+   they each have their own starter kit file.
+
+- snippets for various modes other than org-mode
+
+* TODO update yasnippet documentation
+  yas expand key customization is rediculously hard to figure out
+  and completely undocumented
+* TODO fix org source indenting, send patch
+* TODO check out bundling aka compiling yasnippet
+* TODO try xml/html mode url func
+
+(defun view-url ()
+  "Open a new buffer containing the contents of URL."
+  (interactive)
+  (let* ((default (thing-at-point-url-at-point))
+         (url (read-from-minibfer "URL: " default)))
+    (switch-to-buffer (url-retrieve-synchronously url))
+    (rename-buffer url t)
+    ;; TODO: switch to nxml/nxhtml mode
+    (cond ((search-forward "<?xml" nil t) (xml-mode))
+          ((search-forward "<html" nil t) (html-mode)))))
+
+* TODO flyspell-buffer automatically
+
+* TODO respond to ediff thread
+* TODO fix horizontal mouse resizing
+  resizing a window horizontally with the mouse should be allowed in more places
+
+* TODO try using / making abbreviations
+
+* TODO move over to ivy, ditch ido
+
+* key binds. keep at end of file
+this should come at the end because it depends on key maps being
+created in earlier sections.
+
+** emacs keys notes
+commands not needed in ido mode and their replacement in ido mode
+spell check fix -> use current pattern and start new one
+narrow -> create subdirectory
+org-cycle -> M-s search recently used directory
+vert split Window -> create file instead of select match
+delete-other-windows -> open dired buffer
+delete current window -> delete buffer/file
+find file -> search within all subdirectories
+
+forward/back error
+
+buffer select -> toggle find file / buffer
+up/down -> next/previous history
+forward/back -> ido-forward/back
+
+
+right keyboard attributes:  movement, involve typing words
+left keyboard attributes:  non-typing  universal  non-movement
+
+
+
+
+todo
+fix global unpop mark ring
+setup helm
+learn cedet and projectile and helm
+setup key for pop-global-mark
+try out C-M-\ indent region
+set quoted insert to some obscure keybind
+make currently overrided M-u uppercase word into something obscure
+remember mode
+bind shell-command to something better
+investigate tags
+investigate keys in isearch mode and find file mode
+try out occur. M-s o
+investigate programming modes. M-g n/b next/previous error. gdb?
+investigate org mode keys
+learn version control
+learn mail
+check out imenu
+bind capitalize-word to something obscure
+sentance/paragraph movement/marking should be swapped with sexp/paren movement based on mode
+bind fill-paragraph to something obscure
+setup linewise paste
+install magit (git control)
+magpie expansion provides a completion key for acronym expansion based on buffer text
+learn ediff
+universal google
+figure out auto-indent
+learn eshell and prelude settings for it
+combine register prefix and c-x prefix
+note: remember to think of mouse & foot pedals
+commands to change: select other window: C-x o.
+
+** named commands
+*** gdb
+gdb-many-windows
+*** tramp sudo
+/ssh:host|sudo:host:
+when in the same session, you can then do:
+/sudo:root@host:
+
+*** org insert table row
+[org-shiftmetadown/up]
+*** toggle line continuation / truncation / wrap
+    toggle-truncate-lines
+*** auto-save on/off
+    my-as-on/my-as-off
+*** toggle menu bar
+menu-bar-mode
+*** show abbreviations
+list-abbrevs
+
+*** rename-file-and-buffer
+*** ediff-buffers
+*** refill-mode
+automatically balance a paragraph with newlines
+*** executable-make-buffer-file-executable-if-script-p
+make a script executable
+*** (setq lazy-highlight-cleanup nil)
+keep search highlight on after search is done
+*** auto-revert-tail-mode
+tail a file
+*** what-line
+*** linum-mode
+line numbers
+
+*** sgml-pretty-print
+format xml in nxml-mode
+*** visual-line-mode
+toggle word wrap.
+** compound commands
+*** C-xc
+exit0
+*** C-x s
+save file
+*** C-x e
+eval last sexp
+*** C-c -
+[org insert table horizontal line or create list]
+*** C-x tab
+indent/dedent region
+
+*** C-x *
+[calc-dispatch]
+*** C-x =
+[point information]
+*** C-x d
+[dired]
+*** C-xb
+[ibuffer]
+
+*** C-x r c
+rectangular clear, replace area with whitespace
+** gnus
+searching overview.
+3 types:
+ingroup searching
+nnir searching with notmuch, specific group (not sure if it can do multiple)
+search all groups with mairix
+*** a]
+compose new message
+*** C-c C-c]
+send message
+*** s]
+save newsrc file, alterations to groups.
+*** g]
+gnus refresh / get new
+*** m]
+gnus new message
+*** F]
+gnus quoted reply all
+*** e]
+gnus draft edit message
+*** delete]
+gnus delete draft
+#+begin_src emacs-lisp
+(add-hook 'gnus-startup-hook
+          (lambda ()
+            (define-key gnus-summary-mode-map (kbd "<delete>") 'gnus-summary-delete-article)))
+#+end_src
+
+*** b]
+mairix search
+#+begin_src emacs-lisp
+(add-hook 'gnus-startup-hook
+          (lambda ()
+            (define-key gnus-group-mode-map "b" 'nnmairix-search)
+            (define-key gnus-summary-mode-map "b" 'nnmairix-search)))
+#+end_src
+*** B m]
+move message, or messages in region
+*** #]
+mark article, move with B m
+*** B delete]
+gnus delete draft
+*** / plus x a / b]
+search current group (or see info manual for more groups),
+using the gnus native search (its slow, do a notmuch or mairix search instead)
+x= extra (ie. to)
+todo; send in patch to make author search to in sent folder
+a = author
+/ = subject
+b = body
+see C-h m for a full list
+***  G G ]
+do a nnir notmuch search, for the group on the current line
+***  A T ]
+jump to thread from nnir group
+
+*** marks]
+! = saved for later
+E = expired
+M-& apply process mark to a non-process mark command
+*** S D e]
+edit as new
+*** T k / C-M-k
+maybe rebind this to a shorter keybind, like del
+gnus-summary-kill-thread
+** message mode
+*** C-ck]
+discard message
+** notmuch
+*** space]
+notmuch advance to next message/thread
+
+** readline / bash / .inputrc
+*** C-m
+[--------]
+terminal crap, duplicate of enter
+
+** isearch
+*** C-w
+paste word/char under cursor into isearch
+*** M-n/p
+next/previous isearch history
+*** C-o
+*** m-r
+
+** icomplete
+*** C-. C-,
+icomplete-forward/backward-completions
+
+** info
+*** [, ]
+forward / previous node, descend/ascend tree as needed
+*** x
+Info-follow-nearest-node
+
+m, f, n, p or ^ command, depending on where you click.
+** auto-complete
+*** S-return
+select next completion candidate
+ac-expand
+** agenda
+*** t]
+agenda cycle todo state
+** org
+*** C-c / t]
+make just todo items visible
+*** S-<tab>
+org-shifttab global visibility cycle / move table cell
+*** C-cs]
+schedule todo item
+*** C-cx p]
+org set property
+*** C-c -]
+org insert horizontal line
+*** C-cq]
+    org tag
+** calc
+i'd like to drill these sometime when I have space in my head, or I
+plan to use calc.
+*** space
+[enter input to the stack, or duplicate top stack item]
+*** C-M-i
+[cycle 3 elements on stack]
+*** tab
+[cycle 2 elements on stack]
+*** n
+[negate]
+*** _
+[begin negative number]
+*** /
+[reciprocal]
+*** x
+[calc named command]
+*** M-delete
+[delete 2nd from top of stack]
+*** C-u [-]0-9
+[0=whole stack, 1-9=that many, -1-9=that element]
+*** delete
+[remove from the top of the stack]
+*** '
+[algebraic mode. infix expressions are calculated when input to the stack]
+*** m a
+[auto algebraic mode]
+*** $,$$,$$$
+[top x of stack reference]
+*** s s/t/r/u
+[store to variable: store, top, retrieve, unstore. the quick variables 0-9 don't need s prefix]
+*** U/D
+[undo/redo]
+*** t p/n/]/y
+[trail prev/next/end/yankh]
+*** `
+[calc edit mode, to edit the top of stack]
+
+* keybind tables
+
+  |-----------------+--------------------------------+---------------------------------+-------------------------------+--------------------------|
+  | left primary    | C-                             | M-                              | C-M-                          | C-S-                     |
+  |-----------------+--------------------------------+---------------------------------+-------------------------------+--------------------------|
+  | 2               | copy-symbol                    | shell-cd-to-file                | ---                           |                          |
+  | 3               | dot-mode-execute               |                                 | recenter-top-bottom           |                          |
+  | q               | org-cycle, comint previous arg | org-archive-to-archive-sibling  | quoted-insert                 |                          |
+  | w               | goto-t.org                     | org-clock-in                    |                               |                          |
+  | e               | copy-line                      | org-clock-in-last               |                               |                          |
+  | r               | isearch-backward               | org-clock-out                   |                               |                          |
+  | a               | copy-all                       |                                 |                               |                          |
+  | s               | C-x prefix                     |                                 | split-window-vertically       |                          |
+  | d               | C-c prefix                     |                                 | swap buffer                   |                          |
+  | f               | kill-whole-line                | print-var-at-point              | kill rest of line             |                          |
+  | g               | other-window / cancel          | abort-recursive-edit            | gnus                          |                          |
+  | z               | undo-tree-undo                 |                                 |                               |                          |
+  | x               | kill-region                    | append-next-kill                | append-next-kill              |                          |
+  | c               | copy                           | org-capture                     | copy-to-register              |                          |
+  | v               | yank                           | insert-register                 | yank pop                      |                          |
+  | b               | delete-other-windows           | isearch-backward-current-symbol | isearch-current-symbol        |                          |
+  | tab             | yas-insert-snippet             | indent line                     |                               |                          |
+  | delete          | kill-symbol                    |                                 | kill-sexp                     |                          |
+  | left-arrow      | compile                        |                                 | org-shiftup                   |                          |
+  | right-arrow     | paste selection                |                                 | org-shiftdown                 |                          |
+  | backspace       | backward-kill-symbol           |                                 | backward-kill-sexp            |                          |
+  | f7              |                                |                                 |                               |                          |
+  |-----------------+--------------------------------+---------------------------------+-------------------------------+--------------------------|
+  | right primary   | C-                             | M-                              | C-M-                          | C-S-                     |
+  |-----------------+--------------------------------+---------------------------------+-------------------------------+--------------------------|
+  | *               | split-window-horizontally      |                                 | calc-dispatch                 |                          |
+  | 9               | delete-window-or-exit          | kill-buffer-and-window          | kill client buffer            |                          |
+  | u               | universal-argument             |                                 | search-keybind                |                          |
+  | i               | -----                          |                                 | query-replace-regexp          |                          |
+  | o               | occur                          |                                 | counsel-imenu                 |                          |
+  | p               | move-mouse-to-point            |                                 | delete-horizontal-space       |                          |
+  | j               | pop-to-mark                    | previous-error                  | register prefix               |                          |
+  | k               | jump to register               | next-error                      | man                           |                          |
+  | l               | ivy-switch-buffer              |                                 | move cursor top bottom mid    |                          |
+  | ;               | comment-dwim                   | comment-dwim                    | comment-current-line-dwim     |                          |
+  | m               |                                |                                 | recursive grep                |                          |
+  | ,               | counsel-find-file              |                                 | find-file-in-project          |                          |
+  | .               | recentf-ido-find-file          |                                 | -                             |                          |
+  | /               | join lines                     |                                 | copy-variable                 |                          |
+  | 8               | calc-embedded-word             |                                 |                               |                          |
+  | up-arrow        | back defun/headline            |                                 |                               | winner undo              |
+  | down-arrow      | forward dfun/headline          |                                 | toggle-mark-activation        | smex-major-mode-commands |
+  | lbracket        | ----                           |                                 | scroll-right                  |                          |
+  | rbracket        | fill-paragraph                 |                                 | scroll-left                   |                          |
+  | return          | newline next line              | non-indented newline            | open newline on previous line |                          |
+  | space           | org-edit-special               |                                 | spell check word              |                          |
+  |-----------------+--------------------------------+---------------------------------+-------------------------------+--------------------------|
+  | left secondary  | C-                             | M-                              | C-M-                          | C-S-                     |
+  |-----------------+--------------------------------+---------------------------------+-------------------------------+--------------------------|
+  | =               |                                |                                 |                               |                          |
+  | 1               |                                |                                 |                               |                          |
+  | 4               |                                |                                 | widen                         |                          |
+  | 5               |                                |                                 |                               |                          |
+  | tab-key         | query-replace                  |                                 |                               |                          |
+  | t               | org change todo state          |                                 | org insert timestamp          |                          |
+  | home            | start of buffer                |                                 |                               |                          |
+  | end             | end of buffer                  |                                 |                               |                          |
+  | f9              |                                |                                 |                               |                          |
+  |-----------------+--------------------------------+---------------------------------+-------------------------------+--------------------------|
+  | right secondary | C-                             | M-                              | C-M-                          | C-S-                     |
+  |-----------------+--------------------------------+---------------------------------+-------------------------------+--------------------------|
+  | 6               | save-buffers-kill-emacs        |                                 | insert-small-copyright        |                          |
+  | 7               |                                |                                 | insert-full-copyright         |                          |
+  | 0               | text-scale-reset               |                                 | insert-apache                 |                          |
+  | -               |                                |                                 | org-edit-src-exit             |                          |
+  | y               | undo-tree-redo                 |                                 |                               |                          |
+  | \               | sr-speedbar-toggle             |                                 | mark-defun                    |                          |
+  | h               | help-prefix                    |                                 |                               |                          |
+  | '               | eval-expression                |                                 |                               |                          |
+  | n               | unpop-to-mark-command          |                                 | narrow-to-region              |                          |
+  | rshift          |                                |                                 |                               |                          |
+  | escape          | find-tag                       |                                 |                               |                          |
+  |-----------------+--------------------------------+---------------------------------+-------------------------------+--------------------------|
+
+* keybind notes
+common keys, which would be better off doing swaps than rebinds:
+c-x prefix -> c-s
+c-c prefix -> c-d
+yank c-y -> c-c
+search c-s -> kp-add
+kill line c-k -> c-f
+undo c-_ -> c-z
+set-mark-command c-@ -> kp-enter
+quoted-insert c-q -> c-m-q
+recenter-top-bottom c-l -> c-m-3
+kill-region c-w -> c-x
+
+commands to make less accessible
+narrow-to-defun/subtree -> M-2 maybe
+occur
+
+command to make more accessible, ...
+
+
+* TESTING / DEVELOPMENT AREA
+
+(defun comint-send-string (process string)
+  "Like `process-send-string', but also does extra bookkeeping for Comint mode."
+  (if process
+      (with-current-buffer (if (processp process)
+                              (process-buffer process)
+                            (get-buffer process))
+       (comint-snapshot-last-prompt))
+    (comint-snapshot-last-prompt))
+  (process-send-string process string))