Skip to content

Instantly share code, notes, and snippets.

@miyamuko
miyamuko / gist:520222
Created August 12, 2010 02:59
find-file で環境変数込みのパスを開けるようにする #xyzzy
;; find-file で環境変数込みのパスを開けるようにする
;; (find-file "%SystemRoot%/system32/drivers/etc/hosts")
(defun find-file-expand-env-hook (filename)
(when (and filename
(not (file-exist-p filename)))
(let ((replaced nil))
(while (string-matchp "%\\([a-z]+\\)%" filename)
(setf filename (substitute-string filename (match-string 0)
(map-backslash-to-slash (si:getenv (match-string 1))))
replaced t))
@miyamuko
miyamuko / gist:520353
Created August 12, 2010 05:10
package に対応した apropos #xyzzy
;; 全パッケージから apropos
(defun apropos-all (string)
(interactive "sApropos(Regexp): ")
(with-output-to-temp-buffer ("*Help2*")
;; undo はできるようにする
(setq kept-undo-information (default-value 'kept-undo-information))
(lisp-interaction-mode)
(save-excursion
(dolist (pkg (reverse (list-all-packages)))
(dolist (line (apropos-filter string pkg))
@miyamuko
miyamuko / gist:520355
Created August 12, 2010 05:13
package に対応したタグジャンプ #xyzzy
;; package に対応したタグジャンプ
;; 標準のだと (ed::find-file-internal) などでタグジャンプしても飛べない
(defun lisp-tags-find-target-with-package ()
(multiple-value-bind (class name functionp)
(ed::lisp-tags-find-target)
(values class (substitute-string name "^[a-z]+::?" "") functionp)))
(defun install-lisp-tags-find-target-with-package ()
(setf tags-find-target #'lisp-tags-find-target-with-package))
@miyamuko
miyamuko / gist:520457
Created August 12, 2010 06:25
クリップボードの中身を eval #xyzzy
;; クリップボードの中身を eval
(defun eval-clipboard ()
(interactive)
(let ((buf (get-buffer-create "*Clipboard*")))
(set-buffer buf)
(erase-buffer buf)
(setup-temp-buffer buf)
(insert (get-clipboard-data))
(handler-case
(progn
@miyamuko
miyamuko / gist:520555
Created August 12, 2010 08:18
ソースコードで利用している特定のパッケージのシンボルの一覧を表示する。 #xyzzy
;; ソースコードで利用している特定のパッケージのシンボルの一覧を表示する。
;;
;; 例)
;; xl-github が利用している editor パッケージの何かの一覧を表示
;; (show-inherited-symbols-dir "site-lisp/github" :editor)
(defun show-inherited-symbols-file (file inherited-from)
(interactive "fFile: \nSPackage: ")
@miyamuko
miyamuko / gist:520799
Created August 12, 2010 11:30
xyzzy の loop マクロの while の評価順がおかしい
;; xyzzy 0.2.2.235
(require "cmu_loop")
(loop
for i from 0 to 2
while (progn
(format t "while ~A~%" i)
t)
do (format t "do ~A~%" i))
do 0
while 1
@miyamuko
miyamuko / gist:522772
Created August 13, 2010 12:23
異なるパッケージで関数やマクロを上書きしたら *Trace Output* に警告を出す。 #xyzzy
;; 異なるパッケージで関数やマクロを上書きしたら *Trace Output* に警告を出す
;; #xyzzy
(defmacro with-package-lock (handler &body body)
`(let ((si-fset #'si:*fset))
(funcall si-fset 'si:*fset
#'(lambda (symbol function)
(when (and (fboundp symbol)
(not (eql (symbol-package symbol) *package*)))
(,handler "~A::~A redefined with ~A::~A."
@miyamuko
miyamuko / gist:528722
Created August 17, 2010 06:45
xyzzy ではてな ID や Twitter のユーザ名をクリックできるようにする clickable-uri の設定
;; xyzzy ではてな ID や Twitter のユーザ名をクリックできるようにする clickable-uri の設定
;;
;; * clickable-uri
;; http://ohkubo.s53.xrea.com/xyzzy/index.html#clickable-uri
;;
;; * clickable-uriを導入しよう
;; http://xyzzy.s53.xrea.com/wiki/index.php?QuickTour/ext/clickable-uri#t8450eec
(defun clickable-uri-add-special (prefix id uri-format)
(let ((id-regexp (format nil "~A~A" prefix id))
@miyamuko
miyamuko / gist:536552
Created August 18, 2010 23:41
カーソル情報を取得する #xyzzy
(in-package :winapi)
;; http://msdn.microsoft.com/en-us/library/ms648381(VS.85).aspx
;; packing-align を調整しないと size-of CURSORINFO が 24 になる
(let ((c:*c-structure-packing-align* 4))
(c:*define-c-struct CURSORINFO
(DWORD size)
(DWORD flags)
(HANDLE handle)
(POINT pos)))
@miyamuko
miyamuko / gist:537169
Created August 19, 2010 06:03
クリップボードエンコーディングを自動判別 #xyzzy
;; クリップボードエンコーディングを自動判別 #xyzzy
;; get-clipboard-data を上書きしているのでちょっとキケン
(defvar *get-clipboard-data* #'get-clipboard-data)
(defun get-clipboard-data ()
(let ((*clipboard-char-encoding* *encoding-sjis*))
(declare (special *clipboard-char-encoding*))
(let* ((str (funcall *get-clipboard-data*))
(enc (detect-char-encoding str)))