summaryrefslogtreecommitdiffstats
path: root/lisp/ravi-init-insertion.el
diff options
context:
space:
mode:
authorRavi R Kiran <aine.marina@gmail.com>2015-10-23 18:57:59 (GMT)
committerRavi R Kiran <aine.marina@gmail.com>2015-10-23 18:57:59 (GMT)
commitcd1924466152177ea06b17c843f256463c1b91b8 (patch)
treeaf90afe028e5e392f242a3ea36302aafe1c1769d /lisp/ravi-init-insertion.el
parent5561df232cfa49822f322196d98170f95aa1139e (diff)
parent74c319ef12dd3130f6afc17abc59404b59d601d1 (diff)
downloaddotemacs-cd1924466152177ea06b17c843f256463c1b91b8.zip
dotemacs-cd1924466152177ea06b17c843f256463c1b91b8.tar.gz
dotemacs-cd1924466152177ea06b17c843f256463c1b91b8.tar.bz2
Merge branch 'master' into rtags-attempt
* master: (139 commits) Add pdf-tools as a nicer replacement for doc-view Add pdf-tools submodule Fix maildir data with correct path Add desktop notifications for email Potential use for modes without repls Attach files more easily in mu Update to newest version of mu Please remove tooltips after a while, please ace-window gets confused when tooltips are present Sometimes the dispatch list does come in handy Pre-populate searches Succumb to muscle memory of control keys Remove ropemacs due to disuse Do not let company-quickhelp steal a global key Manage word navigation Use proper helm function to replace completing-read Electric operators on python mode Use which-key in preference to guide-key Navigate easier Simplify config with magit 2.1.0 ...
Diffstat (limited to 'lisp/ravi-init-insertion.el')
-rw-r--r--lisp/ravi-init-insertion.el155
1 files changed, 155 insertions, 0 deletions
diff --git a/lisp/ravi-init-insertion.el b/lisp/ravi-init-insertion.el
new file mode 100644
index 0000000..e75c414
--- /dev/null
+++ b/lisp/ravi-init-insertion.el
@@ -0,0 +1,155 @@
+;;; ravi-init-insertion.el --- inserting text
+
+;; Copyright (C) 2013
+
+;; Author: <ravi@nero.lan>
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Automatic text insertion
+
+;;; Code:
+
+(require 'autoinsert)
+(auto-insert-mode)
+
+(use-package yasnippet
+ :init
+ (progn
+ (setq yas-snippet-dirs
+ `(,(ravi/emacs-file "snippets")
+ yas-installed-snippets-dir)
+ )
+ )
+ :config
+ (progn
+ (yas-global-mode 1)
+
+ ;; No dropdowns
+ (setq yas/prompt-functions '(yas/ido-prompt yas/completing-prompt))
+
+ ;; Wrap around region
+ (setq yas/wrap-around-region t)
+
+ ;; Automatically create throw-away snippets
+ (use-package auto-yasnippet
+ :bind (("C-<f4>" . aya-create)
+ ("<f4>" . aya-expand))
+ :ensure t)
+ )
+ :ensure t
+ :diminish yas-minor-mode
+ )
+
+;; Default completion (some day via "M-/")
+(require 'hippie-exp)
+(setq hippie-expand-try-functions-list
+ '(yas/hippie-try-expand
+ try-expand-dabbrev
+ try-expand-dabbrev-all-buffers
+ try-expand-dabbrev-from-kill
+ try-complete-file-name-partially
+ try-complete-file-name
+ try-expand-all-abbrevs
+ )
+ )
+
+(use-package company
+ :init
+ (progn
+ (add-hook 'after-init-hook 'global-company-mode))
+ :config
+ (progn
+ (setq company-tooltip-flip-when-above t
+ company-idle-delay 0.1
+ company-show-numbers t
+ company-tooltip-align-annotations t
+ company-require-match nil
+ company-minimum-prefix-length 2
+ company-occurrence-weight-function 'company-occurrence-prefer-any-closest
+ company-dabbrev-downcase nil)
+ (defun ravi/complete-or-indent ()
+ (interactive)
+ (if (company-manual-begin)
+ (company-complete-common)
+ (indent-according-to-mode)))
+ (bind-key "\t" 'ravi/complete-or-indent)
+
+ (bind-keys :map company-active-map
+ ("C-n" . company-select-next)
+ ("C-p" . company-select-previous)
+ ;; Swap filter and search since filter is more useful
+ ("C-s" . company-filter-candidates)
+ ("C-M-s" . company-search-candidates))
+ (bind-keys :map company-search-map
+ ("C-n" . company-select-next)
+ ("C-p" . company-select-previous))
+
+ (use-package company-c-headers
+ :init
+ (progn
+ (add-to-list 'company-backends 'company-c-headers))
+ :config
+ (progn
+ (defun ravi/get-default-include-paths ()
+ (let* ((gcc-out (shell-command-to-string "g++ -E -x c++ - -v < /dev/null"))
+ (gcc-list-match (string-match "#include <...> search starts here:\n\\(.*\\(?:\n.*\\)*?\\)End of search list.\n" gcc-out))
+ (combined-list (match-string 1 gcc-out))
+ ;; Need the following rigamarole to handle paths with spaces in them
+ (path-list-with-spaces (and combined-list (split-string combined-list "\n" t)))
+ (path-list (and path-list-with-spaces (mapcar 's-trim-left path-list-with-spaces))))
+ path-list))
+ (mapc (lambda (dir) (add-to-list 'company-c-headers-path-system dir)) (ravi/get-default-include-paths))
+ )
+ :ensure t)
+
+ (use-package company-quickhelp
+ :config
+ (progn
+ (company-quickhelp-mode 1)
+ ;; Enable company-quickhelp only when company-mode is active
+ (unbind-key "M-h" company-quickhelp-mode-map)
+ (bind-key "M-h" 'company-quickhelp-manual-begin company-active-map))
+ :ensure t)
+
+ (use-package company-statistics
+ :init
+ (setq company-statistics-file (expand-file-name "company-statistics-cache.el"
+ (ravi/emacs-file "past")))
+ :config
+ (progn
+ (company-statistics-mode))
+ :ensure t)
+
+ ;; Get rid of company-semantic as it interferes with clang-based backends
+ (setq company-backends (delete 'company-semantic company-backends))
+ ;; Get rid of company-clang since it is too noisy at this point
+ (setq company-backends (delete 'company-clang company-backends))
+
+ (require 'company-yasnippet)
+ (defun ravi/company-to-yasnippet ()
+ (interactive)
+ (company-abort)
+ (call-interactively 'company-yasnippet))
+ (bind-key "<backtab>" 'ravi/company-to-yasnippet company-active-map)
+ (bind-key "<backtab>" 'company-yasnippet))
+
+ :diminish company-mode
+ :ensure t)
+
+(provide 'ravi-init-insertion)
+;;; ravi-init-insertion.el ends here