Skip to content

add Emacs snippets #684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions a1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3123,6 +3123,27 @@ Use file templates or snippets to help follow consistent styles and patterns. He
ngservice // creates an Angular service
```

### Emacs
###### [Style [Y257](#style-y257)]

- [Emacs](https://www.gnu.org/software/emacs/) snippets that follow these styles and guidelines.

- Download the [Emacs Angular snippets](assets/emacs-angular-snippets?raw=true)

Note that yasnippet categorizes snippets by major mode, and there are several Emacs major modes for editing Javascript code. The snippets are in `js2-mode`, and the other directories contain only a dotfile to reference them there.

- install [yasnippet](https://github.com/capitaomorte/yasnippet) (`M-x package-install RET yasnippet RET`)
- copy snippets to snippet directory, or modify your Emacs init to add snippet directory to `yas-snippet-dirs`

```javascript
ngcontroller // creates an Angular controller
ngdirective // creates an Angular directive
ngfactory // creates an Angular factory
ngmodule // creates an Angular module
ngservice // creates an Angular service
ngfilter // creates an Angular filter
```

**[Back to top](#table-of-contents)**

## Yeoman Generator
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
js2-mode
1 change: 1 addition & 0 deletions a1/assets/emacs-angular-snippets/js-mode/.yas-parents
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
js2-mode
26 changes: 26 additions & 0 deletions a1/assets/emacs-angular-snippets/js2-mode/angular.controller.snip
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- mode: snippet; require-final-newline: nil -*-
# name: ngcontroller
# key: ngcontroller
# binding: direct-keybinding
# --

(function() {
'use strict';

angular
.module('${1:module}')
.controller('${2:Controller}Controller', $2Controller);

/* @ngInject */
function $2Controller(${3:dependencies}) {
var vm = this;
vm.title = '$2Controller';

activate();

////////////////

function activate() {
}
}
})();
39 changes: 39 additions & 0 deletions a1/assets/emacs-angular-snippets/js2-mode/angular.directive.snip
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# -*- mode: snippet; require-final-newline: nil -*-
# name: ngdirective
# key: ngdirective
# binding: direct-keybinding
# --

(function() {
'use strict';

angular
.module('${1:module}')
.directive('${2:directive}', $2);

/* @ngInject */
function $2(${3:dependencies}) {
// Usage:
//
// Creates:
//
var directive = {
bindToController: true,
controller: ${4:Controller},
controllerAs: '${5:vm}',
link: link,
restrict: 'A',
scope: {
}
};
return directive;

function link(scope, element, attrs) {
}
}

/* @ngInject */
function $4() {

}
})();
26 changes: 26 additions & 0 deletions a1/assets/emacs-angular-snippets/js2-mode/angular.factory.snip
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- mode: snippet; require-final-newline: nil -*-
# name: ngfactory
# key: ngfactory
# binding: direct-keybinding
# --

(function() {
'use strict';

angular
.module('${1:module}')
.factory('${2:factory}', $2);

/* @ngInject */
function $2(${3:dependencies}) {
var service = {
${4:func}: $4
};
return service;

////////////////

function $4() {
}
}
})();
23 changes: 23 additions & 0 deletions a1/assets/emacs-angular-snippets/js2-mode/angular.filter.snip
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- mode: snippet; require-final-newline: nil -*-
# name: ngfilter
# key: ngfilter
# binding: direct-keybinding
# --

(function() {
'use strict';

angular
.module('${1:module}')
.filter('${2:filter}', $2);

function $2() {
return $2Filter;

////////////////
function $2Filter(${3:params}) {
return $3;
};
}

})();
14 changes: 14 additions & 0 deletions a1/assets/emacs-angular-snippets/js2-mode/angular.module.snip
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- mode: snippet; require-final-newline: nil -*-
# name: ngmodule
# key: ngmodule
# binding: direct-keybinding
# --

(function() {
'use strict';

angular
.module('${1:module}', [
'${2:dependencies}'
]);
})();
23 changes: 23 additions & 0 deletions a1/assets/emacs-angular-snippets/js2-mode/angular.service.snip
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- mode: snippet; require-final-newline: nil -*-
# name: ngservice
# key: ngservice
# binding: direct-keybinding
# --

(function() {
'use strict';

angular
.module('${1:module}')
.service('${2:Service}', $2);

/* @ngInject */
function $2(${3:dependencies}) {
this.${4:func} = $4;

////////////////

function $4() {
}
}
})();
1 change: 1 addition & 0 deletions a1/assets/emacs-angular-snippets/js3-mode/.yas-parents
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
js2-mode