Skip to content

Commit 0dafdc8

Browse files
aaron-emjohnpapa
authored andcommitted
add Emacs snippets (#684)
thanks!
1 parent ccbddf0 commit 0dafdc8

File tree

10 files changed

+175
-0
lines changed

10 files changed

+175
-0
lines changed

a1/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3125,6 +3125,27 @@ Use file templates or snippets to help follow consistent styles and patterns. He
31253125
ngservice // creates an Angular service
31263126
```
31273127
3128+
### Emacs
3129+
###### [Style [Y257](#style-y257)]
3130+
3131+
- [Emacs](https://www.gnu.org/software/emacs/) snippets that follow these styles and guidelines.
3132+
3133+
- Download the [Emacs Angular snippets](assets/emacs-angular-snippets?raw=true)
3134+
3135+
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.
3136+
3137+
- install [yasnippet](https://github.com/capitaomorte/yasnippet) (`M-x package-install RET yasnippet RET`)
3138+
- copy snippets to snippet directory, or modify your Emacs init to add snippet directory to `yas-snippet-dirs`
3139+
3140+
```javascript
3141+
ngcontroller // creates an Angular controller
3142+
ngdirective // creates an Angular directive
3143+
ngfactory // creates an Angular factory
3144+
ngmodule // creates an Angular module
3145+
ngservice // creates an Angular service
3146+
ngfilter // creates an Angular filter
3147+
```
3148+
31283149
**[Back to top](#table-of-contents)**
31293150
31303151
## Yeoman Generator
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
js2-mode
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
js2-mode
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# -*- mode: snippet; require-final-newline: nil -*-
2+
# name: ngcontroller
3+
# key: ngcontroller
4+
# binding: direct-keybinding
5+
# --
6+
7+
(function() {
8+
'use strict';
9+
10+
angular
11+
.module('${1:module}')
12+
.controller('${2:Controller}Controller', $2Controller);
13+
14+
/* @ngInject */
15+
function $2Controller(${3:dependencies}) {
16+
var vm = this;
17+
vm.title = '$2Controller';
18+
19+
activate();
20+
21+
////////////////
22+
23+
function activate() {
24+
}
25+
}
26+
})();
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# -*- mode: snippet; require-final-newline: nil -*-
2+
# name: ngdirective
3+
# key: ngdirective
4+
# binding: direct-keybinding
5+
# --
6+
7+
(function() {
8+
'use strict';
9+
10+
angular
11+
.module('${1:module}')
12+
.directive('${2:directive}', $2);
13+
14+
/* @ngInject */
15+
function $2(${3:dependencies}) {
16+
// Usage:
17+
//
18+
// Creates:
19+
//
20+
var directive = {
21+
bindToController: true,
22+
controller: ${4:Controller},
23+
controllerAs: '${5:vm}',
24+
link: link,
25+
restrict: 'A',
26+
scope: {
27+
}
28+
};
29+
return directive;
30+
31+
function link(scope, element, attrs) {
32+
}
33+
}
34+
35+
/* @ngInject */
36+
function $4() {
37+
38+
}
39+
})();
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# -*- mode: snippet; require-final-newline: nil -*-
2+
# name: ngfactory
3+
# key: ngfactory
4+
# binding: direct-keybinding
5+
# --
6+
7+
(function() {
8+
'use strict';
9+
10+
angular
11+
.module('${1:module}')
12+
.factory('${2:factory}', $2);
13+
14+
/* @ngInject */
15+
function $2(${3:dependencies}) {
16+
var service = {
17+
${4:func}: $4
18+
};
19+
return service;
20+
21+
////////////////
22+
23+
function $4() {
24+
}
25+
}
26+
})();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# -*- mode: snippet; require-final-newline: nil -*-
2+
# name: ngfilter
3+
# key: ngfilter
4+
# binding: direct-keybinding
5+
# --
6+
7+
(function() {
8+
'use strict';
9+
10+
angular
11+
.module('${1:module}')
12+
.filter('${2:filter}', $2);
13+
14+
function $2() {
15+
return $2Filter;
16+
17+
////////////////
18+
function $2Filter(${3:params}) {
19+
return $3;
20+
};
21+
}
22+
23+
})();
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# -*- mode: snippet; require-final-newline: nil -*-
2+
# name: ngmodule
3+
# key: ngmodule
4+
# binding: direct-keybinding
5+
# --
6+
7+
(function() {
8+
'use strict';
9+
10+
angular
11+
.module('${1:module}', [
12+
'${2:dependencies}'
13+
]);
14+
})();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# -*- mode: snippet; require-final-newline: nil -*-
2+
# name: ngservice
3+
# key: ngservice
4+
# binding: direct-keybinding
5+
# --
6+
7+
(function() {
8+
'use strict';
9+
10+
angular
11+
.module('${1:module}')
12+
.service('${2:Service}', $2);
13+
14+
/* @ngInject */
15+
function $2(${3:dependencies}) {
16+
this.${4:func} = $4;
17+
18+
////////////////
19+
20+
function $4() {
21+
}
22+
}
23+
})();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
js2-mode

0 commit comments

Comments
 (0)