From 744fe00eda904d62cfe128a47ad76cc5e75880ce Mon Sep 17 00:00:00 2001 From: Alexandre Tuleu Date: Tue, 18 Jan 2022 19:38:06 +0100 Subject: [PATCH] Makes c-mode works ??? but very slow --- .emacs | 66 +++++++++++++++++++++++++--------------------------------- 1 file changed, 28 insertions(+), 38 deletions(-) diff --git a/.emacs b/.emacs index e92ccf4..df1b195 100644 --- a/.emacs +++ b/.emacs @@ -1,3 +1,4 @@ +;(toggle-debug-on-error) (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3") (custom-set-variables ;; custom-set-variables was added by Custom. @@ -86,25 +87,6 @@ indent-relative-maybe)) (setq indent-tabs-mode nil)) ad-do-it)) - (defmacro smart-tabs-advice (function offset) - `(progn - (defvaralias ',offset 'tab-width) - (defadvice ,function (around smart-tabs activate) - (cond - (indent-tabs-mode - (save-excursion - (beginning-of-line) - (while (looking-at "\t*\\( +\\)\t+") - (replace-match "" nil nil nil 1))) - (setq tab-width tab-width) - (let ((tab-width fill-column) - (,offset fill-column) - (wstart (window-start))) - (unwind-protect - (progn ad-do-it) - (set-window-start (selected-window) wstart)))) - (t - ad-do-it))))) (smart-tabs-advice c-indent-line c-basic-offset) (smart-tabs-advice c-indent-region c-basic-offset) (smart-tabs-add-language-support cmake cmake-mode-hook @@ -138,9 +120,6 @@ (smart-tabs-insinuate 'c 'javascript 'c++ 'cmake 'nxml 'protobuf 'html 'glsl) ) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; magit -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (use-package magit :commands (magit-status) @@ -153,46 +132,49 @@ (global-company-mode t) ) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; CMake -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - (use-package cmake-mode :config (setq cmake-tab-width 4) ) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Company -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(use-package company-irony + :after (company irony) +; :config +; (add-to-list 'company-backends 'company-irony) + ) + +(use-package company-irony-c-headers + :after (company irony) +; :config +; (add-to-list 'company-backends 'company-irony-c-headers) + ) (use-package irony - :hook (c-mode-common) :config (push 'glsl-mode irony-supported-major-modes) (push 'protobuf-mode irony-supported-major-modes) (push 'opencl-mode irony-supported-major-modes) - (company-irony-setup-begin-commands) - (irony-cdb-autosetup-compile-options) - '(add-to-list - 'company-backends - '(company-irony-c-headers company-irony company-yasnippet)) - ) (use-package srefactor - :hook (c-mode-common) :bind (:map c-mode-map ("M-RET" . srefactor-refactor-at-point) :map c++-mode-map ("M-RET" . srefactor-refactor-at-point)) ) + (use-package yasnippet - :hook (c-mode-common) + :after (company) :bind ( :map yas-minor-mode-map ("TAB" . nil) ) + :config + ; (add-to-list 'company-backends 'company-yasnippet) + ) + +(use-package yasnippet-snippets + :after (yasnippet) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -224,7 +206,15 @@ header" (require 'compile) (global-set-key (kbd "C-x f") 'find-file-at-point) (c-set-offset 'inextern-lang 0) + (eval-after-load 'company + '(add-to-list + 'company-backends + '(company-irony company-irony-c-headers company-yasnippet))) (smart-tabs-mode) + (irony-mode) + (yas-minor-mode-on) + (company-irony-setup-begin-commands) + (irony-cdb-autosetup-compile-options) ) (add-hook 'c-mode-common-hook 'my-c-common-hook)