diff --git a/.bashrc b/.bashrc index d683c95..cb98ca1 100755 --- a/.bashrc +++ b/.bashrc @@ -8,6 +8,9 @@ umask 022 # If not running interactively, don't do anything [ -z "$PS1" ] && return +export LC_ALL=en_US.utf8 +export TERM=xterm-256color + # don't put duplicate lines in the history. See bash(1) for more options # don't overwrite GNU Midnight Commander's setting of `ignorespace'. export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 1be8009..8c53ffe 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -31,7 +31,8 @@ ;; No menu, scrollbar, display line and column (menu-bar-mode -1) (tool-bar-mode -1) -(scroll-bar-mode -1) +(when (display-graphic-p) + (scroll-bar-mode -1)) (column-number-mode t) (line-number-mode t) @@ -202,7 +203,7 @@ (setq-default fill-column 95) (setq-local whitespace-line-column 95) (visual-line-mode t) - (visual-fill-column-mode t) +;; (visual-fill-column-mode t) (define-key visual-line-mode-map [remap kill-line] nil) (whitespace-mode t)) @@ -326,6 +327,13 @@ ;; (add-to-list 'mmm-mode-ext-classes-alist '(html-mode nil embedded-css)) ;; (add-to-list 'mmm-mode-ext-classes-alist '(html-mode nil fancy-html))) +;; Go +(require 'go-template-mode) + +;; Dockers +(require 'dockerfile-mode) +(add-to-list 'auto-mode-alist '("Dockerfile\\'" . dockerfile-mode)) + ;; Term (setq explicit-shell-file-name "/bin/bash") diff --git a/.emacs.d/one-file-mode/dockerfile-mode.el b/.emacs.d/one-file-mode/dockerfile-mode.el new file mode 100644 index 0000000..0bd78ae --- /dev/null +++ b/.emacs.d/one-file-mode/dockerfile-mode.el @@ -0,0 +1,168 @@ +;;; dockerfile-mode.el --- Major mode for editing Docker's Dockerfiles + +;; Copyright (c) 2013 Spotify AB +;; +;; Licensed under the Apache License, Version 2.0 (the "License"); you may not +;; use this file except in compliance with the License. You may obtain a copy of +;; the License at +;; +;; http://www.apache.org/licenses/LICENSE-2.0 +;; +;; Unless required by applicable law or agreed to in writing, software +;; distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +;; WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +;; License for the specific language governing permissions and limitations under +;; the License. + +;;; Code: + +(require 'sh-script) +(require 'rx) + +(declare-function cygwin-convert-file-name-to-windows "cygw32.c" (file &optional absolute-p)) + +(defvar docker-image-name nil) + +(defgroup dockerfile nil + "dockerfile code editing commands for Emacs." + :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces) + :prefix "dockerfile-" + :group 'languages) + +(defcustom dockerfile-mode-hook nil + "*Hook called by `dockerfile-mode'." + :type 'hook + :group 'dockerfile) + +(defcustom dockerfile-use-sudo nil + "Runs docker builder command with sudo.") + +(defcustom dockerfile-build-args nil + "List of --build-arg to pass to docker build. + +Each element of the list will be passed as a separate + --build-arg to the docker build command." + :type '(repeat string) + :group 'dockerfile) + +(defvar dockerfile-font-lock-keywords + `(,(cons (rx (or line-start "onbuild ") + (group (or "from" "maintainer" "run" "cmd" "expose" "env" "arg" + "add" "copy" "entrypoint" "volume" "user" "workdir" "onbuild" + "label" "stopsignal")) + word-boundary) + font-lock-keyword-face) + ,@(sh-font-lock-keywords) + ,@(sh-font-lock-keywords-2) + ,@(sh-font-lock-keywords-1)) + "Default font-lock-keywords for `dockerfile mode'.") + +(defvar dockerfile-mode-map + (let ((map (make-sparse-keymap)) + (menu-map (make-sparse-keymap))) + (define-key map "\C-c\C-b" 'dockerfile-build-buffer) + (define-key map "\C-c\M-b" 'dockerfile-build-no-cache-buffer) + (define-key map "\C-c\C-z" 'dockerfile-test-function) + (define-key map "\C-c\C-c" 'comment-region) + (define-key map [menu-bar dockerfile-mode] (cons "Dockerfile" menu-map)) + (define-key menu-map [dfc] + '(menu-item "Comment Region" comment-region + :help "Comment Region")) + (define-key menu-map [dfb] + '(menu-item "Build" dockerfile-build-buffer + :help "Send the Dockerfile to docker build")) + (define-key menu-map [dfb] + '(menu-item "Build without cache" dockerfile-build-no-cache-buffer + :help "Send the Dockerfile to docker build without cache")) + map)) + +(defvar dockerfile-mode-syntax-table + (let ((table (make-syntax-table))) + (modify-syntax-entry ?# "<" table) + (modify-syntax-entry ?\n ">" table) + (modify-syntax-entry ?' "\"" table) + table) + "Syntax table for `dockerfile-mode'.") + +(define-abbrev-table 'dockerfile-mode-abbrev-table nil + "Abbrev table used while in `dockerfile-mode'.") + +(unless dockerfile-mode-abbrev-table + (define-abbrev-table 'dockerfile-mode-abbrev-table ())) + +(defun dockerfile-build-arg-string () + "Create a --build-arg string for each element in `dockerfile-build-args'." + (mapconcat (lambda (arg) (concat "--build-arg " "\"" arg "\"")) + dockerfile-build-args " ")) + +(defun standard-filename (file) + "Convert the file name to OS standard. +If in Cygwin environment, uses Cygwin specific function to convert the +file name. Otherwise, uses Emacs' standard conversion function." + (format "%s" (if (fboundp 'cygwin-convert-file-name-to-windows) + (s-replace "\\" "\\\\" (cygwin-convert-file-name-to-windows file)) + (convert-standard-filename file)))) + +;;;###autoload +(defun dockerfile-build-buffer (image-name) + "Build an image based upon the buffer" + (interactive + (if (null docker-image-name) + (list (read-string "image-name: " nil nil)) + (list docker-image-name))) + (save-buffer) + (if (stringp image-name) + (async-shell-command + (format "%sdocker build -t %s %s -f \"%s\" \"%s\"" + (if dockerfile-use-sudo "sudo " "") + image-name + (dockerfile-build-arg-string) + (standard-filename (buffer-file-name)) + (standard-filename (file-name-directory (buffer-file-name)))) + "*docker-build-output*") + (print "docker-image-name must be a string, consider surrounding it with double quotes"))) + +;;;###autoload +(defun dockerfile-build-no-cache-buffer (image-name) + "Build an image based upon the buffer without cache" + (interactive + (if (null docker-image-name) + (list (read-string "image-name: " nil nil)) + (list docker-image-name))) + (save-buffer) + (if (stringp image-name) + (async-shell-command + (format "%s docker build --no-cache -t %s %s -f \"%s\" \"%s\"" + (if dockerfile-use-sudo "sudo" "") + image-name + (dockerfile-build-arg-string) + (standard-filename (buffer-file-name)) + (standard-filename (file-name-directory (buffer-file-name)))) + "*docker-build-output*") + (print "docker-image-name must be a string, consider surrounding it with double quotes"))) + +;; Handle emacs < 24, which does not have prog-mode +(defalias 'dockerfile-parent-mode + (if (fboundp 'prog-mode) 'prog-mode 'fundamental-mode)) + +;;;###autoload +(define-derived-mode dockerfile-mode dockerfile-parent-mode "Dockerfile" + "A major mode to edit Dockerfiles. +\\{dockerfile-mode-map} +" + (set-syntax-table dockerfile-mode-syntax-table) + (set (make-local-variable 'require-final-newline) mode-require-final-newline) + (set (make-local-variable 'comment-start) "#") + (set (make-local-variable 'comment-end) "") + (set (make-local-variable 'comment-start-skip) "#+ *") + (set (make-local-variable 'parse-sexp-ignore-comments) t) + (set (make-local-variable 'font-lock-defaults) + '(dockerfile-font-lock-keywords nil t)) + (setq local-abbrev-table dockerfile-mode-abbrev-table)) + +;;;###autoload +(add-to-list 'auto-mode-alist '("Dockerfile.*\\'" . dockerfile-mode)) + +(provide 'dockerfile-mode) + +;;; dockerfile-mode.el ends here diff --git a/.emacs.d/one-file-mode/go-template-mode.el b/.emacs.d/one-file-mode/go-template-mode.el new file mode 100644 index 0000000..8083b8e --- /dev/null +++ b/.emacs.d/one-file-mode/go-template-mode.el @@ -0,0 +1,267 @@ +;;; go-template-mode.el --- Major mode for Go template language + +;;; Commentary: + +;; 1) Copy this file somewhere in your Emacs `load-path'. To see what +;; your `load-path' is, run inside emacs: C-h v load-path +;; +;; 2) Add the following to your .emacs file: +;; +;; (require 'go-template-mode) + +;;; Known Bugs: + +;; 1) Highlights all strings in the source file, including HTML attributes, +;; and does not properly highlight template actions inside these strings. + +(defvar go-template-mode-syntax-table + (let ((st (make-syntax-table))) + ;; Add _ to :word: character class + (modify-syntax-entry ?_ "w" st) + + ;; Operators (punctuation) + (modify-syntax-entry ?: "." st) + (modify-syntax-entry ?= "." st) + (modify-syntax-entry ?| "." st) + + ;; Strings and comments are font-locked separately. + (modify-syntax-entry ?\" "." st) + (modify-syntax-entry ?\' "." st) + (modify-syntax-entry ?` "." st) + (modify-syntax-entry ?\\ "." st) + + st) + "Syntax table for Go template mode.") + +(defvar go-template-mode-keywords + '("define" "else" "end" "if" "range" "template" "with") + "All keywords in the Go template language. Used for font locking.") + +(defvar go-template-mode-builtins + '("and" "html" "index" "js" "len" "not" "or" "print" "printf" "println" "urlquery") + "All builtin functions in the Go template language. Used for font locking.") + + +(defconst go-template-mode-pair-tag + (regexp-opt + '("a" "abbr" "acronym" "address" "applet" "area" "b" "bdo" + "big" "blockquote" "body" "button" "caption" "center" "cite" + "code" "col" "colgroup" "dd" "del" "dfn" "dif" "div" "dl" + "dt" "em" "fieldset" "font" "form" "frame" "frameset" "h1" + "header" "nav" "footer" "section" + "h2" "h3" "h4" "h5" "h6" "head" "html" "i" "iframe" "ins" + "kbd" "label" "legend" "li" "link" "map" "menu" "noframes" + "noscript" "object" "ol" "optgroup" "option" "p" "pre" "q" + "s" "samp" "script" "select" "small" "span" "strike" + "strong" "style" "sub" "sup" "table" "tbody" "td" "textarea" + "tfoot" "th" "thead" "title" "tr" "tt" "u" "ul" "var") + t)) +(defconst go-template-mode-standalone-tag + (regexp-opt + '("base" "br" "hr" "img" "input" "meta" "param") + t)) + +(defconst go-template-mode-font-lock-keywords + `((go-template-mode-font-lock-cs-comment 0 font-lock-comment-face t) + (go-template-mode-font-lock-cs-string 0 font-lock-string-face t) + (,(regexp-opt '("{{" "}}")) (0 font-lock-preprocessor-face)) + ("$[a-zA-Z0-9]*" (0 font-lock-variable-name-face)) + (,(regexp-opt go-template-mode-keywords 'words) . font-lock-keyword-face) + (,(regexp-opt go-template-mode-builtins 'words) . font-lock-builtin-face) + (,(concat "?") (0 font-lock-function-name-face)) + (,(concat "<" go-template-mode-standalone-tag ">?") (0 font-lock-function-name-face)))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Parser +;; + +(defvar go-template-mode-mark-cs-end 1 + "The point at which the comment/string cache ends. The buffer +will be marked from the beginning up to this point (that is, up +to and including character (1- go-template-mode-mark-cs-end)).") +(make-variable-buffer-local 'go-template-mode-mark-cs-end) + +(defvar go-template-mode-mark-nesting-end 1 + "The point at which the nesting cache ends. The buffer will be +marked from the beginning up to this point.") +(make-variable-buffer-local 'go-template-mode-mark-nesting-end) + +(defun go-template-mode-mark-clear-cache (b e) + "A before-change-function that clears the comment/string and +nesting caches from the modified point on." + + (save-restriction + (widen) + (when (<= b go-template-mode-mark-cs-end) + ;; Remove the property adjacent to the change position. + ;; It may contain positions pointing beyond the new end mark. + (let ((b (let ((cs (get-text-property (max 1 (1- b)) 'go-template-mode-cs))) + (if cs (car cs) b)))) + (remove-text-properties + b (min go-template-mode-mark-cs-end (point-max)) '(go-template-mode-cs nil)) + (setq go-template-mode-mark-cs-end b))) + (when (< b go-template-mode-mark-nesting-end) + (remove-text-properties b (min go-template-mode-mark-nesting-end (point-max)) '(go-template-mode-nesting nil)) + (setq go-template-mode-mark-nesting-end b)))) + +(defmacro go-template-mode-parser (&rest body) + "Evaluate BODY in an environment set up for parsers that use +text properties to mark text. This inhibits changes to the undo +list or the buffer's modification status and inhibits calls to +the modification hooks. It also saves the excursion and +restriction and widens the buffer, since most parsers are +context-sensitive." + + (let ((modified-var (make-symbol "modified"))) + `(let ((buffer-undo-list t) + (,modified-var (buffer-modified-p)) + (inhibit-modification-hooks t) + (inhibit-read-only t)) + (save-excursion + (save-restriction + (widen) + (unwind-protect + (progn ,@body) + (set-buffer-modified-p ,modified-var))))))) + +(defun go-template-mode-cs (&optional pos) + "Return the comment/string state at point POS. If point is +inside a comment or string (including the delimiters), this +returns a pair (START . END) indicating the extents of the +comment or string." + + (unless pos + (setq pos (point))) + (when (> pos go-template-mode-mark-cs-end) + (go-template-mode-mark-cs pos)) + (get-text-property pos 'go-template-mode-cs)) + +(defun go-template-mode-mark-cs (end) + "Mark comments and strings up to point END. Don't call this +directly; use `go-template-mode-cs'." + (setq end (min end (point-max))) + (go-template-mode-parser + (save-match-data + (let ((pos + ;; Back up to the last known state. + (let ((last-cs + (and (> go-template-mode-mark-cs-end 1) + (get-text-property (1- go-template-mode-mark-cs-end) + 'go-template-mode-cs)))) + (if last-cs + (car last-cs) + (max 1 (1- go-template-mode-mark-cs-end)))))) + (while (< pos end) + (goto-char pos) + (let ((cs-end ; end of the text property + (cond + ((looking-at "{{/\\*") + (goto-char (+ pos 4)) + (if (search-forward "*/}}" (1+ end) t) + (point) + end)) + ((looking-at "\"") + (goto-char (1+ pos)) + (if (looking-at "[^\"\n\\\\]*\\(\\\\.[^\"\n\\\\]*\\)*\"") + (match-end 0) + (end-of-line) + (point))) + ((looking-at "'") + (goto-char (1+ pos)) + (if (looking-at "[^'\n\\\\]*\\(\\\\.[^'\n\\\\]*\\)*'") + (match-end 0) + (end-of-line) + (point))) + ((looking-at "`") + (goto-char (1+ pos)) + (while (if (search-forward "`" end t) + (if (eq (char-after) ?`) + (goto-char (1+ (point)))) + (goto-char end) + nil)) + (point))))) + (cond + (cs-end + (put-text-property pos cs-end 'go-template-mode-cs (cons pos cs-end)) + (setq pos cs-end)) + ((re-search-forward "[\"'`]\\|{{/\\*" end t) + (setq pos (match-beginning 0))) + (t + (setq pos end))))) + (setq go-template-mode-mark-cs-end pos))))) + + + +(defun go-template-mode-font-lock-cs (limit comment) + "Helper function for highlighting comment/strings. If COMMENT is t, +set match data to the next comment after point, and advance point +after it. If COMMENT is nil, use the next string. Returns nil +if no further tokens of the type exist." + ;; Ensures that `next-single-property-change' below will work properly. + (go-template-mode-cs limit) + (let (cs next (result 'scan)) + (while (eq result 'scan) + (if (or (>= (point) limit) (eobp)) + (setq result nil) + (setq cs (go-template-mode-cs)) + (if cs + (if (eq (= (char-after (car cs)) ?/) comment) + ;; If inside the expected comment/string, highlight it. + (progn + ;; If the match includes a "\n", we have a + ;; multi-line construct. Mark it as such. + (goto-char (car cs)) + (when (search-forward "\n" (cdr cs) t) + (put-text-property + (car cs) (cdr cs) 'font-lock-multline t)) + (set-match-data (list (car cs) (cdr cs) (current-buffer))) + (goto-char (cdr cs)) + (setq result t)) + ;; Wrong type. Look for next comment/string after this one. + (goto-char (cdr cs))) + ;; Not inside comment/string. Search for next comment/string. + (setq next (next-single-property-change + (point) 'go-template-mode-cs nil limit)) + (if (and next (< next limit)) + (goto-char next) + (setq result nil))))) + result)) + +(defun go-template-mode-font-lock-cs-string (limit) + "Font-lock iterator for strings." + (go-template-mode-font-lock-cs limit nil)) + +(defun go-template-mode-font-lock-cs-comment (limit) + "Font-lock iterator for comments." + (go-template-mode-font-lock-cs limit t)) + +;;;###autoload +(define-derived-mode go-template-mode fundamental-mode "Go-Template" + "Major mode for editing Go template text. + +This provides basic syntax highlighting for keyword, built-ins, functions, +and some types. It does not provide indentation." + + ;; Font lock + (set (make-local-variable 'font-lock-defaults) + '(go-template-mode-font-lock-keywords nil nil nil nil)) + + ;; Remove stale text properties + (save-restriction + (widen) + (remove-text-properties 1 (point-max) + '(go-template-mode-cs nil go-template-mode-nesting nil))) + + ;; Reset the syntax mark caches + (setq go-template-mode-mark-cs-end 1 + go-template-mode-mark-nesting-end 1) + (add-hook 'before-change-functions #'go-template-mode-mark-clear-cache nil t) + + ;; Use tabs (Go style) + (setq indent-tabs-mode t)) + +(add-to-list 'auto-mode-alist '("\\.gotmpl$" . go-template-mode)) + +(provide 'go-template-mode) + +;;; go-template-mode.el ends here \ No newline at end of file diff --git a/emacs.tar b/emacs.tar deleted file mode 100644 index 8e85c28..0000000 Binary files a/emacs.tar and /dev/null differ diff --git a/fish/config.fish b/fish/config.fish index c8f8218..607b316 100644 --- a/fish/config.fish +++ b/fish/config.fish @@ -1,35 +1,30 @@ # Fish configuration file +set -x LC_ALL en_US.utf8 +set -x TERM xterm-256color + +# Aliases alias ls='ls --color=auto' alias ll='ls -l' alias la='ls -A' alias l='ls -CF' alias rm='rm -i --preserve-root' -alias gcc='gcc-5' -alias g++='g++-5' -alias python='python3' - -alias json='python -m json.tool' +# GUROBI set GUROBI_PATH $HOME/.softwares/gurobi651/linux64 +if [ -e $GUROBI_PATH ] + set -x LD_LIBRARY_PATH $LD_LIBRARY_PATH /usr/local/lib $GUROBI_PATH/lib + set -x GRB_LICENSE_FILE $GUROBI_PATH/gurobi.lic + set -x PATH $PATH $GUROBI_PATH/bin + set -x PYTHONPATH $PYTHONPATH $GUROBI_PATH/lib/python3.4_utf32 +end -set -x LD_LIBRARY_PATH $LD_LIBRARY_PATH /usr/local/lib $GUROBI_PATH/lib -set -x PATH ~/.softwares/bin $PATH $GUROBI_PATH/bin - -set PYTHONPATH $PYTHONPATH $HOME/Dev/python/libs /local/lib/python3.4 -set -x PYTHONPATH $PYTHONPATH /usr/local/lib/python3.4 $GUROBI_PATH/lib/python3.4_utf32 - -set -x DATA_FOLDER /net/cetus/data/ogsn -set -x ACCESS_FOLDER {$DATA_FOLDER}/access -set -x DATASETS_FOLDER {$DATA_FOLDER}/datasets -set -x INSTANCES_FOLDER {$DATA_FOLDER}/instances -set -x RESULTS_FOLDER {$DATA_FOLDER}/results - -set -x GRB_LICENSE_FILE $GUROBI_PATH/gurobi.lic +# CUSTOM +set MYSOFT_PATH $HOME/.softwares/bin +if [ -e $MYSOFT_PATH ] + set -x PATH ~/.softwares/bin $PATH +end +# Creation mask umask 022 - - -set -x LC_ALL en_US.utf8 -set -x TERM xterm-256color