Skip to content

Instantly share code, notes, and snippets.

;; js2-mode
(autoload 'js2-mode "js2" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
(add-hook 'js2-mode-hook
'(lambda ()
(setq js2-cleanup-whitespace nil
js2-mirror-mode nil
js2-bounce-indent-flag nil)
;; js2-mode
(when (load "js2")
(setq js2-cleanup-whitespace nil
js2-mirror-mode nil
js2-bounce-indent-flag nil)
(defun indent-and-back-to-indentation ()
(interactive)
(indent-for-tab-command)
(let ((point-of-indentation
def String.random(size, option={})
option = {
:capital => false,
:exclude => []
}.merge(option)
alphanumerics = ('a'..'z').to_a + ('0'..'9').to_a
alphanumerics += ('A'..'Z').to_a if option[:capital]
alphanumerics -= option[:exclude].to_a
(defadvice find-file
(before find-file-create-intermediate-directories (filename &optional wildcards))
"中間ディレクトリが存在しない時は作成する"
(let ((dir (file-name-directory filename)))
(if (and dir
(not (file-exists-p dir)))
(make-directory dir t))))
(defvar killed-buffers '())
(defun add-killed-buffer-list ()
(let ((b (buffer-file-name)))
(unless (null b)
(add-to-list 'killed-buffers b))))
(add-hook 'kill-buffer-hook 'add-killed-buffer-list)
(defun rebirth-of-buffer ()
(interactive)
(defadvice delete-backward-char
(around stop-when-beginning-of-line (n &optional killflag) activate)
"前の行まで削除しない"
(unless (equal (point) (point-at-bol))
ad-do-it))
(defadvice delete-char
(around stop-when-end-of-line (n &optional killflag) activate)
"次の行まで削除しない"
(unless (equal (point) (point-at-eol))
;; cucumber
;; http://github.com/michaelklishin/cucumber.el
;; 日本語でも色つける
(require 'feature-mode)
(defconst feature-mode-ja-keywords
'("フィーチャ" "機能" "背景" "シナリオ" "シナリオアウトライン"
"シナリオテンプレート" "テンプレ" "シナリオテンプレ"
"例" "サンプル" "前提" "もし" "ならば" "かつ" "しかし" "但し" "ただし"))
(defconst feature-font-lock-ja-keywords
;; (require 'zencoding-builder)
;; (define-key zencoding-mode-keymap (kbd "M-RET") 'zencoding-builder)
(defvar zencoding-builder-start-point nil)
(make-variable-buffer-local 'zencoding-builder-start-point)
(defvar zencoding-builder-end-point nil)
(make-variable-buffer-local 'zencoding-builder-end-point)
(defvar zencoding-builder-window nil)
<html>
<head>
<title>Writing HTML with S-expression</title>
</head>
<body>
(div :id "main"
(h1 "Stag")
(ul :class "navi"
(li (a :href "/menu1" "menu 1"))
(li (a :href "/menu2" "menu 2"))
<html>
<head>
<title>Writing HTML with S-expression</title>
</head>
<body>
<div id="main">
<h1>Stag</h1>
<ul class="navi">
<li>
<a href="/menu1">menu 1</a>