link *

memo *

.xyzzy *

設定例を公開なさっている皆様に感謝

;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; personal preference ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; misc
(cd "~/")
(load-library "isearch") ;; incremental search
(pushnew '("\\.xyzzy$" . lisp-mode) *auto-mode-alist* :test 'equal)

;;; key
(global-set-key '(#\C-x #\C-y) 'paste-from-clipboard)
(global-set-key #\M-% 'replace-string)
(global-set-key '(#\C-x #\u) 'undo)
(global-set-key '(#\C-x #\C-j) 'toggle-ime) ; SKK
(global-set-key '(#\C-x #\r #\d) 'delete-rectangle)
(global-set-key '(#\C-x #\r #\k) 'kill-rectangle)
(global-set-key '(#\C-x #\r #\o) 'open-rectangle)
(global-set-key '(#\C-x #\r #\t) 'string-rectangle)
(global-set-key '(#\C-x #\r #\y) 'yank-rectangle)
(global-set-key '(#\C-x #\r #\w) 'copy-rectangle)


;;; original "view mode"
; thanks to http://www.tsg.ne.jp/GANA/D/diary/2002-05.html 2002年05月09日 (木) JST
(require 'viewmode)
(define-key filer-keymap #\V 'hi-filer-view)
(define-key ed::*view-mode-map* #\Left 'previous-page)
(define-key ed::*view-mode-map* #\Right 'next-page)
(define-key ed::*view-mode-map* #\C-b 'previous-page)
(define-key ed::*view-mode-map* #\C-f 'next-page)
(define-key ed::*view-mode-map* #\SPC 'next-page)

(define-key ed::*view-mode-map* #\RET 'hi-kill-filer-view)
(define-key ed::*view-mode-map* #\E 'hi-view-mode-to-edit)

(defun hi-kill-filer-view ()
  (interactive)
  (delete-buffer (selected-buffer))
  (open-filer)
)

(defun hi-filer-view ()
  (find-file (filer-get-current-file))
  (view-mode)
  (si:*activate-toplevel)
)

(defun hi-view-mode-to-edit ()
  (interactive)
  (setq buffer-read-only nil)
  (setq fname (get-buffer-file-name))
  (delete-buffer (selected-buffer))
  (find-file fname)
  )



;;;;;;;;;;;;;
;;; KaTeX ;;;
;;;;;;;;;;;;;

(push "c:/programs/xyzzy/site-lisp/katex" *load-path*)
(require "elisp")
(push '("\\.tex$" . elisp::katex-mode) *auto-mode-alist*)
(autoload 'elisp::katex-mode "katex" t)


;;;;;;;;;;;;;;;;;;;;;;
;;; iswitchbもどき ;;;
;;;;;;;;;;;;;;;;;;;;;;
;;; http://xyzzy.s53.xrea.com/wiki/?tips%2Fiswitchb%A4%E2%A4%C9%A4%AD
(global-set-key '(#\C-x #\b) 'iswitchb)
(defun iswitchb-list-grep (list input)
 "listを input によって絞り込み"  ; 空白区切りは & とみなす
 (remove-if
  #'(lambda (x)
	   (dolist (s (split-string input " "))
		 (if (not (string-matchp (regexp-quote s) x))
			 (return t))))
  list))
 
(defun iswitchb-buffer-list-init ()
 "iswitchb で選択するバッファ名リストの取り出し(初期値)"
 (remove-if
  #'(lambda (x) (string-match "^ " x)) ; ミニバッファ以外
  (mapcar #'buffer-name
		   (buffer-list :buffer-bar-order *next-buffer-in-tab-order*))))

(defun iswitchb-buffer-list-init-rotate (list name)
 "list を name が先頭に来るまで回転"
 (when (position name list :test 'string=)
	(while (< 0 (position name list :test 'string=))
	  (setq list (append (cdr list) (list (car list))))))
 list)

(defun iswitchb ()
 "バッファの切り替え"
 (interactive)
 (let ((buffer-list
		 (iswitchb-buffer-list-init-rotate
		  (iswitchb-buffer-list-init)
		  (buffer-name (other-buffer))))
		(input "")
		(pre-buffer (selected-buffer))
		(top-buffer (buffer-name (selected-buffer)))
		(buffer-list-grepd)
		(c))
	(loop  ; iswitchb-mode ...
	  (setq buffer-list-grepd (iswitchb-list-grep buffer-list input))
	  (message "~S" buffer-list-grepd)
	  (when (< 0 (length buffer-list-grepd))
		(when (string/= top-buffer (car buffer-list-grepd))
		  (setq top-buffer (car buffer-list-grepd))
		  (switch-to-buffer top-buffer)))
	  (ed:minibuffer-prompt "iswitchb: ~A" input)
	  (setq c (read-char ed:*keyboard*))
	  (case c
		((#\C-g #\ESC)
		 (switch-to-buffer pre-buffer) (quit))
		((#\Left #\Up #\C-r #\Home #\PageDown) ; 'iswitchb-prev-match
		 (when (< 1 (length buffer-list-grepd))
		   (while (string= top-buffer (car (iswitchb-list-grep buffer-list input)))
			 (setq buffer-list (append (last buffer-list) (butlast buffer-list))))))
		((#\Right #\Down #\C-s #\End #\PageUp) ;'iswitchb-next-match
		 (when (< 1 (length buffer-list-grepd))
		   (while (string= top-buffer (car (iswitchb-list-grep buffer-list input)))
			 (setq buffer-list (append (cdr buffer-list) (list (car buffer-list)))))))
		((#\C-m #\RET) ;'iswitchb-exit-minibuffer
		 (return (switch-to-buffer top-buffer)))
		((#\C-j)
		 (switch-to-buffer top-buffer))
		((#\C-a)
		 (setq input ""))
		((#\C-h)
		 (ignore-errors (setq input (substring input 0 -1))))
		((#\TAB)
		 (ignore-errors
		  (multiple-value-bind (result list prefix)
		      (*do-completion input :buffer-name)
		    (cond ((eq result :solo-match)
			   (return (switch-to-buffer top-buffer)))
			  ((stringp result)
			   (setf input result))))))
		(t
		 (setq input (format nil "~A~A" input c)))
		))))

Last-modified: Thu, 25 May 2006 23:10:04 JST