Add company completion for executable in PATH. Enable company for Makefile and progmodes.
--- a/.emacs-my Thu Jan 26 17:33:34 2017 +0200
+++ b/.emacs-my Thu Jan 26 20:01:50 2017 +0200
@@ -1126,6 +1126,23 @@
(when (featurep 'company)
(push #'my/company-filter-out-numbers company-transformers))
+(defun company-executable (command &optional arg &rest ignored)
+ "Company completion for executable in PATH."
+ (interactive (list 'interactive))
+ (cl-case command
+ (interactive (company-begin-backend 'company-executable))
+ (prefix (thing-at-point 'filename))
+ (candidates (locate-file-completion-table exec-path exec-suffixes (thing-at-point 'filename) 'identity t))))
+
+(defun my/company-text-setup ()
+ (setq-local company-backends '((company-dabbrev company-files)))
+ (company-mode 1))
+
+(defun my/company-code-setup ()
+ (setq-local company-dabbrev-code-other-buffers 'code)
+ (setq-local company-backends '((company-capf company-dabbrev-code company-files)))
+ (company-mode 1))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "bookmark")
@@ -2339,6 +2356,9 @@
(mapc (lambda (mode) (add-hook (my-mode2hook mode) #'hs-minor-mode))
'(c-mode c++-mode java-mode js-mode lisp-mode emacs-lisp-mode))
+(when (featurep 'company)
+ (add-hook 'prog-mode-hook #'my/company-code-setup))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "diff, patch, ediff, emerge")
@@ -2703,6 +2723,20 @@
(add-to-list 'auto-mode-alist '("\\(Makefile\\|Makefile\\..+\\)\\'" . makefile-gmake-mode) t)
+(defun my/makefile-setup ()
+ (add-hook 'completion-at-point-functions 'comint-filename-completion nil t))
+
+(add-hook 'makefile-mode-hook #'my/makefile-setup)
+
+(defun my/makefile-company-setup ()
+ "Limit search for symbols to Makefiles."
+ (setq-local company-dabbrev-code-other-buffers t)
+ (setq-local company-backends '((company-capf company-dabbrev-code company-files company-executable)))
+ (company-mode 1))
+
+(when (featurep 'company)
+ (add-hook 'makefile-mode-hook #'my/makefile-company-setup))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "asm, assembler")
@@ -3373,10 +3407,8 @@
(add-to-list 'auto-mode-alist '("\\.cygport\\'" . shell-script-mode))
(defun my/sh-company-setup ()
- (make-local-variable 'company-backends)
- (setq company-backends '((company-capf company-files company-dabbrev-code)))
- (make-local-variable 'company-dabbrev-code-other-buffers)
- (setq company-dabbrev-code-other-buffers t)
+ (setq-local company-backends '((company-capf company-files company-dabbrev-code)))
+ (setq-local company-dabbrev-code-other-buffers t)
(company-mode 1))
(when (featurep 'company)