minor gitignore
[dot-emacs] / misc-disabled.el
index 59a88510bfca3fd0d771e9dabc7e1ee9ebb63907..18305264cfe0c8cadc91a4dad4c1d861fd887763 100644 (file)
@@ -1,3 +1,154 @@
+;; auto-completion in minibuffer
+;; disabled while I look for another alternative
+;;(icomplete-mode)
+
+(unless (string= (daemonp) "server")
+  (setq ac-use-comphist nil))
+(require 'auto-complete-config)
+(ac-config-default)
+
+
+;; complete after 1 char instead of default 2
+(setq ac-auto-start 1
+      ac-delay 0.001)
+
+(add-to-list 'ac-modes 'org-mode 'sql-mode)
+
+
+;; for org mode completion source taken from wiki.
+;; it did not work. no idea why. todo, investigate
+;; the ac-sources code is at http://www.emacswiki.org/emacs/AutoCompleteSources
+;; i've deleted it here so as to save space and not spam this file
+;;(defun my-ac-org-mode ()
+;;  (setq ac-sources (append ac-sources '(ac-source-org))))
+
+
+;; this makes the org-self-insert command not do a flyspell spell check.
+;; low priority thing to look into sometime
+(ac-flyspell-workaround)
+
+
+(define-key ac-completing-map (kbd "<up>") nil)
+(define-key ac-completing-map (kbd "<down>") nil)
+(define-key ac-completing-map (kbd "<S-return>") 'ac-expand)
+(define-key ac-completing-map "\t" 'ac-complete)
+;;(define-key ac-completing-map (kbd "<tab>") 'ac-complete)
+(define-key ac-completing-map (kbd "TAB") 'ac-complete)
+
+
+
+;;; auto-complete readline-complete
+
+(require 'readline-complete)
+;; not sure how I made these, but I deleted, and
+;; it would be nice to make them again sometime
+;;(require 'src-loaddefs)
+
+;; disabled cuz broken
+;; redefining function in readline-complete so ac-complete only uses readline as a source
+(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)
+
+
+;; readline-complete says to add this line.
+;; however, it  up my procfs directory tracking hook
+;; because get-process doesn't notice the child shell.
+;; instead, I've removed export EMACS=t from
+;;  comint-exec-1 (the function which initially sets it)
+;; by finding it in emacs sources and redefinind it here
+;; and done stty echo in my bashrc
+;;(setq explicit-bash-args '("-c" "export EMACS=; stty echo; bash"))
+
+;; generally unnecessary, but why not
+(setq explicit-shell-file-name "bash")
+(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)
+
+;; readline-complete recommends this (i assume this format),
+;; but greping finds no reference in emacs or my .emacs.d
+;; so I'm assuming it is for an older emacs
+;;(setq explicit-ssh-args '("-t"))
+
+(add-hook 'shell-mode-hook
+          (lambda ()
+            ;;(define-key shell-mode-map (kbd "<tab>") 'auto-complete)
+            (define-key shell-mode-map (kbd "TAB") 'auto-complete)
+            ))
+
+
+;;; readline complete fix
+
+;; I need this function here, where INSIDE_EMACS is replaced with LC_INSIDE_EMACS.
+;; 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 "LC_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))
+
+
+;; 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)
+
+
+;;; removed from (defun prog-mode-defaults ()
+;;
+;;(setq ac-sources (delq 'ac-source-dictionary ac-sources))
+
+
+
+
+
+
+
 ;; git version of gnus
 ;; (add-to-list 'load-path "~/.emacs.d/src/gnus/lisp")
 ;; (eval-after-load "info"
 ;; git version of gnus
 ;; (add-to-list 'load-path "~/.emacs.d/src/gnus/lisp")
 ;; (eval-after-load "info"
 
 ;; give us a shell to start instead of scratch
 ;;(setq initial-buffer-choice (lambda () (new-shell)))
 
 ;; give us a shell to start instead of scratch
 ;;(setq initial-buffer-choice (lambda () (new-shell)))
+
+
+;;; smartparens
+;; the melpa git version had a catastrophic bug I reported.
+;; downgraded to marmalade version and everything is working fine.
+(require 'smartparens-config)
+
+(defun gp/sp/pair-on-newline-and-indent (id action context)
+  "Open a new brace or bracket expression, with relevant newlines and indent. "
+  (save-excursion
+    (newline)
+    (indent-according-to-mode))
+  (indent-according-to-mode))
+
+;; when opening a pair, and then inserting a newline, push the closing pair to another newline
+(sp-pair "{" nil :post-handlers
+         '(:add ((lambda (id action context)
+                   (gp/sp/pair-on-newline-and-indent id action context)) (kbd "RET"))))
+(sp-pair "[" nil :post-handlers
+         '(:add ((lambda (id action context)
+                   (gp/sp/pair-on-newline-and-indent id action context)) (kbd "RET"))))
+
+
+;; in my version, this is not a pairing.
+;; not sure if it is in a future version since I reverted to marmalade
+;; Don't need c-comments in strings -- they frustrate filename globs
+;; (sp-pair "/*" nil :unless '(sp-in-string-p))
+
+;; Don't need quotes to pair next to words
+(sp-pair "\"" nil :unless '(sp-point-before-word-p sp-point-after-word-p))
+(sp-pair "'" nil :unless '(sp-point-before-word-p sp-point-after-word-p))
+
+
+;; todo, testout these mode specific settings from graphene.
+;; Ruby-specific pairs and handlers
+
+(eval-after-load "ruby"
+  '(require 'smartparens-ruby))
+
+;; Markdown
+(sp-local-pair '(markdown-mode gfm-mode) "*" "*"
+               :unless '(sp-in-string-p)
+               :actions '(insert wrap))
+
+;; Except in HTML
+(sp-local-pair 'html-mode "\"" nil :unless '(:rem sp-point-after-word-p))
+
+
+
+
+;; alias the new `flymake-report-status-slim' to
+;; `flymake-report-status'
+(defalias 'flymake-report-status 'flymake-report-status-slim)
+(defun flymake-report-status-slim (e-w &optional status)
+  "Show \"slim\" flymake status in mode line."
+  (when e-w
+    (setq flymake-mode-line-e-w e-w))
+  (when status
+    (setq flymake-mode-line-status status))
+  (let* ((mode-line " Φ"))
+    (when (> (length flymake-mode-line-e-w) 0)
+      (setq mode-line (concat mode-line ":" flymake-mode-line-e-w)))
+    (setq mode-line (concat mode-line flymake-mode-line-status))
+    (setq flymake-mode-line mode-line)
+    (force-mode-line-update)))
+
+
+
+
+;; this seems like it could be useful, but I havent been using it, so disabled
+;; from http://www.emacswiki.org/emacs/TransposeWindows
+(setq swapping-buffer nil)
+(setq swapping-window nil)
+(defun swap-buffers-in-windows ()
+  "Swap buffers between two windows"
+  (interactive)
+  (if (and swapping-window
+           swapping-buffer)
+      (let ((this-buffer (current-buffer))
+            (this-window (selected-window)))
+        (if (and (window-live-p swapping-window)
+                 (buffer-live-p swapping-buffer))
+            (progn (switch-to-buffer swapping-buffer)
+                   (select-window swapping-window)
+                   (switch-to-buffer this-buffer)
+                   (select-window this-window)
+                   (message "Swapped buffers."))
+          (message "Old buffer/window killed.  Aborting."))
+        (setq swapping-buffer nil)
+        (setq swapping-window nil))
+    (progn
+      (setq swapping-buffer (current-buffer))
+      (setq swapping-window (selected-window))
+      (message "Buffer and window marked for swapping."))))
+
+(global-set-key (kbd "C-M-d") 'swap-buffers-in-windows)