various updates, mail
[dot-emacs] / my-init.org
index e716e33a00af836a1d2b19340ead7a931e6e2261..1c98c882a264559deba457bd13a86f0f627618ca 100644 (file)
@@ -1,7 +1,7 @@
 #+TITLE: My Personal Init Customization
 #+OPTIONS: toc:nil num:nil ^:nil
 * copyright
-# Copyright (C) 2016 Ian Kelling
+# Copyright (C) 2017 Ian Kelling
 
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -161,6 +161,51 @@ If it is different, emacs will give a message about recovering it when you open
 
 
 
+* 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.
@@ -169,6 +214,9 @@ with documentation.
 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
@@ -532,6 +580,8 @@ I need this function here, where INSIDE_EMACS is replaced with RLC_INSIDE_EMACS.
   (when (and
          my-as
          (buffer-file-name)
+         ;; mu4e has a bug right now, undo breaks when saving drafts
+         (not (string= (buffer-file-name) "*draft*"))
          (buffer-modified-p)
          (not (org-src-edit-buffer-p)))
     (let (message-log-max)
@@ -692,6 +742,7 @@ seems they are created
 
 (add-to-list 'load-path "~/.emacs.d/src/bbdb-csv-import")
 (require 'bbdb-csv-import)
+
         #+end_src
 
 * bookmark settings
@@ -725,53 +776,58 @@ interesting light themes
 
 
   #+begin_src emacs-lisp
-    (defun override-theme (arg)
-      (interactive)
-      (while custom-enabled-themes
-        (disable-theme (car custom-enabled-themes)))
-      (load-theme arg t))
-    (setq color-theme-is-global t)
-
-    (defun toggle-night ()
-     (interactive)
-      (if (equal (car custom-enabled-themes) 'naquadah)
-          (override-theme 'leuven)
-      (override-theme 'naquadah)))
-
+(defun override-theme (arg)
+  (interactive)
+  (while custom-enabled-themes
+    (disable-theme (car custom-enabled-themes)))
+  (load-theme arg t))
+(setq color-theme-is-global t)
 
-    (override-theme 'leuven) ;; org mode features, with monitor darkened. part of org-mode i think
+(defun toggle-night ()
+  (interactive)
+  (cond  ((equal (car custom-enabled-themes) 'naquadah)
+          ;; background off white to be better on the eyes. took this
+          ;; color from gitweb.
+          (custom-set-faces `(default ((t (:background "#F6F6F0")))))
+          (override-theme 'leuven))
+         (t
+          ;; revert previous background change
+          (custom-set-faces `(default ((t (:background nil)))))
+          (override-theme 'naquadah))))
 
+(custom-set-faces `(default ((t (:background "#F6F6F0")))))
+(override-theme 'leuven) ;; org mode features, with monitor darkened. part of org-mode i think
 
 
-    ;; disable color thing with this:
-    ;;(disable-theme (car custom-enabled-themes))
+;; disable color thing with this:
+;;(disable-theme (car custom-enabled-themes))
 
-    ;; decent dark themes
+;; decent dark themes
 
-   ;;(override-theme 'tangotango)
-    ;;(override-theme 'deeper-blue)
-    ;;(override-theme 'tango-dark)
-    ;;(override-theme 'tsdh-dark)
+;;(override-theme 'tangotango)
+;;(override-theme 'deeper-blue)
+;;(override-theme 'tango-dark)
+;;(override-theme 'tsdh-dark)
 
-    ;;(override-theme 'heroku)
-    ;;(override-theme 'inkpot)  ;; part of inkpot-theme package
-    ;;(override-theme 'naquadah) ; org mode features, part of  naquadah-theme package
-    ;;(override-theme 'spolsky) ;; part of sublime-themes package
-    ;;(override-theme 'twilight-anti-bright)  ;; from twilight-anti-bright-theme package
+;;(override-theme 'heroku)
+;;(override-theme 'inkpot)  ;; part of inkpot-theme package
+;;(override-theme 'naquadah) ; org mode features, part of  naquadah-theme package
+;;(override-theme 'spolsky) ;; part of sublime-themes package
+;;(override-theme 'twilight-anti-bright)  ;; from twilight-anti-bright-theme package
 
-    ;; interesting but not usable colors
-    ;;(override-theme 'cyberpunk) ; cool org mode features, from cyberpunk-theme package
-    ;;(override-theme 'wombat) ; cursor not visible enough. from a wombat package, not sure which
-    ;;(override-theme 'misterioso) ; cursor not visible enough
+;; interesting but not usable colors
+;;(override-theme 'cyberpunk) ; cool org mode features, from cyberpunk-theme package
+;;(override-theme 'wombat) ; cursor not visible enough. from a wombat package, not sure which
+;;(override-theme 'misterioso) ; cursor not visible enough
 
 
 
-    ;;decent light themes
-    ;;(override-theme 'alect-light) ; theres a -alt version, don't see a dif. could use this without dimming. from alect-something package
-    ;;(override-theme 'occidental) ; from occidental-theme package
+;;decent light themes
+;;(override-theme 'alect-light) ; theres a -alt version, don't see a dif. could use this without dimming. from alect-something package
+;;(override-theme 'occidental) ; from occidental-theme package
 
 
-    ;;color-theme is deprecated in emacs 24.
+;;color-theme is deprecated in emacs 24.
 
 ;; theme packages i tried then removed:
 ;; ignored ones that didn't use the new theme engine
@@ -869,6 +925,108 @@ Things I tried which didn't work, which intuitively I think should work better:
 (put 'dired-find-alternate-file 'disabled nil)
 #+end_src
 
+* mu4e
+[[info:org#External links]]
+[[info:mu4e#Keybindings]]
+
+alsot tried notmuch, it had some glitches, and it's config
+has a list of folders which i'd rather not publish, so it's config is archived.
+
+#+begin_src emacs-lisp
+;;(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu4e")
+(require 'mu4e)
+(setq send-mail-function (quote sendmail-send-it) ;; common to gnus also
+      mu4e-maildir "/m/4e"
+      ;; use the standard imap folders
+      mu4e-sent-folder   "/Sent"
+      mu4e-drafts-folder "/Drafts"
+      mu4e-trash-folder  "/Trash"
+      ;; standard imap folder is /Archive, but I've set this to /Junk,
+      ;; because I don't manually archive individual messages, and mu4e
+      ;; is lacking a button to move to the spam folder "Junk", and I
+      ;; want one to train spamassassin better.  Note: It calls
+      ;; archiving "refiling", so it's bound to r.
+      mu4e-refile-folder "/Junk"
+      ;; reindex new mail this often in seconds
+      ;; show addresses instead of just names
+      mu4e-view-show-addresses t
+      mu4e-use-fancy-chars t
+      mu4e-confirm-quit nil
+      mu4e-headers-leave-behavior 'apply ;; dont ask, do whatever was marked
+      mu4e-headers-fields (delq (assoc :mailing-list mu4e-headers-fields) mu4e-headers-fields)
+      ;; a bit faster than the default 500. trying out the default for now
+      ;;mu4e-headers-results-limit 80
+
+      ;; looking up the list of maildirs when doing jo from summary
+      ;; can take a few seconds if we have a ton of messages.
+      ;; Only take that time for the first lookup.
+      ;; if we add a new maildir, just restart mu4e for it to be in that list.
+      mu4e-cache-maildir-list t
+      ;; default is 8, way too small for my big monitors
+      mu4e-headers-visible-lines 50
+      )
+
+;; fucks up reading unread bookmark. when that is fixed, enable it
+;; (setq mu4e-update-interval 60)
+
+
+;; this file includes setting up my email addresses, which are not public,
+;; including
+;; mu4e-user-mail-address-list
+;; and a function
+;; inspired by mu4e info manual, search for mu4e-compose-pre-hook.
+(load "/p/c/mu4e.el")
+
+;; it's implemented in mu4e, but not in the actions list for
+;; some reason.
+(add-to-list 'mu4e-view-actions
+             '("browser view" . mu4e-action-view-in-browser) t)
+(setq mu4e-maildir-shortcuts
+      '( ("/INBOX"     . ?i)
+         ("/github" . ?g)
+         ("/zroe"  . ?z)
+         ("/Drafts"     . ?d)
+         ("/Sent"     . ?d)
+         ))
+
+;; normally, you would add to this, but we want to
+;; modify unread messages. the first 4 are defined by default.
+(setq mu4e-bookmarks
+      `( ,(make-mu4e-bookmark
+           :name  "Unread messages"
+           :query "flag:unread AND NOT flag:trashed AND NOT maildir:/Junk AND NOT maildir:/fwfw"
+           :key ?u)
+         ,(make-mu4e-bookmark
+           :name "Today's messages"
+           :query "date:today..now"
+           :key ?t)
+         ,(make-mu4e-bookmark
+           :name "Last 7 days"
+           :query "date:7d..now"
+           :key ?w)
+         ,(make-mu4e-bookmark
+           :name "Messages with images"
+           :query "mime:image/*"
+           :key ?p))
+      )
+
+
+(defun mu4e-action-msgs-by-this-sender (msg)
+  "In header view, view messages by the sender of the message under point."
+  (let ((from (mu4e-message-field msg :from)))
+    (unless from
+      (mu4e-error "No from header for this message"))
+    ;; from is structured like: (("Anacron" . "root@x2.lan"))
+    (mu4e-headers-search (concat "f:" (cdar from)))))
+
+(add-to-list 'mu4e-headers-actions
+             '("from this sender" . mu4e-action-msgs-by-this-sender) t)
+(add-to-list 'mu4e-view-actions
+             '("from this sender" . mu4e-action-msgs-by-this-sender) t)
+#+end_src
+
+
+
 * disabled but saved for documentation purposes
 :PROPERTIES:
 :header-args: :tangle no
@@ -1102,55 +1260,6 @@ seems like 1 in 100 times, an invisible command to restore prompt didn't work
 
 
 
-** mu4e
-
-alsot tried notmuch, it had some glitches, and it's config
-has a list of folders which i'd rather not publish, so it's config is archived.
-
-#+begin_src emacs-lisp
-(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu4e")
-(require 'mu4e)
-(setq send-mail-function (quote sendmail-send-it) ;; common to gnus also
-      mu4e-sent-folder   "/Sent Items"
-      mu4e-drafts-folder "/Drafts"
-      mu4e-trash-folder  "/Trash"
-      mu4e-refile-folder "/Archive"
-      mu4e-get-mail-command "offlineimap"
-      mu4e-update-interval 60
-      mu4e-sent-messages-behavior 'delete
-      mu4e-use-fancy-chars t
-      mu4e-confirm-quit nil
-      mu4e-headers-leave-behavior 'apply ;; dont ask
-      mu4e-headers-fields (delq (assoc :mailing-list mu4e-headers-fields) mu4e-headers-fields)
-      ;; a bit faster than the default 500
-      mu4e-headers-results-limit 80)
-
-(define-key mu4e-headers-mode-map (kbd "<return>") 'mu4e-headers-view-message)
-
-(defun my-mu4e-to ()
-  "inspired by mu4e info manual"
-  (--reduce-from (if (mu4e-message-contact-field-matches
-                      mu4e-compose-parent-message :to (cadr it))
-                     (concat (car it) (cadr it))
-                   acc)
-                 '("Ian Kelling <ian@iankelling.org")
-                 ;;'(("Ian Kelling " "<alternate1@example.com>")
-                 ;;  ("Ian Kelling " "<alternate2@example.com>"))
-                   ))
-
-(add-hook 'mu4e-compose-pre-hook 'my-mu4e-to)
-
-(add-to-list 'mu4e-view-actions
-             '("ViewInBrowser" . mu4e-action-view-in-browser) t)
-(setq mu4e-maildir-shortcuts
-      '( ("/INBOX"     . ?i)
-         ("/bog"  . ?b)
-         ("/Drafts"     . ?d)))
-
-#+end_src
-
-
-
 
 ** org-mode auto-complete source
 
@@ -1189,6 +1298,13 @@ this looks nice, but it lags gnus just a bit
 ** 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)
 
@@ -2201,7 +2317,6 @@ currently makes emacs hang a bunch. dunno why. just using eclipse instead
 (blink-cursor-mode '(-4))
 (menu-bar-mode -1)
 (tool-bar-mode -1)
-(set-scroll-bar-mode 'left)
 
 
 ;; enable various commands
@@ -3628,6 +3743,9 @@ to use with up and down.
 #+begin_src emacs-lisp
   (global-set-key (kbd "C-x C-b") 'ibuffer)
 #+end_src
+
+*** C-x r c
+rectangular clear, replace area with whitespace
 ** gnus
 searching overview.
 3 types:
@@ -3690,6 +3808,9 @@ 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
@@ -4914,16 +5035,15 @@ calc-dispatch
 *** C-9]
 delete-window-or-exit
 #+begin_src emacs-lisp
-  (global-set-key (kbd "C-9") 'delete-window-or-exit)
-
-  (defun delete-window-or-exit ()
-    "Delete window or exit emacs."
-    (interactive)
-    (if (condition-case nil (delete-window) (error t))
-        (if (or (boundp 'server-process) (> (length (frame-list)) 1))
-            (delete-frame)
-          (save-buffers-kill-terminal t))))
+(global-set-key (kbd "C-9") 'delete-window-or-exit)
 
+(defun delete-window-or-exit ()
+  "Delete window or exit emacs."
+  (interactive)
+  (if (condition-case nil (delete-window) (error t))
+      (if (or (boundp 'server-process) (> (length (frame-list)) 1))
+          (progn (basic-save-buffer) (delete-frame))
+        (save-buffers-kill-terminal t))))
 #+end_src
 *** M-9]
 kill-buffer
@@ -4941,7 +5061,7 @@ I did a grep of the emacs sources, but couldn't find anything.
 
 *** C-M-9]
 end server edit
-    ,save & kill buffer it was opened externally via emacsclient
+    ,save & kill buffer if it was opened externally via emacsclient
 
     #+begin_src emacs-lisp
 (defun server-edit-save ()
@@ -5438,7 +5558,7 @@ save-buffers-kill-emacs
     (interactive)
     (beginning-of-line)
     (let ((beg (point)))
-      (insert "Copyright (C) 2016 Ian Kelling\nThis program is under GPL v. 3 or later, see <http://www.gnu.org/licenses/>")
+      (insert "Copyright (C) 2017 Ian Kelling\nThis program is under GPL v. 3 or later, see <http://www.gnu.org/licenses/>")
       (comment-region beg (point))))
 
   (global-set-key (kbd "C-M-6") 'insert-small-copyright)
@@ -5453,7 +5573,7 @@ insert-full-copyright
   (interactive)
   (beginning-of-line)
   (let ((beg (point)))
-    (insert "Copyright (C) 2016 Ian Kelling\n")
+    (insert "Copyright (C) 2017 Ian Kelling\n")
     (insert "\n")
     (insert "This program is free software: you can redistribute it and/or modify\n")
     (insert "it under the terms of the GNU General Public License as published by\n")
@@ -5489,7 +5609,7 @@ insert-apache
   (interactive)
   (beginning-of-line)
   (let ((beg (point)))
-    (insert "Copyright (C) 2016 Ian Kelling\n")
+    (insert "Copyright (C) 2017 Ian Kelling\n")
     (insert "\n")
     (insert "Licensed under the Apache License, Version 2.0 (the \"License\");\n")
     (insert "you may not use this file except in compliance with the License.\n")