hoge

;;my-test-mode
;; マイナーモードの定義
(easy-mmode-define-minor-mode
 test-mode
 ;; ドキュメント
 "This is Test Mode."
 ;; 初期値
 nil
 ;; on の時のモード行への表示
 " TestMode"
 ;; マイナーモード用キーマップの初期値
 '(
;;   ("\C-o" . test-function)
   ("\r" . test-mode)
   ))

(add-hook 'test-mode-on-hook 'test-mode-init)
(add-hook 'test-mode-off-hook 'test-mode-finish)

(put 'indented-line 'forward-op 'forward-to-indentation)

;; (defun my-bounds-list(thing-list beginningp descp)
;;   (let ((getfunc (if beginningp 'car 'cdr)))
;;     (sort
;;      (delq nil
;; 	   (let ((ret-list (list(list(point)))))
;; 	     (dolist (i thing-list ret-list)
;; 	       (let ((bounds (bounds-of-thing-at-point i)))
;; 		 (if (not (assoc (funcall getfunc bounds) ret-list))
;; 		     (setq ret-list (cons bounds ret-list)))))))
;;      (if descp 
;; 	 '(lambda(a b) (> (funcall getfunc a) (funcall getfunc b)))
;;        	 '(lambda(a b) (< (funcall getfunc a) (funcall getfunc b))))
;;      )
;;     )
;;   )

(defun my-point-list(thing-list beginningp descp)
  (let ((getfunc (if beginningp 'car 'cdr)))
    (sort
     (delq nil
	   (let ((ret-list (list(list(point)))))
	     (dolist (i thing-list ret-list)
	       (let ((bounds (list(funcall getfunc (bounds-of-thing-at-point i))i)))
		 (if (not (assoc (car bounds) ret-list))
		     (setq ret-list (cons bounds ret-list)))))))
     (if descp 
	 '(lambda(a b) (> (car a) (car b)))
       	 '(lambda(a b) (< (car a) (car b))))
     )
    )
  )

(defun test-mode-init()
  (if my-hoge-bounds-list
      (progn
	(message "%s" my-hoge-bounds-list)
	(setq test-mode-count 1)
	(setq my-overlay-list
	      (mapcar '(lambda(bounds)
			 (make-overlay (car bounds) (1+ (car bounds))))
		      my-hoge-bounds-list))
	(mapcar '(lambda(my-ov)
		   (overlay-put my-ov 'face 'lazy-highlight))my-overlay-list)
	)))

(defun test-mode-finish()
  (mapcar '(lambda(my-ov)
	     (delete-overlay my-ov))my-overlay-list))

(defvar test-mode-count 0)
(defvar my-hoge-bounds-list nil)
(defvar my-overlay-list nil)

(defun test-function ()
  (interactive)
  (if (not (eq last-command this-command))
      (setq my-hoge-bounds-list 
	    ;;	(my-bounds-list 
	    (my-point-list 
	     '(line word symbol sentence sexp defun indented-line) t t)))
  (if (eq test-mode nil) (test-mode))
  (goto-char 
   (car (nth (mod test-mode-count 
		  (length my-hoge-bounds-list))
	     my-hoge-bounds-list)))
  (setq test-mode-count (1+ test-mode-count))
  )

(defun test-function-a ()
  (interactive)
  (if (not (eq last-command this-command))
      (setq my-hoge-bounds-list 
	    ;;	(my-bounds-list 
	    (my-point-list 
	     '(line indented-line buffer) t t)))
  (if (eq test-mode nil) (test-mode))
  (goto-char 
   (car (nth (mod test-mode-count 
		  (length my-hoge-bounds-list))
	     my-hoge-bounds-list)))
  (setq test-mode-count (1+ test-mode-count))
  )


(global-set-key (kbd "C-o") 'test-function)
(global-set-key (kbd "C-a") 'test-function-a)