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 |
--------------------------------------------------------------------------------