├── users ├── magnars ├── christian │ ├── init.el │ ├── org-mode-hacks.el │ ├── project-mappings.el │ └── mu3e.el └── fimasvee │ ├── init.el │ ├── my-defuns.el │ └── js2r-keys.el ├── snippets ├── js2-mode │ └── .yas-parents ├── html-mode │ ├── kbd │ ├── em │ ├── code │ ├── c-if │ ├── strong │ ├── include │ ├── script │ ├── link │ ├── input │ ├── c-forEach │ ├── oocss-module │ ├── media │ └── html ├── js-mode │ ├── this.yasnippet │ ├── try │ ├── for │ ├── jstd.log.yasnippet │ ├── jstd-doc │ ├── node.module.exports.yasnippet │ ├── declare-global.yasnippet │ ├── finn-element-builder │ ├── object.create-property │ ├── object.create-property+ │ ├── for-in │ ├── function.yasnippet │ ├── node.ifnode.yasnippet │ ├── object.create │ ├── node.require.yasnippet │ ├── jstd.additionalTestCase.yasnippet │ ├── immediately-invoked-function-expression.yasnippet │ ├── jstd.testCase.yasnippet │ └── directive-oiiku-shared ├── clojure-mode │ ├── div │ ├── test │ ├── div-class │ ├── namespace │ ├── dev │ ├── testcase │ ├── cljsbuild │ └── defproject ├── emacs-lisp-mode │ ├── req │ ├── autoload │ ├── ends │ └── provide.yasnippet ├── ruby-mode │ ├── def │ ├── deftest │ ├── do-block │ ├── def.self │ ├── assert_equal │ ├── class │ └── testcase ├── feature-mode │ ├── feature │ └── scenario ├── php-mode │ ├── fun │ ├── req │ ├── funs │ ├── public-function │ └── private-function ├── crappy-jsp-mode │ └── elvariable └── markdown-mode │ └── octopress-post ├── site-lisp ├── bash-completion │ ├── .gitignore │ └── README.md ├── eproject │ ├── .gitignore │ ├── lang │ │ └── README │ ├── contrib │ │ ├── README │ │ └── eproject-tags.el │ └── eproject-tests.el ├── evil │ ├── .gitattributes │ ├── .gitignore │ ├── evil-pkg.el │ ├── lib │ │ └── README │ ├── evil-compatibility.el │ ├── evil-replace.el │ ├── evil.el │ ├── Makefile │ └── evil-undo.el ├── skewer-mode │ ├── TODO │ ├── example.html │ ├── UNLICENSE │ ├── skewer-everything.user.js │ ├── cache-table.el │ ├── skewer-css.el │ ├── skewer-repl.el │ └── skewer-html.el ├── rhtml-mode │ ├── DEPTREE │ ├── README │ ├── LICENSE │ ├── test.rhtml │ ├── rhtml-navigation.el │ ├── rhtml-ruby-hook.el │ └── rhtml-mode.el ├── single-quotes-mode.el ├── groovy-mode │ └── README ├── jade-mode │ ├── example.jade │ ├── jade-mode.el │ ├── README.md │ └── sws-mode.el ├── oppdrag-mode.el ├── jmc-mode.el ├── project-archetypes │ └── project-archetypes.el ├── mouse-slider-mode.el └── core-async-mode.el ├── project-archetypes ├── js-buster-browser │ ├── .gitignore │ ├── .rvmrc │ ├── run-tests.sh │ ├── lib │ │ └── main.js │ ├── todo.org │ ├── test │ │ └── main-test.js │ ├── README.md │ ├── package.json │ ├── buster.js │ ├── autolint.js │ └── watch-tests.watchr ├── emacs-package │ ├── .gitignore │ ├── features │ │ ├── __project-name__.feature │ │ ├── support │ │ │ └── env.el │ │ └── step-definitions │ │ │ └── __project-name__-steps.el │ ├── run-tests.sh │ ├── Carton │ ├── run-travis-ci.sh │ ├── .travis.yml │ ├── watch-tests.watchr │ ├── __project-name__.el │ └── README.md ├── emacs-snippets │ ├── Carton │ ├── snippets │ │ └── __major-mode__ │ │ │ └── example-snippet-with-docs │ ├── README.md │ └── __target__-snippets.el ├── clj-ring │ ├── .gitignore │ ├── src │ │ └── __project_name__ │ │ │ └── core.clj │ └── resources │ │ └── public │ │ └── css │ │ └── reset.css ├── emacs-package-archetype.el ├── clj-ring-archetype.el ├── emacs-snippets-archetype.el └── js-buster-browser-archetype.el ├── .dir-locals.el ├── defuns ├── lisp-defuns.el ├── project-defuns.el ├── snippet-helpers.el ├── file-defuns.el └── clj-defuns.el ├── .gitignore ├── settings ├── setup-elnode.el ├── setup-markdown-mode.el ├── setup-skewer.el ├── setup-ruby-mode.el ├── setup-perspective.el ├── setup-shell.el ├── setup-dired.el ├── setup-flycheck.el ├── setup-package.el ├── setup-yasnippet.el ├── setup-org.el ├── setup-magit.el ├── mac.el ├── my-misc.el ├── setup-ffip.el ├── setup-html-mode.el ├── setup-ido.el ├── setup-paredit.el ├── appearance.el ├── mode-mappings.el ├── setup-rgrep.el └── sane-defaults.el ├── themes └── default-black-theme.el ├── kk.el └── README.md /users/magnars: -------------------------------------------------------------------------------- 1 | fimasvee/ -------------------------------------------------------------------------------- /snippets/js2-mode/.yas-parents: -------------------------------------------------------------------------------- 1 | js-mode -------------------------------------------------------------------------------- /site-lisp/bash-completion/.gitignore: -------------------------------------------------------------------------------- 1 | *.elc 2 | -------------------------------------------------------------------------------- /site-lisp/eproject/.gitignore: -------------------------------------------------------------------------------- 1 | *.elc 2 | TAGS 3 | -------------------------------------------------------------------------------- /site-lisp/evil/.gitattributes: -------------------------------------------------------------------------------- 1 | *.el diff=lisp 2 | -------------------------------------------------------------------------------- /site-lisp/evil/.gitignore: -------------------------------------------------------------------------------- 1 | *.elc 2 | .depend 3 | -------------------------------------------------------------------------------- /project-archetypes/js-buster-browser/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /project-archetypes/js-buster-browser/.rvmrc: -------------------------------------------------------------------------------- 1 | rvm use 1.9.2@autotest --create -------------------------------------------------------------------------------- /project-archetypes/js-buster-browser/run-tests.sh: -------------------------------------------------------------------------------- 1 | buster test -F warning 2 | -------------------------------------------------------------------------------- /snippets/html-mode/kbd: -------------------------------------------------------------------------------- 1 | # key: kbd 2 | # name: kbd 3 | # -- 4 | $1$0 -------------------------------------------------------------------------------- /project-archetypes/emacs-package/.gitignore: -------------------------------------------------------------------------------- 1 | *.elc 2 | .rvmrc 3 | /TAGS 4 | elpa 5 | -------------------------------------------------------------------------------- /project-archetypes/js-buster-browser/lib/main.js: -------------------------------------------------------------------------------- 1 | var __GLOBAL__ = this.__GLOBAL__ || {}; -------------------------------------------------------------------------------- /project-archetypes/js-buster-browser/todo.org: -------------------------------------------------------------------------------- 1 | * Todo [0/1] 2 | ** TODO Write a README 3 | -------------------------------------------------------------------------------- /users/christian/init.el: -------------------------------------------------------------------------------- 1 | ;; Easily navigate sillycased words 2 | (global-subword-mode 1) 3 | -------------------------------------------------------------------------------- /snippets/html-mode/em: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: em 3 | # key: em 4 | # -- 5 | $0 -------------------------------------------------------------------------------- /project-archetypes/emacs-package/features/__project-name__.feature: -------------------------------------------------------------------------------- 1 | Feature: 2 | 3 | Scenario: 4 | -------------------------------------------------------------------------------- /snippets/html-mode/code: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: code 3 | # key: code 4 | # -- 5 | $0 -------------------------------------------------------------------------------- /snippets/js-mode/this.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: this 3 | # key: . 4 | # -- 5 | this.$0 -------------------------------------------------------------------------------- /site-lisp/skewer-mode/TODO: -------------------------------------------------------------------------------- 1 | * eval-print-last-expression 2 | * recover gracefully from long poll timeouts 3 | -------------------------------------------------------------------------------- /snippets/clojure-mode/div: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: div 3 | # key: d 4 | # -- 5 | (d/div {} 6 | $0) -------------------------------------------------------------------------------- /snippets/emacs-lisp-mode/req: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: req 3 | # key: req 4 | # -- 5 | (require '$0) -------------------------------------------------------------------------------- /snippets/html-mode/c-if: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: c:if 3 | # key: cif 4 | # -- 5 | $0 -------------------------------------------------------------------------------- /snippets/html-mode/strong: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: strong 3 | # key: strong 4 | # -- 5 | $0 -------------------------------------------------------------------------------- /snippets/ruby-mode/def: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: def 3 | # key: def 4 | # -- 5 | def $1 6 | $0 7 | end -------------------------------------------------------------------------------- /snippets/emacs-lisp-mode/autoload: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: autoload 3 | # key: auto 4 | # -- 5 | ;;;###autoload -------------------------------------------------------------------------------- /snippets/clojure-mode/test: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: test 3 | # key: tt 4 | # -- 5 | (deftest $1 6 | (is (= $0))) -------------------------------------------------------------------------------- /snippets/html-mode/include: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: include 3 | # key: inc 4 | # -- 5 | <%@ include file="_$0.jsp" %> -------------------------------------------------------------------------------- /snippets/html-mode/script: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: script 3 | # key: script 4 | # -- 5 | -------------------------------------------------------------------------------- /snippets/js-mode/try: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: try 3 | # key: try 4 | # -- 5 | try { 6 | $0 7 | } catch (e) { 8 | } -------------------------------------------------------------------------------- /snippets/ruby-mode/deftest: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: tt 3 | # key: tt 4 | # -- 5 | def test_$1 6 | $0 7 | end 8 | -------------------------------------------------------------------------------- /snippets/ruby-mode/do-block: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: do-block 3 | # key: do 4 | # -- 5 | do ${1:|$2|} 6 | $0 7 | end -------------------------------------------------------------------------------- /snippets/clojure-mode/div-class: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: div-class 3 | # key: d. 4 | # -- 5 | (d/div {:className "$1"}$0) -------------------------------------------------------------------------------- /snippets/feature-mode/feature: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: feature 3 | # key: ft 4 | # -- 5 | Feature: $1 6 | 7 | sc$0 8 | -------------------------------------------------------------------------------- /snippets/html-mode/link: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: link 3 | # key: link 4 | # -- 5 | -------------------------------------------------------------------------------- /snippets/js-mode/for: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: for 3 | # key: for 4 | # -- 5 | for (var i = 0, l = ${num}; i < l; i++) {$0} -------------------------------------------------------------------------------- /snippets/ruby-mode/def.self: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: def.self 3 | # key: defs 4 | # -- 5 | def self.$1($2) 6 | $0 7 | end -------------------------------------------------------------------------------- /snippets/js-mode/jstd.log.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: jstd.log 3 | # key: log 4 | # -- 5 | jstestdriver.console.log($0); -------------------------------------------------------------------------------- /snippets/php-mode/fun: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: fun 3 | # key: fun 4 | # -- 5 | public function ${1:name}($2) { 6 | $0 7 | } -------------------------------------------------------------------------------- /snippets/php-mode/req: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: req 3 | # key: req 4 | # -- 5 | require_once(dirname(__FILE__) . "/$1.php");$0 -------------------------------------------------------------------------------- /project-archetypes/emacs-package/run-tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | ECUKES=$(find elpa/ecukes-*/ecukes | tail -1) 3 | carton exec "$ECUKES" "$@" 4 | -------------------------------------------------------------------------------- /site-lisp/evil/evil-pkg.el: -------------------------------------------------------------------------------- 1 | (define-package 2 | "evil" 3 | "0.0.0" 4 | "Extensible Vi layer for Emacs." 5 | '((undo-tree "0.3.0"))) 6 | -------------------------------------------------------------------------------- /snippets/emacs-lisp-mode/ends: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: ends 3 | # key: ends 4 | # -- 5 | ;;; `(buffer-file-name-body)`.el ends here$0 -------------------------------------------------------------------------------- /snippets/html-mode/input: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: input 3 | # key: input 4 | # -- 5 | -------------------------------------------------------------------------------- /snippets/js-mode/jstd-doc: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: jstd-doc 3 | # key: doc 4 | # -- 5 | /*:DOC ${1:element} = <${2:div}>$0*/ -------------------------------------------------------------------------------- /project-archetypes/emacs-snippets/Carton: -------------------------------------------------------------------------------- 1 | (source "melpa" "http://melpa.milkbox.net/packages/") 2 | 3 | (package-file "__target__-snippets.el") 4 | -------------------------------------------------------------------------------- /snippets/crappy-jsp-mode/elvariable: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: elvariable 3 | # key: el 4 | # -- 5 | <%--@elvariable id="$1" type="$2"--%> -------------------------------------------------------------------------------- /snippets/php-mode/funs: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: funs 3 | # key: funs 4 | # -- 5 | public static function ${1:name}($2) { 6 | $0 7 | } -------------------------------------------------------------------------------- /snippets/emacs-lisp-mode/provide.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: provide 3 | # key: pro 4 | # -- 5 | (provide '`(buffer-file-name-body)`)$0 -------------------------------------------------------------------------------- /snippets/feature-mode/scenario: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: scenario 3 | # key: sc 4 | # -- 5 | Scenario: $1 6 | Given $0 7 | When 8 | Then -------------------------------------------------------------------------------- /snippets/js-mode/node.module.exports.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: node.module.exports 3 | # key: mx 4 | # -- 5 | module.exports = $0; -------------------------------------------------------------------------------- /snippets/ruby-mode/assert_equal: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: assert_equal 3 | # key: ase 4 | # -- 5 | assert_equal ${1:expected}, ${2:actual}$0 -------------------------------------------------------------------------------- /snippets/clojure-mode/namespace: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: namespace 3 | # key: ns 4 | # -- 5 | (ns `(snippet--clojure-namespace-from-buffer-file-name)`)$0 -------------------------------------------------------------------------------- /snippets/php-mode/public-function: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: public function 3 | # key: f 4 | # -- 5 | public function ${1:name}($2) { 6 | $0 7 | } -------------------------------------------------------------------------------- /snippets/ruby-mode/class: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: class 3 | # key: cla 4 | # -- 5 | class `(s-upper-camel-case (buffer-file-name-body))` 6 | $0 7 | end -------------------------------------------------------------------------------- /snippets/js-mode/declare-global.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: declare-global 3 | # key: dg 4 | # -- 5 | var ${1:`buster-default-global`} = this.$1 || {}; -------------------------------------------------------------------------------- /snippets/js-mode/finn-element-builder: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: finn-element-builder 3 | # key: eb 4 | # -- 5 | var $1 = FINN.elementBuilder("${1:div}");$0 -------------------------------------------------------------------------------- /snippets/js-mode/object.create-property: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: object.create-property 3 | # key: pp 4 | # -- 5 | ${2:$1}: { value: params.${1:property} }$0 -------------------------------------------------------------------------------- /snippets/php-mode/private-function: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: private-function 3 | # key: pri 4 | # -- 5 | private function ${1:name}($2) { 6 | $0 7 | } -------------------------------------------------------------------------------- /snippets/clojure-mode/dev: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: dev-profile 3 | # key: dev 4 | # -- 5 | :profiles {:dev {:plugins [$1] 6 | :dependencies [$0]}} -------------------------------------------------------------------------------- /snippets/html-mode/c-forEach: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: c:forEach 3 | # key: cfe 4 | # -- 5 | 6 | $0 7 | -------------------------------------------------------------------------------- /snippets/js-mode/object.create-property+: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: object.create-property+ 3 | # key: ppp 4 | # -- 5 | ${2:$1}: { value: params.${1:property} }, 6 | ppp$0 -------------------------------------------------------------------------------- /snippets/js-mode/for-in: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: for-in 3 | # key: forin 4 | # -- 5 | for (var key in ${1:obj}) { 6 | if ($1.hasOwnProperty(key)) { 7 | $0 8 | } 9 | } -------------------------------------------------------------------------------- /snippets/js-mode/function.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: function 3 | # key: f 4 | # -- 5 | function ${1:`(snippet--function-name)`}($2) {$0}`(snippet--function-punctuation)` -------------------------------------------------------------------------------- /project-archetypes/js-buster-browser/test/main-test.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | buster.testCase("Main", { 3 | "Your blank slate, Sir": function () { 4 | assert(true); 5 | } 6 | }); 7 | }()); -------------------------------------------------------------------------------- /snippets/js-mode/node.ifnode.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: node.ifnode 3 | # key: ifnode 4 | # -- 5 | if (typeof require === "function" && typeof module !== "undefined") { 6 | $0 7 | } -------------------------------------------------------------------------------- /snippets/js-mode/object.create: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: object.create 3 | # key: create 4 | # -- 5 | create: function (params) { 6 | return Object.create(this, { 7 | ppp$0 8 | }); 9 | } -------------------------------------------------------------------------------- /site-lisp/skewer-mode/example.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Skewer 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /snippets/html-mode/oocss-module: -------------------------------------------------------------------------------- 1 | # key: mod 2 | # name: oocss-module 3 | # -- 4 |
5 |
6 |
7 | $0 8 |
9 |
10 |
-------------------------------------------------------------------------------- /snippets/js-mode/node.require.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: node.require 3 | # key: req 4 | # -- 5 | var ${3:${1:$(lower-camel-case (file-name-nondirectory yas/text))}} = require("${1:fs}")$2;$0 -------------------------------------------------------------------------------- /project-archetypes/emacs-snippets/snippets/__major-mode__/example-snippet-with-docs: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: example 3 | # key: example 4 | # -- 5 | example` 6 | (__target__-snippets/show-docs "example")` -------------------------------------------------------------------------------- /project-archetypes/emacs-package/Carton: -------------------------------------------------------------------------------- 1 | (source "melpa" "http://melpa.milkbox.net/packages/") 2 | 3 | (package-file "__project-name__.el") 4 | 5 | (development 6 | (depends-on "ecukes") 7 | (depends-on "espuds")) 8 | -------------------------------------------------------------------------------- /project-archetypes/js-buster-browser/README.md: -------------------------------------------------------------------------------- 1 | # __project-name__ 2 | 3 | __description__ 4 | 5 | ## License 6 | 7 | Copyright © 2013, Magnar Sveen. uses semantic versioning. Code 8 | released under the BSD license. 9 | -------------------------------------------------------------------------------- /snippets/html-mode/media: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: media 3 | # key: media 4 | # -- 5 |
6 | $2 7 |
8 | $0 9 |
10 |
-------------------------------------------------------------------------------- /project-archetypes/clj-ring/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /lib 3 | /classes 4 | /checkouts 5 | pom.xml 6 | pom.xml.asc 7 | *.jar 8 | *.class 9 | .lein-deps-sum 10 | .lein-failures 11 | .lein-plugins 12 | .lein-repl-history 13 | -------------------------------------------------------------------------------- /.dir-locals.el: -------------------------------------------------------------------------------- 1 | ;;; Directory Local Variables -*- no-byte-compile: t -*- 2 | ;;; For more information see (info "(emacs) Directory Variables") 3 | 4 | ((emacs-lisp-mode . ((flycheck-disabled-checkers . (emacs-lisp-checkdoc))))) 5 | -------------------------------------------------------------------------------- /snippets/clojure-mode/testcase: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: testcase 3 | # key: tc 4 | # -- 5 | (ns `(snippet--clojure-namespace-from-buffer-file-name)` 6 | (:use [`(snippet--clojure-namespace-under-test)`]) 7 | (:use [clojure.test])) 8 | 9 | tt$0 -------------------------------------------------------------------------------- /snippets/ruby-mode/testcase: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: testcase 3 | # key: tc 4 | # -- 5 | require 'test/unit' 6 | require '$1' 7 | 8 | class ${1:$(upper-camel-case yas/text)}TestCase < Test::Unit::TestCase 9 | 10 | tt$0 11 | 12 | end -------------------------------------------------------------------------------- /project-archetypes/js-buster-browser/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "__project-name__", 3 | "version": "0.1.0", 4 | "description": "__description__", 5 | "author": { "name": "Magnar Sveen" }, 6 | "devDependencies": { 7 | "buster": "~0.6", 8 | "buster-lint": "~0" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /project-archetypes/js-buster-browser/buster.js: -------------------------------------------------------------------------------- 1 | exports["Browser tests"] = { 2 | environment: "browser", 3 | libs: ["external/cull.js", "external/dome.js"], 4 | sources: ["lib/*.js"], 5 | tests: ["test/*.js"], 6 | extensions: [require("buster-lint")], 7 | "buster-lint": require("./autolint") 8 | }; 9 | -------------------------------------------------------------------------------- /site-lisp/evil/lib/README: -------------------------------------------------------------------------------- 1 | This folder contains external libraries that are freely distributable 2 | under the GNU GPL license. They may not be up to date. 3 | 4 | Emacs does not add subdirectories to the `load-path' by default. 5 | Therefore this directory is not covered by the installation 6 | instructions. 7 | -------------------------------------------------------------------------------- /snippets/js-mode/jstd.additionalTestCase.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: jstd.additionalTestCase 3 | # key: tcc 4 | # condition: (not buster-testcase-snippets-enabled) 5 | # -- 6 | testCase("${2:`(chop-suffix "Test" (upper-camel-case (buffer-file-name-body)))`}$3", sinon.testCase({ 7 | tt$0 8 | })); 9 | -------------------------------------------------------------------------------- /project-archetypes/emacs-package/run-travis-ci.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | cd "$(dirname "$0")" 4 | 5 | ECUKES_EMACS=${EMACS:-$(which emacs)} 6 | export ECUKES_EMACS 7 | 8 | echo "*** Emacs version ***" 9 | echo "ECUKES_EMACS = $ECUKES_EMACS" 10 | "$ECUKES_EMACS" --version 11 | echo 12 | 13 | exec ./run-tests.sh $TAGS 14 | -------------------------------------------------------------------------------- /snippets/html-mode/html: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: html 3 | # key: html 4 | # -- 5 | 6 | 7 | 8 | 9 | 10 | $1 11 | 12 | 13 | $0 14 | 15 | 16 | -------------------------------------------------------------------------------- /snippets/js-mode/immediately-invoked-function-expression.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: immediately-invoked-function-expression 3 | # key: ff 4 | # -- 5 | (function (${2:${1:$(buster--shortcuts-for-globals yas/text)}}) { 6 | `(buster--maybe-use-strict) 7 | `$0 8 | }(${1:`(if buster-add-default-global-to-iife buster-default-global)`})); 9 | -------------------------------------------------------------------------------- /defuns/lisp-defuns.el: -------------------------------------------------------------------------------- 1 | ;; Lisp specific defuns 2 | 3 | (defun eval-and-replace () 4 | "Replace the preceding sexp with its value." 5 | (interactive) 6 | (backward-kill-sexp) 7 | (condition-case nil 8 | (prin1 (eval (read (current-kill 0))) 9 | (current-buffer)) 10 | (error (message "Invalid expression") 11 | (insert (current-kill 0))))) 12 | -------------------------------------------------------------------------------- /site-lisp/rhtml-mode/DEPTREE: -------------------------------------------------------------------------------- 1 | Rough overview of dependencies 2 | (2006SEP24) 3 | 4 | rhtml-mode 5 | sgml-mode 6 | rhtml-fonts (optional) 7 | rhtml-erb 8 | ruby-mode 9 | rthml-sgml-hacks (optional) 10 | rhtml-erb 11 | rhtml-ruby-hook 12 | ruby-mode 13 | sgml-mode (from emacs 22) 14 | rhtml-navigation (optional) 15 | rhtml-dirty-fonts (optional) 16 | rhtml-erb 17 | -------------------------------------------------------------------------------- /site-lisp/rhtml-mode/README: -------------------------------------------------------------------------------- 1 | rhtml --- mmm-free mode for editing .rhtml files using Emacs 2 | 3 | Can be used with Rinari (http://github.com/eschulte/rinari/tree/master) 4 | 5 | to use download this directory and place it in your elisp directory, 6 | then include the following in you emacs .init file 7 | 8 | ;;; rhtml mode 9 | (add-to-list 'load-path "~/path/to/rhtml") 10 | (require 'rhtml-mode) 11 | -------------------------------------------------------------------------------- /snippets/markdown-mode/octopress-post: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: octopress-post 3 | # key: post 4 | # -- 5 | --- 6 | layout: post 7 | title: "$1" 8 | date: `(substring (buffer-file-name-body) 0 10)` `(substring (current-time-string) 11 16)` 9 | comments: true 10 | --- 11 | {% img imgs /photos/`(substring (buffer-file-name-body) 0 10)`-`(substring (buffer-file-name-body) 11)`-1.jpg %} 12 | $0 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | auto-save-list 2 | backups 3 | *~ 4 | .places 5 | session.* 6 | tramp 7 | elpa 8 | swank 9 | emms 10 | site-lisp/adventur-mode 11 | *.elc 12 | .DS_Store 13 | .yas-compiled-snippets.el 14 | .cask 15 | /url/ 16 | /var/ 17 | /.sx/ 18 | /ensime/ 19 | /history 20 | /ido.last 21 | /recentf 22 | /projectile-bookmarks.eld 23 | /projectile.cache 24 | /transient/history.el 25 | /transient/values.el 26 | /forge-database.sqlite 27 | /smex-items 28 | -------------------------------------------------------------------------------- /snippets/clojure-mode/cljsbuild: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: cljsbuild 3 | # key: cljsbuild 4 | # -- 5 | :cljsbuild {:builds [{:source-paths ["src" "dev"] 6 | :compiler {:output-to "target/classes/public/app.js" 7 | :output-dir "target/classes/public/out" 8 | :optimizations :none 9 | :recompile-dependents true 10 | :source-map true}}]} -------------------------------------------------------------------------------- /snippets/js-mode/jstd.testCase.yasnippet: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: jstd.testCase 3 | # key: tc 4 | # condition: (not buster-testcase-snippets-enabled) 5 | # -- 6 | (function (${2:${1:$(buster--shortcuts-for-globals yas/text)}}) { 7 | testCase("${3:`(chop-suffix "Test" (upper-camel-case (buffer-file-name-body)))`}$4Test", sinon.testCase({ 8 | tt$0 9 | })); 10 | }(${1:`(if buster-add-default-global-to-iife buster-default-global)`})); 11 | -------------------------------------------------------------------------------- /project-archetypes/emacs-package-archetype.el: -------------------------------------------------------------------------------- 1 | (defun create-emacs-package (project-name description) 2 | (interactive "sProject name: \nsDescription: ") 3 | (pa-with-new-project project-name "emacs-package" 4 | ((cons "__project-name__" project-name) 5 | (cons "__description__" description)) 6 | (pa-sh "carton"))) 7 | 8 | (pa-declare-project-archetype "emacs-package" 'create-emacs-package) 9 | 10 | (provide 'emacs-package-archetype) 11 | -------------------------------------------------------------------------------- /snippets/js-mode/directive-oiiku-shared: -------------------------------------------------------------------------------- 1 | # key: ng 2 | # name: directive-oiiku-shared 3 | # -- 4 | angular.module("OIIKU_SHARED") 5 | .directive("`(s-lower-camel-case (buffer-file-name-body))`", function (getContextPath) { 6 | return { 7 | restrict: "E", 8 | templateUrl: getContextPath("angular-shared") + "/`(buffer-file-name-body)`.html", 9 | link: function () { 10 | 11 | } 12 | }; 13 | }); -------------------------------------------------------------------------------- /defuns/project-defuns.el: -------------------------------------------------------------------------------- 1 | (defmacro project-specifics (name &rest body) 2 | (declare (indent 1)) 3 | `(progn 4 | (add-hook 'find-file-hook 5 | (lambda () 6 | (when (string-match-p ,name (buffer-file-name)) 7 | ,@body))) 8 | (add-hook 'dired-after-readin-hook 9 | (lambda () 10 | (when (string-match-p ,name (dired-current-directory)) 11 | ,@body))))) 12 | -------------------------------------------------------------------------------- /settings/setup-elnode.el: -------------------------------------------------------------------------------- 1 | ;; Some basic elnode setup that should probably have been the default 2 | (setq elnode-do-init nil) ;; don't start a server on port 8000 when starting emacs 3 | (setq elnode-error-log-to-messages nil) ;; mute the crazy logging 4 | (setq elnode-log-files-directory nil) ;; don't clutter my file system with logs either 5 | 6 | ;; Some more nice autoloads 7 | (autoload 'elnode-webserver-handler-maker "elnode") 8 | 9 | (provide 'setup-elnode) 10 | -------------------------------------------------------------------------------- /project-archetypes/js-buster-browser/autolint.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "paths": [ 3 | "test/**/*.js", 4 | "lib/**/*.js" 5 | ], 6 | 7 | "linterOptions": { 8 | "indent": 2, 9 | "vars": true, 10 | "nomen": true, 11 | "sloppy": true, 12 | "plusplus": true, 13 | "predef": [ 14 | "assert", 15 | "refute", 16 | "buster", 17 | "cull", 18 | "dome", 19 | "__GLOBAL__" 20 | ] 21 | }, 22 | 23 | "excludes": [ 24 | "external" 25 | ] 26 | }; 27 | -------------------------------------------------------------------------------- /site-lisp/single-quotes-mode.el: -------------------------------------------------------------------------------- 1 | (defvar single-quotes-mode-map (make-sparse-keymap) 2 | "single-quotes-mode keymap") 3 | 4 | (defun single-quotes-insert () 5 | (self-insert-command)) 6 | 7 | (define-key single-quotes-mode-map 8 | (kbd "\"") (kbd "'")) 9 | 10 | (define-minor-mode single-quotes-mode 11 | "A minor mode to insert single quotes ' instead of double quotes \". 12 | How do you insert double quotes then? With C-q." 13 | nil 14 | "''" 15 | single-quotes-mode-map) 16 | 17 | (provide 'single-quotes-mode) 18 | -------------------------------------------------------------------------------- /snippets/clojure-mode/defproject: -------------------------------------------------------------------------------- 1 | # -*- mode: snippet -*- 2 | # name: defproject 3 | # key: project 4 | # -- 5 | (defproject ${1:`(file-name-base (f-parent (buffer-file-name)))`} "0.1.0-SNAPSHOT" 6 | :description "$2" 7 | :url "https://github.com/magnars/$1" 8 | :license {:name "Eclipse Public License" 9 | :url "http://www.eclipse.org/legal/epl-v10.html"} 10 | :dependencies [[org.clojure/clojure "1.9.0"]] 11 | :profiles {:dev {:plugins [] 12 | :dependencies [] 13 | :source-paths ["dev"]}}) 14 | -------------------------------------------------------------------------------- /project-archetypes/clj-ring/src/__project_name__/core.clj: -------------------------------------------------------------------------------- 1 | (ns __project-name__.core 2 | (:use compojure.core) 3 | (:use hiccup.core) 4 | (:use hiccup.page) 5 | (:require [compojure.route :as route])) 6 | 7 | (defn render-index [] 8 | (html5 9 | [:head 10 | [:meta {:charset "utf-8"}] 11 | [:meta {:name "viewport" 12 | :content "width=device-width, initial-scale=1.0, maximum-scale=1"}]])) 13 | 14 | (defroutes app 15 | (GET "/" [] (render-index)) 16 | (route/resources "/") 17 | (route/not-found "

Page not found

")) 18 | -------------------------------------------------------------------------------- /project-archetypes/clj-ring-archetype.el: -------------------------------------------------------------------------------- 1 | (defun create-clj-ring (project-name) 2 | (interactive "sProject name: ") 3 | (pa-with-new-project project-name "clj-ring" 4 | ((cons "__project-name__" project-name) 5 | (cons "__project_name__" (s-snake-case project-name))))) 6 | 7 | (defun pa--testing-fn () 8 | (shell-command "rm -rf ~/projects/test-test" pa-out) 9 | (create-clj-ring "test-test") 10 | (find-file-other-window "~/projects/test-test")) 11 | 12 | (pa-declare-project-archetype "clj-ring" 'create-clj-ring) 13 | 14 | (provide 'clj-ring-archetype) 15 | -------------------------------------------------------------------------------- /site-lisp/groovy-mode/README: -------------------------------------------------------------------------------- 1 | This is a collection of (X)Emacs modes for use with Groovy-related technology -- Groovy, Grails, etc. 2 | 3 | The Groovy mode is a derived mode of Java mode which is itself a derived mode in CC Mode. Inspiration came 4 | from Dylan R.E. Moonfire's C# mode. 5 | 6 | This software is licenced using GNU General Public Licence version 2. 7 | 8 | The master of all the material is the Bazaar branch lp:groovy-emacs-mode. See https://launchpad.net/groovy-emacs-mode. 9 | 10 | Bazaar is used for development, with public feature branches being held on Launchpad. 11 | -------------------------------------------------------------------------------- /site-lisp/jade-mode/example.jade: -------------------------------------------------------------------------------- 1 | !!! 2 | html(lang="en") 3 | head 4 | title My page 5 | body.bp 6 | #container 7 | #header 8 | h1.page-title= My.awesome. page #is awesome# 9 | #nav 10 | ul#nav_list something sweet 11 | li 12 | #content 13 | - if (youAreUsingJade) 14 | p You are amazing 15 | - else 16 | p Get on it! 17 | form 18 | input(type: "text", name='user[name]', readonly: true, disabled) 19 | #footer 20 | #copywrite-text= locals 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /project-archetypes/emacs-package/features/support/env.el: -------------------------------------------------------------------------------- 1 | (let* ((current-directory (file-name-directory load-file-name)) 2 | (features-directory (expand-file-name ".." current-directory)) 3 | (project-directory (expand-file-name ".." features-directory))) 4 | (setq __project-name__-root-path project-directory)) 5 | 6 | (add-to-list 'load-path __project-name__-root-path) 7 | 8 | (require '__project-name__) 9 | (require 'espuds) 10 | (require 'ert) 11 | 12 | (Before 13 | (switch-to-buffer 14 | (get-buffer-create "*__project-name__*")) 15 | (erase-buffer) 16 | (fundamental-mode) 17 | (deactivate-mark)) 18 | 19 | (After) 20 | -------------------------------------------------------------------------------- /settings/setup-markdown-mode.el: -------------------------------------------------------------------------------- 1 | (setq markdown-imenu-generic-expression 2 | '(("title" "^\\(.*\\)[\n]=+$" 1) 3 | ("h2-" "^\\(.*\\)[\n]-+$" 1) 4 | ("h1" "^# \\(.*\\)$" 1) 5 | ("h2" "^## \\(.*\\)$" 1) 6 | ("h3" "^### \\(.*\\)$" 1) 7 | ("h4" "^#### \\(.*\\)$" 1) 8 | ("h5" "^##### \\(.*\\)$" 1) 9 | ("h6" "^###### \\(.*\\)$" 1) 10 | ("fn" "^\\[\\^\\(.*\\)\\]" 1) 11 | )) 12 | 13 | (add-hook 'markdown-mode-hook 14 | (lambda () 15 | (setq imenu-generic-expression markdown-imenu-generic-expression))) 16 | 17 | (provide 'setup-markdown-mode) 18 | -------------------------------------------------------------------------------- /project-archetypes/emacs-snippets-archetype.el: -------------------------------------------------------------------------------- 1 | (defun create-emacs-snippets (target name website major-mode) 2 | (interactive "sSnippets for (short name): \nsSnippets for (full name): \nsWebsite: \naMajor mode: ") 3 | (pa-with-new-project (format "%s-snippets" target) "emacs-snippets" 4 | ((cons "__target__" target) 5 | (cons "__name__" name) 6 | (cons "__website__" website) 7 | (cons "__major-mode__" (format "%S" major-mode)) 8 | (cons "__year__" (format-time-string "%Y"))) 9 | (pa-sh "carton package"))) 10 | 11 | (pa-declare-project-archetype "emacs-snippets" 'create-emacs-snippets) 12 | 13 | (provide 'emacs-snippets-archetype) 14 | -------------------------------------------------------------------------------- /settings/setup-skewer.el: -------------------------------------------------------------------------------- 1 | 2 | ;; Bookmarklet to load skewer: 3 | ;; 4 | ;; javascript:(function(){var d=document ;var s=d.createElement('script');s.src='http://localhost:8023/skewer';d.body.appendChild(s);})() 5 | ;; 6 | 7 | (require 'skewer-mode) 8 | (require 'skewer-repl) 9 | (require 'skewer-html) 10 | (require 'skewer-css) 11 | 12 | (defun skewer-start () 13 | (interactive) 14 | (let ((httpd-port 8023)) 15 | (httpd-start) 16 | (message "Ready to skewer the browser. Now jack in with the bookmarklet."))) 17 | 18 | (defun skewer-demo () 19 | (interactive) 20 | (let ((httpd-port 8024)) 21 | (run-skewer) 22 | (skewer-repl))) 23 | 24 | (provide 'setup-skewer) 25 | -------------------------------------------------------------------------------- /project-archetypes/js-buster-browser-archetype.el: -------------------------------------------------------------------------------- 1 | (require 'magit) 2 | 3 | (defun create-js-buster-browser (project-name description global) 4 | (interactive "sProject name: \nsDescription: \nsGlobal namespace: ") 5 | (pa-with-new-project project-name "js-buster-browser" 6 | ((cons "__project-name__" project-name) 7 | (cons "__description__" description) 8 | (cons "__GLOBAL__" global)) 9 | (magit-ignore-file ".rvmrc" nil t) 10 | (magit-ignore-file "todo.org" nil t) 11 | (pa-sh "npm link buster") 12 | (pa-sh "npm install"))) 13 | 14 | (pa-declare-project-archetype "js-buster-browser" 'create-js-buster-browser) 15 | 16 | (provide 'js-buster-browser-archetype) 17 | -------------------------------------------------------------------------------- /users/christian/org-mode-hacks.el: -------------------------------------------------------------------------------- 1 | (defun increment-number-at-point () 2 | (interactive) 3 | (insert "(1+ ") 4 | (search-forward-regexp "[^0-9]") 5 | (backward-char) 6 | (insert ")") 7 | (eval-and-replace)) 8 | 9 | (defun add-table-line-readjust-formula () 10 | "This function is very specific to one specific org-mode table I work on" 11 | (interactive) 12 | (end-of-line) 13 | (org-return) 14 | (insert "|") 15 | (let ((currpos (point))) 16 | (org-cycle) 17 | (search-forward "#+TBLFM") 18 | (search-forward "::@") 19 | (increment-number-at-point) 20 | (search-forward "..@") 21 | (increment-number-at-point) 22 | (org-ctrl-c-ctrl-c) 23 | (goto-char (1+ currpos)))) 24 | -------------------------------------------------------------------------------- /site-lisp/rhtml-mode/LICENSE: -------------------------------------------------------------------------------- 1 | !!!ATTENTION!!! 2 | 3 | Files for RHTML-MODE are licensed under the MPL Tri-license (MPL 4 | 1.1/GPL 2.0/LGPL 2.1) 5 | EXCEPT for the following: 6 | ``rhtml-sgml-hacks.el'' 7 | ``rhtml-font.el'' 8 | Which are licensed under the GPL License due to using GPL'ed code verbatim. 9 | 10 | Also, since FSF Emacs (the reference elisp implementaion) is released 11 | under the GPL it is questionable as to wether elisp which can run in 12 | Emacs--and indeed, Emacs is the intendend target--should also fall 13 | under the GPL. I hold to the belief that license violations for elisp 14 | code ONLY OCCUR DURING EXECUTION and not for "at rest" code which may 15 | make reference to GPL'ed functions. However, if you have any doubts 16 | the MPL Tri-license allows you to choose the GPL. -------------------------------------------------------------------------------- /project-archetypes/js-buster-browser/watch-tests.watchr: -------------------------------------------------------------------------------- 1 | ENV["WATCHR"] = "1" 2 | system 'clear' 3 | 4 | def run(cmd) 5 | `#{cmd}` 6 | end 7 | 8 | def run_all_tests 9 | system('clear') 10 | result = run "./run-tests.sh" 11 | puts result 12 | end 13 | 14 | run_all_tests 15 | watch('.*.js') { run_all_tests } 16 | 17 | # Ctrl-\ 18 | Signal.trap 'QUIT' do 19 | puts " --- Running all tests ---\n\n" 20 | run_all_tests 21 | end 22 | 23 | @interrupted = false 24 | 25 | # Ctrl-C 26 | Signal.trap 'INT' do 27 | if @interrupted then 28 | @wants_to_quit = true 29 | abort("\n") 30 | else 31 | puts "Interrupt a second time to quit" 32 | @interrupted = true 33 | Kernel.sleep 1.5 34 | # raise Interrupt, nil # let the run loop catch it 35 | run_all_tests 36 | @interrupted = false 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /settings/setup-ruby-mode.el: -------------------------------------------------------------------------------- 1 | ;; avoid ridiculous ruby indentation 2 | (setq ruby-deep-indent-paren nil) 3 | 4 | (defun ruby--jump-to-test () 5 | (find-file 6 | (replace-regexp-in-string 7 | "/lib/" "/test/" 8 | (replace-regexp-in-string 9 | "/\\([^/]+\\).rb$" "/test_\\1.rb" 10 | (buffer-file-name))))) 11 | 12 | (defun ruby--jump-to-lib () 13 | (find-file 14 | (replace-regexp-in-string 15 | "/test/" "/lib/" 16 | (replace-regexp-in-string 17 | "/test_\\([^/]+\\).rb$" "/\\1.rb" 18 | (buffer-file-name))))) 19 | 20 | (defun ruby-jump-to-other () 21 | (interactive) 22 | (if (string-match-p "/test/" (buffer-file-name)) 23 | (ruby--jump-to-lib) 24 | (ruby--jump-to-test))) 25 | 26 | (define-key ruby-mode-map (kbd "C-c t") 'ruby-jump-to-other) 27 | 28 | (provide 'setup-ruby-mode) 29 | -------------------------------------------------------------------------------- /project-archetypes/clj-ring/resources/public/css/reset.css: -------------------------------------------------------------------------------- 1 | /* Eric Meyer's Reset CSS v2.0 - http://cssreset.com */ 2 | html,body,div,span,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{border:0;font-size:100%;font:inherit;vertical-align:baseline;margin:0;padding:0}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:none}table{border-collapse:collapse;border-spacing:0} -------------------------------------------------------------------------------- /project-archetypes/emacs-package/.travis.yml: -------------------------------------------------------------------------------- 1 | language: emacs-lisp 2 | before_install: 3 | - if [ "$EMACS" = 'emacs-snapshot' ]; then 4 | sudo add-apt-repository -y ppa:cassou/emacs && 5 | sudo apt-get update -qq && 6 | sudo apt-get install -qq 7 | emacs-snapshot-el emacs-snapshot-gtk emacs-snapshot; 8 | fi 9 | - if [ "$EMACS" = 'emacs24' ]; then 10 | sudo add-apt-repository -y ppa:cassou/emacs && 11 | sudo apt-get update -qq && 12 | sudo apt-get install -qq 13 | emacs24 emacs24-el emacs24-common-non-dfsg; 14 | fi 15 | - curl -fsSkL https://raw.github.com/rejeep/carton/master/go | sh 16 | - export PATH="/home/travis/.carton/bin:$PATH" 17 | - carton 18 | env: 19 | - EMACS=emacs24 TAGS="--tags ~@requires-e24-3" 20 | - EMACS=emacs-snapshot TAGS="" 21 | script: 22 | ./run-travis-ci.sh 23 | -------------------------------------------------------------------------------- /settings/setup-perspective.el: -------------------------------------------------------------------------------- 1 | ;; Load Perspective 2 | (require 'perspective) 3 | 4 | (global-set-key (kbd "C-x C-b") 'persp-list-buffers) 5 | (customize-set-variable 'persp-mode-prefix-key (kbd "C-x x")) 6 | 7 | ;; Enable perspective mode 8 | (persp-mode) 9 | 10 | ;; TODO: implement persp-last as before-advice on persp-switch (?) 11 | 12 | (defmacro custom-persp (name &rest body) 13 | `(let ((initialize (not (gethash ,name (perspectives-hash)))) 14 | (current-perspective (persp-curr))) 15 | (persp-switch ,name) 16 | (when initialize ,@body) 17 | (set-frame-parameter nil 'persp--last current-perspective))) 18 | 19 | ;; Jump to last perspective 20 | (defun custom-persp-last () 21 | (interactive) 22 | (persp-switch (persp-name persp-last))) 23 | 24 | (define-key persp-mode-map (kbd "C-x p -") 'custom-persp-last) 25 | 26 | (provide 'setup-perspective) 27 | -------------------------------------------------------------------------------- /themes/default-black-theme.el: -------------------------------------------------------------------------------- 1 | (deftheme default-black 2 | "Automatically created 2013-05-20.") 3 | 4 | (custom-theme-set-faces 5 | 'default-black 6 | '(default ((t (:inherit nil :stipple nil :background "Black" :foreground "White" :inverse-video nil :box nil :strike-t*hrough nil :overline nil :underline nil :slant normal :weight normal :width normal :height 105)))) 7 | '(highlight ((((class color) (min-colors 88) (background dark)) (:background "#111111")))) 8 | '(region ((nil (:background "#464740")))) 9 | '(hl-line ((nil (:background "#222222")))) 10 | '(yas-field-highlight-face ((nil (:background "#333399")))) 11 | '(js2-function-param-face ((t (:foreground "LightGoldenrod")))) 12 | '(font-lock-warning-face ((nil (:foreground "#ff6666")))) 13 | '(show-paren-match ((nil (:background "#333399")))) 14 | '(show-paren-mismatch ((((class color)) (:background "red"))))) 15 | 16 | (provide-theme 'default-black) 17 | -------------------------------------------------------------------------------- /project-archetypes/emacs-package/watch-tests.watchr: -------------------------------------------------------------------------------- 1 | ENV["WATCHR"] = "1" 2 | system 'clear' 3 | 4 | def run(cmd) 5 | `#{cmd}` 6 | end 7 | 8 | def run_all_tests 9 | system('clear') 10 | result = run "./run-tests.sh" 11 | puts result 12 | end 13 | 14 | def run_test(file) 15 | system('clear') 16 | result = run "./run-tests.sh #{file} --verbose" 17 | puts result 18 | end 19 | 20 | run_all_tests 21 | watch('.*.feature') { |file| run_test file } 22 | watch('.*.el') { run_all_tests } 23 | 24 | # Ctrl-\ 25 | Signal.trap 'QUIT' do 26 | puts " --- Running all tests ---\n\n" 27 | run_all_tests 28 | end 29 | 30 | @interrupted = false 31 | 32 | # Ctrl-C 33 | Signal.trap 'INT' do 34 | if @interrupted then 35 | @wants_to_quit = true 36 | abort("\n") 37 | else 38 | puts "Interrupt a second time to quit" 39 | @interrupted = true 40 | Kernel.sleep 1.5 41 | # raise Interrupt, nil # let the run loop catch it 42 | run_all_tests 43 | @interrupted = false 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /settings/setup-shell.el: -------------------------------------------------------------------------------- 1 | ;; Setup shell 2 | 3 | ;; Note: Emacs runs .bashrc in *shell* 4 | ;; So mac users should ln -s .profile .bashrc 5 | 6 | ;; bash-completion 7 | 8 | (autoload 'bash-completion-dynamic-complete 9 | "bash-completion" 10 | "BASH completion hook") 11 | (add-hook 'shell-dynamic-complete-functions 12 | 'bash-completion-dynamic-complete) 13 | (add-hook 'shell-command-complete-functions 14 | 'bash-completion-dynamic-complete) 15 | 16 | ;; tab-completion for shell-command 17 | 18 | (require 'shell-command) 19 | (shell-command-completion-mode) 20 | 21 | ;; C-d to kill buffer if process is dead. 22 | 23 | (defun comint-delchar-or-eof-or-kill-buffer (arg) 24 | (interactive "p") 25 | (if (null (get-buffer-process (current-buffer))) 26 | (kill-buffer) 27 | (comint-delchar-or-maybe-eof arg))) 28 | 29 | (add-hook 'shell-mode-hook 30 | (lambda () 31 | (define-key shell-mode-map (kbd "C-d") 'comint-delchar-or-eof-or-kill-buffer))) 32 | 33 | (provide 'setup-shell) 34 | -------------------------------------------------------------------------------- /project-archetypes/emacs-package/__project-name__.el: -------------------------------------------------------------------------------- 1 | ;;; __project-name__.el --- __description__ 2 | 3 | ;; Copyright (C) 2013 Magnar Sveen 4 | 5 | ;; Author: Magnar Sveen 6 | ;; Version: 0.1.0 7 | ;; Package-Requires: ((s "1.4.0") (dash "1.2.0")) 8 | 9 | ;; This program is free software; you can redistribute it and/or modify 10 | ;; it under the terms of the GNU General Public License as published by 11 | ;; the Free Software Foundation, either version 3 of the License, or 12 | ;; (at your option) any later version. 13 | 14 | ;; This program is distributed in the hope that it will be useful, 15 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ;; GNU General Public License for more details. 18 | 19 | ;; You should have received a copy of the GNU General Public License 20 | ;; along with this program. If not, see . 21 | 22 | ;;; Commentary: 23 | 24 | ;; __description__ 25 | 26 | ;;; Code: 27 | 28 | (provide '__project-name__) 29 | ;;; __project-name__.el ends here 30 | -------------------------------------------------------------------------------- /settings/setup-dired.el: -------------------------------------------------------------------------------- 1 | (require 'dired) 2 | (require 'dired-x) 3 | (require 'dash) 4 | 5 | ;; Make dired less verbose 6 | (add-hook 'dired-mode-hook (lambda () (dired-hide-details-mode 1))) 7 | 8 | ;; Move files between split panes 9 | (setq dired-dwim-target t) 10 | 11 | ;; C-a is nicer in dired if it moves back to start of files 12 | (defun dired-back-to-start-of-files () 13 | (interactive) 14 | (backward-char (- (current-column) 2))) 15 | 16 | (define-key dired-mode-map (kbd "C-a") 'dired-back-to-start-of-files) 17 | (define-key dired-mode-map (kbd "k") 'dired-do-delete) 18 | 19 | ;; Enable 'a'-keybinding in dired - which opens the file and closes dired buffer 20 | 21 | (put 'dired-find-alternate-file 'disabled nil) 22 | 23 | ;; Delete with C-x C-k to match file buffers and magit 24 | (define-key dired-mode-map (kbd "C-x C-k") 'dired-do-delete) 25 | 26 | (eval-after-load "wdired" 27 | '(progn 28 | (define-key wdired-mode-map (kbd "C-a") 'dired-back-to-start-of-files) 29 | (define-key wdired-mode-map (vector 'remap 'beginning-of-buffer) 'dired-back-to-top) 30 | (define-key wdired-mode-map (vector 'remap 'end-of-buffer) 'dired-jump-to-bottom))) 31 | 32 | (provide 'setup-dired) 33 | -------------------------------------------------------------------------------- /settings/setup-flycheck.el: -------------------------------------------------------------------------------- 1 | (require 'flycheck) 2 | (require 'flycheck-pos-tip) 3 | 4 | (defun magnars/adjust-flycheck-automatic-syntax-eagerness () 5 | "Adjust how often we check for errors based on if there are any. 6 | 7 | This lets us fix any errors as quickly as possible, but in a 8 | clean buffer we're an order of magnitude laxer about checking." 9 | (setq flycheck-idle-change-delay 10 | (if flycheck-current-errors 0.5 30.0))) 11 | 12 | ;; Each buffer gets its own idle-change-delay because of the 13 | ;; buffer-sensitive adjustment above. 14 | (make-variable-buffer-local 'flycheck-idle-change-delay) 15 | 16 | (add-hook 'flycheck-after-syntax-check-hook 17 | 'magnars/adjust-flycheck-automatic-syntax-eagerness) 18 | 19 | ;; Remove newline checks, since they would trigger an immediate check 20 | ;; when we want the idle-change-delay to be in effect while editing. 21 | (setq flycheck-check-syntax-automatically '(save 22 | idle-change 23 | mode-enabled)) 24 | 25 | (eval-after-load 'flycheck 26 | '(custom-set-variables 27 | '(flycheck-display-errors-function #'flycheck-pos-tip-error-messages))) 28 | 29 | (provide 'setup-flycheck) 30 | -------------------------------------------------------------------------------- /settings/setup-package.el: -------------------------------------------------------------------------------- 1 | (require 'package) 2 | (require 'dash) 3 | 4 | ;; Add melpa to package repos 5 | (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) 6 | (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t) 7 | 8 | (setq package-pinned-packages '()) 9 | 10 | (package-initialize) 11 | 12 | (unless (file-exists-p "~/.emacs.d/elpa/archives/melpa") 13 | (package-refresh-contents)) 14 | 15 | (defun packages-install (packages) 16 | (--each packages 17 | (when (not (package-installed-p it)) 18 | (package-install it))) 19 | (delete-other-windows)) 20 | 21 | ;;; On-demand installation of packages 22 | 23 | (defun require-package (package &optional min-version no-refresh) 24 | "Install given PACKAGE, optionally requiring MIN-VERSION. 25 | If NO-REFRESH is non-nil, the available package lists will not be 26 | re-downloaded in order to locate PACKAGE." 27 | (if (package-installed-p package min-version) 28 | t 29 | (if (or (assoc package package-archive-contents) no-refresh) 30 | (package-install package) 31 | (progn 32 | (package-refresh-contents) 33 | (require-package package min-version t))))) 34 | 35 | (provide 'setup-package) 36 | -------------------------------------------------------------------------------- /project-archetypes/emacs-package/features/step-definitions/__project-name__-steps.el: -------------------------------------------------------------------------------- 1 | (eval-when-compile (require 'cl)) 2 | 3 | (When "^I place the cursor after \"\\(.+\\)\"$" 4 | (lambda (arg) 5 | (goto-char (point-min)) 6 | (let ((search (search-forward arg nil t)) 7 | (message "Can not place cursor after '%s', because there is no such point: '%s'")) 8 | (assert search nil message arg (espuds-buffer-contents))))) 9 | 10 | (When "^I place the cursor before \"\\(.+\\)\"$" 11 | (lambda (arg) 12 | (goto-char (point-max)) 13 | (let ((search (search-backward arg nil t)) 14 | (message "Can not place cursor before '%s', because there is no such point: '%s'")) 15 | (assert search nil message arg (espuds-buffer-contents))))) 16 | 17 | (When "^I go to the \\(front\\|end\\) of the word \"\\(.+\\)\"$" 18 | (lambda (pos word) 19 | (goto-char (point-min)) 20 | (let ((search (re-search-forward (format "%s" word) nil t)) 21 | (message "Can not go to character '%s' since it does not exist in the current buffer: %s")) 22 | (assert search nil message word (espuds-buffer-contents)) 23 | (if (string-equal "front" pos) (backward-word))))) 24 | -------------------------------------------------------------------------------- /site-lisp/skewer-mode/UNLICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /site-lisp/eproject/lang/README: -------------------------------------------------------------------------------- 1 | This is the area for project type definitions. Each file should add a 2 | specific type of project with define-project-type and contain any 3 | necessary support functions. The project types need not be language 4 | specific, and may not relate to any programming language -- there 5 | could be both "perl" and "catalyst" project types, for example. 6 | 7 | Please keep the following in mind: 8 | 9 | * License your code with the same license as Emacs, the GPLv3. 10 | 11 | * Play nicely with others. Choose a selector function that won't 12 | activate your project type unless it's the best. That means you 13 | can identify a Perl project with Makefile.PL in the root directory, 14 | but you can't identify a C project by looking for Makefile in the 15 | root directory. Too many other things use Makefiles. 16 | 17 | * Namespace your functions with eproject-- or 18 | similar. Try to keep functions and commands to a minimum; your 19 | code should provide information, not perform any actions. If you 20 | want to perform actions, add a file to the contrib section of 21 | eproject. 22 | 23 | * Make all relevant tunable parameters defcustoms with documentation. 24 | The goal is for non-Lisp-programmers to be able to use your code. 25 | 26 | The eproject community thanks you for your contribution! Please do 27 | not hesitate to ask for direct commit access to the main repository. 28 | It will be granted. 29 | -------------------------------------------------------------------------------- /settings/setup-yasnippet.el: -------------------------------------------------------------------------------- 1 | (require 'yasnippet) 2 | 3 | ;; Use only own snippets, do not use bundled ones 4 | (setq yas-snippet-dirs '("~/.emacs.d/snippets")) 5 | (yas-global-mode 1) 6 | 7 | ;; Include snippets for stuff 8 | (require 'buster-snippets) 9 | (require 'angular-snippets) 10 | (require 'datomic-snippets) 11 | 12 | ;; Jump to end of snippet definition 13 | (define-key yas-keymap (kbd "") 'yas-exit-all-snippets) 14 | 15 | ;; Inter-field navigation 16 | (defun yas/goto-end-of-active-field () 17 | (interactive) 18 | (let* ((snippet (car (yas--snippets-at-point))) 19 | (position (yas--field-end (yas--snippet-active-field snippet)))) 20 | (if (= (point) position) 21 | (move-end-of-line 1) 22 | (goto-char position)))) 23 | 24 | (defun yas/goto-start-of-active-field () 25 | (interactive) 26 | (let* ((snippet (car (yas--snippets-at-point))) 27 | (position (yas--field-start (yas--snippet-active-field snippet)))) 28 | (if (= (point) position) 29 | (move-beginning-of-line 1) 30 | (goto-char position)))) 31 | 32 | (define-key yas-keymap (kbd "C-e") 'yas/goto-end-of-active-field) 33 | (define-key yas-keymap (kbd "C-a") 'yas/goto-start-of-active-field) 34 | 35 | ;; No dropdowns please, yas 36 | (setq yas-prompt-functions '(yas-ido-prompt yas-completing-prompt)) 37 | 38 | ;; No need to be so verbose 39 | (setq yas-verbosity 1) 40 | 41 | ;; Wrap around region 42 | (setq yas-wrap-around-region t) 43 | 44 | (provide 'setup-yasnippet) 45 | -------------------------------------------------------------------------------- /project-archetypes/emacs-snippets/README.md: -------------------------------------------------------------------------------- 1 | # __target__-snippets.el 2 | 3 | Yasnippets for [__name__](__website__). 4 | 5 | ## Installation 6 | 7 | I highly recommend installing __target__-snippets through elpa. 8 | 9 | It's available on [melpa](http://melpa.milkbox.net/): 10 | 11 | M-x package-install __target__-snippets 12 | 13 | You can also install the dependencies on your own, and just dump 14 | __target__-snippets in your path somewhere: 15 | 16 | - s.el 17 | - dash.el 18 | 19 | ## Usage 20 | 21 | TODO: Write some stuff about available snippets. 22 | 23 | ## Setup 24 | 25 | Well, you'll have to require it. You'll also need 26 | [yasnippets](https://github.com/capitaomorte/yasnippet) of course. 27 | 28 | (require '__target__-snippets) 29 | 30 | ## License 31 | 32 | Copyright (C) __year__ Magnar Sveen 33 | 34 | This program is free software; you can redistribute it and/or modify 35 | it under the terms of the GNU General Public License as published by 36 | the Free Software Foundation, either version 3 of the License, or 37 | (at your option) any later version. 38 | 39 | This program is distributed in the hope that it will be useful, 40 | but WITHOUT ANY WARRANTY; without even the implied warranty of 41 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 42 | GNU General Public License for more details. 43 | 44 | You should have received a copy of the GNU General Public License 45 | along with this program. If not, see . 46 | -------------------------------------------------------------------------------- /users/fimasvee/init.el: -------------------------------------------------------------------------------- 1 | ;; Default js indentation levels 2 | (setq-default js2-basic-offset 2) 3 | (setq js-indent-level 2) 4 | 5 | ;; Disallow scrolling with mouse wheel 6 | (when window-system 7 | (mouse-wheel-mode -1)) 8 | 9 | ;; Monday ftw 10 | (set-variable 'calendar-week-start-day 1) 11 | 12 | ;; Font size 13 | (define-key global-map (kbd "M-s +") 'zoom-in) 14 | (define-key global-map (kbd "M-s -") 'zoom-out) 15 | 16 | ;; No more scrolling surprises 17 | (global-unset-key (kbd "C-v")) 18 | (global-unset-key (kbd "M-v")) 19 | 20 | ;; No graphics please o.O 21 | (setq speedbar-use-images nil) 22 | 23 | ;; god-mode tweaks 24 | ;(god-mode) 25 | (defun my-update-cursor () 26 | (setq cursor-type (if (or (not god-global-mode) 27 | god-local-mode 28 | buffer-read-only) 29 | 'box 'bar))) 30 | 31 | ;(add-hook 'post-command-hook 'my-update-cursor) 32 | 33 | (defun my-delete-region-and-go-to-insert-mode () 34 | (delete-region (region-beginning) (region-end)) 35 | (god-local-mode -1)) 36 | 37 | ;; (define-key god-local-mode-map (kbd "'") 38 | ;; (λ (when (use-region-p) 39 | ;; (my-delete-region-and-go-to-insert-mode)))) 40 | 41 | ;; PHP 42 | (autoload 'php-mode "php-mode") 43 | (setq php-file-patterns nil) 44 | (add-to-list 'auto-mode-alist '("[^.][^t][^p][^l]\\.php$" . php-mode)) 45 | (add-to-list 'auto-mode-alist '("\\.tpl.php$" . html-mode)) 46 | (eval-after-load "php-mode" 47 | '(define-key php-mode-map (kbd "C-.") nil)) 48 | 49 | ;; Use GNU ls - install with: 50 | ;; brew install xz coreutils 51 | (setq insert-directory-program "gls") 52 | -------------------------------------------------------------------------------- /settings/setup-org.el: -------------------------------------------------------------------------------- 1 | (defun myorg-update-parent-cookie () 2 | (when (equal major-mode 'org-mode) 3 | (save-excursion 4 | (ignore-errors 5 | (org-back-to-heading) 6 | (org-update-parent-todo-statistics))))) 7 | 8 | (defadvice org-kill-line (after fix-cookies activate) 9 | (myorg-update-parent-cookie)) 10 | 11 | (defadvice kill-whole-line (after fix-cookies activate) 12 | (myorg-update-parent-cookie)) 13 | 14 | (setq org-directory "~/Dropbox/org") 15 | (setq org-default-notes-file (concat org-directory "/notes.org")) 16 | (define-key global-map (kbd "M-") 'org-capture) 17 | 18 | ;; Add function to sort org-mode entries by their ** TODO -state 19 | 20 | (defun todo-to-int (todo) 21 | (first (-non-nil 22 | (mapcar (lambda (keywords) 23 | (let ((todo-seq 24 | (-map (lambda (x) (first (split-string x "("))) 25 | (rest keywords)))) 26 | (cl-position-if (lambda (x) (string= x todo)) todo-seq))) 27 | org-todo-keywords)))) 28 | 29 | (defun my/org-sort-key () 30 | (let* ((todo-max (apply #'max (mapcar #'length org-todo-keywords))) 31 | (todo (org-entry-get (point) "TODO")) 32 | (todo-int (if todo (todo-to-int todo) todo-max)) 33 | (priority (org-entry-get (point) "PRIORITY")) 34 | (priority-int (if priority (string-to-char priority) org-default-priority))) 35 | (format "%03d %03d" todo-int priority-int) 36 | )) 37 | 38 | (defun my/org-sort-entries () 39 | (interactive) 40 | (org-sort-entries nil ?f #'my/org-sort-key)) 41 | 42 | (provide 'setup-org) 43 | -------------------------------------------------------------------------------- /defuns/snippet-helpers.el: -------------------------------------------------------------------------------- 1 | ;;; javascript 2 | 3 | (defun js-method-p () 4 | (save-excursion 5 | (word-search-backward "function") 6 | (looking-back ": "))) 7 | 8 | (defun js-function-declaration-p () 9 | (save-excursion 10 | (word-search-backward "function") 11 | (looking-back "^\\s *"))) 12 | 13 | (defun snippet--function-punctuation () 14 | (if (js-method-p) 15 | (when (not (looking-at "[ \n\t\r]*[},]")) 16 | (insert ",")) 17 | (unless (js-function-declaration-p) 18 | (if (looking-at "$") (insert ";"))))) 19 | 20 | (defun snippet--function-name () 21 | (if (js-function-declaration-p) "name" "")) 22 | 23 | ;;; clojure 24 | 25 | (defun snippet--clojure-namespace-from-buffer-file-name () 26 | (replace-regexp-in-string "_" "-" 27 | (replace-regexp-in-string "/" "." 28 | (chop-prefix "test/" 29 | (chop-prefix "src/" 30 | (chop-suffix ".clj" 31 | (substring (buffer-file-name) (length eproject-root)))))))) 32 | 33 | (defun snippet--clojure-namespace-under-test () 34 | (replace-regexp-in-string "-test" "" (snippet--clojure-namespace-from-buffer-file-name))) 35 | 36 | ;; snippet-helper-helpers 37 | 38 | (defun chop-suffix (suffix s) 39 | "Remove string 'suffix' if it is at end of string 's'" 40 | (let ((pos (- (length suffix)))) 41 | (if (and (>= (length s) (length suffix)) 42 | (string= suffix (substring s pos))) 43 | (substring s 0 pos) 44 | s))) 45 | 46 | (defun chop-prefix (prefix s) 47 | "Remove string 'prefix' if it is at start of string 's'" 48 | (let ((pos (length prefix))) 49 | (if (and (>= (length s) (length prefix)) 50 | (string= prefix (substring s 0 pos))) 51 | (substring s pos) 52 | s))) 53 | -------------------------------------------------------------------------------- /site-lisp/skewer-mode/skewer-everything.user.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name Skewer Everything 3 | // @description Add a toggle button to run Skewer on the current page 4 | // @lastupdated 2013-01-24 5 | // @version 1.1 6 | // @license Public Domain 7 | // @include /^https?:/// 8 | // ==/UserScript== 9 | 10 | var host = 'http://localhost:8080'; 11 | 12 | var toggle = document.createElement('div'); 13 | toggle.onclick = inject; 14 | toggle.style.width = '0px'; 15 | toggle.style.height = '0px'; 16 | toggle.style.borderStyle = 'solid'; 17 | toggle.style.borderWidth = '0 12px 12px 0'; 18 | toggle.style.borderColor = 'transparent #F00 transparent transparent'; 19 | toggle.style.position = 'absolute'; 20 | toggle.style.right = 0; 21 | toggle.style.top = 0; 22 | toggle.style.zIndex = 214748364; 23 | 24 | var injected = false; 25 | 26 | function inject() { 27 | if (!injected) { 28 | var script = document.createElement('script'); 29 | script.src = host + '/skewer'; 30 | document.body.appendChild(script); 31 | toggle.style.borderRightColor = '#0F0'; 32 | } else { 33 | /* break skewer to disable it */ 34 | if (unsafeWindow.skewer) { // Greasemonkey 35 | unsafeWindow.skewer.fn = null; 36 | } else if (unsafeWindow.window.skewer) { // Tampermonkey 37 | unsafeWindow.window.skewer.fn = null; 38 | } 39 | toggle.style.borderRightColor = '#F00'; 40 | } 41 | injected = !injected; 42 | GM_setValue('auto.' + location, injected); 43 | } 44 | 45 | /* Don't use on iframes. */ 46 | if (window.top === window.self) { 47 | document.body.appendChild(toggle); 48 | if (GM_getValue('auto.' + location)) { 49 | inject(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /site-lisp/eproject/contrib/README: -------------------------------------------------------------------------------- 1 | This is the contrib section, an area for eproject-using features that 2 | are more complicated than a few functions, or may not be suitable for 3 | eproject-extras. 4 | 5 | Please contribute anything you want here, but keep the following in 6 | mind: 7 | 8 | * The code must be released under the same license as Emacs itself. 9 | 10 | * Nothing in here will be loaded by default; if your file is being 11 | loaded, it's because the user wants it to take effect. Therefore, 12 | feel free to add hooks and keybindings, if necessary. 13 | 14 | * Ensure that any configuration is made customizable via defcustom. 15 | 16 | * Follow the proper conventions for keybindings that you create by 17 | default. 18 | 19 | * Namespace your functions with 20 | eproject--. If you don't want the 21 | function to be public, use two dashes between your extension name 22 | and the function name, like: eproject-foo--internal-foobar. 23 | Public functions should retain backwards compatability between 24 | releases, so if you're not sure you want to obligate yourself to 25 | that, keep the function internal. 26 | 27 | * Commands (interactive functions) should have a docstring that 28 | checkdoc (M-x checkdoc) likes. Yes, you really need to write 29 | "Return FOO.", not "Returns foo". 30 | 31 | * Documentation is always helpful. Feel free to write long-form 32 | documentation in another file, perhaps your-extension.txt or 33 | your-extension.md. 34 | 35 | * Do not define project types here. Do that in the lang/ section. 36 | 37 | The eproject community thanks you for your contribution! Please do 38 | not hesitate to ask for direct commit access to the main repository. 39 | It will be granted. 40 | -------------------------------------------------------------------------------- /users/christian/project-mappings.el: -------------------------------------------------------------------------------- 1 | ;; FINN Oppdrag 2 | 3 | (defun custom-persp/oppdrag () 4 | (interactive) 5 | (custom-persp "Oppdrag" 6 | (find-file "~/projects/finn.no/oppdrag-services/app-main/web/src/"))) 7 | 8 | (define-key persp-mode-map (kbd "C-x p o") 'custom-persp/oppdrag) 9 | 10 | (require 'oppdrag-mode) 11 | (add-hook 'find-file-hook 12 | (lambda () 13 | (when (string-match-p "oppdrag-services" (buffer-file-name)) 14 | (oppdrag-mode)))) 15 | 16 | ;; Buster 17 | 18 | (defun custom-persp/buster () 19 | (interactive) 20 | (custom-persp "Buster" 21 | (find-file "~/projects/buster/todo.org"))) 22 | 23 | (define-key persp-mode-map (kbd "C-x p b") 'custom-persp/buster) 24 | 25 | (add-hook 'js2-mode-hook 26 | (lambda () 27 | (when (string-match-p "buster" (buffer-file-name)) 28 | (setq js2-additional-externs '("buster")) 29 | (setq buster-default-global "buster") 30 | (setq buster-add-default-global-to-iife t) 31 | (setq buster-use-strict t)))) 32 | 33 | ;; Gitorious 34 | 35 | (defun custom-persp/gitorious () 36 | (interactive) 37 | (custom-persp "Gts" 38 | (find-file "~/projects/gitorious/org/christian.org"))) 39 | 40 | (define-key persp-mode-map (kbd "C-x p g") 'custom-persp/gitorious) 41 | 42 | ;; Emacs 43 | 44 | (defun custom-persp/emacs () 45 | (interactive) 46 | (custom-persp "Emacs" 47 | (find-file "~/.emacs.d/init.el"))) 48 | (define-key persp-mode-map (kbd "C-x p e") 'custom-persp/emacs) 49 | 50 | ;; Org 51 | 52 | (defun custom-persp/org () 53 | (interactive) 54 | (custom-persp "org" 55 | (find-file "~/Dropbox/org/"))) 56 | (define-key persp-mode-map (kbd "C-") 'custom-persp/org) 57 | -------------------------------------------------------------------------------- /settings/setup-magit.el: -------------------------------------------------------------------------------- 1 | ;; expand sections by default 2 | (setq magit-section-initial-visibility-alist 3 | '((untracked . show) 4 | (unstaged . show) 5 | (unpushed . show) 6 | (unpulled . show) 7 | (stashes . show))) 8 | 9 | ;; full screen magit-status 10 | (defun magit-status-fullscreen (prefix) 11 | (interactive "P") 12 | (magit-status) 13 | (unless prefix 14 | (delete-other-windows))) 15 | 16 | ;; don't prompt me 17 | (set-default 'magit-push-always-verify nil) 18 | (set-default 'magit-revert-buffers 'silent) 19 | (set-default 'magit-no-confirm '(stage-all-changes 20 | unstage-all-changes)) 21 | 22 | ;; Real dates, please 23 | (set-default 'magit-log-margin '(t "%Y-%m-%d %H:%M " magit-log-margin-width t 18)) 24 | 25 | ;; move cursor into position when entering commit message 26 | (defun my/magit-cursor-fix () 27 | (beginning-of-buffer) 28 | (when (looking-at "#") 29 | (forward-line 2))) 30 | 31 | (add-hook 'git-commit-mode-hook 'my/magit-cursor-fix) 32 | 33 | ;; full screen vc-annotate 34 | (defun vc-annotate-quit () 35 | "Restores the previous window configuration and kills the vc-annotate buffer" 36 | (interactive) 37 | (kill-buffer) 38 | (jump-to-register :vc-annotate-fullscreen)) 39 | 40 | (eval-after-load "vc-annotate" 41 | '(progn 42 | (defadvice vc-annotate (around fullscreen activate) 43 | (window-configuration-to-register :vc-annotate-fullscreen) 44 | ad-do-it 45 | (delete-other-windows)) 46 | 47 | (define-key vc-annotate-mode-map (kbd "q") 'vc-annotate-quit))) 48 | 49 | (set-default 'magit-diff-refine-hunk t) 50 | 51 | ;; update diff-hl 52 | 53 | (global-diff-hl-mode) 54 | (add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh) 55 | 56 | ;; use forge 57 | 58 | (with-eval-after-load 'magit 59 | (require 'forge)) 60 | 61 | (provide 'setup-magit) 62 | -------------------------------------------------------------------------------- /project-archetypes/emacs-package/README.md: -------------------------------------------------------------------------------- 1 | # __project-name__.el [![Build Status](https://secure.travis-ci.org/magnars/__project-name__.el.png)](http://travis-ci.org/magnars/__project-name__.el) 2 | 3 | __description__ 4 | 5 | ## Installation 6 | 7 | I highly recommend installing __project-name__ through elpa. 8 | 9 | It's available on [marmalade](http://marmalade-repo.org/) and 10 | [melpa](http://melpa.milkbox.net/): 11 | 12 | M-x package-install __project-name__ 13 | 14 | You can also install the dependencies on your own, and just dump 15 | __project-name__ in your path somewhere: 16 | 17 | - s.el 18 | - dash.el 19 | 20 | ## Contribute 21 | 22 | Yes, please do. :-) 23 | 24 | All changes must be accompanied by feature tests, or I might break it later. 25 | They are written in [Ecukes](http://ecukes.info), a Cucumber for Emacs. 26 | 27 | You'll find the repo at: 28 | 29 | https://github.com/magnars/__project-name__.el 30 | 31 | To fetch the test dependencies, install 32 | [carton](https://github.com/rejeep/carton) if you haven't already, 33 | then: 34 | 35 | $ cd /path/to/__project-name__ 36 | $ carton 37 | 38 | Run the tests with: 39 | 40 | $ ./run-tests.sh 41 | 42 | ## License 43 | 44 | Copyright (C) 2013 Magnar Sveen 45 | 46 | Author: Magnar Sveen 47 | 48 | This program is free software; you can redistribute it and/or modify 49 | it under the terms of the GNU General Public License as published by 50 | the Free Software Foundation, either version 3 of the License, or 51 | (at your option) any later version. 52 | 53 | This program is distributed in the hope that it will be useful, 54 | but WITHOUT ANY WARRANTY; without even the implied warranty of 55 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 56 | GNU General Public License for more details. 57 | 58 | You should have received a copy of the GNU General Public License 59 | along with this program. If not, see . 60 | -------------------------------------------------------------------------------- /site-lisp/evil/evil-compatibility.el: -------------------------------------------------------------------------------- 1 | ;;;; Compatibility with different Emacs versions 2 | 3 | ;; Emacs <23 does not know `characterp' 4 | (unless (fboundp 'characterp) 5 | (defalias 'characterp 'char-valid-p)) 6 | 7 | ;; In older versions of Emacs, `called-interactively-p' takes 8 | ;; no arguments. In Emacs 23.2 and newer, it takes one argument. 9 | (defmacro evil-called-interactively-p () 10 | (if (version< emacs-version "23.2") 11 | '(called-interactively-p) 12 | '(called-interactively-p 'any))) 13 | 14 | (unless (fboundp 'region-active-p) 15 | (defun region-active-p () 16 | "Returns t iff region and mark are active." 17 | (and transient-mark-mode mark-active))) 18 | 19 | (defun evil-read-key (&optional prompt) 20 | "Read a key from the keyboard. 21 | Translates it according to the input method." 22 | (let ((old-global-map (current-global-map)) 23 | (new-global-map (make-sparse-keymap)) 24 | (overriding-terminal-local-map (make-sparse-keymap)) 25 | overriding-local-map char) 26 | (unwind-protect 27 | (progn 28 | (define-key new-global-map [menu-bar] 29 | (lookup-key global-map [menu-bar])) 30 | (define-key new-global-map [tool-bar] 31 | (lookup-key global-map [tool-bar])) 32 | (add-to-list 'new-global-map 33 | (make-char-table 'display-table 34 | 'self-insert-command) t) 35 | (use-global-map new-global-map) 36 | (setq char (aref (read-key-sequence prompt nil t) 0)) 37 | (if (memq char '(?\C-q ?\C-v)) 38 | (read-quoted-char) 39 | (unless (eq char ?\e) 40 | (or (cdr (assq char '((?\r . ?\n)))) 41 | char)))) 42 | (use-global-map old-global-map)))) 43 | 44 | ;; `make-char-table' requires this property in Emacs 22 45 | (unless (get 'display-table 'char-table-extra-slots) 46 | (put 'display-table 'char-table-extra-slots 0)) 47 | 48 | (provide 'evil-compatibility) 49 | 50 | ;;; evil-compatibility.el ends here 51 | -------------------------------------------------------------------------------- /site-lisp/rhtml-mode/test.rhtml: -------------------------------------------------------------------------------- 1 |
2 |

MONTLY REPORT

3 |

Highest scoring ypredictions by team.

4 |
5 | <% %> 6 | 7 | <% form_tag({:action => :monthly}, {:method => :get}) do -%> 8 | <%= select_month @date %><%= select_year @date -%> 9 | <%= submit_tag 'Select month' -%> 10 | <% end -%> 11 | <%#= debug @report_data -%> 12 | <% for row in @rows -%> 13 | <% team = row[:team] -%> 14 | <% max_avail = row[:max_avail] -%> 15 | 16 |
17 | <%= team_shirt(team) -%> 18 | <%= team -%> 19 |
20 |
21 | Highest points #<%=ddd #-%> scored by #<%=dfdf%> players 22 | (from <%= max_avail %> points available) 23 |
24 | 25 | <% for inner in row[:matches] -%> 26 | <%@dmatch = iner[:match] -%> 27 | <% count = inner[:count] -%> 28 | <%# winners = inner[:winners] -%> 29 | <%# p_pred = inner[:top_pred] -%> 30 | 31 |

<%= "#{match}.id})" %>

32 | <% if match.scored? -%> 33 |

Max <%= top_pred %> scored by 34 | <%= content_tag :a, 35 | sf #{count} playersef 36 | safsadf :oncli ck => "Effect.toggle('match_#{team.id}_#{match.id}', 'slide')" -%> 37 | (from <%= match.points %> available)

38 | 39 | <%# Match winner's list -%> 40 | 49 |
50 |
54 | <%= "true!" -%> 55 | <% else -%> 56 | <%= "false!" -%> 57 | <% end -%> 58 | 59 | <%- if true -%> 60 | <%= "true!" -%> 61 | <%- else -%> 62 | <%= "false!" -%> 63 | <%- end -%> 64 | 65 |
66 | <% else -%> 67 | (not scored!) 68 | <% end -%> 69 | <% end -%> 70 | <% end %> 71 | -------------------------------------------------------------------------------- /site-lisp/rhtml-mode/rhtml-navigation.el: -------------------------------------------------------------------------------- 1 | ;; TODO -- need a license boiler-plate 2 | 3 | ;; Handy RHTML functions 4 | ;; (C) 2006 Phil Hagelberg 5 | 6 | ;; Ripped from the previous rhtml-mode, sorry about making it break 7 | ;; too :( -- pst 8 | 9 | (defun rhtml-controller-name-from-view () 10 | (let* ((dirname (expand-file-name ".")) 11 | (controller-with-module 12 | (and (string-match "app/views/\\(.*\\)$" dirname) 13 | (match-string 1 dirname)))) 14 | (concat (rails-root) 15 | "/app/controllers/" 16 | controller-with-module 17 | "_controller.rb"))) 18 | 19 | (defun rhtml-find-action () 20 | (interactive) 21 | (let ((action (file-name-sans-extension (file-name-nondirectory buffer-file-name)))) 22 | (find-file (rhtml-controller-name-from-view)) 23 | (beginning-of-buffer) 24 | (search-forward-regexp (concat "def *" action)) 25 | (recenter))) 26 | 27 | (defun rinari-find-by-context () 28 | (interactive) 29 | (mapc (lambda (rule) (let ((pattern (car rule)) (line (current-line))) 30 | (if (string-match pattern line) (apply (cdr rule) (match-strings line))))) 31 | ;; rules (warning; ALL matches will be acted upon, not just first!) 32 | '((":partial +=> +['\":]\\([a-zA-Z_]+\\)['\" ]" . rhtml-find-partial) 33 | (":controller +=> +['\":]\\([a-zA-Z_]+\\)['\" ,]?.*:action +=> +['\":]\\([a-zA-Z_]+\\)['\" ,]?" 34 | . rinari-find-action) 35 | (":action +=> +['\":]\\([a-zA-Z_]+\\)['\"]?" . rinari-find-action) 36 | ) 37 | )) 38 | 39 | (defun rhtml-find-partial (partial) 40 | (interactive "MPartial: ") 41 | (find-file (concat "_" partial "\\.html\\.erb"))) 42 | 43 | ;; utility functions 44 | 45 | (defun current-line () 46 | (save-excursion 47 | (beginning-of-line) 48 | (set-mark-command nil) 49 | (end-of-line) 50 | (buffer-substring-no-properties (mark) (point)))) 51 | 52 | (defun match-strings (string &optional n) 53 | (let* ((n (or n 1)) 54 | (this-match (match-string n string))) 55 | (when this-match 56 | (append (list this-match) (match-strings string (+ 1 n)))))) 57 | 58 | (provide 'rhtml-navigation) 59 | -------------------------------------------------------------------------------- /site-lisp/evil/evil-replace.el: -------------------------------------------------------------------------------- 1 | ;;;; Replace state 2 | 3 | (require 'evil-core) 4 | (require 'evil-repeat) 5 | (require 'evil-operators) 6 | 7 | (evil-define-state replace 8 | "Replace state." 9 | :tag " " 10 | :cursor hbar 11 | :message "-- REPLACE --" 12 | (cond 13 | ((evil-replace-state-p) 14 | (overwrite-mode 1) 15 | (add-hook 'pre-command-hook 'evil-replace-pre-command nil t)) 16 | (t 17 | (overwrite-mode -1) 18 | (remove-hook 'pre-command-hook 'evil-replace-pre-command t) 19 | (when evil-move-cursor-back 20 | (evil-adjust)))) 21 | (setq evil-replace-alist nil)) 22 | 23 | (defun evil-replace-pre-command () 24 | "Remember the character under point." 25 | (when (evil-replace-state-p) 26 | (unless (assq (point) evil-replace-alist) 27 | (add-to-list 'evil-replace-alist 28 | (cons (point) 29 | (unless (eolp) 30 | (char-after))))))) 31 | 32 | (defun evil-replace-backspace () 33 | "Restore character under cursor." 34 | (interactive) 35 | (let (char) 36 | (backward-char) 37 | (when (assq (point) evil-replace-alist) 38 | (setq char (cdr (assq (point) evil-replace-alist))) 39 | (save-excursion 40 | (delete-char 1) 41 | (when char 42 | (insert char)))))) 43 | 44 | (evil-define-operator evil-replace (beg end type char) 45 | "Replace text from BEG to END with CHAR." 46 | :motion evil-forward-char 47 | (interactive "" 48 | (evil-save-cursor 49 | (evil-refresh-cursor 'replace) 50 | (list (evil-read-key)))) 51 | (when char 52 | (if (eq type 'block) 53 | (save-excursion 54 | (evil-apply-on-block 'evil-replace beg end nil char)) 55 | (goto-char beg) 56 | (while (< (point) end) 57 | (if (eq (char-after) ?\n) 58 | (forward-char) 59 | (delete-char 1) 60 | (if (eq char ?\n) 61 | (newline) 62 | (insert-char char 1)))) 63 | (if (eq char ?\n) 64 | (when evil-auto-indent 65 | (indent-according-to-mode)) 66 | (goto-char (max beg (1- end))))))) 67 | 68 | (provide 'evil-replace) 69 | 70 | ;;; evil-replace.el ends here 71 | -------------------------------------------------------------------------------- /settings/mac.el: -------------------------------------------------------------------------------- 1 | (require 'dash) 2 | 3 | ;; change command to meta, and ignore option to use weird Norwegian keyboard 4 | (setq mac-option-modifier 'super) 5 | (setq mac-command-modifier 'meta) 6 | (setq ns-function-modifier 'hyper) 7 | (setq mac-right-option-modifier nil) 8 | 9 | ;; Norwegian mac-keyboard alt-keys) 10 | (define-key key-translation-map (kbd "s-8") (kbd "[")) 11 | (define-key key-translation-map (kbd "s-(") (kbd "{")) 12 | (define-key key-translation-map (kbd "s-9") (kbd "]")) 13 | (define-key key-translation-map (kbd "s-)") (kbd "}")) 14 | (define-key key-translation-map (kbd "s-7") (kbd "|")) 15 | (define-key key-translation-map (kbd "s-/") (kbd "\\")) 16 | (define-key key-translation-map (kbd "M-s-7") (kbd "M-|")) 17 | 18 | (defun insert-backslash () 19 | (interactive) 20 | (insert "\\")) 21 | 22 | (global-set-key (kbd "H-7") 'insert-backslash) 23 | 24 | (global-set-key (kbd "s-u") 'universal-argument) 25 | (global-set-key (kbd "s--") 'negative-argument) 26 | (--dotimes 5 (global-set-key (read-kbd-macro (format "s-%d" it)) 'digit-argument)) 27 | 28 | ;; mac friendly font 29 | (when window-system 30 | (defvar magnars/default-font "-apple-Monaco-medium-normal-normal-*-15-*-*-*-m-0-iso10646-1") 31 | (defvar magnars/presentation-font "-apple-Monaco-medium-normal-normal-*-21-*-*-*-m-0-iso10646-1") 32 | (set-face-attribute 'default nil :font magnars/default-font)) 33 | 34 | ;; keybinding to toggle full screen mode 35 | (global-set-key '[M-f10] 'toggle-frame-fullscreen) 36 | 37 | ;; Move to trash when deleting stuff 38 | (setq delete-by-moving-to-trash t 39 | trash-directory "~/.Trash/emacs") 40 | 41 | ;; Ignore .DS_Store files with ido mode 42 | (add-to-list 'ido-ignore-files "\\.DS_Store") 43 | 44 | ;; Don't open files from the workspace in a new frame 45 | (setq ns-pop-up-frames nil) 46 | 47 | ;; Use aspell for spell checking: brew install aspell --lang=en 48 | (setq ispell-program-name "/opt/homebrew/bin/aspell") 49 | 50 | ;; Open files 51 | (defun mac-open-current-file () 52 | (interactive) 53 | (shell-command (concat "open " (buffer-file-name)))) 54 | 55 | (global-set-key (kbd "C-c C-S-o") 'mac-open-current-file) 56 | 57 | ;; fix osx weirdness with magit avatars 58 | 59 | (setq-default magit-revision-use-gravatar-kludge t) 60 | 61 | (provide 'mac) 62 | -------------------------------------------------------------------------------- /site-lisp/jade-mode/jade-mode.el: -------------------------------------------------------------------------------- 1 | ;; copied from http://xahlee.org/emacs/elisp_syntax_coloring.html 2 | (require 'font-lock) 3 | 4 | (defun jade-debug (string &rest args) 5 | "Prints a debug message" 6 | (apply 'message (append (list string) args))) 7 | 8 | (defmacro jade-line-as-string () 9 | "Returns the current line as a string." 10 | `(buffer-substring (point-at-bol) (point-at-eol))) 11 | 12 | 13 | (defun jade-empty-line-p () 14 | "If line is empty or not." 15 | (= (point-at-eol) (point-at-bol))) 16 | 17 | (defun jade-blank-line-p () 18 | "If line contains only spaces." 19 | (string-match-p "^[ ]*$" (jade-line-as-string))) 20 | 21 | (setq jade-font-lock-keywords 22 | `((,"!!!\\( \\(default\\|5\\|transitional\\)\\)?" 0 font-lock-constant-face) ;; doctype 23 | (,"#\\(\\w\\|_\\|-\\)*" . font-lock-type-face) ;; id 24 | (,"\\(?:^[ {2,}]+\\(?:[a-z0-9_:\\-]*\\)\\)?\\(#[A-Za-z0-9\-\_]*[^ ]\\)" 1 font-lock-type-face) ;; class name 25 | (,"\\(?:^[ {2,}]+\\(?:[a-z0-9_:\\-]*\\)\\)?\\(\\.[A-Za-z0-9\-\_]*\\)" 1 font-lock-function-name-face) ;; class name 26 | (,"^[ {2,}]+[a-z0-9_:\\-]*" 0 font-lock-comment-face))) 27 | 28 | (defun jade-region-for-sexp () 29 | "Selects the current sexp as the region" 30 | (interactive) 31 | (beginning-of-line) 32 | (let ((ci (current-indentation))) 33 | (push-mark nil nil t) 34 | (while (> (jade-next-line-indent) ci) 35 | (next-line) 36 | (end-of-line)))) 37 | 38 | (defvar jade-mode-map (make-sparse-keymap)) 39 | ;;defer to sws-mode 40 | ;;(define-key jade-mode-map [S-tab] 'jade-unindent-line) 41 | 42 | ;; mode declaration 43 | (define-derived-mode jade-mode sws-mode 44 | "Jade" 45 | "Major mode for editing jade node.js templates" 46 | (kill-all-local-variables) 47 | (setq tab-width 2) 48 | 49 | (setq mode-name "Jade") 50 | (setq major-mode 'jade-mode) 51 | 52 | ;; default tab width 53 | (setq sws-tab-width 2) 54 | (make-local-variable 'indent-line-function) 55 | (setq indent-line-function 'sws-indent-line) 56 | (make-local-variable 'indent-region-function) 57 | 58 | (setq indent-region-function 'sws-indent-region) 59 | 60 | 61 | ;; keymap 62 | (use-local-map jade-mode-map) 63 | 64 | ;; highlight syntax 65 | (setq font-lock-defaults '(jade-font-lock-keywords))) 66 | 67 | (provide 'jade-mode) 68 | 69 | (add-to-list 'auto-mode-alist '("\\.jade$" . jade-mode)) 70 | -------------------------------------------------------------------------------- /site-lisp/evil/evil.el: -------------------------------------------------------------------------------- 1 | ;;; evil.el --- extensible vi layer 2 | 3 | ;; Author: Frank Fischer 4 | ;; Vegard Øye 5 | ;; Nikolai Weibull 6 | ;; Maintainer: 7 | ;; Created: 2011-03-01 8 | ;; Version: 0.1 9 | ;; Keywords: emulation, vim 10 | ;; URL: http://gitorious.org/evil 11 | ;; 12 | ;; This file is not part of GNU Emacs. 13 | 14 | ;;; Commentary: 15 | 16 | ;; Evil is an extensible vi layer for Emacs. It emulates the main 17 | ;; features of Vim, and provides facilities for writing custom 18 | ;; extensions. 19 | ;; 20 | ;; Evil lives in a Git repository. To obtain Evil, do 21 | ;; 22 | ;; git clone git://gitorious.org/evil/evil.git 23 | ;; 24 | ;; Evil is discussed at , 25 | ;; a mailing list to which you can subscribe at: 26 | ;; 27 | ;; http://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list 28 | ;; 29 | ;; Subscription is not required; we usually reply within a few days 30 | ;; and CC our replies back to you. 31 | 32 | ;;; License: 33 | 34 | ;; This program is free software; you can redistribute it and/or 35 | ;; modify it under the terms of the GNU General Public License as 36 | ;; published by the Free Software Foundation; either version 2 of the 37 | ;; License, or any later version. 38 | ;; 39 | ;; This program is distributed in the hope that it will be useful, but 40 | ;; WITHOUT ANY WARRANTY; without even the implied warranty of 41 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 42 | ;; General Public License for more details. 43 | ;; 44 | ;; You should have received a copy of the GNU General Public License 45 | ;; along with this program; if not, write to the Free Software 46 | ;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 47 | ;; 02111-1307, USA. 48 | 49 | ;;; Code: 50 | 51 | (require 'evil-vars) 52 | (require 'evil-compatibility) 53 | (require 'evil-interactive) 54 | (require 'evil-common) 55 | (require 'evil-types) 56 | (require 'evil-undo) 57 | (require 'evil-core) 58 | (require 'evil-repeat) 59 | (require 'evil-visual) 60 | (require 'evil-search) 61 | (require 'evil-window) 62 | (require 'evil-digraphs) 63 | (require 'evil-insert) 64 | (require 'evil-operators) 65 | (require 'evil-motions) 66 | (require 'evil-replace) 67 | (require 'evil-integration) 68 | (require 'evil-maps) 69 | (require 'evil-ex) 70 | 71 | (provide 'evil) 72 | 73 | ;;; evil.el ends here 74 | -------------------------------------------------------------------------------- /users/fimasvee/my-defuns.el: -------------------------------------------------------------------------------- 1 | (defun wte--unique-filename (stub &optional index) 2 | (setq index (or index 1)) 3 | (let ((filename (concat "~/stuff/what-the-emacsd/resources/posts/" 4 | stub 5 | ".el" 6 | (if (< index 10) "-0" "-") 7 | (number-to-string index) 8 | ".html"))) 9 | (if (file-exists-p filename) 10 | (wte--unique-filename stub (1+ index)) 11 | filename))) 12 | 13 | (defun what-the-emacsd-post (beg end) 14 | (interactive "r") 15 | (let ((example (with-current-buffer (htmlize-region beg end) 16 | (search-forward "
")
17 |                     (setq beg (point))
18 |                     (search-forward "
") 19 | (forward-char -7) 20 | (buffer-substring beg (point)))) 21 | (filename (wte--unique-filename (buffer-file-name-body))) 22 | (timestamp (floor (time-to-seconds (current-time))))) 23 | (find-file filename) 24 | (insert (format " 25 | 26 |

27 | 28 |
29 | 30 |
%s
31 | 32 |
33 | 34 |

35 | " timestamp example)) 36 | (goto-char 25))) 37 | 38 | (defun what-the-emacsd-publish () 39 | (interactive) 40 | (let ((filename (file-name-nondirectory (buffer-file-name)))) 41 | (save-buffer) 42 | (compile 43 | (format "git add %s && git ci -m %S && git push" 44 | filename 45 | filename) t))) 46 | 47 | (defun -flash-region (start end) 48 | "Temporarily highlight region from START to END." 49 | (let ((overlay (make-overlay start end))) 50 | (overlay-put overlay 'face 'secondary-selection) 51 | (overlay-put overlay 'priority 100) 52 | (run-with-timer 0.2 nil 'delete-overlay overlay))) 53 | 54 | (defun js2r--flash-node (node) 55 | (-flash-region (js2-node-abs-pos node) 56 | (js2-node-abs-end node)) 57 | (js2-node-short-name node)) 58 | 59 | ;; run clojure.test at point, with fixture (hardcoded I know) 60 | 61 | (defun run-deftest-at-point () 62 | (interactive) 63 | (save-excursion 64 | (search-backward "deftest") 65 | (search-forward "(") 66 | (backward-char) 67 | (let* ((beg (point)) 68 | (end (forward-list)) 69 | (contents (buffer-substring-no-properties beg end))) 70 | (nrepl-find-and-clear-repl-buffer) 71 | (nrepl-interactive-eval 72 | (concat "(h/reset-state-fixture (fn [] " contents "))"))))) 73 | 74 | (provide 'my-defuns) 75 | -------------------------------------------------------------------------------- /settings/my-misc.el: -------------------------------------------------------------------------------- 1 | ;; Seed the random-number generator 2 | (random t) 3 | 4 | ;; Keep region when undoing in region 5 | (defadvice undo-tree-undo (around keep-region activate) 6 | (if (use-region-p) 7 | (let ((m (set-marker (make-marker) (mark))) 8 | (p (set-marker (make-marker) (point)))) 9 | ad-do-it 10 | (goto-char p) 11 | (set-mark m) 12 | (set-marker p nil) 13 | (set-marker m nil)) 14 | ad-do-it)) 15 | 16 | ;; Enter passwords in minibuffer 17 | (setq epa-pinentry-mode 'loopback) 18 | 19 | ;; Whitespace-style 20 | (setq whitespace-style '(trailing lines space-before-tab 21 | indentation space-after-tab) 22 | whitespace-line-column 100) 23 | 24 | ;; Add Urban Dictionary to webjump (C-x g) 25 | (eval-after-load "webjump" 26 | '(add-to-list 'webjump-sites '("Urban Dictionary" . 27 | [simple-query 28 | "www.urbandictionary.com" 29 | "http://www.urbandictionary.com/define.php?term=" 30 | ""]))) 31 | 32 | ;; Fix whitespace on save, but only if the file was clean 33 | (global-whitespace-cleanup-mode) 34 | 35 | ;; Use normal tabs in makefiles 36 | (add-hook 'makefile-mode-hook 'indent-tabs-mode) 37 | 38 | ;; More neat bindings for C-x 8 39 | (global-set-key (kbd "C-x 8 t m") (λ (insert "™"))) 40 | (global-set-key (kbd "C-x 8 ( c )") (λ (insert "©"))) 41 | (global-set-key (kbd "C-x 8 - >") (λ (insert "→"))) 42 | (global-set-key (kbd "C-x 8 8") (λ (insert "∞"))) 43 | (global-set-key (kbd "C-x 8 ( c )") (λ (insert "©"))) 44 | (global-set-key (kbd "C-x 8 v") (λ (insert "✓"))) 45 | 46 | ;; Add JSP expansions to html-mode 47 | (eval-after-load "sgml-mode" '(require 'jsp-expansions)) 48 | 49 | ;; A bit of misc cargo culting in misc.el 50 | (setq xterm-mouse-mode t) 51 | 52 | ;; Some stupid multiple cursors things 53 | (defun mc--cursor-region-contents () 54 | (let (entries) 55 | (mc/for-each-cursor-ordered 56 | (setq entries (cons (buffer-substring-no-properties (overlay-get cursor 'point) 57 | (overlay-get cursor 'mark)) 58 | entries))) 59 | (reverse entries))) 60 | 61 | (defun mc/eval-with-cursor-regions () 62 | (interactive) 63 | (eval-expression 64 | (read--expression "Eval: " 65 | (concat "(" (s-join " " (mc--cursor-region-contents)) ")")))) 66 | 67 | (define-key mc/keymap (kbd "H-:") 'mc/eval-with-cursor-regions) 68 | 69 | (provide 'my-misc) 70 | -------------------------------------------------------------------------------- /project-archetypes/emacs-snippets/__target__-snippets.el: -------------------------------------------------------------------------------- 1 | ;;; __target__-snippets.el --- Yasnippets for __name__ 2 | 3 | ;; Copyright (C) __year__ Magnar Sveen 4 | 5 | ;; Author: Magnar Sveen 6 | ;; Keywords: snippets 7 | ;; Version: 0.1.0 8 | ;; Package-Requires: ((s "1.4.0") (dash "1.2.0") (yasnippet "0.6.1")) 9 | 10 | ;; This program is free software; you can redistribute it and/or modify 11 | ;; it under the terms of the GNU General Public License as published by 12 | ;; the Free Software Foundation, either version 3 of the License, or 13 | ;; (at your option) any later version. 14 | 15 | ;; This program is distributed in the hope that it will be useful, 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | ;; GNU General Public License for more details. 19 | 20 | ;; You should have received a copy of the GNU General Public License 21 | ;; along with this program. If not, see . 22 | 23 | ;;; Commentary: 24 | 25 | ;; Yasnippets for [__name__](__website__). 26 | ;; 27 | ;; Please visit README.md for more commentary. 28 | 29 | ;;; Code: 30 | 31 | ;;;###autoload 32 | (defun __target__-snippets-show-docs-at-point () 33 | (interactive) 34 | (__target__-snippets/show-docs (__target__-snippets/closest-__target__-identifer))) 35 | 36 | (defvar __target__-snippets/docstrings 37 | '(("key" . "docstring") 38 | ("key" . "docstring"))) 39 | 40 | (defvar __target__-snippets/docstrings-regexp 41 | (regexp-opt (-map 'car __target__-snippets/docstrings))) 42 | 43 | (defun -aget (alist key) 44 | (cdr (assoc key alist))) 45 | 46 | (defun __target__-snippets/show-docs (id) 47 | (message (-aget __target__-snippets/docstrings id)) 48 | nil) 49 | 50 | (defun __target__-snippets/closest-__target__-identifer () 51 | (save-excursion 52 | (search-forward " ") 53 | (search-backward-regexp __target__-snippets/docstrings-regexp) 54 | (match-string-no-properties 0))) 55 | 56 | (setq __target__-snippets-root (file-name-directory (or load-file-name 57 | (buffer-file-name)))) 58 | 59 | ;;;###autoload 60 | (defun __target__-snippets-initialize () 61 | (let ((snip-dir (expand-file-name "snippets" __target__-snippets-root))) 62 | (when (boundp 'yas-snippet-dirs) 63 | (add-to-list 'yas-snippet-dirs snip-dir t)) 64 | (yas-load-directory snip-dir))) 65 | 66 | ;;;###autoload 67 | (eval-after-load "yasnippet" 68 | '(__target__-snippets-initialize)) 69 | 70 | (provide '__target__-snippets) 71 | ;;; __target__-snippets.el ends here 72 | -------------------------------------------------------------------------------- /defuns/file-defuns.el: -------------------------------------------------------------------------------- 1 | ;; Defuns for working with files 2 | 3 | (defun rename-current-buffer-file () 4 | "Renames current buffer and file it is visiting." 5 | (interactive) 6 | (let ((name (buffer-name)) 7 | (filename (buffer-file-name))) 8 | (if (not (and filename (file-exists-p filename))) 9 | (error "Buffer '%s' is not visiting a file!" name) 10 | (let ((new-name (read-file-name "New name: " filename))) 11 | (if (get-buffer new-name) 12 | (error "A buffer named '%s' already exists!" new-name) 13 | (rename-file filename new-name 1) 14 | (rename-buffer new-name) 15 | (set-visited-file-name new-name) 16 | (set-buffer-modified-p nil) 17 | (message "File '%s' successfully renamed to '%s'" 18 | name (file-name-nondirectory new-name))))))) 19 | 20 | (defun delete-current-buffer-file () 21 | "Removes file connected to current buffer and kills buffer." 22 | (interactive) 23 | (let ((filename (buffer-file-name)) 24 | (buffer (current-buffer)) 25 | (name (buffer-name))) 26 | (if (not (and filename (file-exists-p filename))) 27 | (ido-kill-buffer) 28 | (when (yes-or-no-p "Are you sure you want to remove this file? ") 29 | (delete-file filename) 30 | (kill-buffer buffer) 31 | (message "File '%s' successfully removed" filename))))) 32 | 33 | (defun copy-current-file-path () 34 | "Add current file path to kill ring. Limits the filename to project root if possible." 35 | (interactive) 36 | (let ((filename (buffer-file-name))) 37 | (kill-new (if eproject-mode 38 | (s-chop-prefix (eproject-root) filename) 39 | filename)))) 40 | 41 | (defun find-or-create-file-at-point () 42 | "Guesses what parts of the buffer under point is a file name and opens it." 43 | (interactive) 44 | (find-file (file-name-at-point))) 45 | 46 | (defun find-or-create-file-at-point-other-window () 47 | "Guesses what parts of the buffer under point is a file name and opens it." 48 | (interactive) 49 | (find-file-other-window (file-name-at-point))) 50 | 51 | (defun file-name-at-point () 52 | (save-excursion 53 | (let* ((file-name-regexp "[./a-zA-Z0-9\-_~]") 54 | (start (progn 55 | (while (looking-back file-name-regexp) 56 | (forward-char -1)) 57 | (point))) 58 | (end (progn 59 | (while (looking-at file-name-regexp) 60 | (forward-char 1)) 61 | (point)))) 62 | (buffer-substring start end)))) 63 | 64 | (defun touch-buffer-file () 65 | (interactive) 66 | (insert " ") 67 | (backward-delete-char 1) 68 | (save-buffer)) 69 | 70 | (provide 'file-defuns) 71 | -------------------------------------------------------------------------------- /users/fimasvee/js2r-keys.el: -------------------------------------------------------------------------------- 1 | (require 'dash) 2 | (require 's) 3 | 4 | (defun my-js2-keys (keys) 5 | (->> (string-to-list keys) 6 | (--map (concat "C-s-" (char-to-string it))) 7 | (s-join " ") 8 | (read-kbd-macro))) 9 | 10 | (eval-after-load "js2-refactor" 11 | '(progn 12 | (define-key js2-mode-map (my-js2-keys "eo") 'js2r-expand-object) 13 | (define-key js2-mode-map (my-js2-keys "co") 'js2r-contract-object) 14 | (define-key js2-mode-map (my-js2-keys "wi") 'js2r-wrap-buffer-in-iife) 15 | (define-key js2-mode-map (my-js2-keys "ig") 'js2r-inject-global-in-iife) 16 | (define-key js2-mode-map (my-js2-keys "ev") 'js2r-extract-var) 17 | (define-key js2-mode-map (my-js2-keys "iv") 'js2r-inline-var) 18 | (define-key js2-mode-map (my-js2-keys "rv") 'js2r-rename-var) 19 | (define-key js2-mode-map (my-js2-keys "vt") 'js2r-var-to-this) 20 | (define-key js2-mode-map (my-js2-keys "ag") 'js2r-add-to-globals-annotation) 21 | (define-key js2-mode-map (my-js2-keys "sv") 'js2r-split-var-declaration) 22 | (define-key js2-mode-map (my-js2-keys "ef") 'js2r-extract-function) 23 | (define-key js2-mode-map (my-js2-keys "em") 'js2r-extract-method) 24 | (define-key js2-mode-map (my-js2-keys "ip") 'js2r-introduce-parameter) 25 | (define-key js2-mode-map (my-js2-keys "lp") 'js2r-localize-parameter) 26 | (define-key js2-mode-map (my-js2-keys "tf") 'js2r-toggle-function-expression-and-declaration) 27 | (define-key js2-mode-map (my-js2-keys "ao") 'js2r-arguments-to-object) 28 | (define-key js2-mode-map (my-js2-keys "uw") 'js2r-unwrap) 29 | (define-key js2-mode-map (my-js2-keys "wl") 'js2r-wrap-in-for-loop) 30 | (define-key js2-mode-map (my-js2-keys "3i") 'js2r-ternary-to-if) 31 | (define-key js2-mode-map (my-js2-keys "jt") 'jump-to-test-file) 32 | (define-key js2-mode-map (my-js2-keys "ot") 'jump-to-test-file-other-window) 33 | (define-key js2-mode-map (my-js2-keys "js") 'jump-to-source-file) 34 | (define-key js2-mode-map (my-js2-keys "os") 'jump-to-source-file-other-window) 35 | (define-key js2-mode-map (my-js2-keys "jo") 'jump-between-source-and-test-files) 36 | (define-key js2-mode-map (my-js2-keys "oo") 'jump-between-source-and-test-files-other-window) 37 | (define-key js2-mode-map (my-js2-keys "ta") 'toggle-assert-refute) 38 | (define-key js2-mode-map (my-js2-keys "dp") 'js2r-duplicate-object-property-node) 39 | (define-key js2-mode-map (my-js2-keys "lt") 'js2r-log-this) 40 | (define-key js2-mode-map (kbd "C-s-SPC") 'js2r-split-string) 41 | (define-key js2-mode-map (kbd "s-") 'js2r-forward-slurp) 42 | (define-key js2-mode-map (kbd "s-") 'js2r-forward-barf) 43 | 44 | (define-key js2-mode-map (kbd "s-j") 'jump-between-source-and-test-files) 45 | 46 | )) 47 | -------------------------------------------------------------------------------- /site-lisp/skewer-mode/cache-table.el: -------------------------------------------------------------------------------- 1 | ;;; cache-table.el --- a hash table with expiring entries 2 | 3 | ;; This is free and unencumbered software released into the public domain. 4 | 5 | ;; Author: Christopher Wellons 6 | ;; Version: 1.0 7 | 8 | ;;; Commentary: 9 | 10 | ;; See the docstring of `make-cache-table'. There is no 11 | ;; `put-cache-table': use `setf' on `get-cache-table' instead. 12 | 13 | ;;; Code: 14 | 15 | (eval-when-compile (require 'cl)) 16 | 17 | (defstruct cache-table-struct 18 | "A cache table with expiring entries. Use `make-cache-table' to 19 | create instances of this struct." 20 | expire-time table) 21 | 22 | (defun make-cache-table (expire-time &rest keyword-args) 23 | "Create a new cache-table with entries automatically removed 24 | from the table after EXPIRE-TIME seconds. This function accepts 25 | the same keyword arguments as `make-hash-table'. Entries are not 26 | actually removed from the cache-table until an access is made to 27 | the cache-table. 28 | 29 | Use `get-cache-table' to get and put (via setf) entries." 30 | (make-cache-table-struct :expire-time expire-time 31 | :table (apply #'make-hash-table keyword-args))) 32 | 33 | (defun cache-table-clear-expired (cache-table) 34 | "Remove all expired entries from CACHE-TABLE." 35 | (loop with expire-time = (cache-table-struct-expire-time cache-table) 36 | with table = (cache-table-struct-table cache-table) 37 | with dead-time = (- (float-time) expire-time) 38 | for key being the hash-keys of table using (hash-value entry) 39 | for (time . value) = entry 40 | when (< time dead-time) do (remhash key table))) 41 | 42 | (defun get-cache-table (key cache-table &optional default) 43 | "Access the value for KEY in CACHE-TABLE if it has not yet 44 | expired. Behaves just like `gethash'." 45 | (cache-table-clear-expired cache-table) 46 | (cdr (gethash key (cache-table-struct-table cache-table) (cons 0 default)))) 47 | 48 | (defsetf get-cache-table (key cache-table) (value) 49 | "Put an entry in the hash table, like (setf (gethash key table) value)." 50 | `(progn 51 | (cache-table-clear-expired ,cache-table) 52 | (puthash ,key (cons (float-time) ,value) 53 | (cache-table-struct-table ,cache-table)))) 54 | 55 | (defun cache-table-map (f cache-table) 56 | "Like `maphash', call F for all non-expired entries in CACHE-TABLE." 57 | (cache-table-clear-expired cache-table) 58 | (maphash (lambda (k v) (funcall f k (cdr v))) 59 | (cache-table-struct-table cache-table))) 60 | 61 | (defun cache-table-count (cache-table) 62 | "Like `hash-table-count', count the number of non-expired entries." 63 | (hash-table-count (cache-table-struct-table cache-table))) 64 | 65 | (provide 'cache-table) 66 | 67 | ;;; cache-table.el ends here 68 | -------------------------------------------------------------------------------- /settings/setup-ffip.el: -------------------------------------------------------------------------------- 1 | (require 'find-file-in-project) 2 | (require 's) 3 | 4 | ;; No need to be stingy 5 | (setq ffip-limit 4096) 6 | 7 | ;; Use full project path for ffip 8 | 9 | (defun ffip-project-files () 10 | "Return an alist of all filenames in the project and their path." 11 | (let ((file-alist nil)) 12 | (mapcar (lambda (file) 13 | (let ((file-cons (cons (s-chop-prefix (file-truename (ffip-project-root)) (expand-file-name file)) 14 | (expand-file-name file)))) 15 | (add-to-list 'file-alist file-cons) 16 | file-cons)) 17 | (split-string (shell-command-to-string 18 | (format "find %s -type f \\( %s \\) %s | head -n %s" 19 | (or ffip-project-root 20 | (ffip-project-root) 21 | (error "No project root found")) 22 | (ffip-join-patterns) 23 | ffip-find-options 24 | ffip-limit)))))) 25 | 26 | ;; Helper methods to create local settings 27 | 28 | (defun ffip--create-exclude-find-options (names) 29 | (mapconcat (lambda (name) 30 | (concat "-not -regex \".*" name ".*\"")) names " ")) 31 | 32 | (defun ffip-local-excludes (&rest names) 33 | "Given a set of names, will exclude results with those names in the path." 34 | (set (make-local-variable 'ffip-find-options) 35 | (ffip--create-exclude-find-options names))) 36 | 37 | (defun ffip-local-patterns (&rest patterns) 38 | "An exhaustive list of file name patterns to look for." 39 | (set (make-local-variable 'ffip-patterns) patterns)) 40 | 41 | ;; Function to create new functions that look for a specific pattern 42 | (defun ffip-create-pattern-file-finder (&rest patterns) 43 | (lexical-let ((patterns patterns)) 44 | (lambda () 45 | (interactive) 46 | (let ((ffip-patterns patterns)) 47 | (find-file-in-project))))) 48 | 49 | ;; Default excludes - override with ffip-local-excludes 50 | 51 | (setq-default ffip-find-options 52 | (ffip--create-exclude-find-options 53 | '("/node_modules/" 54 | "/bower_components/" 55 | "/target/" 56 | "/out/" 57 | "/tests-out/" 58 | "/overlays/" 59 | "/build/" 60 | "/dist/" 61 | "/vendor/" 62 | ".cask/" 63 | "/generated/" 64 | "/resources/public/js/compiled/" 65 | "/.repl/" 66 | "/.tmp/"))) 67 | 68 | ;; Try out projectile 69 | 70 | (projectile-mode +1) 71 | (define-key projectile-mode-map (kbd "s-p") 'projectile-command-map) 72 | (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map) 73 | 74 | (provide 'setup-ffip) 75 | -------------------------------------------------------------------------------- /site-lisp/oppdrag-mode.el: -------------------------------------------------------------------------------- 1 | ;;; oppdrag-mode.el --- Convenience utilities for working with Finn Oppdrag in Emacs 2 | 3 | ;; Copyright (C) 2011 Christian Johansen 4 | 5 | ;; Author: Christian Johansen 6 | ;; Keywords: 7 | 8 | ;; This program is free software; you can redistribute it and/or modify 9 | ;; it under the terms of the GNU General Public License as published by 10 | ;; the Free Software Foundation, either version 3 of the License, or 11 | ;; (at your option) any later version. 12 | 13 | ;; This program is distributed in the hope that it will be useful, 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ;; GNU General Public License for more details. 17 | 18 | ;; You should have received a copy of the GNU General Public License 19 | ;; along with this program. If not, see . 20 | 21 | ;;; Code: 22 | 23 | (require 's) 24 | 25 | (defun oppdrag-hot-deploy-buffer-file () 26 | "If the current buffer is visiting a file, and that file is deployed 27 | in an exploded war, re-deploy the file." 28 | (interactive) 29 | (let* ((source (buffer-file-name)) 30 | (target (s-replace "src/main/webapp" "target/oppdrag" source))) 31 | (if (and (file-writable-p target) 32 | (not (string= source target))) 33 | (progn 34 | (copy-file source target t) 35 | (message (concat "Deployed " source " to " target))) 36 | (message (concat target " does not exist, file not deployed"))))) 37 | 38 | (define-minor-mode oppdrag-mode 39 | "Convenience utilities for working with Finn Oppdrag" 40 | nil " Oppdrag" nil 41 | (if oppdrag-mode 42 | (add-hook 'after-save-hook 'oppdrag-hot-deploy-buffer-file nil t) 43 | (remove-hook 'after-save-hook 'oppdrag-hot-deploy-buffer-file t))) 44 | 45 | (defun oppdrag--setup-js-quirks () 46 | (when (string-match-p "oppdrag-services" (buffer-file-name)) 47 | (fci-mode 1) 48 | (setq js2-additional-externs '("FINN" "testCase" "cull" "dome" "bane")) 49 | (setq js2r-path-to-tests "/test/javascript/tests/") 50 | (setq js2r-path-to-sources "/main/webapp/oppdrag/scripts/") 51 | (setq js2r-test-suffix "Test") 52 | (setq buster-default-global "FINN.oppdrag") 53 | (setq buster-add-default-global-to-iife t) 54 | (setq buster-testcase-snippets-enabled nil) 55 | (make-variable-buffer-local 'buster-test-prefix) 56 | (setq buster-test-prefix "test should ") 57 | (set (make-local-variable 'sgml-basic-offset) 4) 58 | (make-variable-buffer-local 'js2-basic-offset) 59 | (setq js2-basic-offset 4))) 60 | 61 | (eval-after-load "grep" 62 | '(progn (add-to-list 'grep-find-ignored-directories "ckeditor") 63 | (add-to-list 'grep-find-ignored-directories "external"))) 64 | 65 | (add-hook 'js2-mode-hook 'oppdrag--setup-js-quirks) 66 | 67 | (provide 'oppdrag-mode) 68 | ;;; oppdrag-mode.el ends here 69 | -------------------------------------------------------------------------------- /settings/setup-html-mode.el: -------------------------------------------------------------------------------- 1 | (defun skip-to-next-blank-line () 2 | (interactive) 3 | (let ((inhibit-changing-match-data t)) 4 | (skip-syntax-forward " >") 5 | (unless (search-forward-regexp "^\\s *$" nil t) 6 | (goto-char (point-max))))) 7 | 8 | (defun skip-to-previous-blank-line () 9 | (interactive) 10 | (let ((inhibit-changing-match-data t)) 11 | (skip-syntax-backward " >") 12 | (unless (search-backward-regexp "^\\s *$" nil t) 13 | (goto-char (point-min))))) 14 | 15 | (defun html-wrap-in-tag (beg end) 16 | (interactive "r") 17 | (let ((oneline? (= (line-number-at-pos beg) (line-number-at-pos end)))) 18 | (deactivate-mark) 19 | (goto-char end) 20 | (unless oneline? (newline-and-indent)) 21 | (insert "

") 22 | (goto-char beg) 23 | (insert "

") 24 | (unless oneline? (newline-and-indent)) 25 | (indent-region beg (+ end 7)) 26 | (goto-char (+ beg 2)))) 27 | 28 | (defun --setup-simplezen () 29 | (require 'simplezen) 30 | (set (make-local-variable 'yas-fallback-behavior) 31 | '(apply simplezen-expand-or-indent-for-tab))) 32 | 33 | (add-hook 'sgml-mode-hook '--setup-simplezen) 34 | 35 | (eval-after-load "sgml-mode" 36 | '(progn 37 | ;; don't include equal sign in symbols 38 | (modify-syntax-entry ?= "." html-mode-syntax-table) 39 | 40 | (define-key html-mode-map [remap forward-paragraph] 'skip-to-next-blank-line) 41 | (define-key html-mode-map [remap backward-paragraph] 'skip-to-previous-blank-line) 42 | (define-key html-mode-map (kbd "C-c C-w") 'html-wrap-in-tag) 43 | (define-key html-mode-map (kbd "/") nil) ;; no buggy matching of slashes 44 | 45 | (define-key html-mode-map (kbd "C-c C-d") 'ng-snip-show-docs-at-point) 46 | 47 | (require 'tagedit) 48 | 49 | ;; paredit lookalikes 50 | (define-key html-mode-map (kbd "s-") 'tagedit-forward-slurp-tag) 51 | (define-key html-mode-map (kbd "C-)") 'tagedit-forward-slurp-tag) 52 | (define-key html-mode-map (kbd "s-") 'tagedit-forward-barf-tag) 53 | (define-key html-mode-map (kbd "C-}") 'tagedit-forward-barf-tag) 54 | (define-key html-mode-map (kbd "M-r") 'tagedit-raise-tag) 55 | (define-key html-mode-map (kbd "s-s") 'tagedit-splice-tag) 56 | (define-key html-mode-map (kbd "M-S") 'tagedit-split-tag) 57 | (define-key html-mode-map (kbd "M-J") 'tagedit-join-tags) 58 | (define-key html-mode-map (kbd "M-?") 'tagedit-convolute-tags) 59 | 60 | (tagedit-add-experimental-features) 61 | (add-hook 'html-mode-hook (lambda () (tagedit-mode 1))) 62 | 63 | ;; no paredit equivalents 64 | (define-key html-mode-map (kbd "M-k") 'tagedit-kill-attribute) 65 | (define-key html-mode-map (kbd "s-") 'tagedit-toggle-multiline-tag))) 66 | 67 | ;; after deleting a tag, indent properly 68 | (defadvice sgml-delete-tag (after reindent activate) 69 | (indent-region (point-min) (point-max))) 70 | 71 | (provide 'setup-html-mode) 72 | -------------------------------------------------------------------------------- /site-lisp/eproject/eproject-tests.el: -------------------------------------------------------------------------------- 1 | ;;; eproject-tests.el --- unit tests for eproject 2 | 3 | ;; Copyright (C) 2010 Jonathan Rockway 4 | 5 | ;; Author: Jonathan Rockway 6 | ;; Keywords: 7 | 8 | ;; This program is free software; you can redistribute it and/or modify 9 | ;; it under the terms of the GNU General Public License as published by 10 | ;; the Free Software Foundation, either version 3 of the License, or 11 | ;; (at your option) any later version. 12 | 13 | ;; This program is distributed in the hope that it will be useful, 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ;; GNU General Public License for more details. 17 | 18 | ;; You should have received a copy of the GNU General Public License 19 | ;; along with this program. If not, see . 20 | 21 | ;;; Commentary: 22 | 23 | ;; This file is for developers, not end-users. Run the tests to see 24 | ;; whether or not your changes horribly broke eproject. If they did, 25 | ;; fix the code or tests :) 26 | 27 | (defvar eproject-tests nil "List of unit tests.") 28 | 29 | (defun eproject-test-named (name value) 30 | "Return T if the test VALUE is named NAME." 31 | (eq (getf value :test-name) name)) 32 | 33 | (defmacro define-eproject-test (name &optional docstring &rest body) 34 | "Define an eproject unit test called NAME that is executed as BODY. 35 | If BODY returns T, the test passes. If BODY returns NIL, the test fails. 36 | Optional argument DOCSTRING is ... the docstring." 37 | (declare (debug (&define name [&optional stringp] [&rest sexp] def-body)) 38 | (doc-string 2)) 39 | 40 | `(setq eproject-tests 41 | (cons 42 | (list :test-name ',name 43 | :test-description ,docstring 44 | :test-body (lambda () ,@body)) 45 | (remove* ',name eproject-tests :test 'eproject-test-named)))) 46 | 47 | (defun eproject-runtests () 48 | (interactive) 49 | (with-current-buffer (get-buffer-create "*eproject tests*") 50 | (pop-to-buffer (current-buffer)) 51 | (delete-region (point-min) (point-max)) 52 | (goto-char (point-max)) 53 | (dolist (test (reverse eproject-tests)) 54 | (let* ((name (getf test :test-name)) 55 | (description (getf test :test-description "")) 56 | (body (getf test :test-body))) 57 | (if (ignore-errors (funcall body)) 58 | (insert (format "ok '%s' - %s\n" name description)) 59 | (insert (format "not ok '%s' - %s\n" name description))))))) 60 | 61 | (define-eproject-test harness-sanity 62 | "Make sure the test harness sort of works." 63 | t) 64 | 65 | (define-eproject-test eproject-loaded 66 | "Make sure eproject is on for this file, and that the root is correct." 67 | (with-current-buffer (get-buffer "eproject-tests.el") 68 | (equal (eproject-root) (file-name-directory buffer-file-name)))) 69 | 70 | ;;; eproject-tests.el ends here 71 | -------------------------------------------------------------------------------- /site-lisp/jmc-mode.el: -------------------------------------------------------------------------------- 1 | (require 'regex-dsl) 2 | 3 | (defvar jmc-bracket-face 'jmc-bracket-face 4 | "Face name to use for brackets in jmc-mode.") 5 | (defface jmc-bracket-face 6 | '((((class color)) (:foreground "#666666")) 7 | (t (:foreground "gray100"))) 8 | "Face for brackets in jmc-mode") 9 | 10 | (setq jmc-mode-map (make-sparse-keymap)) 11 | 12 | (setq jmc-mode-syntax-table 13 | (let ((table (make-syntax-table))) 14 | (modify-syntax-entry ?\[ "w" table) 15 | (modify-syntax-entry ?\] " " table) 16 | (modify-syntax-entry ?{ "(" table) 17 | (modify-syntax-entry ?} ")" table) 18 | table)) 19 | 20 | (setq jmc-nop-regexp 21 | (redsl-to-regexp 22 | '(concat "#nop " 23 | (* (anychar)) 24 | (line-end)))) 25 | 26 | (setq jmc-command-regexp 27 | (redsl-to-regexp 28 | '(concat "#" 29 | (or 30 | (+ (char-set "0-9")) 31 | "alias" "ali" "action" "act" "antisubstitute" "bell" "char" 32 | "connect" "con" "cr" "echo" "drop" "gag" "group" "highlight" "hig" 33 | "hotkey" "if" "ignore" "info" "killall" "log" "loop" "map" "mark" 34 | "math" "message" "multiaction" "multihighlight" "nop" "path" 35 | "pathdir" "presub" "read" "return" "savepath" "script" "showme" 36 | "speedwalk" "status" "substitute" "sub" "textin" "tick" "tickon" 37 | "tickoff" "tickset" "ticksize" "togglesubs" "tabadd" "tabdel" 38 | "unaction" "unact" "unalias" "unantisub" "ungag" "unhotkey" 39 | "unhighlight" "unpath" "unsubs" "unsub" "unvariable" "variable" 40 | "var" "verbatim" "write" "zap")))) 41 | 42 | (setq jmc-vars-regexp 43 | (redsl-to-regexp 44 | '(or (concat "$" (+ (word-char))) 45 | (concat (+ "%") (char-set "0-9"))))) 46 | 47 | (setq jmc-brackets-regexp 48 | (redsl-to-regexp 49 | '(char-set "{}"))) 50 | 51 | (setq jmc-ansi-code-regexp 52 | (redsl-to-regexp 53 | '(concat "[" 54 | (+ (char-set "0-9")) 55 | (\? ";1") 56 | "m"))) 57 | 58 | (setq jmc-mode-font-lock-keywords 59 | (list 60 | (cons jmc-nop-regexp '(0 font-lock-comment-face)) 61 | (cons jmc-command-regexp '(0 font-lock-builtin-face)) 62 | (cons jmc-vars-regexp '(0 font-lock-variable-name-face)) 63 | (cons jmc-brackets-regexp '(0 jmc-bracket-face)) 64 | (cons jmc-ansi-code-regexp '(0 jmc-bracket-face)))) 65 | 66 | (defun jmc-mode () 67 | "Major mode for editing JMC script files. 68 | Special commands: 69 | \\{jmc-mode-map}" 70 | (interactive) 71 | (kill-all-local-variables) 72 | (setq major-mode 'jmc-mode) 73 | (setq mode-name "JMC") 74 | (use-local-map jmc-mode-map) 75 | (set-syntax-table jmc-mode-syntax-table) 76 | (setq font-lock-defaults '(jmc-mode-font-lock-keywords)) 77 | (run-hooks 'jmc-mode-hook)) 78 | 79 | (provide 'jmc-mode) 80 | -------------------------------------------------------------------------------- /settings/setup-ido.el: -------------------------------------------------------------------------------- 1 | ;; Interactively Do Things 2 | 3 | (require 'ido) 4 | (ido-mode t) 5 | (setq ido-enable-prefix nil 6 | ido-enable-flex-matching t 7 | ido-case-fold nil 8 | ido-auto-merge-work-directories-length -1 9 | ido-create-new-buffer 'always 10 | ido-use-filename-at-point nil 11 | ido-max-prospects 10) 12 | 13 | ;; Try out flx-ido for better flex matching between words 14 | (require 'flx-ido) 15 | (flx-ido-mode 1) 16 | ;; disable ido faces to see flx highlights. 17 | (setq ido-use-faces nil) 18 | 19 | ;; flx-ido looks better with ido-vertical-mode 20 | (require 'ido-vertical-mode) 21 | (ido-vertical-mode) 22 | 23 | ;; C-n/p is more intuitive in vertical layout 24 | (setq ido-vertical-define-keys 'C-n-C-p-up-down-left-right) 25 | 26 | (require 'dash) 27 | 28 | (defun my/ido-go-straight-home () 29 | (interactive) 30 | (cond 31 | ((looking-back "~/") (insert "projects/")) 32 | ((looking-back "/") (insert "~/")) 33 | (:else (call-interactively 'self-insert-command)))) 34 | 35 | (defun my/setup-ido () 36 | ;; Go straight home 37 | (define-key ido-file-completion-map (kbd "~") 'my/ido-go-straight-home) 38 | (define-key ido-file-completion-map (kbd "C-~") 'my/ido-go-straight-home) 39 | 40 | ;; Use C-w to go back up a dir to better match normal usage of C-w 41 | ;; - insert current file name with C-x C-w instead. 42 | (define-key ido-file-completion-map (kbd "C-w") 'ido-delete-backward-updir) 43 | (define-key ido-file-completion-map (kbd "C-x C-w") 'ido-copy-current-file-name) 44 | 45 | (define-key ido-file-dir-completion-map (kbd "C-w") 'ido-delete-backward-updir) 46 | (define-key ido-file-dir-completion-map (kbd "C-x C-w") 'ido-copy-current-file-name)) 47 | 48 | (add-hook 'ido-setup-hook 'my/setup-ido) 49 | 50 | ;; Always rescan buffer for imenu 51 | (set-default 'imenu-auto-rescan t) 52 | 53 | (add-to-list 'ido-ignore-directories "target") 54 | (add-to-list 'ido-ignore-directories "node_modules") 55 | 56 | ;; Ido at point (C-,) 57 | (require 'ido-at-point) 58 | (ido-at-point-mode) 59 | 60 | ;; Use ido everywhere 61 | (ido-mode 1) 62 | (ido-everywhere 1) 63 | (require 'ido-completing-read+) 64 | (ido-ubiquitous-mode 1) 65 | (require 'icomplete) 66 | (icomplete-mode 1) 67 | (setq magit-completing-read-function 'magit-ido-completing-read) 68 | 69 | ;; but not everywhere-everywhere 70 | 71 | (defun my/anti-ido-advice (func &rest args) 72 | "Temporarily disable IDO and call function FUNC with arguments ARGS." 73 | (interactive) 74 | (progn 75 | (ido-everywhere 0) 76 | (ido-ubiquitous-mode 0) 77 | (icomplete-mode 0) 78 | (unwind-protect 79 | (if (called-interactively-p 'any) 80 | (call-interactively func) 81 | (apply func args)) 82 | (ido-everywhere 1) 83 | (ido-ubiquitous-mode 1) 84 | (icomplete-mode 1)))) 85 | 86 | (defun my/disable-ido (command) 87 | "Disable IDO when command COMMAND is called." 88 | (advice-add command :around #'my/anti-ido-advice)) 89 | 90 | (my/disable-ido 'dired-create-directory) 91 | (my/disable-ido 'cljr-rename-file) 92 | 93 | (provide 'setup-ido) 94 | -------------------------------------------------------------------------------- /site-lisp/jade-mode/README.md: -------------------------------------------------------------------------------- 1 | # sws-mode 2 | 3 | ## major mode for jade-mode and stylus-mode 4 | 5 | __S__ignificant __W__hitespace __M__ode. Because Jade and Stylus are both 'significant white space' languages, sws-mode can be used to edit both types of files 6 | 7 | Lines can be indented or un-indented (is that a word?) with tab, shift-tab respectively. Indentation will look at the proceeding line and not indent more than 1 level of nesting below it. 8 | 9 | html 10 | body 11 | #container 12 | .content 13 | ^ 14 | |----cursor anywhere on this line except at beginning of text, press tab or S-tab 15 | 16 | html 17 | body 18 | #container 19 | .content 20 | ^ 21 | |---- cursor moves to beginning of text...once cursor is at beginning of text, press tab 22 | 23 | html 24 | body 25 | #container 26 | .content 27 | ^ 28 | |---- now line is maximum indented, press tab again 29 | 30 | html 31 | body 32 | #container 33 | .content 34 | ^ 35 | |---- line moves to minimum indentation level (no indentation) 36 | 37 | Regions can be indentend in a similar way; however, this is still buggy... 38 | 39 | Since jade and stylus nesting is somewhat related to sexp layout I hope to have sexp related selection & manipulation working in the future. See `jade-highlight-sexp` for an example 40 | 41 | ## key bindings 42 | 43 | - [tab] if region is active, do 'smart indent' on region. otherwise, move cursor to beginning of line text. If cursor already at beginning of line text, do 'smart indent' on line. 44 | - [shift-tab] if region is active, do 'smart dedent' on region. otherwise, move cursor to beginning of line text. If cursor already at beginning of line text, do 'smart dedent' on line. 45 | 46 | 47 | ### jade-mode 48 | 49 | Emacs major mode for [jade template](http://github.com/visionmedia/jade) highlighting. This mode extends sws-mode to provide some rudimentary syntax highlighting. 50 | 51 | Still in very early stages. Some simple highlighting of tags, ids, and classes works; however, it highlights incorrectly into the javascript code and plain text code as well. 52 | 53 | 54 | I would like to get the highlighting working better. Also note javascript highlighting with either js2-mode or espresso-mode should be possible...I'm a major major-mode writing noob so it'll take a while. 55 | 56 | ### stylus-mode 57 | I'm not sure yet how to highlight .styl files, so for now, just use sws-mode when editing stylus mode. 58 | 59 | ## Installation instructions 60 | 61 | Copy the jade-mode.el and sws-mode.el to some directory on your computer. I put mine under `~/code/jade-mode` and sym-link the jade-mode folder into `~/.emacs.d/vendor/`. You can just as easily put the folder itself under '~/.emacs.d/vendor/` 62 | 63 | Add the following lines to any of your initialization files 64 | 65 | (add-to-list 'load-path "~/.emacs.d/vendor/jade-mode") 66 | (require 'sws-mode) 67 | (require 'jade-mode) 68 | (add-to-list 'auto-mode-alist '("\\.styl$" . sws-mode)) 69 | (add-to-list 'auto-mode-alist '("\\.jade$" . sws-mode)) 70 | -------------------------------------------------------------------------------- /site-lisp/project-archetypes/project-archetypes.el: -------------------------------------------------------------------------------- 1 | (require 'dash) 2 | (require 's) 3 | 4 | (defvar pa-project-archetypes nil 5 | "The list of available project archetypes.") 6 | 7 | (defvar pa-folder (expand-file-name "project-archetypes" user-emacs-directory) 8 | "The directory containing project archetypes.") 9 | 10 | (defvar pa-project-folder (expand-file-name "projects" "~") 11 | "The directory where projects should be created.") 12 | 13 | (defvar pa-out "*project-archetypes-output*" 14 | "Name of the buffer where output from the running process is displayed.") 15 | 16 | (defun pa-declare-project-archetype (name fn) 17 | "Add project archetype to the list of available ones." 18 | (add-to-list 'pa-project-archetypes (cons name fn))) 19 | 20 | (defun pa-create-project () 21 | (interactive) 22 | (let ((name (completing-read "Archetype: " (-map 'car pa-project-archetypes) nil t))) 23 | (call-interactively (cdr (assoc name pa-project-archetypes))))) 24 | 25 | (defun pa--join-patterns (patterns) 26 | "Turn `patterns' into a string that `find' can use." 27 | (mapconcat (lambda (pat) (format "-name \"%s\"" pat)) 28 | patterns " -or ")) 29 | 30 | (defun pa--files-matching (patterns folder &optional type) 31 | (split-string (shell-command-to-string 32 | (format "find %s %s \\( %s \\) | head -n %s" 33 | folder 34 | (or type "") 35 | (pa--join-patterns patterns) 36 | 1000)))) 37 | 38 | (defun pa--instantiate-template-file (file replacements) 39 | (with-temp-file file 40 | (insert-file-contents-literally file) 41 | (--each replacements 42 | (goto-char 0) 43 | (while (search-forward (car it) nil t) 44 | (replace-match (cdr it)))))) 45 | 46 | (defun pa-sh (cmd) 47 | (shell-command cmd pa-out)) 48 | 49 | (defun pa-instantiate-template-directory (template folder &rest replacements) 50 | (let ((tmp-folder (expand-file-name (concat "__pa_tmp_" template) pa-project-folder))) 51 | (copy-directory (expand-file-name template pa-folder) tmp-folder nil nil t) 52 | (--each (pa--files-matching (--map (s-concat "*" (car it) "*") replacements) tmp-folder) 53 | (rename-file it (s-replace-all replacements it))) 54 | (--each (pa--files-matching ["*"] tmp-folder "-type f") 55 | (pa--instantiate-template-file it replacements)) 56 | (copy-directory tmp-folder folder) 57 | (delete-directory tmp-folder t))) 58 | 59 | (put 'pa-instantiate-template-directory 'lisp-indent-function 2) 60 | 61 | (defmacro pa-with-new-project (project-name archetype replacements &rest body) 62 | `(let ((folder (expand-file-name ,project-name pa-project-folder))) 63 | (pa-instantiate-template-directory ,archetype folder ,@replacements) 64 | (view-buffer-other-window pa-out) 65 | (let ((default-directory (concat folder "/"))) 66 | (pa-sh "git init") 67 | ,@body 68 | (pa-sh "git add -A") 69 | (pa-sh "git ci -m \"Initial commit\"")))) 70 | 71 | (put 'pa-with-new-project 'lisp-indent-function 2) 72 | 73 | (when (file-exists-p pa-folder) 74 | (--each (directory-files pa-folder nil "^[^#].*el$") 75 | (load (expand-file-name it pa-folder)))) 76 | 77 | (provide 'project-archetypes) 78 | ;;; project-archetypes.el ends here 79 | -------------------------------------------------------------------------------- /defuns/clj-defuns.el: -------------------------------------------------------------------------------- 1 | (require 's) 2 | 3 | (defun clj--src-file-name-from-test (name) 4 | (s-with name 5 | (s-replace "/test/" "/src/") 6 | (s-replace "_test.clj" ".clj"))) 7 | 8 | (defun clj--test-file-name-from-src (name) 9 | (s-with name 10 | (s-replace "/src/" "/test/") 11 | (s-replace ".clj" "_test.clj"))) 12 | 13 | (defun clj--src-file-name-from-cards (name) 14 | (s-with name 15 | (s-replace "/devcards/" "/src/") 16 | (s-replace "_cards.clj" ".clj"))) 17 | 18 | (defun clj--src-file-name-from-scenes (name) 19 | (s-with name 20 | (s-replace "/portfolio/" "/ui/") 21 | (s-replace "_scenes.cljs" ".cljc"))) 22 | 23 | (defun clj--cards-file-name-from-src (name) 24 | (s-with name 25 | (s-replace "/src/" "/devcards/") 26 | (s-replace ".clj" "_cards.clj") 27 | (s-replace ".cljc" ".cljs"))) 28 | 29 | (defun clj--scenes-file-name-from-src (name) 30 | (s-with name 31 | (s-replace "/ui/" "/portfolio/") 32 | (s-replace ".clj" "_scenes.clj") 33 | (s-replace ".cljc" ".cljs"))) 34 | 35 | (defun clj--is-test? (name) 36 | (string-match-p "/test/" name)) 37 | 38 | (defun clj--is-card? (name) 39 | (string-match-p "/devcards/" name)) 40 | 41 | (defun clj--is-scene? (name) 42 | (string-match-p "/portfolio/" name)) 43 | 44 | (defun clj--is-ui? (name) 45 | (string-match-p "/ui/" name)) 46 | 47 | (defun clj-other-file-name () 48 | (let ((name (buffer-file-name))) 49 | (cond 50 | ((clj--is-test? name) (clj--src-file-name-from-test name)) 51 | ((clj--is-scene? name) (clj--src-file-name-from-scenes name)) 52 | ((clj--is-card? name) (clj--src-file-name-from-cards name)) 53 | ((clj--is-ui? name) (if (cljr--project-depends-on-p "portfolio") 54 | (clj--scenes-file-name-from-src name) 55 | (clj--cards-file-name-from-src name))) 56 | (:else (clj--test-file-name-from-src name))))) 57 | 58 | (defun clj-find-alternative-name (file) 59 | (cond 60 | ((s-ends-with? ".cljs" file) 61 | (s-replace ".cljs" ".cljc" file)) 62 | ((s-ends-with? ".clj" file) 63 | (s-replace ".clj" ".cljc" file)) 64 | ((s-ends-with? ".cljc" file) 65 | (s-replace ".cljc" ".clj" file)))) 66 | 67 | (defun clj-jump-to-other-file (arg) 68 | (interactive "P") 69 | (let* ((file (clj-other-file-name)) 70 | (alternative-file (clj-find-alternative-name file))) 71 | (cond 72 | ((file-exists-p file) (find-file file)) 73 | ((file-exists-p alternative-file) (find-file alternative-file)) 74 | (arg (find-file file) 75 | (save-buffer)) 76 | (t (ido-find-file-in-dir (file-name-directory file)))))) 77 | 78 | (defun clj-jump-to-other-file-other-window (arg) 79 | (interactive "P") 80 | (let ((file (clj-other-file-name))) 81 | (if (or (file-exists-p file) arg) 82 | (find-file-other-window file) 83 | (error "%s not found." file)))) 84 | 85 | (defun css-statement-to-clj () 86 | (interactive) 87 | (let ((beg (point)) 88 | (end nil) 89 | (attr-name nil)) 90 | (re-search-forward ":") 91 | (delete-char -1) 92 | (setq end (point)) 93 | (setq attr-name (buffer-substring beg end)) 94 | (delete-region beg end) 95 | (insert ":") 96 | (insert (s-lower-camel-case attr-name)) 97 | (forward-char 1) 98 | (insert "\"") 99 | (re-search-forward ";") 100 | (delete-char -1) 101 | (insert "\""))) 102 | -------------------------------------------------------------------------------- /site-lisp/evil/Makefile: -------------------------------------------------------------------------------- 1 | SHELL = /bin/bash 2 | EMACS = emacs 3 | FILES = $(filter-out evil-tests.el,$(filter-out evil-pkg.el,$(wildcard evil*.el))) 4 | VERSION := $(shell sed -n '3s/.*"\(.*\)".*/\1/p' evil-pkg.el) 5 | ELPAPKG = evil-$(VERSION) 6 | PROFILER = 7 | TAG = 8 | LIBS = -L lib 9 | 10 | ELCFILES = $(FILES:.el=.elc) 11 | 12 | .PHONY: all compile compile-batch clean tests test emacs term terminal profiler indent elpa version 13 | 14 | # Byte-compile Evil. 15 | all: compile 16 | compile: $(ELCFILES) 17 | 18 | 19 | .depend: $(FILES) 20 | @echo Compute dependencies 21 | @rm -f .depend 22 | @for f in $(FILES); do \ 23 | sed -n "s/(require '\(evil-.*\))/$${f}c: \1.elc/p" $$f >> .depend;\ 24 | done 25 | 26 | -include .depend 27 | 28 | $(ELCFILES): %.elc: %.el 29 | $(EMACS) --batch -Q -L . $(LIBS) -f batch-byte-compile $< 30 | 31 | # Byte-compile all files in one batch. This is faster than 32 | # compiling each file in isolation, but also less stringent. 33 | compile-batch: clean 34 | $(EMACS) --batch -Q -L . $(LIBS) -f batch-byte-compile ${FILES} 35 | 36 | # Delete byte-compiled files etc. 37 | clean: 38 | rm -f *~ 39 | rm -f \#*\# 40 | rm -f *.elc 41 | rm -f .depend 42 | 43 | # Run tests. 44 | # The TAG variable may specify a test tag or a test name: 45 | # make test TAG=repeat 46 | # This will only run tests pertaining to the repeat system. 47 | test: 48 | $(EMACS) --batch -Q -L . $(LIBS) -l evil-tests.el \ 49 | --eval "(evil-tests-initialize '(${TAG}) '(${PROFILER}))" 50 | 51 | # Byte-compile Evil and run all tests. 52 | tests: compile-batch 53 | $(EMACS) --batch -Q -L . $(LIBS) -l evil-tests.el \ 54 | --eval "(evil-tests-initialize '(${TAG}) '(${PROFILER}))" 55 | rm -f *.elc 56 | 57 | # Load Evil in a fresh instance of Emacs and run all tests. 58 | emacs: 59 | $(EMACS) -Q -L . $(LIBS) -l evil-tests.el --eval "(evil-mode 1)" \ 60 | --eval "(evil-tests-initialize '(${TAG}) '(${PROFILER}) t)" & 61 | 62 | # Load Evil in a terminal Emacs and run all tests. 63 | term: terminal 64 | terminal: 65 | $(EMACS) -nw -Q -L . $(LIBS) -l evil-tests.el --eval "(evil-mode 1)" \ 66 | --eval "(evil-tests-initialize '(${TAG}) '(${PROFILER}) t)" 67 | 68 | # Run all tests with profiler. 69 | profiler: 70 | $(EMACS) --batch -Q -L . $(LIBS) -l evil-tests.el \ 71 | --eval "(evil-tests-initialize '(${TAG}) (or '(${PROFILER}) t))" 72 | 73 | # Re-indent all Evil code. 74 | # Loads Evil into memory in order to indent macros properly. 75 | # Also removes trailing whitespace, tabs and extraneous blank lines. 76 | indent: clean 77 | $(EMACS) --batch --eval '(setq vc-handled-backends nil)' ${FILES} evil-tests.el -Q -L . $(LIBS) -l evil-tests.el \ 78 | --eval "(dolist (buffer (reverse (buffer-list))) \ 79 | (when (buffer-file-name buffer) \ 80 | (set-buffer buffer) \ 81 | (message \"Indenting %s\" (current-buffer)) \ 82 | (setq-default indent-tabs-mode nil) \ 83 | (untabify (point-min) (point-max)) \ 84 | (indent-region (point-min) (point-max)) \ 85 | (delete-trailing-whitespace) \ 86 | (untabify (point-min) (point-max)) \ 87 | (goto-char (point-min)) \ 88 | (while (re-search-forward \"\\n\\\\{3,\\\\}\" nil t) \ 89 | (replace-match \"\\n\\n\")) \ 90 | (when (buffer-modified-p) (save-buffer 0))))" 91 | 92 | # Create an ELPA package. 93 | elpa: 94 | @echo "Creating ELPA package $(ELPAPKG).tar" 95 | @rm -rf ${ELPAPKG} 96 | @mkdir ${ELPAPKG} 97 | @cp $(FILES) evil-pkg.el ${ELPAPKG} 98 | @tar cf ${ELPAPKG}.tar ${ELPAPKG} 99 | @rm -rf ${ELPAPKG} 100 | 101 | # Change the version using make VERSION=x.y.z 102 | version: 103 | cat evil-pkg.el | sed "3s/\".*\"/\"${VERSION}\"/" > evil-pkg.el 104 | 105 | -------------------------------------------------------------------------------- /site-lisp/rhtml-mode/rhtml-ruby-hook.el: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; rhtml-ruby-hook.el - `ruby-mode' access for `rhtml-mode' 3 | ;;; 4 | 5 | ;; ***** BEGIN LICENSE BLOCK ***** 6 | ;; Version: MPL 1.1/GPL 2.0/LGPL 2.1 7 | 8 | ;; The contents of this file are subject to the Mozilla Public License Version 9 | ;; 1.1 (the "License"); you may not use this file except in compliance with 10 | ;; the License. You may obtain a copy of the License at 11 | ;; http://www.mozilla.org/MPL/ 12 | 13 | ;; Software distributed under the License is distributed on an "AS IS" basis, 14 | ;; WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 15 | ;; for the specific language governing rights and limitations under the 16 | ;; License. 17 | 18 | ;; The Original Code is RUBY-MODE Hook Support for RHTML-MODE. 19 | 20 | ;; The Initial Developer of the Original Code is 21 | ;; Paul Nathan Stickney . 22 | ;; Portions created by the Initial Developer are Copyright (C) 2006 23 | ;; the Initial Developer. All Rights Reserved. 24 | 25 | ;; Contributor(s): 26 | 27 | ;; Alternatively, the contents of this file may be used under the terms of 28 | ;; either the GNU General Public License Version 2 or later (the "GPL"), or 29 | ;; the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 30 | ;; in which case the provisions of the GPL or the LGPL are applicable instead 31 | ;; of those above. If you wish to allow use of your version of this file only 32 | ;; under the terms of either the GPL or the LGPL, and not to allow others to 33 | ;; use your version of this file under the terms of the MPL, indicate your 34 | ;; decision by deleting the provisions above and replace them with the notice 35 | ;; and other provisions required by the GPL or the LGPL. If you do not delete 36 | ;; the provisions above, a recipient may use your version of this file under 37 | ;; the terms of any one of the MPL, the GPL or the LGPL. 38 | 39 | ;; ***** END LICENSE BLOCK ***** 40 | 41 | 42 | ;;; 43 | ;;; Provide an API to 'hook' into Ruby-mode, or rather, provide access 44 | ;;; to a temporary `ruby-mode' buffer which can be used to apply 45 | ;;; various ruby-mode stuff, primarily indenting. 46 | ;;; 47 | 48 | ;;; History: 49 | 50 | ;; 2006SEP18 51 | ;; - initial implementation 52 | 53 | (require 'rhtml-erb) 54 | (require 'ruby-mode) ; for well, `ruby-mode' 55 | 56 | (defvar rhtml-ruby-temp-buffer-name 57 | "*rhtml-ruby-hook temp buffer*" 58 | "Buffer name to use for temporary Ruby buffer. Should begin with a * or 59 | space as those carry special meaning.") 60 | 61 | (defun rhtml-ruby-temp-buffer () 62 | "Returns the temporary ruby buffer creating it if needed." 63 | (or (get-buffer rhtml-ruby-temp-buffer-name) 64 | (let ((ruby-buffer (get-buffer-create rhtml-ruby-temp-buffer-name))) 65 | (with-current-buffer ruby-buffer 66 | (buffer-disable-undo) 67 | (ruby-mode)) 68 | ruby-buffer))) 69 | 70 | (defun rhtml-copy-to-ruby-temp (begin end) 71 | "Buffer to copy from should be selected. BEGIN and END are points in the 72 | current buffer. All existing text in the temporary buffer is replaced." 73 | (let ((source-buffer (current-buffer)) 74 | (temp-buffer (rhtml-ruby-temp-buffer))) 75 | (with-current-buffer temp-buffer 76 | (delete-region (point-min) (point-max)) 77 | (insert-buffer-substring source-buffer begin end)))) 78 | 79 | (defun rhtml-ruby-indent-at (indent-pos) 80 | "Returns the indentation for INDENT-POS inside the temporary Ruby buffer 81 | after updating the indenting." 82 | (with-current-buffer (rhtml-ruby-temp-buffer) 83 | (indent-region 0 indent-pos) ; force update 84 | (goto-char indent-pos) 85 | (ruby-calculate-indent))) 86 | 87 | (defun rthml-insert-from-ruby-temp () 88 | "Insert the contents of `rhtml-ruby-temp-buffer' into the current 89 | buffer." 90 | (insert-from-buffer (rhtml-ruby-temp-buffer))) 91 | 92 | 93 | (provide 'rhtml-ruby-hook) -------------------------------------------------------------------------------- /settings/setup-paredit.el: -------------------------------------------------------------------------------- 1 | ;; My keybindings for paredit 2 | 3 | (require 'paredit) 4 | (require 'dash) 5 | (require 's) 6 | 7 | (defun paredit-wrap-round-from-behind () 8 | (interactive) 9 | (forward-sexp -1) 10 | (paredit-wrap-round) 11 | (insert " ") 12 | (forward-char -1)) 13 | 14 | (defun paredit-wrap-square-from-behind () 15 | (interactive) 16 | (forward-sexp -1) 17 | (paredit-wrap-square)) 18 | 19 | (defun paredit-wrap-curly-from-behind () 20 | (interactive) 21 | (forward-sexp -1) 22 | (paredit-wrap-curly)) 23 | 24 | (defun paredit-kill-region-or-backward-word () 25 | (interactive) 26 | (if (region-active-p) 27 | (kill-region (region-beginning) (region-end)) 28 | (paredit-backward-kill-word))) 29 | 30 | (add-hook 'clojure-mode-hook (lambda () (paredit-mode 1))) 31 | (add-hook 'cider-repl-mode-hook (lambda () (paredit-mode 1))) 32 | (add-hook 'emacs-lisp-mode-hook (lambda () (paredit-mode 1))) 33 | 34 | (define-key paredit-mode-map (kbd "M-(") 'paredit-wrap-round) 35 | (define-key paredit-mode-map (kbd "M-)") 'paredit-wrap-round-from-behind) 36 | (define-key paredit-mode-map (kbd "M-s-8") 'paredit-wrap-square) 37 | (define-key paredit-mode-map (kbd "M-s-9") 'paredit-wrap-square-from-behind) 38 | (define-key paredit-mode-map (kbd "M-s-(") 'paredit-wrap-curly) 39 | (define-key paredit-mode-map (kbd "M-s-)") 'paredit-wrap-curly-from-behind) 40 | 41 | (define-key paredit-mode-map (kbd "C-w") 'paredit-kill-region-or-backward-word) 42 | (define-key paredit-mode-map (kbd "M-C-") 'backward-kill-sexp) 43 | (define-key paredit-mode-map (kbd "C-d") 'paredit-forward-delete) 44 | 45 | ;; Change nasty paredit keybindings 46 | (defvar my-nasty-paredit-keybindings-remappings 47 | '(("M-s" "s-s" paredit-splice-sexp) 48 | ("M-" "s-" paredit-splice-sexp-killing-backward) 49 | ("M-" "s-" paredit-splice-sexp-killing-forward) 50 | ("C-" "s-" paredit-forward-slurp-sexp) 51 | ("C-" "s-" paredit-forward-barf-sexp) 52 | ("C-M-" "s-S-" paredit-backward-slurp-sexp) 53 | ("C-M-" "s-S-" paredit-backward-barf-sexp))) 54 | 55 | (define-key paredit-mode-map (kbd "s-r") 'paredit-raise-sexp) 56 | 57 | (--each my-nasty-paredit-keybindings-remappings 58 | (let ((original (car it)) 59 | (replacement (cadr it)) 60 | (command (car (last it)))) 61 | (define-key paredit-mode-map (read-kbd-macro original) nil) 62 | (define-key paredit-mode-map (read-kbd-macro replacement) command))) 63 | 64 | ;; Enable `paredit-mode' in the minibuffer, during `eval-expression'. 65 | (defun conditionally-enable-paredit-mode () 66 | (when (eq this-command 'eval-expression) 67 | (paredit-mode 1) 68 | (disable-inconvenient-paredit-keybindings-in-minor-mode))) 69 | 70 | (defun disable-inconvenient-paredit-keybindings-in-minor-mode () 71 | (let ((oldmap (cdr (assoc 'paredit-mode minor-mode-map-alist))) 72 | (newmap (make-sparse-keymap))) 73 | (set-keymap-parent newmap oldmap) 74 | (define-key newmap (kbd "RET") nil) 75 | (make-local-variable 'minor-mode-overriding-map-alist) 76 | (push `(paredit-mode . ,newmap) minor-mode-overriding-map-alist))) 77 | 78 | (add-hook 'minibuffer-setup-hook 'conditionally-enable-paredit-mode) 79 | 80 | ;; making paredit work with delete-selection-mode 81 | (put 'paredit-forward-delete 'delete-selection 'supersede) 82 | (put 'paredit-backward-delete 'delete-selection 'supersede) 83 | (put 'paredit-newline 'delete-selection t) 84 | 85 | ;; functions in smartparens that do not have an equivalent in paredit - take a look at them 86 | (when nil 87 | '(sp-beginning-of-sexp 88 | sp-end-of-sexp 89 | sp-next-sexp 90 | sp-previous-sexp 91 | sp-kill-sexp 92 | sp-unwrap-sexp 93 | sp-backward-unwrap-sexp 94 | sp-select-next-thing-exchange 95 | sp-select-next-thing 96 | sp-forward-symbol 97 | sp-backward-symbol)) 98 | 99 | (provide 'setup-paredit) 100 | -------------------------------------------------------------------------------- /settings/appearance.el: -------------------------------------------------------------------------------- 1 | (setq font-lock-maximum-decoration t 2 | color-theme-is-global t 3 | truncate-partial-width-windows nil) 4 | 5 | ;; Don't beep. Don't visible-bell (fails on el capitan). Just blink the modeline on errors. 6 | 7 | (setq visible-bell nil) 8 | (setq ring-bell-function (lambda () 9 | (invert-face 'mode-line) 10 | (run-with-timer 0.05 nil 'invert-face 'mode-line))) 11 | 12 | ;; Highlight current line 13 | (global-hl-line-mode 1) 14 | 15 | (setq css-fontify-colors nil) 16 | 17 | ;; Set custom theme path 18 | (setq custom-theme-directory (concat user-emacs-directory "themes")) 19 | 20 | (dolist 21 | (path (directory-files custom-theme-directory t "\\w+")) 22 | (when (file-directory-p path) 23 | (add-to-list 'custom-theme-load-path path))) 24 | 25 | ;; Default theme 26 | (defun use-presentation-theme () 27 | (interactive) 28 | (when (boundp 'magnars/presentation-font) 29 | (set-face-attribute 'default nil :font magnars/presentation-font))) 30 | 31 | (defun use-default-theme () 32 | (interactive) 33 | (load-theme 'default-black) 34 | (when (boundp 'magnars/default-font) 35 | (set-face-attribute 'default nil :font magnars/default-font))) 36 | 37 | (defun toggle-presentation-mode () 38 | (interactive) 39 | (if (string= (frame-parameter nil 'font) magnars/default-font) 40 | (use-presentation-theme) 41 | (use-default-theme))) 42 | 43 | (global-set-key (kbd "C-") 'toggle-presentation-mode) 44 | 45 | (use-default-theme) 46 | 47 | ;; Don't defer screen updates when performing operations 48 | (setq redisplay-dont-pause t) 49 | 50 | ;; org-mode colors 51 | (setq org-todo-keyword-faces 52 | '( 53 | ("INPR" . (:foreground "yellow" :weight bold)) 54 | ("DONE" . (:foreground "green" :weight bold)) 55 | ("IMPEDED" . (:foreground "red" :weight bold)) 56 | )) 57 | 58 | ;; Highlight matching parentheses when the point is on them. 59 | (show-paren-mode 1) 60 | 61 | (when window-system 62 | (setq frame-title-format '(buffer-file-name "%f" ("%b"))) 63 | (tooltip-mode -1) 64 | (blink-cursor-mode -1)) 65 | 66 | ;; Make zooming affect frame instead of buffers 67 | (require 'zoom-frm) 68 | 69 | (defun enable-zoom-one-shot-keybindings () 70 | (set-transient-map 71 | (let ((map (make-sparse-keymap))) 72 | (define-key map (kbd "+") 'zoom-frm-in) 73 | (define-key map (kbd "-") 'zoom-frm-out) 74 | (define-key map (kbd "0") 'zoom-frm-unzoom) 75 | map) t)) 76 | 77 | (defun zoom-frame-in () 78 | (interactive) 79 | (zoom-frm-in) 80 | (enable-zoom-one-shot-keybindings)) 81 | 82 | (defun zoom-frame-out () 83 | (interactive) 84 | (zoom-frm-out) 85 | (enable-zoom-one-shot-keybindings)) 86 | 87 | (global-set-key (kbd "C-x +") 'zoom-frame-in) 88 | (global-set-key (kbd "C-x -") 'zoom-frame-out) 89 | (global-set-key (kbd "C-x C-0") 'zoom-frm-unzoom) 90 | 91 | ;; Unclutter the modeline 92 | (require 'diminish) 93 | (eval-after-load "yasnippet" '(diminish 'yas-minor-mode)) 94 | (eval-after-load "eldoc" '(diminish 'eldoc-mode)) 95 | (eval-after-load "paredit" '(diminish 'paredit-mode)) 96 | (eval-after-load "tagedit" '(diminish 'tagedit-mode)) 97 | (eval-after-load "elisp-slime-nav" '(diminish 'elisp-slime-nav-mode)) 98 | (eval-after-load "skewer-mode" '(diminish 'skewer-mode)) 99 | (eval-after-load "skewer-css" '(diminish 'skewer-css-mode)) 100 | (eval-after-load "skewer-html" '(diminish 'skewer-html-mode)) 101 | (eval-after-load "smartparens" '(diminish 'smartparens-mode)) 102 | ;;(eval-after-load "guide-key" '(diminish 'guide-key-mode)) 103 | (eval-after-load "whitespace-cleanup-mode" '(diminish 'whitespace-cleanup-mode)) 104 | (eval-after-load "subword" '(diminish 'subword-mode)) 105 | 106 | (defmacro rename-modeline (package-name mode new-name) 107 | `(eval-after-load ,package-name 108 | '(defadvice ,mode (after rename-modeline activate) 109 | (setq mode-name ,new-name)))) 110 | 111 | (rename-modeline "js2-mode" js2-mode "JS2") 112 | (rename-modeline "clojure-mode" clojure-mode "Clj") 113 | 114 | (provide 'appearance) 115 | -------------------------------------------------------------------------------- /site-lisp/evil/evil-undo.el: -------------------------------------------------------------------------------- 1 | ;;;; Undo 2 | 3 | (require 'evil-common) 4 | 5 | ;; load undo-tree.el if available 6 | (unless (featurep 'undo-tree) 7 | (condition-case nil 8 | (require 'undo-tree) 9 | (error nil))) 10 | 11 | (when (fboundp 'global-undo-tree-mode) 12 | (global-undo-tree-mode 1)) 13 | 14 | (defmacro evil-with-single-undo (&rest body) 15 | "Execute BODY as a single undo step." 16 | (declare (indent defun) 17 | (debug t)) 18 | `(let (evil-undo-list-pointer) 19 | (evil-with-undo 20 | (unwind-protect 21 | (progn 22 | (evil-start-undo-step) 23 | ,@body) 24 | (evil-end-undo-step))))) 25 | 26 | (defun evil-start-undo-step (&optional continue) 27 | "Start a undo step. 28 | All following buffer modifications are grouped together as a 29 | single action. If CONTINUE is non-nil, preceding modifications 30 | are included. The step is terminated with `evil-end-undo-step'." 31 | (when (listp buffer-undo-list) 32 | (if evil-undo-list-pointer 33 | (evil-refresh-undo-step) 34 | (unless (or continue (null (car-safe buffer-undo-list))) 35 | (undo-boundary)) 36 | (setq evil-undo-list-pointer (or buffer-undo-list t))))) 37 | 38 | (defun evil-end-undo-step (&optional continue) 39 | "End a undo step started with `evil-start-undo-step'. 40 | Adds an undo boundary unless CONTINUE is specified." 41 | (when evil-undo-list-pointer 42 | (evil-refresh-undo-step) 43 | (unless continue 44 | (undo-boundary)) 45 | (remove-hook 'post-command-hook 'evil-refresh-undo-step t) 46 | (setq evil-undo-list-pointer nil))) 47 | 48 | ;; TODO: This destroys undo information during an undo step. 49 | ;; Ideally, we'd like to postpone it until the step is ended, 50 | ;; so that "C-_" works properly in Insert state. 51 | (defun evil-refresh-undo-step () 52 | "Refresh `buffer-undo-list' entries for current undo step. 53 | Undo boundaries until `evil-undo-list-pointer' are removed 54 | to make the entries undoable as a single action. 55 | See `evil-start-undo-step'." 56 | (when evil-undo-list-pointer 57 | (setq buffer-undo-list 58 | (evil-filter-list 'null buffer-undo-list 59 | evil-undo-list-pointer) 60 | evil-undo-list-pointer (or buffer-undo-list t)))) 61 | 62 | ;;; Undo ring 63 | 64 | (defmacro evil-with-undo (&rest body) 65 | "Execute BODY with enabled undo. 66 | If undo is disabled in the current buffer, the undo information 67 | is stored in `evil-temporary-undo' instead of `buffer-undo-list'." 68 | (declare (indent defun) 69 | (debug t)) 70 | `(unwind-protect 71 | (let (buffer-undo-list) 72 | ,@body 73 | (setq evil-temporary-undo (cons nil buffer-undo-list))) 74 | (unless (eq buffer-undo-list t) 75 | ;; undo is enabled, so update the global buffer undo list 76 | (setq buffer-undo-list 77 | ;; prepend new undos (if there are some) 78 | (if (cdr evil-temporary-undo) 79 | (nconc evil-temporary-undo buffer-undo-list) 80 | buffer-undo-list) 81 | evil-temporary-undo nil)))) 82 | 83 | (defun evil-undo-pop () 84 | "Undo the last buffer change. 85 | Removes the last undo information from `buffer-undo-list'. 86 | If undo is disabled in the current buffer, use the information 87 | in `evil-temporary-undo' instead." 88 | (let ((paste-undo (list nil))) 89 | (let ((undo-list (if (eq buffer-undo-list t) 90 | evil-temporary-undo 91 | buffer-undo-list))) 92 | (when (or (not undo-list) (car undo-list)) 93 | (error "Can't undo previous change")) 94 | (while (and undo-list (null (car undo-list))) 95 | (pop undo-list)) ; remove nil 96 | (while (and undo-list (car undo-list)) 97 | (push (pop undo-list) paste-undo)) 98 | (let ((buffer-undo-list (nreverse paste-undo))) 99 | (evil-save-echo-area 100 | (undo))) 101 | (if (eq buffer-undo-list t) 102 | (setq evil-temporary-undo nil) 103 | (setq buffer-undo-list undo-list))))) 104 | 105 | (provide 'evil-undo) 106 | 107 | ;;; evil-undo.el ends here 108 | -------------------------------------------------------------------------------- /site-lisp/mouse-slider-mode.el: -------------------------------------------------------------------------------- 1 | ;;; mouse-slider-mode.el --- scale numbers dragged under the mouse 2 | 3 | ;; This is free and unencumbered software released into the public domain. 4 | 5 | ;;; Commentary: 6 | 7 | ;; With this minor mode enabled in a buffer, right-clicking and 8 | ;; dragging horizontally with the mouse on any number will 9 | ;; increase/decrease it. It's works like this (video is not actually 10 | ;; about this minor mode): 11 | 12 | ;; http://youtu.be/FpxIfCHKGpQ 13 | 14 | ;; If an evaluation function is defined for the current major mode in 15 | ;; `mouse-slider-mode-eval-funcs', the local expression will also be 16 | ;; evaluated as the number is updated. For example, to add support for 17 | ;; [Skewer](https://github.com/skeeto/skewer-mode) in 18 | ;; [js2-mode](https://github.com/mooz/js2-mode), 19 | 20 | ;; (add-to-list 'mouse-slider-mode-eval-funcs 21 | ;; '(js2-mode . skewer-eval-defun)) 22 | 23 | ;; The variable `mouse-slider-eval' enables/disables this evaluation 24 | ;; step. 25 | 26 | ;;; Code: 27 | 28 | (require 'cl) 29 | (require 'thingatpt) 30 | 31 | (defvar mouse-slider-scale 1500 32 | "Rate at which numbers scale. Smaller means faster.") 33 | 34 | (defvar mouse-slider-mode-eval-funcs 35 | `((emacs-lisp-mode . ,(apply-partially #'eval-defun nil))) 36 | "Alist of evaluation functions to run after scaling numbers in 37 | various major modes.") 38 | 39 | (defvar-local mouse-slider-eval t 40 | "When true, run the evaluation function listed in 41 | `mouse-slider-mode-eval-funcs' after updating numbers.") 42 | 43 | (defvar mouse-slider-mode-map 44 | (let ((map (make-sparse-keymap))) 45 | (prog1 map 46 | (define-key map (kbd "") 'mouse-slider-slide))) 47 | "Keymap for mouse-slider-mode.") 48 | 49 | (define-minor-mode mouse-slider-mode 50 | "Scales numbers when they are right-click dragged over." 51 | :keymap mouse-slider-mode-map 52 | :lighter " MSlider") 53 | 54 | (defvar mouse-slider-number-regexp 55 | "[-+]?[0-9]*\\.?[0-9]+\\([eE][-+]?[0-9]+\\)?" 56 | "Regular expression used to match numbers.") 57 | 58 | (defun mouse-slider-number-bounds () 59 | "Return the bounds of the number at point." 60 | (save-excursion 61 | (while (and (not (bobp)) (looking-at-p mouse-slider-number-regexp)) 62 | (backward-char 1)) 63 | (unless (bobp) (forward-char 1)) 64 | (let ((start (point))) 65 | (re-search-forward mouse-slider-number-regexp) 66 | (cons start (point))))) 67 | 68 | (defun* mouse-slider-replace-number (value) 69 | "Replace the number at point with VALUE." 70 | (save-excursion 71 | (let ((region (mouse-slider-number-bounds))) 72 | (delete-region (car region) (cdr region)) 73 | (goto-char (car region)) 74 | (insert (format "%s" value))))) 75 | 76 | (defun mouse-slider-round (value decimals) 77 | "Round VALUE to DECIMALS decimal places." 78 | (let ((n (expt 10 decimals))) 79 | (/ (round (* value n)) 1.0 n))) 80 | 81 | (defun mouse-slider-scale (base pixels) 82 | "Scale BASE by a drag distance of PIXELS." 83 | (expt base (1+ (/ pixels 1.0 mouse-slider-scale)))) 84 | 85 | (defun mouse-slider-slide (event) 86 | "Handle a mouse slider event by continuously updating the 87 | number where the mouse drag began." 88 | (interactive "e") 89 | (save-excursion 90 | (goto-char (posn-point (second event))) 91 | (let ((base (thing-at-point 'number))) 92 | (when base 93 | (flet ((x (event) (car (posn-x-y (second event))))) 94 | (track-mouse 95 | (loop for movement = (read-event) 96 | while (mouse-movement-p movement) 97 | ;; Replace 98 | for diff = (- (x movement) (x event)) 99 | for value = (mouse-slider-scale base diff) 100 | when (not (zerop (x movement))) 101 | do (mouse-slider-replace-number 102 | (mouse-slider-round value 2)) 103 | ;; Eval 104 | for f = (cdr (assoc major-mode mouse-slider-mode-eval-funcs)) 105 | when (and f mouse-slider-eval) 106 | do (funcall f)))))))) 107 | 108 | (provide 'mouse-slider-mode) 109 | 110 | ;;; mouse-slider-mode.el ends here 111 | -------------------------------------------------------------------------------- /site-lisp/core-async-mode.el: -------------------------------------------------------------------------------- 1 | ;;; core-async-mode.el 2 | 3 | ;; It requires core async functions and macros for you 4 | 5 | (require 'dash) 6 | (require 'clj-refactor) 7 | (require 'old-clj-refactor-stuff) 8 | 9 | (defvar core-async--functions 10 | (list 11 | "!" ">!!" "admix" "alt!" "alt!!" "alts!" "alts!!" "buffer" 12 | "chan" "close!" "do-alts" "dropping-buffer" "mix" "mult" "offer!" 13 | "onto-chan" "pipe" "pipeline" "pipeline-async" "pipeline-blocking" 14 | "poll!" "pub" "put!" "sliding-buffer" "solo-mode" "sub" "take!" 15 | "tap" "thread" "thread-call" "timeout" "to-chan" "unblocking-buffer?" 16 | "unmix" "unmix-all" "unsub" "unsub-all" "untap" "untap-all")) 17 | 18 | (defvar core-async--macros 19 | (list "go" "go-loop")) 20 | 21 | (defvar core-async--functions-re 22 | (concat (regexp-opt '("(" "[")) 23 | (regexp-opt (-concat core-async--functions 24 | core-async--macros) 25 | 'symbols))) 26 | 27 | (defun core-async--in-comment? () 28 | (nth 4 (syntax-ppss))) 29 | 30 | (defun core-async--find-usages () 31 | (let (result) 32 | (save-excursion 33 | (goto-char (point-min)) 34 | (while (re-search-forward core-async--functions-re nil t) 35 | (unless (core-async--in-comment?) 36 | (!cons (cider-symbol-at-point) result)))) 37 | (-distinct result))) 38 | 39 | (defun core-async--remove-from-ns (type s) 40 | (cljr--goto-ns) 41 | (when (cljr--search-forward-within-sexp (concat "(" type)) 42 | (skip-syntax-forward " >") 43 | (while (not (looking-at ")")) 44 | (if (looking-at (regexp-quote (concat "[" s))) 45 | (cljr--delete-sexp) 46 | (paredit-forward)) 47 | (skip-syntax-forward " >")))) 48 | 49 | (defun core-async--update-clj-namespace () 50 | (save-excursion 51 | (cljr--goto-ns) 52 | (unless (cljr--search-forward-within-sexp "clojure.core.async :as") 53 | (let ((usages (core-async--find-usages))) 54 | (core-async--remove-from-ns ":require" "clojure.core.async") 55 | (when usages 56 | (cljr--insert-in-ns ":require") 57 | (insert "[clojure.core.async :refer [") 58 | (apply 'insert (->> usages 59 | (-sort ocljr-sort-comparator) 60 | (-interpose " "))) 61 | (insert "]]")))) 62 | (ocljr-sort-ns))) 63 | 64 | (defun core-async--update-cljs-namespace () 65 | (save-excursion 66 | (cljr--goto-ns) 67 | (unless (cljr--search-forward-within-sexp "cljs.core.async :as") 68 | (let* ((usages (core-async--find-usages)) 69 | (used-fns (--filter (member it core-async--functions) usages)) 70 | (used-macros (--filter (member it core-async--macros) usages))) 71 | (core-async--remove-from-ns ":require" "cljs.core.async") 72 | (core-async--remove-from-ns ":require-macros" "cljs.core.async.macros") 73 | (when used-fns 74 | (cljr--insert-in-ns ":require") 75 | (just-one-space) 76 | (insert "[cljs.core.async :refer [") 77 | (apply 'insert (->> used-fns 78 | (-sort ocljr-sort-comparator) 79 | (-interpose " "))) 80 | (insert "]]")) 81 | (when used-macros 82 | (cljr--insert-in-ns ":require-macros") 83 | (just-one-space) 84 | (insert "[cljs.core.async.macros :refer [") 85 | (apply 'insert (->> used-macros 86 | (-sort ocljr-sort-comparator) 87 | (-interpose " "))) 88 | (insert "]]")) 89 | (ocljr-sort-ns))))) 90 | 91 | (defun core-async-update-namespace () 92 | (interactive) 93 | (cond ((s-ends-with? ".clj" (buffer-file-name)) 94 | (core-async--update-clj-namespace)) 95 | 96 | ((s-ends-with? ".cljs" (buffer-file-name)) 97 | (core-async--update-cljs-namespace)))) 98 | 99 | (define-minor-mode core-async-mode 100 | "Core async mode" nil " async" nil 101 | (if core-async-mode 102 | (add-hook 'before-save-hook 'core-async-update-namespace t t) 103 | (remove-hook 'before-save-hook 'core-async-update-namespace t))) 104 | 105 | (provide 'core-async-mode) 106 | -------------------------------------------------------------------------------- /site-lisp/jade-mode/sws-mode.el: -------------------------------------------------------------------------------- 1 | (require 'font-lock) 2 | 3 | (defvar sws-tab-width 2) 4 | 5 | (defmacro sws-line-as-string () 6 | "Returns the current line as a string." 7 | `(buffer-substring (point-at-bol) (point-at-eol))) 8 | 9 | (defun sws-previous-indentation () 10 | "Gets indentation of previous line" 11 | (save-excursion 12 | (previous-line) 13 | (current-indentation))) 14 | 15 | (defun sws-max-indent () 16 | "Calculates max indentation" 17 | (+ (sws-previous-indentation) sws-tab-width)) 18 | 19 | (defun sws-empty-line-p () 20 | "If line is completely empty" 21 | (= (point-at-bol) (point-at-eol))) 22 | 23 | (defun sws-point-to-bot () 24 | "Moves point to beginning of text" 25 | (beginning-of-line-text)) 26 | 27 | (defun sws-do-indent-line () 28 | "Performs line indentation" 29 | ;;if we are not tabbed out past max indent 30 | (if (sws-empty-line-p) 31 | (indent-to (sws-max-indent)) 32 | (if (< (current-indentation) (sws-max-indent)) 33 | (indent-to (+ (current-indentation) sws-tab-width)) 34 | ;; if at max indent move text to beginning of line 35 | (progn 36 | (beginning-of-line) 37 | (delete-horizontal-space))))) 38 | 39 | (defun sws-indent-line () 40 | "Indents current line" 41 | (interactive) 42 | (if mark-active 43 | (sws-indent-region) 44 | (if (sws-at-bot-p) 45 | (sws-do-indent-line) 46 | ;; instead of adjusting indent, move point to text 47 | (sws-point-to-bot)))) 48 | 49 | (defun sws-at-bol-p () 50 | "If point is at beginning of line" 51 | (interactive) 52 | (= (point) (point-at-bol))) 53 | 54 | (defun sws-at-bot-p () 55 | "If point is at beginning of text" 56 | (= (point) (+ (current-indentation) (point-at-bol)))) 57 | 58 | (defun sws-print-line-number () 59 | "Prints line number" 60 | (sws-print-num (point))) 61 | 62 | (defun sws-print-num (arg) 63 | "Prints line number" 64 | (message (number-to-string arg))) 65 | 66 | (defun sws-indent-to (num) 67 | "Force indentation to level including those below current level" 68 | (save-excursion 69 | (beginning-of-line) 70 | (delete-horizontal-space) 71 | (indent-to num))) 72 | 73 | (defun sws-move-region (begin end prog) 74 | "Moves left is dir is null, otherwise right. prog is '+ or '-" 75 | (save-excursion 76 | (let (first-indent indent-diff) 77 | (goto-char begin) 78 | (setq first-indent (current-indentation)) 79 | (sws-indent-to 80 | (funcall prog first-indent sws-tab-width)) 81 | (setq indent-diff (- (current-indentation) first-indent)) 82 | ;; move other lines based on movement of first line 83 | (while (< (point) end) 84 | (forward-line 1) 85 | (if (< (point) end) 86 | (sws-indent-to (+ (current-indentation) indent-diff))))))) 87 | 88 | (defun sws-indent-region (begin end) 89 | "Indents the selected region" 90 | (interactive) 91 | (sws-move-region begin end '+)) 92 | 93 | 94 | (defun sws-dendent-line () 95 | "De-indents current line" 96 | (interactive) 97 | (if mark-active 98 | (sws-move-region (region-beginning) (region-end) '-) 99 | (if (sws-at-bol-p) 100 | (progn 101 | (message "at mother fucking bol") 102 | (delete-horizontal-space) 103 | (indent-to (sws-max-indent))) 104 | (let ((ci (current-indentation))) 105 | (beginning-of-line) 106 | (delete-horizontal-space) 107 | (indent-to (- ci sws-tab-width)))))) 108 | 109 | (defvar sws-mode-map (make-sparse-keymap)) 110 | (define-key sws-mode-map [S-tab] 'sws-dendent-line) 111 | (define-key sws-mode-map [backtab] 'sws-dendent-line) 112 | 113 | (define-derived-mode sws-mode fundamental-mode 114 | "sws" 115 | "Major mode for editing significant whitespace files" 116 | (kill-all-local-variables) 117 | 118 | ;; default tab width 119 | (setq sws-tab-width 2) 120 | (make-local-variable 'indent-line-function) 121 | (setq indent-line-function 'sws-indent-line) 122 | (make-local-variable 'indent-region-function) 123 | 124 | (setq indent-region-function 'sws-indent-region) 125 | 126 | ;; TODO needed? 127 | (setq indent-tabs-mode nil) 128 | 129 | ;; keymap 130 | (use-local-map sws-mode-map) 131 | (setq major-mode 'sws-mode)) 132 | 133 | (provide 'sws-mode) 134 | -------------------------------------------------------------------------------- /kk.el: -------------------------------------------------------------------------------- 1 | (require 'elnode) 2 | 3 | ;; You can define a handler function: 4 | 5 | (defun create-attack-action (me target) 6 | (setq arr [nil nil nil]) 7 | (aset arr 0 (alist-get 'id me)) 8 | (aset arr 1 "attack") 9 | (aset arr 2 (list (cons 'x (alist-get 'x target)) 10 | (cons 'y (alist-get 'y target)))) 11 | (copy-sequence arr)) 12 | 13 | (defun create-heal-action (me target) 14 | (setq arr [nil nil nil]) 15 | (aset arr 0 (alist-get 'id me)) 16 | (aset arr 1 "heal") 17 | (aset arr 2 (list (cons 'x (alist-get 'x target)) 18 | (cons 'y (alist-get 'y target)))) 19 | (copy-sequence arr)) 20 | 21 | (defun create-move-action (me direction) 22 | (setq arr [nil nil nil]) 23 | (aset arr 0 (alist-get 'id me)) 24 | (aset arr 1 "move") 25 | (aset arr 2 (list (cons 'x (+ (alist-get 'x me) (cl-case direction ('up 0) ('down 0) ('left -1) ('right 1)))) 26 | (cons 'y (+ (alist-get 'y me) (cl-case direction ('up -1) ('down 1) ('left 0) ('right 0)))))) 27 | (copy-sequence arr)) 28 | 29 | (defun attack-actions (target) 30 | (--keep (when (can-hit? it target) 31 | (create-attack-action it target)) 32 | friendly-units)) 33 | 34 | (defun directions-to (me target) 35 | (setq dirs ()) 36 | (when (< (alist-get 'x me) (alist-get 'x target)) 37 | (!cons 'right dirs)) 38 | (when (> (alist-get 'x me) (alist-get 'x target)) 39 | (!cons 'left dirs)) 40 | (when (< (alist-get 'y me) (alist-get 'y target)) 41 | (!cons 'down dirs)) 42 | (when (> (alist-get 'y me) (alist-get 'y target)) 43 | (!cons 'up dirs)) 44 | dirs) 45 | 46 | (defun nshuffle (sequence) 47 | (cl-loop for i from (length sequence) downto 2 48 | do (cl-rotatef (elt sequence (random i)) 49 | (elt sequence (1- i)))) 50 | sequence) 51 | 52 | (defun move-towards (me target) 53 | (--map (create-move-action me it) 54 | (nshuffle (directions-to me target)))) 55 | 56 | (defun my-test-handler (httpcon) 57 | "Demonstration function" 58 | (elnode-http-start httpcon 200 '("Content-type" . "application/json")) 59 | 60 | (setq params (elnode-http-params httpcon)) 61 | (setq data 62 | (json-read-from-string 63 | (caar params))) 64 | 65 | (setq enemy-units (mapcar 'identity (alist-get 'enemy-units data))) 66 | (setq friendly-units (mapcar 'identity (alist-get 'friendly-units data))) 67 | 68 | (setq healer (--find (alist-get 'heals it) friendly-units)) 69 | 70 | (setq heal-target nil) 71 | (when healer 72 | (setq heal-target (--find (and (can-hit? healer it) 73 | ;; (< (alist-get 'health it) 74 | ;; (alist-get 'max-health it)) 75 | (not (eq healer it))) 76 | friendly-units)) 77 | (when heal-target 78 | (setq opportunity-heal (create-heal-action healer heal-target)))) 79 | 80 | (setq target (car (--sort (+ (alist-get 'health it) 81 | (alist-get 'armor it)) 82 | (nshuffle enemy-units)))) 83 | 84 | (setq opportunity-attacks (-mapcat 'attack-actions enemy-units)) 85 | (setq moves-to-target (--mapcat (move-towards it target) 86 | (--remove (can-hit? it target) friendly-units))) 87 | (setq attacks-on-target (--map (create-attack-action it target) friendly-units)) 88 | 89 | (elnode-http-return httpcon (json-encode 90 | (-concat (when heal-target (list opportunity-heal)) 91 | opportunity-attacks 92 | moves-to-target 93 | attacks-on-target)))) 94 | 95 | ;; And then start the server: 96 | 97 | (defun rand-nth (coll) 98 | (nth (random (length coll)) coll)) 99 | 100 | (defun range-between (a b) 101 | (+ (abs (- (alist-get 'x a) 102 | (alist-get 'x b))) 103 | (abs (- (alist-get 'y a) 104 | (alist-get 'y b))))) 105 | 106 | (defun can-hit? (me target) 107 | (= (or (alist-get 'range me) 1) 108 | (range-between me target))) 109 | 110 | (require 'json) 111 | 112 | (comment 113 | (elnode-start 'my-test-handler :port 8010 :host "0.0.0.0") 114 | 115 | ) 116 | -------------------------------------------------------------------------------- /settings/mode-mappings.el: -------------------------------------------------------------------------------- 1 | ;; YAML 2 | (autoload 'yaml-mode "yaml-mode") 3 | (add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode)) 4 | (add-to-list 'auto-mode-alist '("\\.yaml$" . yaml-mode)) 5 | (add-to-list 'auto-mode-alist '("jsTestDriver\\.conf$" . yaml-mode)) 6 | 7 | ;; Emacs lisp 8 | (add-to-list 'auto-mode-alist '("Carton$" . emacs-lisp-mode)) 9 | (add-to-list 'auto-mode-alist '("Cask$" . emacs-lisp-mode)) 10 | 11 | ;; CSS 12 | (add-to-list 'auto-mode-alist '("\\.scss$" . css-mode)) 13 | 14 | ;; Restclient 15 | (add-to-list 'auto-mode-alist '("\\.restclient$" . restclient-mode)) 16 | 17 | ;; Cucumber 18 | (autoload 'feature-mode "feature-mode") 19 | (add-to-list 'auto-mode-alist '("\\.feature$" . feature-mode)) 20 | 21 | ;; Adventur 22 | (autoload 'adventur-mode "adventur-mode") 23 | (add-to-list 'auto-mode-alist '("\\.adv$" . adventur-mode)) 24 | 25 | ;; Jade and Stylus (sws = significant whitespace) 26 | (autoload 'sws-mode "sws-mode") 27 | (autoload 'jade-mode "jade-mode") 28 | (add-to-list 'auto-mode-alist '("\\.styl$" . sws-mode)) 29 | (add-to-list 'auto-mode-alist '("\\.jade$" . jade-mode)) 30 | 31 | ;; HTML 32 | (add-to-list 'auto-mode-alist '("\\.html\\'" . crappy-jsp-mode)) 33 | (add-to-list 'auto-mode-alist '("\\.tag$" . html-mode)) 34 | (add-to-list 'auto-mode-alist '("\\.vm$" . html-mode)) 35 | (add-to-list 'auto-mode-alist '("\\.ejs$" . html-mode)) 36 | 37 | ;; JSP 38 | (autoload 'crappy-jsp-mode "crappy-jsp-mode") 39 | (add-to-list 'auto-mode-alist '("\\.jsp$" . crappy-jsp-mode)) 40 | (add-to-list 'auto-mode-alist '("\\.jspf$" . crappy-jsp-mode)) 41 | 42 | ;; Ruby 43 | (autoload 'rhtml-mode "rhtml-mode") 44 | (add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode)) 45 | (add-to-list 'auto-mode-alist '("\\.watchr$" . ruby-mode)) 46 | (add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode)) 47 | (add-to-list 'auto-mode-alist '("\\.gemspec$" . ruby-mode)) 48 | (add-to-list 'auto-mode-alist '("\\.ru$" . ruby-mode)) 49 | (add-to-list 'auto-mode-alist '("Gemfile" . ruby-mode)) 50 | (add-to-list 'auto-mode-alist '("Vagrantfile" . ruby-mode)) 51 | (add-to-list 'auto-mode-alist '("capfile" . ruby-mode)) 52 | (add-to-list 'auto-mode-alist '("\\.erb$" . rhtml-mode)) 53 | 54 | ;; Puppet 55 | (autoload 'puppet-mode "puppet-mode") 56 | (add-to-list 'auto-mode-alist '("\\.pp$" . puppet-mode)) 57 | 58 | ;; Groovy 59 | (autoload 'groovy-mode "groovy-mode") 60 | (add-to-list 'auto-mode-alist '("\\.groovy$" . groovy-mode)) 61 | (add-to-list 'auto-mode-alist '("\\.gradle$" . groovy-mode)) 62 | 63 | ;; Scala 64 | (autoload 'scala-mode "scala-mode2") 65 | (add-to-list 'auto-mode-alist '("\\.scala$" . scala-mode)) 66 | 67 | ;; Clojure 68 | (autoload 'clojure-mode "clojure-mode") 69 | (add-to-list 'auto-mode-alist '("\\.clj$" . clojure-mode)) 70 | (add-to-list 'auto-mode-alist '("\\.cljs$" . clojurescript-mode)) 71 | (add-to-list 'auto-mode-alist '("\\.cljc$" . clojurec-mode)) 72 | 73 | ;; SVG 74 | (add-to-list 'auto-mode-alist '("\\.svg$" . image-mode)) 75 | 76 | ;; JavaScript 77 | (autoload 'js2-mode "js2-mode" nil t) 78 | (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode)) 79 | (add-to-list 'auto-mode-alist '("\\.json$" . javascript-mode)) 80 | (add-to-list 'auto-mode-alist '("\\.jshintrc$" . javascript-mode)) 81 | (add-to-list 'magic-mode-alist '("#!/usr/bin/env node" . js2-mode)) 82 | 83 | ;; Configuration files 84 | (add-to-list 'auto-mode-alist '("\\.offlineimaprc$" . conf-mode)) 85 | 86 | ;; Snippets 87 | (add-to-list 'auto-mode-alist '("yasnippet/snippets" . snippet-mode)) 88 | (add-to-list 'auto-mode-alist '("\\.yasnippet$" . snippet-mode)) 89 | 90 | ;; Buster.JS 91 | ;(autoload 'buster-mode "buster-mode") 92 | ;(setq buster-node-executable "/usr/local/bin/node") 93 | ;(add-file-find-hook-with-pattern "test\\.js$" (lambda () (buster-mode)) "require(\\(\"\\|'\\)buster") 94 | 95 | ;; Markdown 96 | (autoload 'markdown-mode "markdown-mode") 97 | (add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode)) 98 | (add-to-list 'auto-mode-alist '("\\.markdown$" . markdown-mode)) 99 | 100 | ;; org-mode 101 | (add-to-list 'auto-mode-alist '("\\.org$" . org-mode)) 102 | 103 | ;; Apache config 104 | (autoload 'apache-mode "apache-mode" nil t) 105 | (add-to-list 'auto-mode-alist '("\\.htaccess\\'" . apache-mode)) 106 | (add-to-list 'auto-mode-alist '("httpd\\.conf\\'" . apache-mode)) 107 | (add-to-list 'auto-mode-alist '("srm\\.conf\\'" . apache-mode)) 108 | (add-to-list 'auto-mode-alist '("access\\.conf\\'" . apache-mode)) 109 | (add-to-list 'auto-mode-alist '("sites-\\(available\\|enabled\\)/" . apache-mode)) 110 | 111 | (provide 'mode-mappings) 112 | -------------------------------------------------------------------------------- /site-lisp/rhtml-mode/rhtml-mode.el: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; rhtml-mode.el - major mode for editing RHTML files 3 | ;;; 4 | 5 | ;; ***** BEGIN LICENSE BLOCK ***** 6 | ;; Version: MPL 1.1/GPL 2.0/LGPL 2.1 7 | 8 | ;; The contents of this file are subject to the Mozilla Public License Version 9 | ;; 1.1 (the "License"); you may not use this file except in compliance with 10 | ;; the License. You may obtain a copy of the License at 11 | ;; http://www.mozilla.org/MPL/ 12 | 13 | ;; Software distributed under the License is distributed on an "AS IS" basis, 14 | ;; WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 15 | ;; for the specific language governing rights and limitations under the 16 | ;; License. 17 | 18 | ;; The Original Code is RHTML-MODE. 19 | 20 | ;; The Initial Developer of the Original Code is 21 | ;; Paul Nathan Stickney . 22 | ;; Portions created by the Initial Developer are Copyright (C) 2006 23 | ;; the Initial Developer. All Rights Reserved. 24 | 25 | ;; Contributor(s): 26 | ;; Phil Hagelberg 27 | 28 | ;; Alternatively, the contents of this file may be used under the terms of 29 | ;; either the GNU General Public License Version 2 or later (the "GPL"), or 30 | ;; the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 31 | ;; in which case the provisions of the GPL or the LGPL are applicable instead 32 | ;; of those above. If you wish to allow use of your version of this file only 33 | ;; under the terms of either the GPL or the LGPL, and not to allow others to 34 | ;; use your version of this file under the terms of the MPL, indicate your 35 | ;; decision by deleting the provisions above and replace them with the notice 36 | ;; and other provisions required by the GPL or the LGPL. If you do not delete 37 | ;; the provisions above, a recipient may use your version of this file under 38 | ;; the terms of any one of the MPL, the GPL or the LGPL. 39 | 40 | ;; ***** END LICENSE BLOCK ***** 41 | 42 | 43 | (require 'rhtml-fonts) ;; basic fontification 44 | 45 | ;; don't require if you don't want it... 46 | (require 'rhtml-sgml-hacks) ;; indent erb with sgml 47 | 48 | (define-derived-mode rhtml-mode 49 | html-mode "RHTML" 50 | "Embedded Ruby Mode (RHTML)" 51 | (interactive) 52 | (abbrev-mode) 53 | ;; disable if you don't want it... 54 | (rhtml-activate-fontification)) 55 | 56 | (add-to-list 'auto-mode-alist '("\\.html\\.erb$" . rhtml-mode)) 57 | 58 | (define-key ruby-mode-map 59 | "\C-c\C-v" (lambda () (interactive) (toggle-buffer 'rails-view))) 60 | (define-key rhtml-mode-map 61 | "\C-c\C-b" 'rinari-find-by-context) 62 | 63 | (defun extract-partial (begin end partial-name) 64 | (interactive "r\nsName your partial: ") 65 | (kill-region begin end) 66 | (find-file (concat "_" partial-name "\\.html\\.erb")) 67 | (yank) 68 | (pop-to-buffer nil) 69 | (insert (concat "<%= render :partial => '" partial-name "' %>\n"))) 70 | 71 | ;; PST -- uses rhtml-erb-regions which is defined in rhtml-font which 72 | ;; should be moved. 73 | (defun rhtml-dashize (&optional mode) 74 | "Add or remove dashes from the end of ERb blocks. The dash tells ERb to 75 | strip the following newline. This function will NOT add or remove dashes 76 | from blocks that end in a # or #- sequence. 77 | 78 | MODE controls how dashes are added or removed. If MODE is `strip' then all 79 | ERb blocks will have the dash removed. If MODE is `add' then all blocks 80 | will have a dash added. If MODE is `auto' or nil then ERb blocks which are 81 | followed by a newline will have a dash added while all other blocks will 82 | have the dash removed." 83 | (interactive "cDashize mode: s) strip, a) add, x) auto (default)") 84 | (let ((real-mode (case mode 85 | ((?s strip) 'strip) 86 | ((?a add) 'add)))) 87 | (mapc (lambda (i) 88 | (let ((end (nth 2 i))) 89 | (save-excursion 90 | (goto-char (- end 2)) 91 | (case (or real-mode 92 | (if (eq (char-after end) ?\n) 93 | 'add 94 | 'strip)) 95 | (strip 96 | (when (and (eq (char-before) ?-) 97 | (not (eq (char-before (1- (point))) ?#))) 98 | (delete-backward-char 1))) 99 | (add 100 | (unless (memq (char-before) '(?# ?-)) 101 | (insert "-"))))))) 102 | ;; seq. 103 | (rhtml-erb-regions (point-min) (point-max))))) 104 | 105 | 106 | (require 'rhtml-navigation) 107 | (provide 'rhtml-mode) -------------------------------------------------------------------------------- /site-lisp/bash-completion/README.md: -------------------------------------------------------------------------------- 1 | bash-completion.el defines dynamic completion hooks for shell-mode and 2 | shell-command prompts that are based on bash completion. 3 | 4 | You will need shell-command.el to get tab completion in the 5 | minibuffer. See [http://www.namazu.org/~tsuchiya/elisp/shell-command.el](http://www.namazu.org/~tsuchiya/elisp/shell-command.el) 6 | 7 | Bash completion for emacs: 8 | 9 | - is aware of bash builtins, aliases and functions 10 | - does file expansion inside of colon-separated variables 11 | and after redirections (> or <) 12 | - escapes special characters when expanding file names 13 | - is configurable through programmable bash completion 14 | 15 | When the first completion is requested in shell model or a shell 16 | command, bash-completion.el starts a separate bash 17 | process. Bash-completion.el then uses this process to do the actual 18 | completion and includes it into Emacs completion suggestions. 19 | 20 | A simpler and more complete alternative to bash-completion.el is to 21 | run a bash shell in a buffer in term mode(M-x `ansi-term'). 22 | Unfortunately, many Emacs editing features are not available when 23 | running in term mode. Also, term mode is not available in 24 | shell-command prompts. 25 | 26 | ## INSTALLATION 27 | 28 | 1. copy bash-completion.el into a directory that's on Emacs load-path 29 | 2. add this into your .emacs file: 30 | 31 | (autoload 'bash-completion-dynamic-complete 32 | "bash-completion" 33 | "BASH completion hook") 34 | (add-hook 'shell-dynamic-complete-functions 35 | 'bash-completion-dynamic-complete) 36 | (add-hook 'shell-command-complete-functions 37 | 'bash-completion-dynamic-complete) 38 | 39 | or simpler, but forces you to load this file at startup: 40 | 41 | (require 'bash-completion) 42 | (bash-completion-setup) 43 | 44 | 3. reload your .emacs (M-x `eval-buffer') or restart 45 | 46 | Once this is done, use as usual to do dynamic completion from 47 | shell mode or a shell command minibuffer, such as the one started 48 | for M-x `compile'. Note that the first completion is slow, as emacs 49 | launches a new bash process. 50 | 51 | You'll get better results if you turn on programmable bash completion. 52 | On Ubuntu, this means running: 53 | 54 | sudo apt-get install bash-completion 55 | 56 | and then adding this to your .bashrc: 57 | 58 | . /etc/bash_completion 59 | 60 | Right after enabling programmable bash completion, and whenever you 61 | make changes to you .bashrc, call `bash-completion-reset' to make 62 | sure bash completion takes your new settings into account. 63 | 64 | Loading /etc/bash_completion often takes time, and is not necessary 65 | in shell mode, since completion is done by a separate process, not 66 | the process shell-mode process. 67 | 68 | To turn off bash completion when running from emacs but keep it on 69 | for processes started by bash-completion.el, add this to your .bashrc: 70 | 71 | if [[ ( -z "$INSIDE_EMACS" || "$EMACS_BASH_COMPLETE" = "t" ) &&\ 72 | -f /etc/bash_completion ]]; then 73 | . /etc/bash_completion 74 | fi 75 | 76 | Emacs sets the environment variable INSIDE_EMACS to the processes 77 | started from it. Processes started by bash-completion.el have 78 | the environment variable EMACS_BASH_COMPLETE set to t. 79 | 80 | ## CAVEATS 81 | 82 | Using a separate process for doing the completion has several 83 | important disadvantages: 84 | 85 | - bash completion is slower than standard emacs completion 86 | - the first completion can take a long time, since a new bash process 87 | needs to be started and initialized 88 | - the separate process is not aware of any changes made to bash 89 | in the current buffer. 90 | In a standard terminal, you could do: 91 | 92 | $ alias myalias=ls 93 | $ myal 94 | 95 | and bash would propose the new alias. 96 | Bash-completion.el cannot do that, as it is not aware of anything 97 | configured in the current shell. To make bash-completion.el aware 98 | of a new alias, you need to add it to .bashrc and restart the 99 | completion process using `bash-completion-reset'. 100 | 101 | ## COMPATIBILITY 102 | 103 | bash-completion.el is quite sensitive to the OS and BASH version. 104 | This package is known to work on the following environment: 105 | 106 | - GNU Emacs 22.3.1 (Aquamacs 1.7) 107 | - GNU Emacs 22.1.1 (OSX 10.5) 108 | - GNU Emacs 22.1.1 (Ubuntu 8.04) 109 | - GNU Emacs 23.0.94.1 (Ubuntu 8.10) 110 | 111 | and using the following bash versions: 112 | 113 | - BASH 3.2.17 114 | - BASH 3.2.32 115 | - BASH 3.2.39 116 | 117 | bash-completion.el does not works on XEmacs. 118 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # My emacs settings 2 | 3 | An ever-changing set of emacs settings. Micro-optimizations are super fun. 4 | These are used in the [Emacs Rocks](http://emacsrocks.com) screencasts. 5 | You can also see some thoughts behind the settings on my [What the .emacs.d!?](http://whattheemacsd.com)-blog. 6 | 7 | Please note: I have [rebooted my emacs configuration](https://github.com/magnars/emacsd-reboot), so this is no longer being used or maintained. 8 | 9 | ## Setup 10 | 11 | To grab all the dependencies: 12 | 13 | git clone --recursive git://github.com/magnars/.emacs.d.git 14 | 15 | The first time you start emacs, it will install some additional packages 16 | that are best handled by the package manager. 17 | 18 | ## Install emacs on mac 19 | 20 | I use Cocoa Emacs, installed like this: 21 | 22 | brew install --cask emacs 23 | 24 | ## Tips for using these emacs settings 25 | 26 | If you want to use my settings straight out of the box, here are some things to note: 27 | 28 | * I recommend starting with a blank emacs + 29 | [Technomancy's better-defaults package](https://git.sr.ht/~technomancy/better-defaults), 30 | and then dig through this repo for useful nuggets, instead of forking it directly. 31 | 32 | * The key bindings are optimized for a norwegian keyboard layout. 33 | 34 | * Start by reading up on all the cool stuff in [key-bindings.el](settings/key-bindings.el). 35 | 36 | * You quit emacs with `C-x r q`, mnemonic *Really Quit*. 37 | 38 | * Find file in project with `C-x o`, in dir with `C-x C-f`, recent with `C-x f` 39 | 40 | * Add your user- and project-specific stuff in .emacs.d/users/[machine name]/*.el 41 | 42 | * `C-h` is rebound to backspace, like in the shell. Get help on `F1` instead. 43 | 44 | * Autocomplete with `C-.` (autocomplete entire lines with `C-:`) 45 | 46 | * expand-region is your friend. Find its bound key by doing `F1 f er/expand-region` 47 | 48 | * Undo with `C-_` and redo with `M-_`. Watch the undo-tree with `C-x u` 49 | 50 | * Quickly jump anywhere in the buffer with `C-ø` then the starting letter of a word. 51 | 52 | * Indent and clean up white space in the entire buffer with `C-c n` 53 | 54 | * On a mac, the Meta key `M` is bound to Command. 55 | 56 | * I recommend rebinding Caps Lock to Ctrl and use that instead of the often badly placed Ctrl-key. 57 | 58 | * Watch [emacsrocks.com](http://emacsrocks.com) 59 | 60 | ## Survival guide for the first week of emacs 61 | 62 | When you start using emacs for the first time, your habits fight you every inch 63 | of the way. Your fingers long for the good old familiar keybindings. Here's an 64 | overview of the most commonly used shortcuts to get you through this pain: 65 | 66 | * `C ` Shorthand for the ctrl-key 67 | * `M ` Shorthand for the meta-key (bound to cmd on my mac settings) 68 | * `S ` Shorthand for the shift-key 69 | 70 | ### Files 71 | 72 | * `C-x C-f` Open a file. Starts in the current directory 73 | * `C-x f ` Open a recently visited file 74 | * `C-x o ` Open a file in the current project (based on .git ++) 75 | * `C-x C-s` Save this file 76 | * `C-x C-w` Save as ... 77 | * `C-x C-j` Jump to this files' current directory 78 | * `C-x b ` Switch to another open file (buffer) 79 | * `C-x C-b` List all open files (buffers) 80 | 81 | ### Cut copy and paste 82 | 83 | * `C-space` Start marking stuff. C-g to cancel. 84 | * `C-w ` Cut (aka kill) 85 | * `C-k ` Cut till end of line 86 | * `M-w ` Copy 87 | * `C-y ` Paste (aka yank) 88 | * `M-y ` Cycle last paste through previous kills 89 | * `C-x C-y` Choose what to paste from previous kills 90 | * `C-@ ` Mark stuff quickly. Press multiple times 91 | 92 | ### General 93 | 94 | * `C-g ` Quit out of whatever mess you've gotten yourself into 95 | * `M-x ` Run a command by name 96 | * `C-. ` Autocomplete 97 | * `C-_ ` Undo 98 | * `M-_ ` Redo 99 | * `C-x u ` Show the undo-tree 100 | * `C-x m ` Open magit. It's a magical git interface for emacs 101 | 102 | ### Navigation 103 | 104 | * `C-arrow` Move past words/paragraphs 105 | * `C-a ` Go to start of line 106 | * `C-e ` Go to end of line 107 | * `M-g M-g` Go to line number 108 | * `C-x C-i` Go to symbol 109 | * `C-s ` Search forward. Press `C-s` again to go further. 110 | * `C-r ` Search backward. Press `C-r` again to go further. 111 | 112 | ### Window management 113 | 114 | * `C-x 0 ` Close this window 115 | * `C-x 1 ` Close other windows 116 | * `C-x 2 ` Split window horizontally 117 | * `C-x 3 ` Split window vertically 118 | * `S-arrow` Jump to window to the left/right/up/down 119 | 120 | ### Help 121 | 122 | * `F1 t ` Basic tutorial 123 | * `F1 k ` Help for a keybinding 124 | * `F1 r ` Emacs' extensive documentation 125 | -------------------------------------------------------------------------------- /site-lisp/skewer-mode/skewer-css.el: -------------------------------------------------------------------------------- 1 | ;;; skewer-css.el --- skewer support for live-interaction CSS 2 | 3 | ;; This is free and unencumbered software released into the public domain. 4 | 5 | ;;; Commentary: 6 | 7 | ;; This minor mode provides functionality for CSS like plain Skewer 8 | ;; does for JavaScript. 9 | 10 | ;; * C-x C-e -- `skewer-css-eval-current-declaration' 11 | ;; * C-M-x -- `skewer-css-eval-current-rule' 12 | ;; * C-c C-k -- `skewer-css-eval-buffer' 13 | 14 | ;; These functions assume there are no comments within a CSS rule, 15 | ;; *especially* not within a declaration. In the former case, if you 16 | ;; keep the comment free of CSS syntax it should be able to manage 17 | ;; reasonably well. This may be fixed someday. 18 | 19 | ;;; Code: 20 | 21 | (require 'css-mode) 22 | (require 'skewer-mode) 23 | 24 | (defun skewer-css-trim (string) 25 | "Trim and compress whitespace in the string." 26 | (let ((cleaned (replace-regexp-in-string "[\t\n ]+" " " string))) 27 | (replace-regexp-in-string "^[\t\n ]+\\|[\t\n ]+$" "" cleaned))) 28 | 29 | ;; Parsing 30 | 31 | (defun skewer-css-beginning-of-rule () 32 | "Move to the beginning of the current rule and return point." 33 | (skewer-css-end-of-rule) 34 | (let ((end (re-search-backward "{"))) 35 | (when (re-search-backward "[}/]" nil 'start) 36 | (forward-char)) 37 | (re-search-forward "[^ \t\n]") 38 | (backward-char) 39 | (point))) 40 | 41 | (defun skewer-css-end-of-rule () 42 | "Move to the end of the current rule and return point." 43 | (if (eql (char-before) ?}) 44 | (point) 45 | (re-search-forward "}"))) 46 | 47 | (defun skewer-css-end-of-declaration () 48 | "Move to the end of the current declaration and return point." 49 | (if (eql (char-before) ?\;) 50 | (point) 51 | (re-search-forward ";"))) 52 | 53 | (defun skewer-css-beginning-of-declaration () 54 | "Move to the end of the current declaration and return point." 55 | (skewer-css-end-of-declaration) 56 | (re-search-backward ":") 57 | (css-backward-sexp 1) 58 | (point)) 59 | 60 | (defun skewer-css-selectors () 61 | "Return the selectors for the current rule." 62 | (save-excursion 63 | (let ((start (skewer-css-beginning-of-rule)) 64 | (end (1- (re-search-forward "{")))) 65 | (skewer-css-trim 66 | (buffer-substring-no-properties start end))))) 67 | 68 | (defun skewer-css-declaration () 69 | "Return the current declaration as a pair of strings." 70 | (save-excursion 71 | (let ((start (skewer-css-beginning-of-declaration)) 72 | (end (skewer-css-end-of-declaration))) 73 | (let* ((clip (buffer-substring-no-properties start end)) 74 | (pair (split-string clip ":"))) 75 | (mapcar #'skewer-css-trim pair))))) 76 | 77 | ;; Evaluation 78 | 79 | (defun skewer-css (rule) 80 | "Add RULE as a new stylesheet." 81 | (skewer-eval rule nil :type "css")) 82 | 83 | (defun skewer-css-eval-current-declaration () 84 | "Evaluate the declaration at the point." 85 | (interactive) 86 | (save-excursion 87 | (let ((selectors (skewer-css-selectors)) 88 | (rule (skewer-css-declaration)) 89 | (start (skewer-css-beginning-of-declaration)) 90 | (end (skewer-css-end-of-declaration))) 91 | (skewer-flash-region start end) 92 | (skewer-css (apply #'format "%s { %s: %s }" selectors rule))))) 93 | 94 | (defun skewer-css-eval-current-rule () 95 | "Evaluate the rule at the point." 96 | (interactive) 97 | (save-excursion 98 | (let* ((start (skewer-css-beginning-of-rule)) 99 | (end (skewer-css-end-of-rule)) 100 | (rule (buffer-substring-no-properties start end))) 101 | (skewer-flash-region start end) 102 | (skewer-css (skewer-css-trim rule))))) 103 | 104 | (defun skewer-css-eval-buffer () 105 | "Send the entire current buffer as a new stylesheet." 106 | (interactive) 107 | (skewer-css (buffer-substring-no-properties (point-min) (point-max)))) 108 | 109 | ;; Minor mode definition 110 | 111 | (defvar skewer-css-mode-map 112 | (let ((map (make-sparse-keymap))) 113 | (prog1 map 114 | (define-key map (kbd "C-x C-e") 'skewer-css-eval-current-declaration) 115 | (define-key map (kbd "C-M-x") 'skewer-css-eval-current-rule) 116 | (define-key map (kbd "C-c C-k") 'skewer-css-eval-buffer))) 117 | "Keymap for skewer-css-mode.") 118 | 119 | ;;;###autoload 120 | (define-minor-mode skewer-css-mode 121 | "Minor mode for interactively loading new CSS rules." 122 | :lighter " skewer-css" 123 | :keymap skewer-css-mode-map 124 | :group 'skewer) 125 | 126 | ;;;###autoload 127 | (add-hook 'css-mode-hook 'skewer-css-mode) 128 | 129 | (provide 'skewer-css) 130 | 131 | ;;; skewer-css.el ends here 132 | -------------------------------------------------------------------------------- /site-lisp/skewer-mode/skewer-repl.el: -------------------------------------------------------------------------------- 1 | ;;; skewer-repl.el --- create a REPL in a visiting browser 2 | 3 | ;; This is free and unencumbered software released into the public domain. 4 | 5 | ;;; Commentary: 6 | 7 | ;; This is largely based on of IELM's code. Run `skewer-repl' to 8 | ;; switch to the REPL buffer and evaluate code. Use 9 | ;; `skewer-repl-toggle-strict-mode' to turn strict mode on and off. 10 | 11 | ;;; Code: 12 | 13 | (require 'comint) 14 | (require 'skewer-mode) 15 | 16 | (defcustom skewer-repl-strict-p nil 17 | "When non-NIL, all REPL evaluations are done in strict mode." 18 | :type 'boolean 19 | :group 'skewer) 20 | 21 | (defcustom skewer-repl-prompt "js> " 22 | "Prompt string for JavaScript REPL." 23 | :type 'string 24 | :group 'skewer) 25 | 26 | (defvar skewer-repl-welcome 27 | (propertize "*** Welcome to Skewer ***\n" 28 | 'font-lock-face 'font-lock-comment-face) 29 | "Header line to show at the top of the REPL buffer. Hack 30 | notice: this allows log messages to appear before anything is 31 | evaluated because it provides insertable space at the top of the 32 | buffer.") 33 | 34 | (defun skewer-repl-process () 35 | "Return the process for the skewer REPL." 36 | (get-buffer-process (current-buffer))) 37 | 38 | (defface skewer-repl-log-face 39 | '((((class color) (background light)) 40 | :foreground "#77F") 41 | (((class color) (background dark)) 42 | :foreground "#77F")) 43 | "Face for skewer.log() messages." 44 | :group 'skewer) 45 | 46 | (define-derived-mode skewer-repl-mode comint-mode "js-REPL" 47 | "Provide a REPL into the visiting browser." 48 | :group 'skewer 49 | :syntax-table emacs-lisp-mode-syntax-table 50 | (setq comint-prompt-regexp (concat "^" (regexp-quote skewer-repl-prompt))) 51 | (setq comint-input-sender 'skewer-input-sender) 52 | (unless (comint-check-proc (current-buffer)) 53 | (insert skewer-repl-welcome) 54 | (start-process "skewer-repl" (current-buffer) nil) 55 | (set-process-query-on-exit-flag (skewer-repl-process) nil) 56 | (goto-char (point-max)) 57 | (set (make-local-variable 'comint-inhibit-carriage-motion) t) 58 | (comint-output-filter (skewer-repl-process) skewer-repl-prompt) 59 | (set-process-filter (skewer-repl-process) 'comint-output-filter))) 60 | 61 | (defun skewer-repl-toggle-strict-mode () 62 | "Toggle strict mode for expressions evaluated by the REPL." 63 | (interactive) 64 | (setq skewer-repl-strict-p (not skewer-repl-strict-p)) 65 | (message "REPL strict mode %s" 66 | (if skewer-repl-strict-p "enabled" "disabled"))) 67 | 68 | (defun skewer-input-sender (proc input) 69 | "REPL comint handler." 70 | (skewer-eval input 'skewer-post-repl 71 | :verbose t :strict skewer-repl-strict-p)) 72 | 73 | (defun skewer-post-repl (result) 74 | "Callback for reporting results in the REPL." 75 | (let ((buffer (get-buffer "*skewer-repl*")) 76 | (output (cdr (assoc 'value result)))) 77 | (when buffer 78 | (with-current-buffer buffer 79 | (comint-output-filter (skewer-repl-process) 80 | (concat output "\n" skewer-repl-prompt)))))) 81 | 82 | (defvar skewer-repl-types 83 | '(("log" . skewer-repl-log-face) 84 | ("error" . skewer-error-face)) 85 | "Faces to use for different types of log messages.") 86 | 87 | (defun skewer-post-log (log) 88 | "Callback for logging messages to the REPL." 89 | (let* ((buffer (get-buffer "*skewer-repl*")) 90 | (face (cdr (assoc (cdr (assoc 'type log)) skewer-repl-types))) 91 | (output (propertize (cdr (assoc 'value log)) 'font-lock-face face))) 92 | (when buffer 93 | (with-current-buffer buffer 94 | (save-excursion 95 | (goto-char (point-max)) 96 | (forward-line 0) 97 | (backward-char) 98 | (insert (concat "\n" output ""))))))) 99 | 100 | ;;;###autoload 101 | (defun skewer-repl--response-hook (response) 102 | "Catches all browser messages logging some to the REPL." 103 | (let ((type (cdr (assoc 'type response)))) 104 | (when (member type '("log" "error")) 105 | (skewer-post-log response)))) 106 | 107 | ;;;###autoload 108 | (defun skewer-repl () 109 | "Start a JavaScript REPL to be evaluated in the visiting browser." 110 | (interactive) 111 | (when (not (get-buffer "*skewer-repl*")) 112 | (with-current-buffer (get-buffer-create "*skewer-repl*") 113 | (skewer-repl-mode))) 114 | (pop-to-buffer (get-buffer "*skewer-repl*"))) 115 | 116 | ;;;###autoload 117 | (eval-after-load 'skewer-mode 118 | '(progn 119 | (add-hook 'skewer-response-hook #'skewer-repl--response-hook) 120 | (define-key skewer-mode-map (kbd "C-c C-z") #'skewer-repl))) 121 | 122 | (provide 'skewer-repl) 123 | 124 | ;;; skewer-repl.el ends here 125 | -------------------------------------------------------------------------------- /site-lisp/skewer-mode/skewer-html.el: -------------------------------------------------------------------------------- 1 | ;;; skewer-html.el --- skewer support for live-interaction HTML 2 | 3 | ;; This is free and unencumbered software released into the public domain. 4 | 5 | ;;; Commentary: 6 | 7 | ;; This minor mode provides functionality for HTML like plain Skewer 8 | ;; does for JavaScript. There's no clean way to replace the body and 9 | ;; head elements of a live document, so "evaluating" these elements is 10 | ;; not supported. 11 | 12 | ;; * C-M-x -- `skewer-html-eval-tag' 13 | 14 | ;; See also `skewer-html-fetch-selector-into-buffer' for grabbing the 15 | ;; page as it current exists. 16 | 17 | ;;; Code: 18 | 19 | (require 'cl) 20 | (require 'sgml-mode) 21 | (require 'skewer-mode) 22 | 23 | ;; Selector computation 24 | 25 | (defun skewer-html--cleanup (name) 26 | "Cleanup tag names provided by sgml-mode." 27 | (replace-regexp-in-string "/$" "" name)) 28 | 29 | (defun skewer-html--tag-after-point () 30 | "Return the tag struct for the tag immediately following point." 31 | (save-excursion 32 | (forward-char 1) 33 | (sgml-parse-tag-backward))) 34 | 35 | (defun skewer-html-compute-tag-nth () 36 | "Compute the position of this tag within its parent." 37 | (save-excursion 38 | (let ((tag (car (last (sgml-get-context))))) 39 | (if (null tag) 40 | 1 41 | (loop with start = (sgml-tag-name tag) 42 | with stop = (save-excursion (sgml-get-context) (point)) 43 | with n = 1 44 | do (sgml-skip-tag-backward 1) 45 | while (> (point) stop) 46 | when (equal start (sgml-tag-name (skewer-html--tag-after-point))) 47 | do (incf n) 48 | finally (return n)))))) 49 | 50 | (defun skewer-html-compute-tag-ancestry () 51 | "Compute the ancestry chain at point." 52 | (save-excursion 53 | (nreverse 54 | (loop for nth = (skewer-html-compute-tag-nth) 55 | for tag = (car (last (sgml-get-context))) 56 | while tag 57 | for name = (skewer-html--cleanup (sgml-tag-name tag)) 58 | for type = (sgml-tag-type tag) 59 | when (not (or (string= name "html") 60 | (eq type 'close))) 61 | collect (list name nth))))) 62 | 63 | (defun skewer-html-compute-selector () 64 | "Compute the selector for exactly the tag around point." 65 | (let ((ancestry (skewer-html-compute-tag-ancestry))) 66 | (mapconcat (lambda (tag) 67 | (format "%s:nth-of-type(%d)" (first tag) (second tag))) 68 | ancestry " > "))) 69 | 70 | ;; Fetching 71 | 72 | (defun skewer-html-fetch-selector (selector) 73 | "Fetch the innerHTML of a selector." 74 | (let ((result (skewer-eval-synchronously selector :type "fetchselector"))) 75 | (if (skewer-success-p result) 76 | (cdr (assoc 'value result)) 77 | ""))) 78 | 79 | (defun skewer-html-fetch-selector-into-buffer (selector) 80 | "Fetch the innerHTML of a selector and insert it into the active buffer." 81 | (interactive "sSelector: ") 82 | (insert (skewer-html-fetch-selector selector))) 83 | 84 | ;; Evaluation 85 | 86 | (defun skewer-html-eval (string ancestry &optional append) 87 | "Load HTML into a selector, optionally appending." 88 | (let ((ancestry* (coerce ancestry 'vector))) ; for JSON 89 | (skewer-eval string nil :type "html" :extra `((ancestry . ,ancestry*) 90 | (append . ,append))))) 91 | 92 | (defun skewer-html-eval-tag () 93 | "Load HTML from the immediately surrounding tag." 94 | (interactive) 95 | (let ((ancestry (skewer-html-compute-tag-ancestry))) 96 | (save-excursion 97 | ;; Move to beginning of opening tag 98 | (loop for tag = (car (last (sgml-get-context))) 99 | while (and tag (eq 'close (sgml-tag-type tag)))) 100 | (let* ((beg (progn (point))) 101 | (end (progn (sgml-skip-tag-forward 1) (point))) 102 | (region (buffer-substring-no-properties beg end))) 103 | (skewer-flash-region beg end) 104 | (if (= (length ancestry) 1) 105 | (error "Error: cannot eval body and head tags.") 106 | (skewer-html-eval region ancestry nil)))))) 107 | 108 | ;; Minor mode definition 109 | 110 | (defvar skewer-html-mode-map 111 | (let ((map (make-sparse-keymap))) 112 | (prog1 map 113 | (define-key map (kbd "C-M-x") 'skewer-html-eval-tag))) 114 | "Keymap for skewer-html-mode") 115 | 116 | ;;;###autoload 117 | (define-minor-mode skewer-html-mode 118 | "Minor mode for interactively loading new HTML." 119 | :lighter " skewer-html" 120 | :keymap skewer-html-mode-map 121 | :group 'skewer) 122 | 123 | ;;;###autoload 124 | (add-hook 'html-mode-hook 'skewer-html-mode) 125 | 126 | (provide 'skewer-html) 127 | 128 | ;;; skewer-html.el ends here 129 | -------------------------------------------------------------------------------- /settings/setup-rgrep.el: -------------------------------------------------------------------------------- 1 | (require 'grep) 2 | (require 's) 3 | 4 | (defun rgrep-fullscreen (regexp &optional files dir confirm) 5 | "Open grep in full screen, saving windows." 6 | (interactive 7 | (progn 8 | (grep-compute-defaults) 9 | (cond 10 | ((and grep-find-command (equal current-prefix-arg '(16))) 11 | (list (read-from-minibuffer "Run: " grep-find-command 12 | nil nil 'grep-find-history))) 13 | ((not grep-find-template) 14 | (error "grep.el: No `grep-find-template' available")) 15 | (t (let* ((regexp (grep-read-regexp)) 16 | (files (grep-read-files regexp)) 17 | (dir (ido-read-directory-name "Base directory: " 18 | nil default-directory t)) 19 | (confirm (equal current-prefix-arg '(4)))) 20 | (list regexp files dir confirm)))))) 21 | (window-configuration-to-register ?$) 22 | (rgrep regexp files dir confirm) 23 | (switch-to-buffer "*grep*") 24 | (delete-other-windows) 25 | (goto-char (point-min))) 26 | 27 | (defun rgrep-quit-window () 28 | (interactive) 29 | (kill-buffer) 30 | (jump-to-register ?$)) 31 | 32 | (defun rgrep-goto-file-and-close-rgrep () 33 | (interactive) 34 | (compile-goto-error) 35 | (kill-buffer "*grep*") 36 | (delete-other-windows) 37 | (message "Type C-x r j $ to return to pre-rgrep windows.")) 38 | 39 | (defvar git-grep-switches "--extended-regexp -I -n" 40 | "Switches to pass to `git grep'.") 41 | 42 | (defun git-grep-fullscreen (regexp &optional files dir confirm) 43 | (interactive 44 | (let* ((regexp (grep-read-regexp)) 45 | (files (grep-read-files regexp)) 46 | (files (if (string= "* .*" files) "*" files)) 47 | (dir (ido-read-directory-name "Base directory: " 48 | nil default-directory t)) 49 | (confirm (equal current-prefix-arg '(4)))) 50 | (list regexp files dir confirm))) 51 | (let ((command (format "cd %s && git --no-pager grep %s %s -e %S -- '%s' " 52 | dir 53 | git-grep-switches 54 | (if (s-lowercase? regexp) " --ignore-case" "") 55 | regexp 56 | files)) 57 | (grep-use-null-device nil)) 58 | (when confirm 59 | (setq command (read-shell-command "Run git-grep: " command 'git-grep-history))) 60 | (window-configuration-to-register ?$) 61 | (grep command) 62 | (switch-to-buffer "*grep*") 63 | (delete-other-windows) 64 | (goto-char (point-min)))) 65 | 66 | (eval-after-load "grep" 67 | '(progn 68 | ;; Don't recurse into some directories 69 | (add-to-list 'grep-find-ignored-directories "target") 70 | (add-to-list 'grep-find-ignored-directories "node_modules") 71 | (add-to-list 'grep-find-ignored-directories "vendor") 72 | 73 | ;; Add custom keybindings 74 | (define-key grep-mode-map "q" 'rgrep-quit-window) 75 | (define-key grep-mode-map (kbd "C-") 'rgrep-goto-file-and-close-rgrep) 76 | (define-key grep-mode-map (kbd "C-x C-s") 'wgrep-save-all-buffers) 77 | 78 | ;; Use same keybinding as occur 79 | (setq wgrep-enable-key "e"))) 80 | 81 | ;; Command to add cursor to all matches in wgrep 82 | 83 | (require 'dash) 84 | 85 | (defvar grep-match-positions nil) 86 | (make-variable-buffer-local 'grep-match-positions) 87 | 88 | (defun grep-register-match-positions () 89 | (save-excursion 90 | (forward-line 0) 91 | (let ((end (point)) beg) 92 | (goto-char compilation-filter-start) 93 | (forward-line 0) 94 | (setq beg (point)) 95 | ;; Only operate on whole lines so we don't get caught with part of an 96 | ;; escape sequence in one chunk and the rest in another. 97 | (when (< (point) end) 98 | (setq end (copy-marker end)) 99 | ;; Register all positions of matches 100 | (while (re-search-forward "\033\\[0?1;31m\\(.*?\\)\033\\[[0-9]*m" end 1) 101 | (add-to-list 'grep-match-positions (set-marker (make-marker) (match-beginning 1)))))))) 102 | 103 | (eval-after-load "grep" 104 | '(defadvice grep-mode (after grep-register-match-positions activate) 105 | (add-hook 'compilation-filter-hook 'grep-register-match-positions nil t))) 106 | 107 | (defun mc/add-cursors-to-all-matches () 108 | (interactive) 109 | (--each grep-match-positions 110 | (unless (= 0 it-index) 111 | (mc/create-fake-cursor-at-point)) 112 | (goto-char it)) 113 | (mc/maybe-multiple-cursors-mode)) 114 | 115 | (eval-after-load "multiple-cursors" 116 | '(add-to-list 'mc--default-cmds-to-run-once 'mc/add-cursors-to-all-matches)) 117 | 118 | (eval-after-load "wgrep" 119 | '(define-key wgrep-mode-map (kbd "C-c C-æ") 'mc/add-cursors-to-all-matches)) 120 | 121 | (provide 'setup-rgrep) 122 | -------------------------------------------------------------------------------- /settings/sane-defaults.el: -------------------------------------------------------------------------------- 1 | ;; Allow pasting selection outside of Emacs 2 | (setq x-select-enable-clipboard t) 3 | 4 | ;; Auto refresh buffers 5 | (global-auto-revert-mode 1) 6 | 7 | ;; Also auto refresh dired, but be quiet about it 8 | (setq global-auto-revert-non-file-buffers t) 9 | (setq auto-revert-verbose nil) 10 | 11 | ;; Show keystrokes in progress 12 | (setq echo-keystrokes 0.1) 13 | 14 | ;; Move files to trash when deleting 15 | (setq delete-by-moving-to-trash t) 16 | 17 | ;; Real emacs knights don't use shift to mark things 18 | (setq shift-select-mode nil) 19 | 20 | ;; Transparently open compressed files 21 | (auto-compression-mode t) 22 | 23 | ;; Enable syntax highlighting for older Emacsen that have it off 24 | (global-font-lock-mode t) 25 | 26 | ;; Answering just 'y' or 'n' will do 27 | (defalias 'yes-or-no-p 'y-or-n-p) 28 | 29 | ;; UTF-8 please 30 | (setq locale-coding-system 'utf-8) ; pretty 31 | (set-terminal-coding-system 'utf-8) ; pretty 32 | (set-keyboard-coding-system 'utf-8) ; pretty 33 | (set-selection-coding-system 'utf-8) ; please 34 | (prefer-coding-system 'utf-8) ; with sugar on top 35 | 36 | ;; Show active region 37 | (transient-mark-mode 1) 38 | (make-variable-buffer-local 'transient-mark-mode) 39 | (put 'transient-mark-mode 'permanent-local t) 40 | (setq-default transient-mark-mode t) 41 | 42 | ;; Remove text in active region if inserting text 43 | (delete-selection-mode 1) 44 | 45 | ;; Don't highlight matches with jump-char - it's distracting 46 | (setq jump-char-lazy-highlight-face nil) 47 | 48 | ;; Always display line and column numbers 49 | (setq line-number-mode t) 50 | (setq column-number-mode t) 51 | 52 | ;; Lines should be 80 characters wide, not 72 53 | (setq fill-column 80) 54 | 55 | ;; Save a list of recent files visited. (open recent file with C-x f) 56 | (recentf-mode 1) 57 | (setq recentf-max-saved-items 100) ;; just 20 is too recent 58 | 59 | ;; Save minibuffer history 60 | (savehist-mode 1) 61 | (setq history-length 1000) 62 | 63 | ;; Undo/redo window configuration with C-c / 64 | (winner-mode 1) 65 | 66 | ;; Never insert tabs 67 | (set-default 'indent-tabs-mode nil) 68 | 69 | ;; Show me empty lines after buffer end 70 | (set-default 'indicate-empty-lines t) 71 | 72 | ;; Easily navigate sillycased words 73 | (global-subword-mode 1) 74 | 75 | ;; Don't break lines for me, please 76 | (setq-default truncate-lines t) 77 | 78 | ;; Keep cursor away from edges when scrolling up/down 79 | (require 'smooth-scrolling) 80 | 81 | ;; Allow recursive minibuffers 82 | (setq enable-recursive-minibuffers t) 83 | 84 | ;; Don't be so stingy on the memory, we have lots now. It's the distant future. 85 | (setq gc-cons-threshold 20000000) 86 | 87 | ;; org-mode: Don't ruin S-arrow to switch windows please (use M-+ and M-- instead to toggle) 88 | (setq org-replace-disputed-keys t) 89 | 90 | ;; Fontify org-mode code blocks 91 | (setq org-src-fontify-natively t) 92 | 93 | ;; Represent undo-history as an actual tree (visualize with C-x u) 94 | (setq undo-tree-mode-lighter "") 95 | (require 'undo-tree) 96 | (global-undo-tree-mode) 97 | 98 | ;; Sentences do not need double spaces to end. Period. 99 | (set-default 'sentence-end-double-space nil) 100 | 101 | ;; 80 chars is a good width. 102 | (set-default 'fill-column 80) 103 | 104 | ;; Add parts of each file's directory to the buffer name if not unique 105 | (require 'uniquify) 106 | (setq uniquify-buffer-name-style 'forward) 107 | 108 | ;; A saner ediff 109 | (setq ediff-diff-options "-w") 110 | (setq ediff-split-window-function 'split-window-horizontally) 111 | (setq ediff-window-setup-function 'ediff-setup-windows-plain) 112 | 113 | ;; No electric indent 114 | (setq electric-indent-mode nil) 115 | 116 | ;; Nic says eval-expression-print-level needs to be set to nil (turned off) so 117 | ;; that you can always see what's happening. Nic is wrong. 118 | (setq eval-expression-print-level 100) 119 | 120 | ;; When popping the mark, continue popping until the cursor actually moves 121 | ;; Also, if the last command was a copy - skip past all the expand-region cruft. 122 | (defadvice pop-to-mark-command (around ensure-new-position activate) 123 | (let ((p (point))) 124 | (when (eq last-command 'save-region-or-current-line) 125 | ad-do-it 126 | ad-do-it 127 | ad-do-it) 128 | (dotimes (i 10) 129 | (when (= p (point)) ad-do-it)))) 130 | 131 | (setq set-mark-command-repeat-pop t) 132 | 133 | ;; Offer to create parent directories if they do not exist 134 | ;; http://iqbalansari.github.io/blog/2014/12/07/automatically-create-parent-directories-on-visiting-a-new-file-in-emacs/ 135 | (defun my-create-non-existent-directory () 136 | (let ((parent-directory (file-name-directory buffer-file-name))) 137 | (when (and (not (file-exists-p parent-directory)) 138 | (y-or-n-p (format "Directory `%s' does not exist! Create it?" parent-directory))) 139 | (make-directory parent-directory t)))) 140 | 141 | (add-to-list 'find-file-not-found-functions 'my-create-non-existent-directory) 142 | 143 | (provide 'sane-defaults) 144 | -------------------------------------------------------------------------------- /site-lisp/eproject/contrib/eproject-tags.el: -------------------------------------------------------------------------------- 1 | ;;; eproject-tags.el --- visit project-specific tags table and keep it up to date 2 | 3 | ;; Copyright (C) 2011 Jonathan Rockway 4 | 5 | ;; Author: Jonathan Rockway 6 | ;; Keywords: convenience, programming, tags 7 | 8 | ;; This program is free software; you can redistribute it and/or modify 9 | ;; it under the terms of the GNU General Public License as published by 10 | ;; the Free Software Foundation, either version 3 of the License, or 11 | ;; (at your option) any later version. 12 | 13 | ;; This program is distributed in the hope that it will be useful, 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ;; GNU General Public License for more details. 17 | 18 | ;; You should have received a copy of the GNU General Public License 19 | ;; along with this program. If not, see . 20 | 21 | ;;; Commentary: 22 | 23 | ;; 24 | 25 | ;;; Code: 26 | 27 | (eval-when-compile 28 | (require 'cl)) 29 | (require 'eproject) 30 | 31 | (defvar eproject-tags-etags "etags" 32 | "The command you want to run to generate the tags file. 33 | 34 | It must accept a list of relative filenames and send its output 35 | to a file named TAGS.") 36 | 37 | (defvar eproject-tags-verbose t 38 | "Set to T if you want the verbose output of etags to stick around. 39 | 40 | Only works with exuberant-ctags; this will cause standard etags to blow up in a giant ball of fire.") 41 | 42 | (defvar eproject-tags-callback nil) 43 | (defvar eproject-tags-state nil) 44 | (make-variable-buffer-local 'eproject-tags-callback) 45 | (make-variable-buffer-local 'eproject-tags-state) 46 | 47 | (defun eproject-tags--buffer (root) 48 | (let* ((name (concat (eproject-attribute :name root) "-TAGS")) 49 | (buf (get-buffer-create (format "*%s*" name)))) 50 | buf)) 51 | 52 | (defun eproject-tags--debug-message (root format &rest rest) 53 | (when eproject-tags-verbose 54 | (with-current-buffer (eproject-tags--buffer root) 55 | (goto-char (point-max)) 56 | (insert (apply #'format (concat "** " format) rest)) 57 | (insert "\n")))) 58 | 59 | (defun eproject-tags--generate (cb &optional state root) 60 | "Generate a tags table for this project (or the project in ROOT), calling CB with the project root and STATE upon completion. 61 | 62 | All project-relevant files are considered and output goes to root/TAGS. The tags table is not visited after generation." 63 | (let* ((root (or root (eproject-root))) 64 | (default-directory root) 65 | (files (eproject-list-project-files-relative root)) 66 | (name (concat (eproject-attribute :name root) "-TAGS")) 67 | (buf (eproject-tags--buffer root)) 68 | (args (append '("-o" ".TAGS-tmp") 69 | (if eproject-tags-verbose '("--verbose")))) 70 | (proc (apply #'start-process name buf eproject-tags-etags 71 | (append args files)))) 72 | 73 | (with-current-buffer buf 74 | (setq eproject-tags-callback cb) 75 | (setq eproject-tags-state state) 76 | (setq eproject-root root)) 77 | 78 | (set-process-sentinel proc #'eproject-tags--sentinel)) 79 | nil) 80 | 81 | (defun eproject-tags--sentinel (process event) 82 | (with-current-buffer (process-buffer process) 83 | (let ((default-directory eproject-root)) 84 | (when (and eproject-tags-callback (equal event "finished\n")) 85 | (rename-file ".TAGS-tmp" "TAGS" t) 86 | (apply eproject-tags-callback eproject-tags-state) 87 | (delete-process process) 88 | (when (not eproject-tags-verbose) 89 | (kill-buffer)))))) 90 | 91 | ;;; TODO: un-visit this table when all project buffers go away? 92 | ;;; TODO: make the tags table "project-local" 93 | 94 | (defun eproject-tags (&optional root) 95 | "Update (or generate) and visit a tags table for the project in ROOT." 96 | (interactive) 97 | (let ((root (or root (eproject-root)))) 98 | (eproject-tags--generate 99 | #'eproject-tags--visit-table (list root) root))) 100 | 101 | (defun eproject-tags--visit-table (root &rest state) 102 | "Callback called by eproject-tags after tags table has been created." 103 | (let ((table (concat (file-name-as-directory root) "TAGS")) 104 | (tags-revert-without-query t)) 105 | (add-to-list 'tags-table-list table t #'equal) 106 | (tags-verify-table table))) 107 | 108 | (defun eproject-tags--from-hook () 109 | (let ((root (ignore-errors (eproject-root))) 110 | (file (ignore-errors (buffer-file-name)))) 111 | (when (and root file 112 | (eproject-classify-file file root) 113 | (not (eproject-attribute :suppress-tags root))) 114 | (eproject-tags--debug-message 115 | root "Regenerating tags table for %s because %s changed" root file) 116 | (eproject-tags root)))) 117 | 118 | (add-hook 'eproject-first-buffer-hook #'eproject-tags--from-hook) 119 | (add-hook 'eproject-project-change-hook #'eproject-tags--from-hook) 120 | 121 | (provide 'eproject-tags) 122 | ;;; eproject-tags.el ends here 123 | -------------------------------------------------------------------------------- /users/christian/mu3e.el: -------------------------------------------------------------------------------- 1 | (setq mu4e-drafts-folder "/cjohansen/drafts") 2 | (setq user-mail-address "christian@cjohansen.no") 3 | 4 | ;; Shortcuts 5 | (setq mu4e-maildir-shortcuts 6 | '(("/cjohansen/inbox" . ?c) 7 | ("/gitorious/inbox" . ?g) 8 | ("/gmail/inbox" . ?G) 9 | ("/shortcut/inbox" . ?s))) 10 | 11 | ;; sending mail 12 | (setq message-send-mail-function 'message-send-mail-with-sendmail 13 | sendmail-program "/usr/bin/msmtp" 14 | user-full-name "Christian Johansen") 15 | 16 | ;; Borrowed from http://ionrock.org/emacs-email-and-mu.html 17 | ;; Choose account label to feed msmtp -a option based on From header 18 | ;; in Message buffer; This function must be added to 19 | ;; message-send-mail-hook for on-the-fly change of From address before 20 | ;; sending message since message-send-mail-hook is processed right 21 | ;; before sending message. 22 | (defun choose-msmtp-account () 23 | (if (message-mail-p) 24 | (save-excursion 25 | (let* 26 | ((from (or (save-restriction 27 | (message-narrow-to-headers) 28 | (message-fetch-field "from")) "")) 29 | (cc (or (save-restriction 30 | (message-narrow-to-headers) 31 | (message-fetch-field "cc")) "")) 32 | (account 33 | (cond 34 | ((or (string-match "christian@shortcut.no" from) 35 | (string-match "christian@shortcut.no" cc)) "shortcut") 36 | ((or (string-match "christian@gitorious.com" from) 37 | (string-match "christian@gitorious.com" cc) 38 | (string-match "christian@gitorious.org" from) 39 | (string-match "christian@gitorious.org" cc) 40 | (string-match "team@gitorious.com" from) 41 | (string-match "team@gitorious.com" cc)) "gitorious") 42 | (t "cjohansen")))) 43 | (setq message-sendmail-extra-arguments (list '"-a" account)))))) 44 | (setq message-sendmail-envelope-from 'header) 45 | (add-hook 'message-send-mail-hook 'choose-msmtp-account) 46 | 47 | ;; Bookmarks 48 | (add-to-list 'mu4e-bookmarks 49 | '("maildir:/gitorious/inbox OR maildir:/shortcut/inbox OR maildir:/gmail/inbox OR maildir:/cjohansen/inbox" "Inbox" ?z)) 50 | 51 | ;; Dynamic sender addresses 52 | (add-hook 'mu4e-compose-pre-hook 53 | (defun my-set-from-address () 54 | "Set the From address based on the To address of the original." 55 | (let ((msg mu4e-compose-parent-message)) ;; msg is shorter... 56 | (if msg 57 | (setq user-mail-address 58 | (cond 59 | ((mu4e-message-contact-field-matches msg :to "@gitorious") 60 | "christian@gitorious.com") 61 | ((mu4e-message-contact-field-matches msg :to "christian@shortcut.no") 62 | "christian@shortcut.no") 63 | ((mu4e-message-contact-field-matches msg :to "christian@cjohansen.no") 64 | "christian@cjohansen.no") 65 | ((mu4e-message-contact-field-matches msg :to "chris@execration.no") 66 | "christian@cjohansen.no") 67 | ((mu4e-message-contact-field-matches msg :cc "@gitorious") 68 | "christian@gitorious.com") 69 | ((mu4e-message-contact-field-matches msg :cc "christian@shortcut.no") 70 | "christian@shortcut.no") 71 | ((mu4e-message-contact-field-matches msg :cc "christian@cjohansen.no") 72 | "christian@cjohansen.no") 73 | ((mu4e-message-contact-field-matches msg :cc "chris@execration.no") 74 | "christian@cjohansen.no") 75 | ((mu4e-message-contact-field-matches msg :cc "chrisjoha@gmail.com") 76 | "christian@cjohansen.no") 77 | (t "christian@cjohansen.no"))))))) 78 | 79 | ;; Smart refile locations 80 | (setq mu4e-refile-folder 81 | (lambda (msg) 82 | (cond 83 | ;; messages sent directly to me go to /archive 84 | ;; also `mu4e-user-mail-address-regexp' can be used 85 | ((mu4e-message-contact-field-matches msg :to "gitorious@googlegroups.com") 86 | "/gitorious/mailinglist") 87 | ((mu4e-message-contact-field-matches msg :to "@gitorious") 88 | "/gitorious/archive") 89 | ((mu4e-message-contact-field-matches msg :to "@cjohansen.no") 90 | "/cjohansen/archive") 91 | ((mu4e-message-contact-field-matches msg :to "chrisjoha@gmail.com") 92 | "/gmail/archive") 93 | ((mu4e-message-contact-field-matches msg :to "christian@shortcut.no") 94 | "/shortcut/archive") 95 | ;; everything else goes to /archive 96 | ;; important to have a catch-all at the end! 97 | (t "/cjohansen/archive")))) 98 | 99 | (setq mu4e-user-mail-address-list 100 | (list "christian@cjohansen.no" "christian@gitorious.com" "christian@shortcut.no")) 101 | --------------------------------------------------------------------------------