From 95b5ab7971b50212144d8201e9df1d7644218328 Mon Sep 17 00:00:00 2001 From: Julien Palard Date: Sat, 23 Jul 2016 13:07:07 +0200 Subject: [PATCH] Merge .emacs --- .emacs | 222 ++++++++++++++++++++++++--------------------------------- 1 file changed, 93 insertions(+), 129 deletions(-) diff --git a/.emacs b/.emacs index 8a7cd8c..1ab5d37 100644 --- a/.emacs +++ b/.emacs @@ -1,4 +1,7 @@ -;; +;;; package -- julien + +;;; Commentary: + ;; .emacs for conf in /home/mandark ;; ;; Made by Palard Julien @@ -8,25 +11,41 @@ ;; ;;; Code: + (setq user-full-name "Julien Palard") (setq user-mail-address "julien@palard.fr") -(eval-when-compile (require 'cl)) +(when (>= emacs-major-version 24) + (require 'package) + (package-initialize) + (defvar package-list) + (setq package-list '(ac-php company company-jedi flycheck jedi jedi-core php-mode geben)) + (add-to-list 'package-archives + '("melpa-stable" . "http://melpa-stable.milkbox.net/packages/") t) + (add-to-list 'package-archives + '("marmalade" . "http://marmalade-repo.org/packages/") t) + (unless package-archive-contents + (package-refresh-contents)) + (dolist (package package-list) + (unless (package-installed-p package) + (package-refresh-contents) + (package-install package))) + ) -(defun load-file-if-exists (file) - "Load a file only if it exists." - (if (file-exists-p file) - (load-file file))) +(require 'ido) +(ido-mode t) -;; Disable all version control backends (Start faster if don't use them) : +;; Disable all version control backends (Start faster): (setq vc-handled-backends ()) -;; Disable transient mark mode, I don't like it : +;; Disable transient mark mode, I don't like it: (transient-mark-mode nil) +;; PHP (autoload 'php-mode "php-mode" "Mode for editing PHP source files") +(add-hook 'php-mode-hook 'php-enable-psr2-coding-style) -;; Never use tabs to indent : +;; Coding style (setq-default indent-tabs-mode nil) (setq-default tab-width 4) (setq-default py-indent-offset 4) @@ -41,7 +60,6 @@ (setq auto-mode-alist (cons '("\\.php" . php-mode) auto-mode-alist)) (setq inhibit-startup-message t) -(setq european-calendar-style t) (global-font-lock-mode t) (column-number-mode t) @@ -53,20 +71,34 @@ (global-set-key "\M-p" 'backward-paragraph) (global-set-key "\C-xrv" 'list-registers) (global-set-key (kbd "M-h") 'backward-kill-word) +(global-set-key (read-kbd-macro "C-M-[") 'shrink-window-horizontally) +(global-set-key (read-kbd-macro "C-M-]") 'enlarge-window-horizontally) +(global-set-key [f12] 'iwb) +(global-set-key [left] 'windmove-left) +(global-set-key [right] 'windmove-right) +(global-set-key [up] 'windmove-up) +(global-set-key [down] 'windmove-down) +(global-set-key "\C-x\M-%" 'query-replace-regexp) ;; As C-M-% is ~impossible to type in a terminal emulator: + +;; (setq hippie-expand-try-functions-list +;; '(try-complete-file-name-partially +;; try-complete-file-name +;; try-expand-all-abbrevs +;; try-expand-list +;; try-expand-line +;; try-expand-dabbrev +;; try-expand-dabbrev-all-buffers +;; try-expand-dabbrev-from-kill) +;; ) +;; (global-set-key "\M-/" 'hippie-expand) -(add-to-list 'load-path "~/.emacs.d/geben-0.26") -(add-to-list 'load-path "~/.emacs.d/geben-0.26/tree-widget") (autoload 'geben "geben" "PHP Debugger on Emacs" t) -(require 'footnote) -(add-hook 'message-mode-hook 'footnote-mode) (show-paren-mode t) (add-hook 'write-file-hooks 'delete-trailing-whitespace) (put 'upcase-region 'disabled nil) -;; ========== Place Backup Files in Specific Directory ========== - ;; Enable backup files. (setq make-backup-files t) @@ -76,113 +108,38 @@ ;; Save all backup file in this directory. (setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/")))) -(global-set-key (read-kbd-macro "C-M-[") 'shrink-window-horizontally) -(global-set-key (read-kbd-macro "C-M-]") 'enlarge-window-horizontally) - (fset 'yes-or-no-p 'y-or-n-p) -(global-set-key "\M-/" 'hippie-expand) -(setq hippie-expand-try-functions-list - '(try-complete-file-name-partially - try-complete-file-name - try-expand-all-abbrevs - try-expand-list - try-expand-line - try-expand-dabbrev - try-expand-dabbrev-all-buffers - try-expand-dabbrev-from-kill) - ) - (setq-default truncate-partial-width-windows nil) (setq-default delete-old-versions t) -;; /* -;; ** Eeple Indent Style -;; ** - Based on the BSD Allman Style, but with an indent of 4 instead of 8. -;; ** - Tab size is set to 4, so each 4 spaces are a tab -;; ** - Opening AND Closing Bracket have to be on the same column -;; ** - -;; ** -;; */ -;; int_main(int_ac,_char_**av) -;; { -;; --->if_(ac_==_ac) -;; --->{ -;; --->--->ac_=_ac; -;; --->} -;; --->else -;; --->{ -;; --->--->av_=_av; -;; --->} -;; } - (defun eeple-indent-style () + "Eeple Indent Style. + + - Based on the BSD Allman Style, but with an indent of 4 instead of 8. + - Tab size is set to 4, so each 4 spaces are a tab + - Opening AND Closing Bracket have to be on the same column" (interactive) (c-set-style "bsd") (c-set-offset 'case-label 4) (setq c-basic-offset 4)) -(add-hook 'php-mode-hook 'eeple-indent-style) (add-hook 'c-mode-hook 'eeple-indent-style) (menu-bar-mode -1) -(setq font-lock-maximum-size nil) - -(load-file-if-exists "~/.emacs.d/rcirc-julien.el") (defun iwb () - "indent whole buffer" + "Indent whole buffer." (interactive) (delete-trailing-whitespace) (indent-region (point-min) (point-max) nil) (untabify (point-min) (point-max))) -(global-set-key [f12] 'iwb) -(global-set-key [left] 'windmove-left) -(global-set-key [right] 'windmove-right) -(global-set-key [up] 'windmove-up) -(global-set-key [down] 'windmove-down) - -;; This one causes by IRC to bug with double quotes: -;; ;; Highlight 80th column -;; (require 'whitespace) -;; (setq whitespace-style '(face empty tabs lines-tail trailing)) -;; (global-whitespace-mode t) - -(defun konix/find-file-hook () - (if (and - (string-match "^\\(.+\\):\\([0-9]+\\)$" buffer-file-name) - (not - (file-exists-p buffer-file-name))) - ;; the given file does not exist and is of the form file_name:number, I - ;; most likely wants to open file_name at line number - (progn - (let ( - (old_buffer (current-buffer)) - (file_name (match-string-no-properties 1 buffer-file-name)) - (line (match-string-no-properties 2 buffer-file-name)) - ) - (if (file-exists-p file_name) - (progn - (find-file file_name) - (goto-line (string-to-int line)) - (kill-buffer old_buffer) - nil) - nil))) - nil)) -(add-to-list 'find-file-hook 'konix/find-file-hook) - -;; As C-M-% is almost impossible to type in a terminal emulator: -(global-set-key "\C-x\M-%" 'query-replace-regexp) - -(when (>= emacs-major-version 24) - (require 'package) - (package-initialize) - (add-to-list 'package-archives - '("melpa-stable" . "http://melpa-stable.milkbox.net/packages/") t) - - ) +;; Highlight 80th column +(require 'whitespace) +(setq whitespace-style '(face empty tabs lines-tail trailing)) +(global-whitespace-mode t) ;; hex color (defvar hexcolour-keywords @@ -209,14 +166,15 @@ (add-hook 'css-mode-hook 'hexcolour-add-to-font-lock) (add-hook 'sass-mode-hook 'hexcolour-add-to-font-lock) -(icomplete-mode 99) - ;; pip install flake8 ;; pip install pylint (add-hook 'after-init-hook #'global-flycheck-mode) + (require 'flycheck) (flycheck-add-next-checker 'python-flake8 'python-pylint) -(setq flycheck-phpcs-standard "Shape") +(setq flycheck-phpcs-standard "/home/julien/www/shape/config/static/phpcs_shape_ruleset.xml") +(setq flycheck-phpmd-rulesets "/home/julien/www/shape/config/static/phpmd_shape_ruleset.xml") +(setq flycheck-jscsrc "/home/julien/www/shape/.jscsrc") (add-hook 'python-mode-hook 'jedi:setup) @@ -249,33 +207,39 @@ (add-to-list 'company-backends 'company-jedi) (add-hook 'after-init-hook 'global-company-mode) -(add-hook 'php-mode-hook - (lambda () - (add-to-list 'company-backends 'company-my-php-backend))) +(add-hook 'php-mode-hook '(lambda () + (auto-complete-mode t) + (require 'ac-php) + (setq ac-sources '(ac-source-php ) ) + (yas-global-mode 1) + + (define-key php-mode-map (kbd "C-]") 'ac-php-find-symbol-at-point) ;goto define + )) -(defun company-my-php-backend (command &optional arg &rest ignored) - (case command - (prefix (and (eq major-mode 'php-mode) - (company-grab-symbol))) - (sorted t) - (candidates (all-completions - arg - (if (and (boundp 'my-php-symbol-hash) - my-php-symbol-hash) - my-php-symbol-hash - - (with-temp-buffer - (call-process-shell-command "php -r '$all=get_defined_functions();foreach ($all[\"internal\"] as $fun) { echo $fun . \";\";};'" - nil t) - (goto-char (point-min)) - (let ((hash (make-hash-table))) - (while (re-search-forward "\\([^;]+\\);" (point-max) t) - (puthash (match-string 1) t hash)) - (setq my-php-symbol-hash hash)))))))) - - -(require 'weechat) +(defun konix/find-file-hook () + "Permits file opening with line suffix like foo.py:21." + (if (and + (string-match "^\\(.+\\):\\([0-9]+\\)$" buffer-file-name) + (not + (file-exists-p buffer-file-name))) + ;; the given file does not exist and is of the form file_name:number, I + ;; most likely wants to open file_name at line number + (progn + (let ( + (old_buffer (current-buffer)) + (file_name (match-string-no-properties 1 buffer-file-name)) + (line (match-string-no-properties 2 buffer-file-name)) + ) + (if (file-exists-p file_name) + (progn + (find-file file_name) + (forward-line (string-to-number line)) + (kill-buffer old_buffer) + nil) + nil))) + nil)) +(add-to-list 'find-file-hook 'konix/find-file-hook) (provide `.emacs) ;;; .emacs ends here