Skip to content

Instantly share code, notes, and snippets.

@yaotti
Created December 21, 2008 01:52
Show Gist options
  • Save yaotti/38477 to your computer and use it in GitHub Desktop.
Save yaotti/38477 to your computer and use it in GitHub Desktop.
(require 'outputz)
;; scheme (gauche) !!
(add-to-list 'outputz-modes 'scheme-mode)
(add-to-list 'outputz-modes 'gauche-mode)
(add-to-list 'outputz-modes 'clmemo-mode)
(add-to-list 'outputz-modes 'change-log-mode)
(setq outputz-uri "http://yaotti.net/outputz/%s")
(global-outputz-mode t)
;; outputz
(defun outputz-percent-encode (str &optional coding-system)
(if (or (null coding-system)
(not (coding-system-p coding-system)))
(setq coding-system 'utf-8))
(mapconcat
(lambda (c)
(cond
((outputz-url-reserved-p c)
(char-to-string c))
((eq c ? ) "+")
(t (format "%%%x" c))))
(encode-coding-string str coding-system)
""))
(defun outputz-url-reserved-p (ch)
(or (and (<= ?A ch) (<= ch ?z))
(and (<= ?0 ch) (<= ch ?9))
(eq ?. ch)
(eq ?- ch)
(eq ?_ ch)
(eq ?~ ch)))
(defadvice outputz (before outputz-setup-uri)
(setq outputz-uri
(outputz-percent-encode
(format "http://%s.com/%s.%s"
(replace-regexp-in-string "\+" "p" (symbol-name major-mode))
(user-login-name)
(system-name)))))
(ad-activate-regexp "outputz-setup-uri")
;; ファイル保存時ではなくEmacs終了時にrequest
;; http://dotfiles.org/~jbromley/.emacs
(remove-hook 'after-save-hook 'outputz)
(add-hook 'kill-buffer-hook 'outputz)
(defvar my-before-kill-emacs-hook nil
"Hook to run before `save-buffers-kill-emacs'.")
(defun outputz-buffers-data ()
;; networkに繋っていない時は何もしない
(dolist (buf (buffer-list))
(with-current-buffer buf
(outputz)
)))
(add-hook 'my-before-kill-emacs-hook 'outputz-buffers-data)
(defadvice save-buffers-kill-emacs (around before-kill-hook activate)
(run-hooks 'my-before-kill-emacs-hook)
(sit-for 5)
ad-do-it
)
(provide 'outputz-init)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment