From: Ian Kelling Date: Sun, 7 Jul 2024 20:04:09 +0000 (-0400) Subject: replace readline-complete with company, it is better maintained X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=70bd503c814a90c179813ff802a3a8dce11263cb;p=dot-emacs replace readline-complete with company, it is better maintained --- diff --git a/init.el b/init.el index 5ba7c9a..0b7df73 100644 --- a/init.el +++ b/init.el @@ -242,60 +242,15 @@ ;;(load custom-file 'noerror) -;;; auto-complete - -;; 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 "") nil) -(define-key ac-completing-map (kbd "") nil) -(define-key ac-completing-map (kbd "") 'ac-expand) -(define-key ac-completing-map "\t" 'ac-complete) -;;(define-key ac-completing-map (kbd "") 'ac-complete) -(define-key ac-completing-map (kbd "TAB") 'ac-complete) - - -;;; auto-complete readline-complete +;;; shell mode stuff (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) ;; generally unnecessary, but why not (setq explicit-shell-file-name "bash") @@ -312,24 +267,18 @@ (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 "") 'auto-complete) - (define-key shell-mode-map (kbd "TAB") 'auto-complete) - )) +;; todo: consider if this is needed in company mode. +;; and we also set shift-return to ac-expand. +;; +;; (add-hook 'shell-mode-hook +;; (lambda () +;; ;;(define-key shell-mode-map (kbd "") '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 @@ -378,6 +327,10 @@ (set-process-coding-system proc decoding encoding)) proc)) +;;; auto-complete + +(add-hook 'after-init-hook 'global-company-mode) + ;;; auto save ;; todo: patch this so i can turn it off like my-as-off-local. @@ -1488,7 +1441,6 @@ Go to the next directory based on where the cursor is." ;; todo, this is causing error message on loading file, prolly not working ;;(flycheck-mode +1) - (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. @@ -2201,10 +2153,6 @@ modes like org-mode which have their own yank function." (global-set-key (kbd "\r") 'indent-new-comment-line) -;; don't use enter for autocomplete, we use tab or something -(define-key ac-completing-map (kbd "") nil) -(define-key ac-completing-map "\r" nil) - (add-hook 'org-mode-hook (lambda () ;; copied from org-mode, replace org-enter with org-enter-indent diff --git a/misc-disabled.el b/misc-disabled.el index 0a7c5b3..1830526 100644 --- a/misc-disabled.el +++ b/misc-disabled.el @@ -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 "") nil) +(define-key ac-completing-map (kbd "") nil) +(define-key ac-completing-map (kbd "") 'ac-expand) +(define-key ac-completing-map "\t" 'ac-complete) +;;(define-key ac-completing-map (kbd "") '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 "") '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 "") 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"