various fixes
[dot-emacs] / my-init.org
index 6d698da5440469124630f21b0a2d84f2b2c0db80..1bd6421f5ad46ed5bd37caff4a4f998d05b5f0f1 100644 (file)
@@ -19,7 +19,7 @@
 * things that should be at the beginning
 #+begin_src emacs-lisp
 ;; todo, evaluating this manually disables debug on error instead of toggling it
-;;(toggle-debug-on-error) ;uncomment to help debug and catch errors
+;(toggle-debug-on-error) ;uncomment to help debug and catch errors
 
 
 #+end_src
@@ -47,9 +47,9 @@ alternate keyboards
     m-enter (kbd "M-m")
     c-enter (kbd "C-8")))
 
+(setq tp (string= (system-name) "tp"))
 (setq x200 (string= (system-name) "x2"))
-(setq search-key (if x200 "<menu>" "<kp-add>"))
-(setq shell-key (if x200 "<S-menu>" "<S-kp-equal>"))
+(setq laptop-keyboard (or tp x200))
 #+end_src
 
 - Ubiquitous Packages which should be loaded on startup rather than
@@ -160,7 +160,14 @@ If it is different, emacs will give a message about recovering it when you open
 
 
 
+* TODO update comint-exec-1
+* TODO learn some more ivy mode stuff
+* TODO disable return overriding ctrl-m
+* TODO declarative package installations,
+with documentation.
 * TODO shell mode reverse search hides 2nd+ line of multi-line result
+* TODO report bug in latest emacs,
+c-c ', does't exit org-mode src editing mode.
 * TODO button for switching to scratch buffer
 * TODO figure out browsing files with broken nfs mount
 causes emacs to freeze until I kill -9 it.
@@ -197,7 +204,9 @@ bad code, the comment this relates to was removed, but not the comment
 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
@@ -373,7 +382,8 @@ if all else fails, edit the abbrev file
 
 #+begin_src emacs-lisp
 ;; auto-completion in minibuffer
-(icomplete-mode)
+;; disabled while I look for another alternative
+;;(icomplete-mode)
 
 (require 'auto-complete-config)
 (ac-config-default)
@@ -441,6 +451,8 @@ if all else fails, edit the abbrev file
 (setenv "EMACS" "")
 (setq explicit-bash-args nil)
 (setq comint-process-echoes t)
+;; default of 30 is way too slow. todo, consider pushing this upstream
+(setq rlc-attempts 5)
 
 (add-to-list 'ac-modes 'shell-mode)
 
@@ -813,6 +825,59 @@ Things I tried which didn't work, which intuitively I think should work better:
   :PROPERTIES:
   :tangle:   no
   :END:
+** 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
@@ -1081,6 +1146,8 @@ this looks nice, but it lags gnus just a bit
 
 ** readline complete fix, replaced with proper solution
 
+update: I need this function here, where INSIDE_EMACS is replaced with RLC_INSIDE_EMACS.
+
 i had commented out a few lines here, but instead I am setting in my profile
 the environment variable I commented out here. Yes, that is not the best explanation, but I will probably delete this as
 old history anyways.
@@ -1105,7 +1172,7 @@ old history anyways.
           ;; ian: commented this out
          ;;(unless (getenv "EMACS")
          ;;  (list "EMACS=t"))
-         (list (format "INSIDE_EMACS=%s,comint" emacs-version))
+          (list (format "RLC_INSIDE_EMACS=%s,comint" emacs-version))
          process-environment))
        (default-directory
          (if (file-accessible-directory-p default-directory)
@@ -1637,117 +1704,6 @@ make all
 #+RESULTS:
 | (lambda nil (define-key haskell-interactive-mode-map (kbd <C-M-return>) (quote haskell-interactive-mode-newline-indent))) | (lambda nil (define-key haskell-interactive-mode-map \n nil) (define-key haskell-interactive-mode-map (kbd <return>) (quote haskell-interactive-mode-return))) | ac-haskell-process-setup |
 
-* ido
-#+begin_src emacs-lisp
-
-;; easier to read, and more than the default 12
-(setq ido-separator nil)
-(setq ido-max-prospects 20)
-
-(ido-mode t)
-(ido-everywhere t)  ;; file dialogs
-
-;; do out of order matching when all else fails
-(setq ido-enable-flex-matching t
-      ido-create-new-buffer 'always ;; create new buffer/file without asking
-      ido-use-filename-at-point 'guess ;; use filename at point if it makes sense
-      ido-save-directory-list-file "~/.emacs.d/.ido.last"
-      ido-default-file-method 'selected-window) ;; make duplicate windows
-;; todo, the next 2 functions seem to do roughly the same.
-;;   figure out which one is better. the first comes from emacs starter kit,
-;;   i forget about the second.
-(defun ido-imenu ()
-  "Update the imenu index and then use ido to select a symbol to navigate to.
-  Symbols matching the text at point are put first in the completion list."
-  (interactive)
-  (imenu--make-index-alist)
-  (let ((name-and-pos '())
-        (symbol-names '()))
-    (cl-flet ((addsymbols (symbol-list)
-                          (when (listp symbol-list)
-                            (dolist (symbol symbol-list)
-                              (let ((name nil) (position nil))
-                                (cond
-                                 ((and (listp symbol) (imenu--subalist-p symbol))
-                                  (addsymbols symbol))
-
-                                 ((listp symbol)
-                                  (setq name (car symbol))
-                                  (setq position (cdr symbol)))
-
-                                 ((stringp symbol)
-                                  (setq name symbol)
-                                  (setq position (get-text-property 1 'org-imenu-marker symbol))))
-
-                                (unless (or (null position) (null name))
-                                  (add-to-list 'symbol-names name)
-                                  (add-to-list 'name-and-pos (cons name position))))))))
-      (addsymbols imenu--index-alist))
-    ;; If there are matching symbols at point, put them at the beginning of `symbol-names'.
-    (let ((symbol-at-point (thing-at-point 'symbol)))
-      (when symbol-at-point
-        (let* ((regexp (concat (regexp-quote symbol-at-point) "$"))
-               (matching-symbols (delq nil (mapcar (lambda (symbol)
-                                                     (if (string-match regexp symbol) symbol))
-                                                   symbol-names))))
-          (when matching-symbols
-            (sort matching-symbols (lambda (a b) (> (length a) (length b))))
-            (mapc (lambda (symbol) (setq symbol-names (cons symbol (delete symbol symbol-names))))
-                  matching-symbols)))))
-    (let* ((selected-symbol (ido-completing-read "Symbol? " symbol-names))
-           (position (cdr (assoc selected-symbol name-and-pos))))
-      (goto-char position))))
-
-(defun ido-goto-symbol (&optional symbol-list)
-  "Refresh imenu and jump to a place in the buffer using Ido."
-  (interactive)
-  (unless (featurep 'imenu)
-    (require 'imenu nil t))
-  (cond
-   ((not symbol-list)
-    (let ((ido-mode ido-mode)
-          (ido-enable-flex-matching
-           (if (boundp 'ido-enable-flex-matching)
-               ido-enable-flex-matching t))
-          name-and-pos symbol-names position)
-      (unless ido-mode
-        (ido-mode 1)
-        (setq ido-enable-flex-matching t))
-      (while (progn
-               (imenu--cleanup)
-               (setq imenu--index-alist nil)
-               (ido-goto-symbol (imenu--make-index-alist))
-               (setq selected-symbol
-                     (ido-completing-read "Symbol? " symbol-names))
-               (string= (car imenu--rescan-item) selected-symbol)))
-      (unless (and (boundp 'mark-active) mark-active)
-        (push-mark nil t nil))
-      (setq position (cdr (assoc selected-symbol name-and-pos)))
-      (cond
-       ((overlayp position)
-        (goto-char (overlay-start position)))
-       (t
-        (goto-char position)))))
-   ((listp symbol-list)
-    (dolist (symbol symbol-list)
-      (let (name position)
-        (cond
-         ((and (listp symbol) (imenu--subalist-p symbol))
-          (ido-goto-symbol symbol))
-         ((listp symbol)
-          (setq name (car symbol))
-          (setq position (cdr symbol)))
-         ((stringp symbol)
-          (setq name symbol)
-          (setq position
-                (get-text-property 1 'org-imenu-marker symbol))))
-        (unless (or (null position) (null name)
-                    (string= (car imenu--rescan-item) name))
-          (add-to-list 'symbol-names (substring-no-properties name))
-          (add-to-list 'name-and-pos (cons (substring-no-properties name) position))))))))
-
-#+end_src
-
 * isearch
 #+begin_src emacs-lisp
 (setq
@@ -1959,6 +1915,8 @@ currently makes emacs hang a bunch. dunno why. just using eclipse instead
 * modes with little configuration needed
   #+begin_src emacs-lisp
 
+(load-file "/a/h/iank-mod.el")
+
 (require 'ws-butler)
 (ws-butler-global-mode)
 
@@ -2332,6 +2290,9 @@ unchecked some stuff so that it inherits from default.
 #+begin_src emacs-lisp
 
 
+
+
+
 (defun next-backup-dir ()
 "In a directory listing from rsync -n,
 Go to the next directory based on where the cursor is."
@@ -3091,46 +3052,16 @@ clicking on info links
     (org-clock-in)))
 
 
-;; 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)
-
 
 ;; based on http://stackoverflow.com/questions/3758139/variable-pitch-for-org-mode-fixed-pitch-for-tables
 ;; keywords: proportional font, monospace
-(add-hook 'fundamental-mode-hook 'variable-pitch-mode)
-(add-hook 'text-mode-hook 'variable-pitch-mode)
+
+(defun variable-pitch-on ()
+  (variable-pitch-mode 1))
+(add-hook 'fundamental-mode-hook 'variable-pitch-on)
+(add-hook 'org-mode-hook 'variable-pitch-on)
+(add-hook 'text-mode-hook 'variable-pitch-on)
+
 (set-face-attribute 'org-table nil :family (face-attribute 'fixed-pitch :family))
 (set-face-attribute 'org-code nil :family (face-attribute 'fixed-pitch :family))
 (set-face-attribute 'org-formula nil :family (face-attribute 'fixed-pitch :family))
@@ -3221,8 +3152,8 @@ disabled cuz I have none yet
   (setq ac-sources (delq 'ac-source-dictionary ac-sources))
   (highlight-symbol-mode)
   (make-local-variable 'column-number-mode)
+  ;; this says do autofilling using newcomment.el. The "only" is a misnomer.
   (set (make-local-variable 'comment-auto-fill-only-comments) t)
-  (auto-fill-mode t)
   (column-number-mode t)
   (turn-on-smartparens-mode)
 
@@ -4315,10 +4246,10 @@ isearch-occur
     (isearch-toggle-regexp)
     (cond (isearch-regexp
            (global-set-key (kbd "C-r") 'isearch-backward-regexp)
-           (define-key global-map (kbd search-key) 'isearch-forward-regexp))
+           (define-key global-map (kbd "<kp-add>") 'isearch-forward-regexp))
           (t
            (global-set-key (kbd "C-r") 'isearch-backward)
-           (define-key global-map (kbd search-key) 'isearch-forward))))
+           (define-key global-map (kbd "<kp-add>") 'isearch-forward))))
   (define-key isearch-mode-map (kbd "M-r") 'my-isearch-toggle-regexp)
   #+end_src
 
@@ -4639,9 +4570,9 @@ isearch
 isearch-forward
 #+begin_src emacs-lisp
 ;; explained in http://stackoverflow.com/questions/7411920/how-to-bind-search-and-search-repeat-to-c-f-in-emacs
-(global-set-key (kbd search-key) 'isearch-forward)
+(global-set-key (kbd "<kp-add>") 'isearch-forward)
 (define-key isearch-mode-map "\t" nil)
-(define-key isearch-mode-map (kbd search-key) 'isearch-repeat-forward)
+(define-key isearch-mode-map (kbd "<kp-add>") 'isearch-repeat-forward)
 ;; get rid of the standard completion binding, always use auto-complete
 ;; this didn't work very well
 ;;(global-set-key (kbd "TAB") 'auto-complete)
@@ -4904,7 +4835,7 @@ modes like org-mode which have their own yank function."
 :END:
 shell
 #+begin_src emacs-lisp
-(global-set-key (kbd shell-key) 'shell-wrap)
+(global-set-key (kbd "<S-kp-equal>") 'shell-wrap)
 #+end_src
 *** s-right arrow
 :PROPERTIES:
@@ -4927,6 +4858,7 @@ new line
 #+begin_src emacs-lisp
 ;; todo, this doesn't set the keybind for the help minibuffer
 (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))
 
@@ -4945,7 +4877,6 @@ new line
 (define-key ac-completing-map "\r" nil)
 (define-key minibuffer-local-map "\r" nil)
 (define-key minibuffer-local-map (kbd "<return>") 'exit-minibuffer)
-(define-key icomplete-minibuffer-map (kbd "C-j") 'exit-minibuffer)
 (define-key minibuffer-local-map (kbd "C-j") 'exit-minibuffer)
 (define-key minibuffer-local-must-match-map (kbd "C-j") 'exit-minibuffer)
 (define-key minibuffer-local-must-match-map "\r" nil)
@@ -6147,6 +6078,7 @@ macro end / call
     [
 #+begin_src emacs-lisp
     (global-set-key (kbd "C-M-a") 'kmacro-end-or-call-macro)
+    (add-hook 'perl-mode-hook (lambda () (define-key perl-mode-map (kbd "C-M-a") nil)))
 (add-hook 'LaTeX-mode-hook (lambda () (define-key LaTeX-mode-map (kbd "C-M-a") nil)))
 (add-hook 'c-mode-hook
           (lambda () (define-key c-mode-map (kbd "C-M-a") nil)))
@@ -6668,16 +6600,9 @@ SCHEDULED: <2014-03-27 Thu>
     :DRILL_LAST_QUALITY: 5
     :DRILL_LAST_REVIEWED: <2014-02-04 Tue 11:42>
     :END:
-yas-expand
-    [
-    #+begin_src emacs-lisp
-;; yas keymaps are already initialized when this runs,
-;; but I use a hook because it the way I do it for all other minor modes
-  (add-hook 'yas-minor-mode-hook (lambda ()
-                                   (define-key yas-minor-mode-map (kbd "<C-tab>") 'yas-expand)
-                                   (define-key yas-keymap (kbd "<C-tab>") 'yas-next-field-or-maybe-expand)))
-  (global-set-key (kbd "<C-tab>") 'yas-insert-snippet)
-#+end_src
+---
+[
+in terminal, it's just TAB, duplicate keybind.
 ]
 *** [M-tab]                                                           :drill:
 SCHEDULED: <2014-03-14 Fri>
@@ -6694,14 +6619,9 @@ SCHEDULED: <2014-03-14 Fri>
     :DRILL_LAST_QUALITY: 4
     :DRILL_LAST_REVIEWED: <2014-02-19 Wed 16:35>
     :END:
-indent line
+---
     [
-#+begin_src emacs-lisp
-
-  (global-set-key (kbd "<M-tab>") 'indent-for-tab-command)
-
-  ; todo, <M-tab> overrides calculator mode map
-#+end_src
+in terminal it's duplicated of C-M-i
 ]
 *** C-M-tab
 :PROPERTIES:
@@ -7483,18 +7403,12 @@ SCHEDULED: <2014-03-19 Wed>
     :DRILL_LAST_QUALITY: 4
     :DRILL_LAST_REVIEWED: <2014-02-19 Wed 17:45>
     :END:
-comment-dwim
-    [
-#+begin_src emacs-lisp
-  (global-set-key (kbd "C-;") 'comment-dwim)
-  (add-hook 'flyspell-mode-hook
-            (lambda () (define-key flyspell-mode-map (kbd "C-;") nil)))
-#+end_src
-]
+used in flyspell, not sure what for, otherwise unbound
 *** M-;
 :PROPERTIES:
 :CUSTOM_ID: 211e76d9-d89a-4cc6-abce-69397d456fda
 :END:
+comment-dwim
 *** [C-M-;]                                                           :drill:
 SCHEDULED: <2014-04-07 Mon>
     :PROPERTIES:
@@ -8041,6 +7955,9 @@ org-edit-special
 (add-hook 'org-mode-hook
           (lambda ()
             (define-key org-mode-map (kbd "C-SPC") 'org-edit-special)
+            ;; org-src-mode-map is broken in git version of emacs.
+            ;; temporarily use this for exiting edit-special mode.
+            (global-set-key (kbd "C-M--") 'org-edit-src-exit)
             (define-key org-src-mode-map (kbd "C-SPC") 'org-edit-src-exit)))
 #+end_src
 ]
@@ -8399,6 +8316,31 @@ text-scale-reset
 :PROPERTIES:
 :CUSTOM_ID: 0e7f83a5-600e-4016-af98-95904300c016
 :END:
+insert-apache
+[
+#+begin_src emacs-lisp
+(defun insert-apache ()
+  (interactive)
+  (beginning-of-line)
+  (let ((beg (point)))
+    (insert "Copyright (C) 2016 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")
+    (insert "You may obtain a copy of the License at\n")
+    (insert "\n")
+    (insert "    http://www.apache.org/licenses/LICENSE-2.0\n")
+    (insert "\n")
+    (insert "Unless required by applicable law or agreed to in writing, software\n")
+    (insert "distributed under the License is distributed on an \"AS IS\" BASIS,\n")
+    (insert "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n")
+    (insert "See the License for the specific language governing permissions and\n")
+    (insert "limitations under the License.\n")
+    (comment-region beg (point))))
+(global-set-key (kbd "C-M-0") 'insert-apache)
+#+end_src
+]
+
 *** C-S-0
 :PROPERTIES:
 :CUSTOM_ID: d1706bc7-7cf0-4b49-87d0-15bf76eaca5f
@@ -8415,6 +8357,7 @@ text-scale-reset
 :PROPERTIES:
 :CUSTOM_ID: 6febc7ea-9cc7-488c-af34-538b8e69633b
 :END:
+org-edit-src-exit
 *** C-S--
 :PROPERTIES:
 :CUSTOM_ID: c73af1d7-61f2-4c1b-935e-43f077d8d915
@@ -8882,7 +8825,9 @@ much, so the added hassle of having to set it within this file is
 worth the benefit of only having one concept in my mind.
 #+begin_src emacs-lisp
   (dolist
-      (r `((?i (file . ,"~/.emacs.d/my-init.org"))
+      (r `(
+      (?i (file . ,"~/.emacs.d/my-init.org"))
+      (?t (file . ,"/a/x.txt"))
            ))
     (set-register (car r) (cadr r)))
 #+end_src