wip
[dot-emacs] / my-init.org
index 1bd6421f5ad46ed5bd37caff4a4f998d05b5f0f1..87d8515b8ab36247af83561cf51b8e6864051d84 100644 (file)
@@ -82,6 +82,7 @@ alternate keyboards
 
 (add-to-list 'package-archives
              '("melpa" . "http://melpa.milkbox.net/packages/") t)
+(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
 
 ;; if this is a new machine/config, get package list
 ;; not sure why we need it, but it is recommended in starter kit,
@@ -160,9 +161,7 @@ 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
@@ -177,6 +176,8 @@ and actually, putting the start of it in th emodeline might be cool
 * 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
@@ -470,8 +471,57 @@ if all else fails, edit the abbrev file
 #+RESULTS:
 : comint-exec-1
 
-debugging
+** readline complete fix
 
+I need this function here, where INSIDE_EMACS is replaced with RLC_INSIDE_EMACS.
+#+begin_src emacs-lisp
+;; ian: last update 2017-1-7. update this periodically from upstream
+;; like when we do a major emacs update
+(defun comint-exec-1 (name buffer command switches)
+  (let ((process-environment
+        (nconc
+         ;; If using termcap, we specify `emacs' as the terminal type
+         ;; because that lets us specify a width.
+         ;; If using terminfo, we specify `dumb' because that is
+         ;; a defined terminal type.  `emacs' is not a defined terminal type
+         ;; and there is no way for us to define it here.
+         ;; Some programs that use terminfo get very confused
+         ;; if TERM is not a valid terminal type.
+         ;; ;; There is similar code in compile.el.
+         (if (and (boundp 'system-uses-terminfo) system-uses-terminfo)
+             (list "TERM=dumb" "TERMCAP="
+                   (format "COLUMNS=%d" (window-width)))
+           (list "TERM=emacs"
+                 (format "TERMCAP=emacs:co#%d:tc=unknown:" (window-width))))
+         (list (format "RLC_INSIDE_EMACS=%s,comint" emacs-version))
+         process-environment))
+       (default-directory
+         (if (file-accessible-directory-p default-directory)
+             default-directory
+           "/"))
+       proc decoding encoding changed)
+    (let ((exec-path (if (and command (file-name-directory command))
+                        ;; If the command has slashes, make sure we
+                        ;; first look relative to the current directory.
+                        (cons default-directory exec-path) exec-path)))
+      (setq proc (apply 'start-file-process name buffer command switches)))
+    ;; Some file name handler cannot start a process, fe ange-ftp.
+    (unless (processp proc) (error "No process started"))
+    (let ((coding-systems (process-coding-system proc)))
+      (setq decoding (car coding-systems)
+           encoding (cdr coding-systems)))
+    ;; Even if start-file-process left the coding system for encoding data
+    ;; sent from the process undecided, we had better use the same one
+    ;; as what we use for decoding.  But, we should suppress EOL
+    ;; conversion.
+    (if (and decoding (not encoding))
+       (setq encoding (coding-system-change-eol-conversion decoding 'unix)
+             changed t))
+    (if changed
+       (set-process-coding-system proc decoding encoding))
+    proc))
+
+#+end_src
 
 * auto save & backup
 
@@ -823,7 +873,7 @@ Things I tried which didn't work, which intuitively I think should work better:
 
 * disabled but saved for documentation purposes
   :PROPERTIES:
-  :tangle:   no
+  :header-args: :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
@@ -899,42 +949,13 @@ don't have a way to set this automatically or a good place to put this
 
 #+end_src
 
-** ace-jump
+** misc stuff
   It is an awesome mode for keyboard navigation.
-  However, using the mouse takes less thought and works as well,
-  especially with my foot mouse ;)
+  However, using the mouse takes less thought and works as well
 
   #+begin_src emacs-lisp
 
 
-
-
-    ;; this has a problem that it doesn't work with emacsclient, so I'm using a more standard method
-    ;; This has the benefit of working with less fuss otherwise, I think.
-    ;; no method works on a terminal
-    ;; makes C-i and tab be distinct. same deal is done for c-m
-    ;;(setq local-function-key-map (delete '(tab . [9]) local-function-key-map))
-    ;;  (define-key input-decode-map (kbd "C-i") [f15])
-    ;;  (define-key input-decode-map (kbd "<f15>") [?\C-i])
-    ;;  (define-key input-decode-map (kbd "<tab>") [?\C-i])
-    ;;  (global-set-key (kbd "<f15>") 'query-replace)
-
-
-                                            ; not using ace jump mode, but if mouse is ever not good,
-                                            ; here is config for it
-    (require 'ace-jump-mode)
-    (eval-after-load "ace-jump-mode"
-      '(ace-jump-mode-enable-mark-sync))
-    (define-key global-map (kbd "") 'ace-jump-mode)
-
-
-
-    ;; revert buffers automatically when underlying files are changed externally
-    ;; too dangerous, and thus disabled.
-    ;; do m-x auto-revert-mode to auto-rever a specific buffer
-    ;;(global-auto-revert-mode t)
-
-
     ;; 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))
@@ -1144,62 +1165,6 @@ this looks nice, but it lags gnus just a bit
 
 #+end_src
 
-** 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.
-#+begin_src emacs-lisp
-
-(defun comint-exec-1 (name buffer command switches)
-  (let ((process-environment
-        (nconc
-         ;; If using termcap, we specify `emacs' as the terminal type
-         ;; because that lets us specify a width.
-         ;; If using terminfo, we specify `dumb' because that is
-         ;; a defined terminal type.  `emacs' is not a defined terminal type
-         ;; and there is no way for us to define it here.
-         ;; Some programs that use terminfo get very confused
-         ;; if TERM is not a valid terminal type.
-         ;; ;; There is similar code in compile.el.
-         (if (and (boundp 'system-uses-terminfo) system-uses-terminfo)
-             (list "TERM=dumb" "TERMCAP="
-                   (format "COLUMNS=%d" (window-width)))
-           (list "TERM=emacs"
-                 (format "TERMCAP=emacs:co#%d:tc=unknown:" (window-width))))
-          ;; ian: commented this out
-         ;;(unless (getenv "EMACS")
-         ;;  (list "EMACS=t"))
-          (list (format "RLC_INSIDE_EMACS=%s,comint" emacs-version))
-         process-environment))
-       (default-directory
-         (if (file-accessible-directory-p default-directory)
-             default-directory
-           "/"))
-       proc decoding encoding changed)
-    (let ((exec-path (if (and command (file-name-directory command))
-                        ;; If the command has slashes, make sure we
-                        ;; first look relative to the current directory.
-                        (cons default-directory exec-path) exec-path)))
-      (setq proc (apply 'start-file-process name buffer command switches)))
-    ;; Some file name handler cannot start a process, fe ange-ftp.
-    (unless (processp proc) (error "No process started"))
-    (let ((coding-systems (process-coding-system proc)))
-      (setq decoding (car coding-systems)
-           encoding (cdr coding-systems)))
-    ;; Even if start-file-process left the coding system for encoding data
-    ;; sent from the process undecided, we had better use the same one
-    ;; as what we use for decoding.  But, we should suppress EOL
-    ;; conversion.
-    (if (and decoding (not encoding))
-       (setq encoding (coding-system-change-eol-conversion decoding 'unix)
-             changed t))
-    (if changed
-       (set-process-coding-system proc decoding encoding))
-    proc))
-#+end_src
 ** misc
 #+begin_src emacs-lisp
 
@@ -1218,10 +1183,6 @@ old history anyways.
   ;(global-set-key (kbd "<tab>")  'complete-symbol)
 
 
-  ; todo, see how mastering emacs defines this function
-  ;(global-set-key (kbd "M-j") 'ido-goto-symbol)
-
-
   ; todo, make my custom overlays have an underline if they are
   ;  overriding a paren matching overlay
   ; make right click set the mark
@@ -1361,6 +1322,21 @@ disabled, as I haven't used it in a long time. I think it was good for learning
 #+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
 * elisp settings
 #+begin_src emacs-lisp
 ; when manually evaluating lisp, go into debugger on error
@@ -1915,12 +1891,32 @@ currently makes emacs hang a bunch. dunno why. just using eclipse instead
 * modes with little configuration needed
   #+begin_src emacs-lisp
 
+;;(require 'dtrt-indent)
+;;(setq dtrt-indent-mode t)
+
+(setq css-indent-offset 2)
+
 (load-file "/a/h/iank-mod.el")
 
 (require 'ws-butler)
 (ws-butler-global-mode)
 
 
+(defun ws-butler-clean-region (beg end)
+  "Delete trailing blanks in region BEG END."
+  (interactive "*r")
+  (ws-butler-with-save
+   (narrow-to-region beg end)
+   ;;  _much slower would be:       (replace-regexp "[ \t]+$" "")
+   (goto-char (point-min))
+   (while (not (eobp))
+     (end-of-line)
+     (delete-horizontal-space)
+     (forward-line 1)))
+  ;; clean return code for hooks
+  nil)
+
+
 (require 'nginx-mode)
 ;;The mode should automatically activate for files called nginx.conf and files under /etc/nginx - if not, you can add something like this to your init file:
 ;;(add-to-list 'auto-mode-alist '("/etc/nginx/sites-available/.*" . nginx-mode))
@@ -1980,35 +1976,7 @@ currently makes emacs hang a bunch. dunno why. just using eclipse instead
 (require 'magit)
 
 
-;; http://ergoemacs.org/emacs/emacs_CSS_colors.html
-;; there's also rainbow mode, which seems to only work for specific colors? it didn't work at all for me in a css file.
-;; todo, do config group on it, and try out one of those colors.
-(defun xah-syntax-color-hsl ()
-  "Syntax color hex color spec such as 「hsl(0,90%,41%)」 in current buffer."
-  (interactive)
-  (font-lock-add-keywords
-   nil
-   '(("hsl( *\\([0-9]\\{1,3\\}\\) *, *\\([0-9]\\{1,3\\}\\)% *, *\\([0-9]\\{1,3\\}\\)% *)"
-      (0 (put-text-property
-          (+ (match-beginning 0) 3)
-          (match-end 0)
-          'face (list :background
-                      (concat "#" (mapconcat 'identity
-                                             (mapcar
-                                              (lambda (x) (format "%02x" (round (* x 255))))
-                                              (color-hsl-to-rgb
-                                               (/ (string-to-number (match-string-no-properties 1)) 360.0)
-                                               (/ (string-to-number (match-string-no-properties 2)) 100.0)
-                                               (/ (string-to-number (match-string-no-properties 3)) 100.0)
-                                               ) )
-                                             "" )) ;  "#00aa00"
-                      ))))) )
-  (font-lock-fontify-buffer)
-  )
-
-(add-hook 'css-mode-hook 'xah-syntax-color-hsl)
-(add-hook 'php-mode-hook 'xah-syntax-color-hsl)
-(add-hook 'html-mode-hook 'xah-syntax-color-hsl)
+;; colorize hex colors: use rainbow mode
 
 
 ;; message mode prompted me on first message.
@@ -2155,9 +2123,6 @@ currently makes emacs hang a bunch. dunno why. just using eclipse instead
 ;; disable this nasty function, as I always use a gui
 (defun suspend-frame() (interactive))
 
-;; to reopen just ido-switch-buffer (c-l), *scratch*
-;;  (kill-buffer "*scratch*")
-
 ;; Seed the random-number generator
 (random t)
 
@@ -2201,8 +2166,11 @@ currently makes emacs hang a bunch. dunno why. just using eclipse instead
       mark-ring-max 160
       sort-fold-case t  ; case insensitive line sorting
       global-mark-ring-max 1000
-      ;; the bell seems to lag the ui
+      ;; the visible bell seems to lag the ui
       ;;visible-bell t
+      ;; turn off audible bell
+      ;; https://www.emacswiki.org/emacs/AlarmBell
+      ring-bell-function 'ignore
       case-replace nil
       revert-without-query '(".*")
       ;; don't pause display code on input.
@@ -3067,7 +3035,6 @@ clicking on info links
 (set-face-attribute 'org-formula nil :family (face-attribute 'fixed-pitch :family))
 (set-face-attribute 'org-link nil :family (face-attribute 'fixed-pitch :family))
 (set-face-attribute 'org-block nil :family (face-attribute 'fixed-pitch :family))
-(set-face-attribute 'org-block-background nil :family (face-attribute 'fixed-pitch :family))
 (set-face-attribute 'org-date nil :family (face-attribute 'fixed-pitch :family))
 
 
@@ -3301,9 +3268,6 @@ downgraded to marmalade version and everything is working fine.
 
 ;; Except in HTML
 (sp-local-pair 'html-mode "\"" nil :unless '(:rem sp-point-after-word-p))
-;; CoffeeScript PyStrings
-(push 'coffee-mode sp-autoescape-string-quote-if-empty)
-
 
 
   #+end_src
@@ -4838,6 +4802,9 @@ shell
 (global-set-key (kbd "<S-kp-equal>") 'shell-wrap)
 #+end_src
 *** s-right arrow
+:LOGBOOK:
+CLOCK: [2016-11-28 Mon 11:03]--[2016-11-28 Mon 11:03] =>  0:00
+:END:
 :PROPERTIES:
 :CUSTOM_ID: 2365f5a7-b89a-4a97-b272-ac8ae9c2cc66
 :END:
@@ -4857,53 +4824,30 @@ 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))
-
-(add-hook 'ido-setup-hook
-          (lambda()
-            (define-key ido-completion-map (kbd "<return>") 'ido-exit-minibuffer)))
-(define-key minibuffer-local-completion-map (kbd "<return>") 'exit-minibuffer)
 
 
-(define-key isearch-mode-map (kbd "<return>") 'isearch-exit)
-(define-key isearch-mode-map "\r" nil)
+;;(global-set-key (kbd "<return>") 'indent-new-comment-line)
 
-
-(global-set-key (kbd "<return>") 'indent-new-comment-line)
+;; don't use enter for autocomplete, we use tab or something
 (define-key ac-completing-map (kbd "<return>") nil)
 (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 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)
-(define-key minibuffer-local-must-match-map (kbd "<return>")
-  'minibuffer-complete-and-exit)
-
-(add-hook 'Man-mode-hook
+
+(add-hook 'org-mode-hook
           (lambda ()
-            (define-key Man-mode-map "\r" nil)
-            (define-key Man-mode-map "x" 'man-follow)))
+          ;; copied from org-mode, replace org-enter with org-enter-indent
+(org-defkey org-mode-map "\C-m"     'org-return-indent)))
+
 
 (add-hook 'comint-mode-hook
           (lambda ()
             (define-key comint-mode-map "\r" nil)
             (define-key comint-mode-map (kbd "<return>") 'comint-send-input)))
 
-(add-hook 'org-mode-hook
-          (lambda ()
-            (define-key org-mode-map "\r" nil)
-            (define-key org-mode-map (kbd "<return>") 'org-return-indent)))
-
 (add-hook 'comint-mode-hook
           (lambda ()
             (define-key comint-mode-map "\C-m" nil)
             (define-key comint-mode-map "\C-d" nil)))
-;; use space instead of enter in calc mode,
-;; cuz it is not easy to rebind enter in calc mode
+
 #+end_src
 
 *** [s-return]                                                        :drill:
@@ -7131,7 +7075,7 @@ occur
 *** [C-M-o]                                                           :drill:
 SCHEDULED: <2014-03-12 Wed>
     :PROPERTIES:
-    ido-goto-symbol
+    counsel-imenu
     :CUSTOM_ID: 05d1ef50-43ee-46d7-b1ad-dd952543ab45
     :ID:       6dfcaa31-d223-4a14-904e-2f2395b2cf75
     :DRILL_LAST_INTERVAL: 10.3122
@@ -7143,10 +7087,10 @@ SCHEDULED: <2014-03-12 Wed>
     :DRILL_LAST_QUALITY: 4
     :DRILL_LAST_REVIEWED: <2014-03-02 Sun 21:09>
     :END:
-ido-goto-symbol
+counsel-imenu
     [
 #+begin_src emacs-lisp
-  (global-set-key (kbd "C-M-o") 'ido-goto-symbol)
+  (global-set-key (kbd "C-M-o") 'counsel-imenu)
 #+end_src
     ]
 *** C-S-o
@@ -7340,7 +7284,7 @@ man
 *** [C-l]                                                             :drill:
 SCHEDULED: <2014-05-13 Tue>
     :PROPERTIES:
-    ido-switch-buffer
+    ivy-switch-buffer
     :ID:       3c7fabd9-572d-4945-ab4b-d7a8dc2cd9c5
     :CUSTOM_ID: 8a7572bd-4b5e-4464-b937-3d35adb1783f
     :DRILL_LAST_INTERVAL: 71.5839
@@ -7352,10 +7296,10 @@ SCHEDULED: <2014-05-13 Tue>
     :DRILL_LAST_QUALITY: 5
     :DRILL_LAST_REVIEWED: <2014-03-02 Sun 21:10>
     :END:
-ido-switch-buffer
+ivy-switch-buffer
     [
 #+begin_src emacs-lisp
-    (global-set-key (kbd "C-l") 'ido-switch-buffer)
+    (global-set-key (kbd "C-l") 'ivy-switch-buffer)
 #+end_src
     ]
 *** M-l
@@ -7478,7 +7422,7 @@ recursive grep
 *** [C-,]                                                             :drill:
 SCHEDULED: <2014-05-13 Tue>
     :PROPERTIES:
-    ido-find-file
+    counsel-find-file
     :CUSTOM_ID: 6cbf3a85-f260-453a-920b-850ff5e986b1
     :ID:       df0f3769-bcfc-4cb9-8943-bb86dafb2711
     :DRILL_LAST_INTERVAL: 71.5839
@@ -7490,10 +7434,10 @@ SCHEDULED: <2014-05-13 Tue>
     :DRILL_LAST_QUALITY: 5
     :DRILL_LAST_REVIEWED: <2014-03-02 Sun 21:10>
     :END:
-ido-find-file
+counsel-find-file
     [
 #+begin_src emacs-lisp
-    (global-set-key (kbd "C-,") 'ido-find-file)
+    (global-set-key (kbd "C-,") 'counsel-find-file)
 (add-hook 'flyspell-mode-hook
             (lambda () (define-key flyspell-mode-map (kbd "C-,") nil)))
 #+end_src
@@ -8691,6 +8635,9 @@ to its output.
       subexpression for close bracket char or nothing: \\(\\]\\|\\)
 
 * keybind tables
+:LOGBOOK:
+CLOCK: [2016-11-28 Mon 10:59]--[2016-11-28 Mon 10:59] =>  0:00
+:END:
 dunno why but it takes doing ctrl-c twice to update this
   #+BEGIN: keybind-dblock
 |---------------------+------------------------|
@@ -8774,10 +8721,10 @@ dunno why but it takes doing ctrl-c twice to update this
 | p               | [[#9c2e2ba9-f34e-48fe-b4ff-b9826882c1cc][move-mouse-to-point]]            |                                 | [[#d55616d3-a3f6-4e83-8807-748578a7b726][delete-horizontal-space]]       |                          |
 | j               | [[#ebcf7c71-3c93-431b-af6b-7c5df7f2945e][register prefix]]                | [[#474a3e12-95ac-4f43-b83a-36716f3e6f76][previous-error]]                  |                               |                          |
 | k               | [[#25a7ba1c-ddf3-47f1-9516-914a552e7a36][jump to register]]               | [[#a96691bb-9e4c-414b-a093-d9961d453e21][next-error]]                      | [[#f61ea4ea-4597-422e-b7e3-d3cfad82603d][man]]                           |                          |
-| l               | [[#8a7572bd-4b5e-4464-b937-3d35adb1783f][ido-switch-buffer]]              |                                 | [[#24b660d4-3ec4-4416-8a6a-b8224ed1ee8b][move cursor top bottom mid]]    |                          |
+| l               | [[#8a7572bd-4b5e-4464-b937-3d35adb1783f][ivy-switch-buffer]]              |                                 | [[#24b660d4-3ec4-4416-8a6a-b8224ed1ee8b][move cursor top bottom mid]]    |                          |
 | ;               | [[#7e3710eb-5460-4460-8bf0-488302e4ce35][comment-dwim]]                   |                                 | [[#28680a96-5223-4632-80b9-b1facdd541e7][comment-current-line-dwim]]     |                          |
 | m               | [[#deee53ba-dfa2-4910-894c-55ae98d11aa4][pop-to-mark]]                    |                                 | [[#f283f705-cba0-45db-b80f-5d20415b2eee][recursive grep]]                |                          |
-| ,               | [[#6cbf3a85-f260-453a-920b-850ff5e986b1][ido-find-file]]                  |                                 | [[#bfdf6111-029d-462b-bcca-50a3ed2162d5][find-file-in-project]]          |                          |
+| ,               | [[#6cbf3a85-f260-453a-920b-850ff5e986b1][counsel-find-file]]                  |                                 | [[#bfdf6111-029d-462b-bcca-50a3ed2162d5][find-file-in-project]]          |                          |
 | .               | [[#0675c171-8677-44a8-882c-e7ed42715e31][recentf-ido-find-file]]          |                                 | [[#824d422c-67b6-4d68-af11-6a2135e528f5][-]]                             |                          |
 | /               | [[#941a7fa8-84b9-434d-89a0-1487385ec479][join lines]]                     |                                 | [[#37f67593-4f60-4d3b-9aad-6c9bc4882443][copy-variable]]                 |                          |
 | 8               | [[#251c4a1a-a683-4804-a706-d0d3752e42fa][calc-embedded-word]]             |                                 |                               |                          |
@@ -8872,7 +8819,7 @@ command to make more accessible, ...
 * TESTING / DEVELOPMENT AREA
 
 :PROPERTIES:
-  :tangle:   no
+:header-args: :tangle no
 :END:
 ** new
 #+begin_src emacs-lisp