From 481decd28b7940d1dae11fd0ff2dc06143c46ee8 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Wed, 17 Feb 2016 07:39:51 +0100 Subject: Add java-mode snippets. Upgrade yasnippet and yaml-mode --- .emacs | 10 +- .emacs.d/lisp/yaml-mode.el | 15 ++- .emacs.d/lisp/yasnippet.el | 180 ++++++++++++------------- .emacs.d/snippets/java-mode/apr_assert | 7 + .emacs.d/snippets/java-mode/assert | 5 + .emacs.d/snippets/java-mode/assertEquals | 7 + .emacs.d/snippets/java-mode/cls | 7 + .emacs.d/snippets/java-mode/constructor | 7 + .emacs.d/snippets/java-mode/define test method | 8 ++ .emacs.d/snippets/java-mode/doc | 7 + .emacs.d/snippets/java-mode/equals | 7 + .emacs.d/snippets/java-mode/file_class | 9 ++ .emacs.d/snippets/java-mode/for | 7 + .emacs.d/snippets/java-mode/fori | 7 + .emacs.d/snippets/java-mode/getter | 7 + .emacs.d/snippets/java-mode/if | 7 + .emacs.d/snippets/java-mode/ife | 10 ++ .emacs.d/snippets/java-mode/import | 6 + .emacs.d/snippets/java-mode/iterator | 7 + .emacs.d/snippets/java-mode/javadoc | 8 ++ .emacs.d/snippets/java-mode/lambda | 5 + .emacs.d/snippets/java-mode/main | 7 + .emacs.d/snippets/java-mode/main_class | 11 ++ .emacs.d/snippets/java-mode/method | 7 + .emacs.d/snippets/java-mode/new | 6 + .emacs.d/snippets/java-mode/override | 6 + .emacs.d/snippets/java-mode/param | 5 + .emacs.d/snippets/java-mode/printf | 5 + .emacs.d/snippets/java-mode/println | 6 + .emacs.d/snippets/java-mode/return | 5 + .emacs.d/snippets/java-mode/test | 8 ++ .emacs.d/snippets/java-mode/testClass | 12 ++ .emacs.d/snippets/java-mode/this | 6 + .emacs.d/snippets/java-mode/toString | 7 + .emacs.d/snippets/java-mode/try | 11 ++ .emacs.d/snippets/java-mode/value | 5 + 36 files changed, 337 insertions(+), 103 deletions(-) create mode 100644 .emacs.d/snippets/java-mode/apr_assert create mode 100644 .emacs.d/snippets/java-mode/assert create mode 100644 .emacs.d/snippets/java-mode/assertEquals create mode 100644 .emacs.d/snippets/java-mode/cls create mode 100644 .emacs.d/snippets/java-mode/constructor create mode 100644 .emacs.d/snippets/java-mode/define test method create mode 100644 .emacs.d/snippets/java-mode/doc create mode 100644 .emacs.d/snippets/java-mode/equals create mode 100644 .emacs.d/snippets/java-mode/file_class create mode 100644 .emacs.d/snippets/java-mode/for create mode 100644 .emacs.d/snippets/java-mode/fori create mode 100644 .emacs.d/snippets/java-mode/getter create mode 100644 .emacs.d/snippets/java-mode/if create mode 100644 .emacs.d/snippets/java-mode/ife create mode 100644 .emacs.d/snippets/java-mode/import create mode 100644 .emacs.d/snippets/java-mode/iterator create mode 100644 .emacs.d/snippets/java-mode/javadoc create mode 100644 .emacs.d/snippets/java-mode/lambda create mode 100644 .emacs.d/snippets/java-mode/main create mode 100644 .emacs.d/snippets/java-mode/main_class create mode 100644 .emacs.d/snippets/java-mode/method create mode 100644 .emacs.d/snippets/java-mode/new create mode 100644 .emacs.d/snippets/java-mode/override create mode 100644 .emacs.d/snippets/java-mode/param create mode 100644 .emacs.d/snippets/java-mode/printf create mode 100644 .emacs.d/snippets/java-mode/println create mode 100644 .emacs.d/snippets/java-mode/return create mode 100644 .emacs.d/snippets/java-mode/test create mode 100644 .emacs.d/snippets/java-mode/testClass create mode 100644 .emacs.d/snippets/java-mode/this create mode 100644 .emacs.d/snippets/java-mode/toString create mode 100644 .emacs.d/snippets/java-mode/try create mode 100644 .emacs.d/snippets/java-mode/value diff --git a/.emacs b/.emacs index 9dab30b..a962b73 100644 --- a/.emacs +++ b/.emacs @@ -58,19 +58,19 @@ (setq python-indent-guess-indent-offset nil) ;; Enable which-function-mode for C, C++ and Python -;;(setq which-func-modes '(python-mode c-mode c++-mode)) -;;(which-function-mode t) +(setq which-func-modes '(c-mode c++-mode java-mode python-mode)) +(which-function-mode t) ;; Custom plugins (add-to-list 'load-path "~/.emacs.d/lisp/") -;;PHP +;; PHP ;; (autoload 'php-mode "php-mode" "Mode for editing PHP source files") ;; (add-to-list 'auto-mode-alist '("\\.\\(inc\\|php[s34]?\\)" . php-mode)) ;; YAML -;;(require 'yaml-mode) -;;(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode)) +;; (require 'yaml-mode) +;; (add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode)) ;; yasnippet (require 'yasnippet) diff --git a/.emacs.d/lisp/yaml-mode.el b/.emacs.d/lisp/yaml-mode.el index 15f3872..b932576 100644 --- a/.emacs.d/lisp/yaml-mode.el +++ b/.emacs.d/lisp/yaml-mode.el @@ -4,6 +4,8 @@ ;; Author: Yoshiki Kurihara ;; Marshall T. Vandegrift +;; Maintainer: Vasilij Schneidermann +;; Package-Requires: ((emacs "24.1")) ;; Keywords: data yaml ;; Version: 0.0.12 @@ -19,10 +21,9 @@ ;; 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 GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. +;; You should have received a copy of the GNU General Public License along +;; with this program; if not, write to the Free Software Foundation, Inc., +;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ;;; Commentary: @@ -144,7 +145,7 @@ that key is pressed to begin a block literal." "Regexp matching a single YAML hash key.") (defconst yaml-scalar-context-re - (concat "\\(?:^\\(?:--- \\)?\\|{\\|\\(?:[-,] +\\)+\\) *" + (concat "\\(?:^\\(?:--- \\)?\\|{\\|\\(?: *[-,] +\\)+\\) *" "\\(?:" yaml-bare-scalar-re " *: \\)?") "Regexp indicating the begininng of a scalar context.") @@ -162,7 +163,7 @@ that key is pressed to begin a block literal." "Regexp matching a line beginning a YAML block literal.") (defconst yaml-nested-sequence-re - (concat "^\\(?: *- +\\)+" + (concat "^\\(?:\\(?: *- +\\)+\\|\\(:? *-$\\)\\)" "\\(?:" yaml-bare-scalar-re " *:\\(?: +.*\\)?\\)?$") "Regexp matching a line containing one or more nested YAML sequences.") @@ -213,7 +214,7 @@ that key is pressed to begin a block literal." (modify-syntax-entry ?\] ")[" yaml-mode-syntax-table)) ;;;###autoload -(define-derived-mode yaml-mode fundamental-mode "YAML" +(define-derived-mode yaml-mode text-mode "YAML" "Simple mode to edit YAML. \\{yaml-mode-map}" diff --git a/.emacs.d/lisp/yasnippet.el b/.emacs.d/lisp/yasnippet.el index f13dc4f..69d6b26 100644 --- a/.emacs.d/lisp/yasnippet.el +++ b/.emacs.d/lisp/yasnippet.el @@ -1,8 +1,8 @@ ;;; yasnippet.el --- Yet another snippet extension for Emacs. ;; Copyright (C) 2008-2013, 2015 Free Software Foundation, Inc. -;; Authors: pluskid , João Távora -;; Maintainer: João Távora +;; Authors: pluskid , João Távora , Noam Postavsky +;; Maintainer: Noam Postavsky ;; Version: 0.8.1 ;; Package-version: 0.8.0 ;; X-URL: http://github.com/capitaomorte/yasnippet @@ -156,8 +156,11 @@ (when load-file-name (concat (file-name-directory load-file-name) "snippets"))) +(defconst yas--default-user-snippets-dir + (concat user-emacs-directory "snippets")) + (defcustom yas-snippet-dirs (remove nil - (list "~/.emacs.d/snippets" + (list yas--default-user-snippets-dir 'yas-installed-snippets-dir)) "List of top-level snippet directories. @@ -199,10 +202,9 @@ created with `yas-new-snippet'. " (defvaralias 'yas/root-directory 'yas-snippet-dirs) (defcustom yas-new-snippet-default "\ -# -*- mode: snippet; require-final-newline: nil -*- +# -*- mode: snippet -*- # name: $1 -# key: ${2:${1:$(yas--key-from-desc yas-text)}}${3: -# binding: ${4:direct-keybinding}} +# key: ${2:${1:$(yas--key-from-desc yas-text)}} # -- $0" "Default snippet to use when creating a new snippet. @@ -210,10 +212,9 @@ If nil, don't use any snippet." :type 'string :group 'yasnippet) -(defcustom yas-prompt-functions '(yas-x-prompt - yas-dropdown-prompt +(defcustom yas-prompt-functions '(yas-dropdown-prompt yas-completing-prompt - yas-ido-prompt + yas-maybe-ido-prompt yas-no-prompt) "Functions to prompt for keys, templates, etc interactively. @@ -459,10 +460,10 @@ Attention: These hooks are not run when exiting nested/stacked snippet expansion "Hooks to run just before expanding a snippet.") (defvar yas-buffer-local-condition - '(if (and (or (fourth (syntax-ppss)) - (fifth (syntax-ppss))) - this-command - (eq this-command 'yas-expand-from-trigger-key)) + '(if (and (let ((ppss (syntax-ppss))) + (or (nth 3 ppss) (nth 4 ppss))) + (memq this-command '(yas-expand yas-expand-from-trigger-key + yas-expand-from-keymap))) '(require-snippet-condition . force-in-comment) t) "Snippet expanding condition. @@ -728,22 +729,21 @@ defined direct keybindings to the command (defun yas--modes-to-activate (&optional mode) "Compute list of mode symbols that are active for `yas-expand' and friends." - (let (dfs explored) - (setq dfs (lambda (mode) - (unless (memq mode explored) - (push mode explored) - (loop for neighbour - in (cl-list* (get mode 'derived-mode-parent) - (ignore-errors (symbol-function mode)) - (gethash mode yas--parents)) - when (and neighbour - (not (memq neighbour explored)) - (symbolp neighbour)) - do (funcall dfs neighbour))))) - (if mode - (funcall dfs mode) - (mapcar dfs (cons major-mode yas--extra-modes))) - explored)) + (let* ((explored (if mode (list mode) ; Building up list in reverse. + (cons major-mode (reverse yas--extra-modes)))) + (dfs + (lambda (mode) + (cl-loop for neighbour + in (cl-list* (get mode 'derived-mode-parent) + (ignore-errors (symbol-function mode)) + (gethash mode yas--parents)) + when (and neighbour + (not (memq neighbour explored)) + (symbolp neighbour)) + do (push neighbour explored) + (funcall dfs neighbour))))) + (mapcar dfs explored) + (nreverse explored))) (defvar yas-minor-mode-hook nil "Hook run when `yas-minor-mode' is turned on.") @@ -1388,16 +1388,6 @@ them all in `yas--menu-table'" :visible (yas--show-menu-p ',mode))) menu-keymap)) - -(defmacro yas--called-interactively-p (&optional kind) - "A backward-compatible version of `called-interactively-p'. - -Optional KIND is as documented at `called-interactively-p' -in GNU Emacs 24.1 or higher." - (if (string< emacs-version "24.1") - '(called-interactively-p) - `(called-interactively-p ,kind))) - ;;; Template-related and snippet loading functions @@ -1449,7 +1439,7 @@ Here's a list of currently recognized directives: (point-max))) (setq bound (point)) (goto-char (point-min)) - (while (re-search-forward "^# *\\([^ ]+?\\) *: *\\(.*\\)$" bound t) + (while (re-search-forward "^# *\\([^ ]+?\\) *: *\\(.*?\\)[[:space:]]*$" bound t) (when (string= "uuid" (match-string-no-properties 1)) (setq uuid (match-string-no-properties 2))) (when (string= "type" (match-string-no-properties 1)) @@ -1593,11 +1583,13 @@ Optional PROMPT sets the prompt to use." (if display-fn (mapcar display-fn choices) choices))))) (keyboard-quit)))) +(defun yas-maybe-ido-prompt (prompt choices &optional display-fn) + (when (bound-and-true-p ido-mode) + (yas-ido-prompt prompt choices display-fn))) + (defun yas-ido-prompt (prompt choices &optional display-fn) - (when (and (fboundp 'ido-completing-read) - (or (>= emacs-major-version 24) - ido-mode)) - (yas-completing-prompt prompt choices display-fn #'ido-completing-read))) + (require 'ido) + (yas-completing-prompt prompt choices display-fn #'ido-completing-read)) (defun yas-dropdown-prompt (_prompt choices &optional display-fn) (when (fboundp 'dropdown-list) @@ -1751,8 +1743,8 @@ With prefix argument USE-JIT do jit-loading of snippets." (funcall fun))) ;; Look for buffers that are already in `mode-sym', and so ;; need the new snippets immediately... - ;; - (when use-jit + ;; + (when use-jit (cl-loop for buffer in (buffer-list) do (with-current-buffer buffer (when (eq major-mode mode-sym) @@ -1760,7 +1752,7 @@ With prefix argument USE-JIT do jit-loading of snippets." (push buffer impatient-buffers))))))) ;; ...after TOP-LEVEL-DIR has been completely loaded, call ;; `yas--load-pending-jits' in these impatient buffers. - ;; + ;; (cl-loop for buffer in impatient-buffers do (with-current-buffer buffer (yas--load-pending-jits)))) (when interactive @@ -1779,9 +1771,9 @@ With prefix argument USE-JIT do jit-loading of snippets." (current-time-string))))) ;; Normal case. (unless (file-exists-p (concat directory "/" ".yas-skip")) - (if (and (progn (yas--message 2 "Loading compiled snippets from %s" directory) t) - (load (expand-file-name ".yas-compiled-snippets" directory) 'noerror (<= yas-verbosity 3))) - (yas--message 2 "Loading snippet files from %s" directory) + (unless (and (load (expand-file-name ".yas-compiled-snippets" directory) 'noerror (<= yas-verbosity 3)) + (progn (yas--message 2 "Loaded compiled snippets from %s" directory) t)) + (yas--message 2 "Loading snippet files from %s" directory) (yas--load-directory-2 directory mode-sym))))) (defun yas--load-directory-2 (directory mode-sym) @@ -1811,16 +1803,18 @@ With prefix argument USE-JIT do jit-loading of snippets." "Reload the directories listed in `yas-snippet-dirs' or prompt the user to select one." (let (errors) - (if yas-snippet-dirs - (dolist (directory (reverse (yas-snippet-dirs))) - (cond ((file-directory-p directory) - (yas-load-directory directory (not nojit)) - (if nojit - (yas--message 3 "Loaded %s" directory) - (yas--message 3 "Prepared just-in-time loading for %s" directory))) - (t - (push (yas--message 0 "Check your `yas-snippet-dirs': %s is not a directory" directory) errors)))) - (call-interactively 'yas-load-directory)) + (if (null yas-snippet-dirs) + (call-interactively 'yas-load-directory) + (when (member yas--default-user-snippets-dir yas-snippet-dirs) + (make-directory yas--default-user-snippets-dir t)) + (dolist (directory (reverse (yas-snippet-dirs))) + (cond ((file-directory-p directory) + (yas-load-directory directory (not nojit)) + (if nojit + (yas--message 3 "Loaded %s" directory) + (yas--message 3 "Prepared just-in-time loading for %s" directory))) + (t + (push (yas--message 0 "Check your `yas-snippet-dirs': %s is not a directory" directory) errors))))) errors)) (defun yas-reload-all (&optional no-jit interactive) @@ -1946,7 +1940,7 @@ This works by stubbing a few functions, then calling (interactive) (message (concat "yasnippet (version " yas--version - ") -- pluskid /joaotavora "))) + ") -- pluskid/joaotavora/npostavs"))) ;;; Apropos snippet menu: @@ -2226,12 +2220,12 @@ Common gateway for `yas-expand-from-trigger-key' and ;; loops when other extensions use mechanisms similar ;; to `yas--keybinding-beyond-yasnippet'. (github #525 ;; and #526) - ;; + ;; (yas-minor-mode nil) (beyond-yasnippet (yas--keybinding-beyond-yasnippet))) (yas--message 4 "Falling back to %s" beyond-yasnippet) (assert (or (null beyond-yasnippet) (commandp beyond-yasnippet))) - (setq this-original-command beyond-yasnippet) + (setq this-command beyond-yasnippet) (when beyond-yasnippet (call-interactively beyond-yasnippet)))) ((and (listp yas-fallback-behavior) @@ -2359,7 +2353,6 @@ visited file in `snippet-mode'." (interactive) (let* ((yas-buffer-local-condition 'always) (templates (yas--all-templates (yas--get-snippet-tables))) - (yas-prompt-functions '(yas-ido-prompt yas-completing-prompt)) (template (and templates (or (yas--prompt-for-template templates "Choose a snippet template to edit: ") @@ -2417,7 +2410,7 @@ where snippets of table might exist." (let ((main-dir (replace-regexp-in-string "/+$" "" (or (first (or (yas-snippet-dirs) - (setq yas-snippet-dirs '("~/.emacs.d/snippets"))))))) + (setq yas-snippet-dirs (list yas--default-user-snippets-dir))))))) (tables (or (and table (list table)) (yas--get-snippet-tables)))) @@ -3042,11 +3035,11 @@ through the field's start point" The most recently-inserted snippets are returned first." (sort - (remove nil (remove-duplicates (mapcar #'(lambda (ov) - (overlay-get ov 'yas--snippet)) - (if all-snippets - (overlays-in (point-min) (point-max)) - (nconc (overlays-at (point)) (overlays-at (1- (point)))))))) + (delq nil (delete-dups + (mapcar (lambda (ov) (overlay-get ov 'yas--snippet)) + (if all-snippets (overlays-in (point-min) (point-max)) + (nconc (overlays-at (point)) + (overlays-at (1- (point)))))))) #'(lambda (s1 s2) (<= (yas--snippet-id s2) (yas--snippet-id s1))))) @@ -3159,12 +3152,6 @@ Also create some protection overlays" (defvar yas--inhibit-overlay-hooks nil "Bind this temporarily to non-nil to prevent running `yas--on-*-modification'.") -(defmacro yas--inhibit-overlay-hooks (&rest body) - "Run BODY with `yas--inhibit-overlay-hooks' set to t." - (declare (indent 0)) - `(let ((yas--inhibit-overlay-hooks t)) - ,@body)) - (defvar yas-snippet-beg nil "Beginning position of the last snippet committed.") (defvar yas-snippet-end nil "End position of the last snippet committed.") @@ -3184,7 +3171,7 @@ This renders the snippet as ordinary text." (setq yas-snippet-end (overlay-end control-overlay)) (delete-overlay control-overlay)) - (yas--inhibit-overlay-hooks + (let ((yas--inhibit-overlay-hooks t)) (when yas--active-field-overlay (delete-overlay yas--active-field-overlay)) (when yas--field-protection-overlays @@ -3396,13 +3383,28 @@ Move the overlay, or create it if it does not exit." (overlay-put yas--active-field-overlay 'insert-behind-hooks '(yas--on-field-overlay-modification)))) -(defun yas--on-field-overlay-modification (overlay after? _beg _end &optional _length) +(defun yas--skip-and-clear-field-p (field _beg _end &optional _length) + "Tell if newly modified FIELD should be cleared and skipped. +BEG, END and LENGTH like overlay modification hooks." + (and (not (yas--field-modified-p field)) + (= (point) (yas--field-start field)) + (require 'delsel) + ;; `yank' sets `this-command' to t during execution. + (let ((clearp (get (if (commandp this-command) this-command + this-original-command) + 'delete-selection))) + (when (and (not (memq clearp '(yank supersede kill))) + (functionp clearp)) + (setq clearp (funcall clearp))) + clearp))) + +(defun yas--on-field-overlay-modification (overlay after? beg end &optional length) "Clears the field and updates mirrors, conditionally. -Only clears the field if it hasn't been modified and it point it -at field start. This hook doesn't do anything if an undo is in -progress." +Only clears the field if it hasn't been modified and point is at +field start. This hook does nothing if an undo is in progress." (unless (or yas--inhibit-overlay-hooks + (not (overlayp yas--active-field-overlay)) ; Avoid Emacs bug #21824. (yas--undo-in-progress)) (let* ((field (overlay-get overlay 'yas--field)) (snippet (overlay-get yas--active-field-overlay 'yas--snippet))) @@ -3412,11 +3414,7 @@ progress." (yas--field-update-display field)) (yas--update-mirrors snippet)) (field - (when (and (not after?) - (not (yas--field-modified-p field)) - (eq (point) (if (markerp (yas--field-start field)) - (marker-position (yas--field-start field)) - (yas--field-start field)))) + (when (yas--skip-and-clear-field-p field beg end) (yas--skip-and-clear field)) (setf (yas--field-modified-p field) t)))))) @@ -3429,7 +3427,7 @@ progress." ;; As of github #537 this no longer inhibits the command by issuing an ;; error: all the snippets at point, including nested snippets, are ;; automatically commited and the current command can proceed. -;; +;; (defun yas--make-move-field-protection-overlays (snippet field) "Place protection overlays surrounding SNIPPET's FIELD. @@ -3443,7 +3441,7 @@ Move the overlays, or create them if they do not exit." ;; (when (< (buffer-size) end) (save-excursion - (yas--inhibit-overlay-hooks + (let ((yas--inhibit-overlay-hooks t)) (goto-char (point-max)) (newline)))) ;; go on to normal overlay creation/moving @@ -3559,7 +3557,7 @@ considered when expanding the snippet." ;; them mostly to make the undo information ;; (setq yas--start-column (current-column)) - (yas--inhibit-overlay-hooks + (let ((yas--inhibit-overlay-hooks t)) (setq snippet (if expand-env (eval `(let* ,expand-env @@ -4241,7 +4239,7 @@ When multiple expressions are found, only the last one counts." (not (string= reflection (buffer-substring-no-properties (yas--mirror-start mirror) (yas--mirror-end mirror))))) (goto-char (yas--mirror-start mirror)) - (yas--inhibit-overlay-hooks + (let ((yas--inhibit-overlay-hooks t)) (insert reflection)) (if (> (yas--mirror-end mirror) (point)) (delete-region (point) (yas--mirror-end mirror)) @@ -4260,7 +4258,7 @@ When multiple expressions are found, only the last one counts." (yas--field-end field))))) (setf (yas--field-modified-p field) t) (goto-char (yas--field-start field)) - (yas--inhibit-overlay-hooks + (let ((yas--inhibit-overlay-hooks t)) (insert transformed) (if (> (yas--field-end field) (point)) (delete-region (point) (yas--field-end field)) diff --git a/.emacs.d/snippets/java-mode/apr_assert b/.emacs.d/snippets/java-mode/apr_assert new file mode 100644 index 0000000..a3942be --- /dev/null +++ b/.emacs.d/snippets/java-mode/apr_assert @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: apr_assert +# key: apr_assert +# -- +if (Globals.useAssertions) { + ${1:assert ..}; +} diff --git a/.emacs.d/snippets/java-mode/assert b/.emacs.d/snippets/java-mode/assert new file mode 100644 index 0000000..686ffea --- /dev/null +++ b/.emacs.d/snippets/java-mode/assert @@ -0,0 +1,5 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: assert +# key: as +# -- +assert ${1:expression}; \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/assertEquals b/.emacs.d/snippets/java-mode/assertEquals new file mode 100644 index 0000000..ce23dae --- /dev/null +++ b/.emacs.d/snippets/java-mode/assertEquals @@ -0,0 +1,7 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: assertEquals +# key: ae +# group: test +# -- +Assert.assertEquals($1, $2); +$0 \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/cls b/.emacs.d/snippets/java-mode/cls new file mode 100644 index 0000000..88f534f --- /dev/null +++ b/.emacs.d/snippets/java-mode/cls @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: cls +# key: cls +# -- +class ${1:Class} { + $0 +} \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/constructor b/.emacs.d/snippets/java-mode/constructor new file mode 100644 index 0000000..602e496 --- /dev/null +++ b/.emacs.d/snippets/java-mode/constructor @@ -0,0 +1,7 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: constructor +# key: c +# -- +public ${1:Class} (${2:args}) { + $0 +} \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/define test method b/.emacs.d/snippets/java-mode/define test method new file mode 100644 index 0000000..fd9daf6 --- /dev/null +++ b/.emacs.d/snippets/java-mode/define test method @@ -0,0 +1,8 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: define test method +# key: dt +# -- +@Test +public void test${1:Name}() throws Exception { + $0 +} diff --git a/.emacs.d/snippets/java-mode/doc b/.emacs.d/snippets/java-mode/doc new file mode 100644 index 0000000..88f556e --- /dev/null +++ b/.emacs.d/snippets/java-mode/doc @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: doc +# key: /* +# -- +/** + * ${1:documentation} + */ \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/equals b/.emacs.d/snippets/java-mode/equals new file mode 100644 index 0000000..e990966 --- /dev/null +++ b/.emacs.d/snippets/java-mode/equals @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: equals +# key: eq +# -- +public boolean equals(${1:Class} other) { + $0 +} \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/file_class b/.emacs.d/snippets/java-mode/file_class new file mode 100644 index 0000000..e0a46f6 --- /dev/null +++ b/.emacs.d/snippets/java-mode/file_class @@ -0,0 +1,9 @@ +# -*- mode: snippet -*- +# name: file_class +# key: file +# -- +public class ${1:`(file-name-base + (or (buffer-file-name) + (buffer-name)))`} { + $0 +} diff --git a/.emacs.d/snippets/java-mode/for b/.emacs.d/snippets/java-mode/for new file mode 100644 index 0000000..833827b --- /dev/null +++ b/.emacs.d/snippets/java-mode/for @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: for +# key: for +# -- +for (${1:int i = 0}; ${2:i < N}; ${3:i++}) { + $0 +} \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/fori b/.emacs.d/snippets/java-mode/fori new file mode 100644 index 0000000..a417f2c --- /dev/null +++ b/.emacs.d/snippets/java-mode/fori @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: fori +# key: fori +# -- +for (${1:Object el} : ${2:iterator}) { + $0 +} diff --git a/.emacs.d/snippets/java-mode/getter b/.emacs.d/snippets/java-mode/getter new file mode 100644 index 0000000..747f9f4 --- /dev/null +++ b/.emacs.d/snippets/java-mode/getter @@ -0,0 +1,7 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: getter +# key: g +# -- +public ${1:int} get${2:Field}() { + return ${3:field}; +} \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/if b/.emacs.d/snippets/java-mode/if new file mode 100644 index 0000000..cae545f --- /dev/null +++ b/.emacs.d/snippets/java-mode/if @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: if +# key: if +# -- +if (${1:condition}) { + $0 +} \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/ife b/.emacs.d/snippets/java-mode/ife new file mode 100644 index 0000000..975643f --- /dev/null +++ b/.emacs.d/snippets/java-mode/ife @@ -0,0 +1,10 @@ +# -*- mode: snippet -*- +# name: ife +# key: ife +# -- +if (${1:cond}) { + $2 +} +else { + $3 +} \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/import b/.emacs.d/snippets/java-mode/import new file mode 100644 index 0000000..56235a2 --- /dev/null +++ b/.emacs.d/snippets/java-mode/import @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# name: import +# key: imp +# -- +import ${1:System.}; +$0 \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/iterator b/.emacs.d/snippets/java-mode/iterator new file mode 100644 index 0000000..69fb2ac --- /dev/null +++ b/.emacs.d/snippets/java-mode/iterator @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: iterator +# key: iterator +# -- +public Iterator<${1:type}> iterator() { + $0 +} diff --git a/.emacs.d/snippets/java-mode/javadoc b/.emacs.d/snippets/java-mode/javadoc new file mode 100644 index 0000000..5bc9051 --- /dev/null +++ b/.emacs.d/snippets/java-mode/javadoc @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# name: javadoc +# key: doc +# -- +/** + * $0 + * + */ \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/lambda b/.emacs.d/snippets/java-mode/lambda new file mode 100644 index 0000000..a73a7a5 --- /dev/null +++ b/.emacs.d/snippets/java-mode/lambda @@ -0,0 +1,5 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: lambda +# key: \ +# -- +(${1:args}) -> ${2:expression}; \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/main b/.emacs.d/snippets/java-mode/main new file mode 100644 index 0000000..b24e49d --- /dev/null +++ b/.emacs.d/snippets/java-mode/main @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: main +# key: main +# -- +public static void main(String[] args) { + $0 +} \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/main_class b/.emacs.d/snippets/java-mode/main_class new file mode 100644 index 0000000..624b31c --- /dev/null +++ b/.emacs.d/snippets/java-mode/main_class @@ -0,0 +1,11 @@ +# contributor: L. Guruprasad +# name: main_class +# key: main_class +# -- +class `(file-name-nondirectory (file-name-sans-extension (buffer-file-name)))` +{ +public static void main(String args[]) +{ +$0 +} +} \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/method b/.emacs.d/snippets/java-mode/method new file mode 100644 index 0000000..7a6b9ed --- /dev/null +++ b/.emacs.d/snippets/java-mode/method @@ -0,0 +1,7 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: method +# key: m +# -- +${1:public} ${2:void} ${3:name}(${4:args}) { + $0 +} \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/new b/.emacs.d/snippets/java-mode/new new file mode 100644 index 0000000..f06091d --- /dev/null +++ b/.emacs.d/snippets/java-mode/new @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# name: new +# key: new +# -- +${1:Type} ${2:obj} = new ${3:Constr}(${4:args}); +$0 \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/override b/.emacs.d/snippets/java-mode/override new file mode 100644 index 0000000..9878c85 --- /dev/null +++ b/.emacs.d/snippets/java-mode/override @@ -0,0 +1,6 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: override +# key: o +# -- +@Override +$0 \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/param b/.emacs.d/snippets/java-mode/param new file mode 100644 index 0000000..4a1f44d --- /dev/null +++ b/.emacs.d/snippets/java-mode/param @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: param +# key: param +# -- +@param ${1:paramater} $0 \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/printf b/.emacs.d/snippets/java-mode/printf new file mode 100644 index 0000000..f93c965 --- /dev/null +++ b/.emacs.d/snippets/java-mode/printf @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: printf +# key: printf +# -- +System.out.printf("$0%n"); \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/println b/.emacs.d/snippets/java-mode/println new file mode 100644 index 0000000..7dd8f0d --- /dev/null +++ b/.emacs.d/snippets/java-mode/println @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# name: println +# key: pr +# -- +System.out.println("${1:text}"); +$0 \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/return b/.emacs.d/snippets/java-mode/return new file mode 100644 index 0000000..5712e0c --- /dev/null +++ b/.emacs.d/snippets/java-mode/return @@ -0,0 +1,5 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: return +# key: r +# -- +return $0 \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/test b/.emacs.d/snippets/java-mode/test new file mode 100644 index 0000000..a37d115 --- /dev/null +++ b/.emacs.d/snippets/java-mode/test @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# name: test +# key: test +# -- +@Test +public void test_${1:Case}() { + $0 +} \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/testClass b/.emacs.d/snippets/java-mode/testClass new file mode 100644 index 0000000..b01a68f --- /dev/null +++ b/.emacs.d/snippets/java-mode/testClass @@ -0,0 +1,12 @@ +# -*- mode: snippet -*- +# name: testClass +# key: tc +# -- +import junit.framework.*; +import junit.textui.*; + +public class Test${1:Class} extends TestCase { + protected void setUp() { + $0 + } +} \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/this b/.emacs.d/snippets/java-mode/this new file mode 100644 index 0000000..45201b4 --- /dev/null +++ b/.emacs.d/snippets/java-mode/this @@ -0,0 +1,6 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: this +# key: . +# -- +this.$1 = $1; +$0 \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/toString b/.emacs.d/snippets/java-mode/toString new file mode 100644 index 0000000..0382a9e --- /dev/null +++ b/.emacs.d/snippets/java-mode/toString @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: toString +# key: toStr +# -- +public String toString() { + $0 +} \ No newline at end of file diff --git a/.emacs.d/snippets/java-mode/try b/.emacs.d/snippets/java-mode/try new file mode 100644 index 0000000..1a17ba3 --- /dev/null +++ b/.emacs.d/snippets/java-mode/try @@ -0,0 +1,11 @@ +# -*- mode: snippet -*- +# name: try +# key: try +# -- +try { + $0 +} +catch (${1:Throwable e}) { + ${2:System.out.println("Error " + e.getMessage()); + e.printStackTrace();} +} diff --git a/.emacs.d/snippets/java-mode/value b/.emacs.d/snippets/java-mode/value new file mode 100644 index 0000000..7ec38ef --- /dev/null +++ b/.emacs.d/snippets/java-mode/value @@ -0,0 +1,5 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: value +# key: val +# -- +final ${1:int} ${2:n} = $0; \ No newline at end of file -- cgit v1.3