From e7eb1abaf51030de5fd8190c81f34b951ad65e73 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Wed, 10 Jan 2018 22:15:02 +0100 Subject: [PATCH] Primo import. Configurazione di emacs. --- .emacs | 419 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 419 insertions(+) create mode 100644 .emacs diff --git a/.emacs b/.emacs new file mode 100644 index 0000000..e251458 --- /dev/null +++ b/.emacs @@ -0,0 +1,419 @@ +(custom-set-faces + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(default ((t (:family "DejaVu Sans Mono" :foundry "unknown" :slant normal :weight normal :height 105 :width normal)))) + '(whitespace-newline ((t (:foreground "gray30")))) + '(whitespace-space ((t (:foreground "gray30")))) + '(whitespace-tab ((t (:foreground "gray30"))))) + +;; +(setq inhibit-startup-message t) + +(server-start) + +;; package manager +(require 'package) +(setq package-enable-at-startup nil) +(add-to-list 'package-archives + '("melpa" . "http://melpa.org/packages/")) + +(package-initialize) + +(unless (package-installed-p 'use-package) + (package-refresh-contents) + (package-install 'use-package)) + +;; path +(if (eq system-type 'windows-nt) +(progn (setenv "PATH" (concat ";C:/msys64/mingw64/bin;C:/msys64/usr/bin" (getenv "PATH"))) + (setq exec-path (append exec-path '("C:/msys64/mingw64/bin" + "C:/msys64/usr/bin"))) + (setq default-directory "c:/msys64/home/a.zagli/") +) +) + +;; generic +(blink-cursor-mode -1) +(column-number-mode t) +(tool-bar-mode -1) +(global-linum-mode 1) + +;; line numbers custom format +(defvar my-linum-format-string "%4d") + +(add-hook 'linum-before-numbering-hook 'my-linum-get-format-string) + +(defun my-linum-get-format-string () + (let* ((width (length (number-to-string + (count-lines (point-min) (point-max))))) + (format (concat "%" (number-to-string width) "d\u2502"))) + (setq my-linum-format-string format))) + +(setq linum-format 'my-linum-format) + +(defun my-linum-format (line-number) + (propertize (replace-regexp-in-string " " "\u2002" (format my-linum-format-string line-number)) 'face 'linum)) + +;; display column numbers +(column-number-mode 1) + +;; highlight current line +(global-hl-line-mode 1) +(set-face-background 'hl-line "gray24") +(set-face-foreground 'highlight nil) + +;; auto backup +(setq version-control t) +(setq vc-make-backup-files t) +(setq delete-old-versions t) +(setq auto-save-default nil) + +;; delete trailing whitespaces on saving +(defun my-delete-trailing-whitespace () + (when (not (eq major-mode 'diff-mode)) + (delete-trailing-whitespace))) +(add-hook 'before-save-hook #'my-delete-trailing-whitespace) + +;; ibuffer +(global-set-key (kbd "C-x C-b") 'ibuffer) + +;; overwrite selected text +(delete-selection-mode 1) + +;; horizontal split +(setq split-width-threshold nil) + +;; default frame size and position +(when window-system + (toggle-frame-maximized)) + +;; indentation +(setq-default tab-width 4) +(setq-default c-basic-offset 4) + +;; +(setq-default scroll-conservatively 1) + +;; show parentesis couple +(setq show-paren-mode t) +(setq show-paren-delay 0) +(show-paren-mode 1) + +;; whitespace +(global-whitespace-mode 1) +(setq whitespace-global-modes '(autoconf-mode c-mode c++-mode diff-mode emacs-lisp-mode lisp-interaction-mode makefile-automake-mode nxml-mode sh-mode)) +(setq whitespace-style (quote (face spaces tabs newline space-mark tab-mark newline-mark))) +(setq whitespace-display-mappings + '( + (space-mark 32 [183] [46]) + (newline-mark 10 [182 10]) + (tab-mark 9 [8594 9] [92 9]))) + +;; ediff +(setq ediff-split-window-function 'split-window-horizontally) +(winner-mode) +(add-hook 'ediff-after-quit-hook-internal 'winner-undo) +(setq ediff-window-setup-function 'ediff-setup-windows-plain) + +;; dired-x +;; omit dot files +(require 'dired-x) +(setq dired-omit-files "^\\...+$") +(add-hook 'dired-mode-hook (lambda () (dired-omit-mode 1))) +(setq dired-dwim-target 't) + +;; theme +(use-package doom-themes + :ensure t + :config + (load-theme 'doom-one t)) + +;; disable line numbers +(use-package linum-off + :ensure t + :config + (require 'linum-off) + (add-to-list 'linum-disabled-modes-list '(Speedbar))) + +;; spaceline +(use-package spaceline + :ensure t + :config + (require 'spaceline-config) + (spaceline-spacemacs-theme) + (setq spaceline-buffer-position-p 'nil) + (setq spaceline-hud-p 'nil)) + +;; autopair +(use-package autopair + :ensure t + :config + (require 'autopair) + (autopair-global-mode)) + +;; yasnippet +(use-package yasnippet + :ensure t + :config + (require 'yasnippet) + (yas-global-mode 1)) + +;; smart-tabs-mode +(use-package smart-tabs-mode + :ensure t + :config + (smart-tabs-insinuate 'c 'c++)) + +;; sr-speedbar +(use-package sr-speedbar + :ensure t + :config + (require 'sr-speedbar) + (setq sr-speedbar-right-side nil)) + +;; auto-complete-nxml +(use-package auto-complete-nxml + :ensure t + :config + (require 'auto-complete-nxml)) + +;; recentf +(use-package recentf + :ensure t + :config + (require 'recentf) + (recentf-mode 1) + (setq recentf-max-menu-items 25) + (global-set-key "\C-x\ \C-r" 'recentf-open-files) + (put 'upcase-region 'disabled nil)) + +;; diff-hl +(use-package diff-hl + :ensure t + :config + (global-diff-hl-mode) + (add-hook 'dired-mode-hook 'diff-hl-dired-mode)) + +;; ibuffer-vc +(use-package ibuffer-vc + :ensure t + :config + (add-hook 'ibuffer-hook + (lambda () + (ibuffer-vc-set-filter-groups-by-vc-root) + (unless (eq ibuffer-sorting-mode 'alphabetic) + (ibuffer-do-sort-by-alphabetic))))) + +;; C environment + +;; flycheck +(use-package flycheck + :ensure t + :config + (add-hook 'after-init-hook #'global-flycheck-mode) + (if (eq system-type 'windows-nt) + (add-hook 'c-mode-hook (lambda () (setq flycheck-gcc-include-path (list "C:\\msys64\\mingw64\\x86_64-w64-mingw32" + "C:\\msys64\\mingw64\\include" + "C:\\msys64\\mingw64\\include\\atk-1.0" + "C:\\msys64\\mingw64\\include\\gtk-3.0" + "C:\\msys64\\mingw64\\include\\cairo" + "C:\\msys64\\mingw64\\include\\pixman-1" + "C:\\msys64\\mingw64\\include\\pango-1.0" + "C:\\msys64\\mingw64\\include\\gdk-pixbuf-2.0" + "C:\\msys64\\mingw64\\include\\glib-2.0" + "C:\\msys64\\mingw64\\include\\libxml2" + "C:\\msys64\\mingw64\\include\\libpng16" + "C:\\msys64\\mingw64\\include\\freetype2" + "C:\\msys64\\mingw64\\include\\harfbuzz" + "C:\\msys64\\mingw64\\include\\libsoup-2.4" + "C:\\msys64\\mingw64\\include\\libsoup-gnome-2.4" + "C:\\msys64\\mingw64\\lib\\glib-2.0\\include" + "C:\\msys64\\mingw64\\include\\libgda-5.0")))) + + (add-hook 'c-mode-hook (lambda () (setq flycheck-gcc-include-path (list "/usr/lib/x86_64-linux-gnu/glib-2.0/include" + "/usr/include/atk-1.0" + "/usr/include/at-spi-2.0" + "/usr/include/at-spi2-atk/2.0" + "/usr/include/cairo" + "/usr/include/dbus-1.0" + "/usr/include/evolution-data-server" + "/usr/include/gdk-pixbuf-2.0" + "/usr/include/gio-unix-2.0" + "/usr/include/glib-2.0" + "/usr/include/gnome-vfs-2.0" + "/usr/include/gobject-introspection-1.0" + "/usr/include/gtk-3.0" + "/usr/include/freetype2" + "/usr/include/harfbuzz" + "/usr/include/libpeas-1.0" + "/usr/include/libpng16" + "/usr/include/libsoup-2.4" + "/usr/include/libsoup-gnome-2.4" + "/usr/include/libxml2" + "/usr/include/nspr" + "/usr/include/nss" + "/usr/include/pixman-1" + "/usr/include/pango-1.0" + "/usr/include/poppler" + "/usr/include/poppler/glib" + "/usr/local/include" + "/usr/local/include/libgda-5.0" + "/usr/local/include/libgda-5.0/libgda" + "/usr/include/postgresql" + "/opt/devenv/include" + "/opt/devenv/include/libgda-5.0" + "/opt/devenv/include/libgda-5.0/libgda" + )))) + ) + (setq-default flycheck-disabled-checkers '(c/c++-clang))) + +;; autocomplete +(semantic-mode 1) +(defun my-semantic-hook () + (if (eq system-type 'windows-nt) + (progn (semantic-add-system-include "C:/msys64/mingw32/include/glib-2.0") + (semantic-add-system-include "C:/msys64/mingw32/include/gtk-3.0") + (semantic-add-system-include "C:/msys64/mingw32/include/atk-1.0") + (semantic-add-system-include "C:/msys64/mingw32/include/libxml2") + (semantic-add-system-include "C:/msys64/mingw32/include/libgda-5.0") + (semantic-add-system-include "C:/msys64/mingw32/include/cairo") + (semantic-add-system-include "C:/msys64/mingw32/include/libpng16") + (semantic-add-system-include "C:/msys64/mingw32/include/libsoup-2.4") + (semantic-add-system-include "C:/msys64/mingw32/include/libsoup-gnome-2.4") + (semantic-add-system-include "C:/msys64/mingw32/lib/glib-2.0/include")) + + (progn (semantic-add-system-include "/usr/lib/x86_64-linux-gnu/glib-2.0/include") + (semantic-add-system-include "/usr/include/") + (semantic-add-system-include "/usr/include/atk-1.0") + (semantic-add-system-include "/usr/include/at-spi-2.0") + (semantic-add-system-include "/usr/include/at-spi2-atk/2.0") + (semantic-add-system-include "/usr/include/cairo") + (semantic-add-system-include "/usr/include/dbus-1.0") + (semantic-add-system-include "/usr/include/evolution-data-server") + (semantic-add-system-include "/usr/include/gdk-pixbuf-2.0") + (semantic-add-system-include "/usr/include/gio-unix-2.0") + (semantic-add-system-include "/usr/include/glib-2.0") + (semantic-add-system-include "/usr/include/gtk-3.0") + (semantic-add-system-include "/usr/include/gnome-vfs-2.0") + (semantic-add-system-include "/usr/include/gobject-introspection-1.0") + (semantic-add-system-include "/usr/include/freetype2") + (semantic-add-system-include "/usr/include/harfbuzz") + (semantic-add-system-include "/usr/include/libpeas-1.0") + (semantic-add-system-include "/usr/include/libpng16") + (semantic-add-system-include "/usr/include/libsoup-2.4") + (semantic-add-system-include "/usr/include/libsoup-gnome-2.4") + (semantic-add-system-include "/usr/include/libxml2") + (semantic-add-system-include "/usr/include/nspr") + (semantic-add-system-include "/usr/include/nss") + (semantic-add-system-include "/usr/include/pixman-1") + (semantic-add-system-include "/usr/include/pango-1.0") + (semantic-add-system-include "/usr/include/poppler") + (semantic-add-system-include "/usr/include/poppler/glib") + (semantic-add-system-include "/usr/local/include") + (semantic-add-system-include "/usr/local/include/libgda-5.0") + (semantic-add-system-include "/usr/local/include/libgda-5.0/libgda") + (semantic-add-system-include "/opt/devenv/include") + (semantic-add-system-include "/opt/devenv/include/libgda-5.0") + (semantic-add-system-include "/opt/devenv/include/libgda-5.0/libgda")) + ) +) +(add-hook 'semantic-init-hooks 'my-semantic-hook) +(global-semantic-idle-summary-mode 1) +(global-semantic-idle-scheduler-mode 1) +(add-to-list 'semantic-default-submodes 'global-semantic-stickyfunc-mode) +(defun my:add-semantic-to-autocomplete() + (add-to-list 'ac-sources 'ac-source-semantic-raw) + (setq-default ac-auto-start 4) + (setq-default ac-use-quick-help nil) + (setq-default ac-ignore-case nil) + (setq-default ac-stop-flymake-on-completing t) +) +(add-hook 'c-mode-common-hook 'my:add-semantic-to-autocomplete) + +(use-package auto-complete-c-headers + :ensure t) + +(require 'auto-complete-config) +(ac-config-default) +(defun my:ac-c-header-init () + (require 'auto-complete-c-headers) + (add-to-list 'ac-sources 'ac-source-c-headers) + (if (eq system-type 'windows-nt) + (progn (add-to-list 'achead:include-directories '"C:/msys64/mingw32/i686-w64-mingw32/include") + (add-to-list 'achead:include-directories '"C:/msys64/mingw32/include") + (add-to-list 'achead:include-directories '"C:/msys64/mingw32/include/glib-2.0") + (add-to-list 'achead:include-directories '"C:/msys64/mingw32/include/gtk-3.0") + (add-to-list 'achead:include-directories '"C:/msys64/mingw32/include/atk-1.0") + (add-to-list 'achead:include-directories '"C:/msys64/mingw32/include/libxml2") + (add-to-list 'achead:include-directories '"C:/msys64/mingw32/include/libgda-5.0") + (add-to-list 'achead:include-directories '"C:/msys64/mingw32/include/cairo") + (add-to-list 'achead:include-directories '"C:/msys64/mingw32/include/libpng16") + (add-to-list 'achead:include-directories '"C:/msys64/mingw32/include/libsoup-2.4") + (add-to-list 'achead:include-directories '"C:/msys64/mingw32/include/libsoup-gnome-2.4") + (add-to-list 'achead:include-directories '"C:/msys64/mingw32/lib/glib-2.0/include")) + + (progn (add-to-list 'achead:include-directories '"/usr/lib/x86_64-linux-gnu/glib-2.0/include") + (add-to-list 'achead:include-directories '"/usr/include") + (add-to-list 'achead:include-directories '"/usr/include/atk-1.0") + (add-to-list 'achead:include-directories '"/usr/include/at-spi-2.0") + (add-to-list 'achead:include-directories '"/usr/include/at-spi2-atk/2.0") + (add-to-list 'achead:include-directories '"/usr/include/cairo") + (add-to-list 'achead:include-directories '"/usr/include/dbus-1.0") + (add-to-list 'achead:include-directories '"/usr/include/evolution-data-server") + (add-to-list 'achead:include-directories '"/usr/include/freetype2") + (add-to-list 'achead:include-directories '"/usr/include/gdk-pixbuf-2.0") + (add-to-list 'achead:include-directories '"/usr/include/gio-unix-2.0") + (add-to-list 'achead:include-directories '"/usr/include/glib-2.0") + (add-to-list 'achead:include-directories '"/usr/include/gtk-3.0") + (add-to-list 'achead:include-directories '"/usr/include/gnome-vfs-2.0") + (add-to-list 'achead:include-directories '"/usr/include/gobject-introspection-1.0") + (add-to-list 'achead:include-directories '"/usr/include/harfbuzz") + (add-to-list 'achead:include-directories '"/usr/include/libxml2") + (add-to-list 'achead:include-directories '"/usr/include/libpeas-1.0") + (add-to-list 'achead:include-directories '"/usr/include/libpng16") + (add-to-list 'achead:include-directories '"/usr/include/libsoup-2.4") + (add-to-list 'achead:include-directories '"/usr/include/libsoup-gnome-2.4") + (add-to-list 'achead:include-directories '"/usr/include/nspr") + (add-to-list 'achead:include-directories '"/usr/include/nss") + (add-to-list 'achead:include-directories '"/usr/include/pango-1.0") + (add-to-list 'achead:include-directories '"/usr/include/pixman-1") + (add-to-list 'achead:include-directories '"/usr/include/poppler") + (add-to-list 'achead:include-directories '"/usr/include/poppler/glib") + (add-to-list 'achead:include-directories '"/usr/local/include") + (add-to-list 'achead:include-directories '"/usr/local/include/libgda-5.0") + (add-to-list 'achead:include-directories '"/usr/local/include/libgda-5.0/libgda") + (add-to-list 'achead:include-directories '"/opt/devenv/include") + (add-to-list 'achead:include-directories '"/opt/devenv/include/libgda-5.0") + (add-to-list 'achead:include-directories '"/opt/devenv/include/libgda-5.0/libgda")) + ) +) +(add-hook 'c++-mode-hook 'my:ac-c-header-init) +(add-hook 'c-mode-hook 'my:ac-c-header-init) + +;; function-args +(use-package function-args + :ensure t + :config + (require 'function-args) + (fa-config-default)) + +(require 'compile) +(setq compilation-directory-matcher '("\\(?:Entering\\|Leavin\\(g\\)\\|ingresso nella\\|uscita dalla\\) directory [`'\"]\\(.+\\)['\"]$" (2 . 1))) +(setq compilation-scroll-output "first-error") + + +(projectile-mode) + + +;; code folding +(add-hook 'c-mode-common-hook 'hs-minor-mode) +(custom-set-variables + ;; custom-set-variables was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(package-selected-packages + (quote + (projectile ibuffer-vc auto-complete-nxml linum-off use-package try sr-speedbar spaceline pkgbuild-mode magit function-args flycheck-tip elfeed diff-hl company autopair auto-complete-c-headers ac-php ac-html)))) -- 2.49.0