[Date Prev] [Date Index] [Date Next]
[Thread Prev] [Thread Index] [Thread Next]

[xyzzy:03370] Re: 括弧のハイライト



喜多さん、こんにちは。

    Mon, 18 Oct 1999 10:21:05 +0900 の
   “[xyzzy:03366] Re: 括弧のハイライト”
    への返事です.

| その某まぬけコマンドとは?
| 気になります.

こんなやつ。人にはなんだかんだ言っておいて add-hook 使
ってないし(^^;

(defvar-local *stupidity-mode* nil)
(defvar-local *real-stupidity-mode* nil)
(make-variable-buffer-local '*post-command-hook*)

(defun real-stupidity ()
  (let ((goal (goal-column)))
    (unwind-protect
	(save-excursion
	  (while (not (looking-for "{"))
	    (unless (backward-up-list 1 t)
	      (return-from real-stupidity nil)))
	  (let ((beg (point))
		(end (progn
		       (unless (forward-list 1 t)
			 (return-from real-stupidity nil))
		       (point))))
	    (clear-all-text-colors)
	    (set-text-color (progn
			      (goto-char beg)
			      (goto-bol)
			      (point))
			    (progn
			      (goto-char end)
			      (or (forward-line 1)
				  (goto-eol))
			      (point))
			    0 9 nil t)))
      (set-goal-column goal))))

(defun stupidity ()
  (let ((goal (goal-column)))
    (unwind-protect
	(save-excursion
	  (while (not (looking-for "{"))
	    (unless (backward-up-list 1 t)
	      (return-from stupidity nil)))
	  (let ((beg (point))
		(end (progn
		       (unless (forward-list 1 t)
			 (return-from stupidity nil))
		       (point))))
	    (clear-all-text-colors)
	    (set-text-color (progn
			      (goto-char beg)
			      (point))
			    (progn
			      (forward-char 1)
			      (point))
			    0 9 nil nil)
	    (set-text-color (progn
			      (goto-char end)
			      (point))
			    (progn
			      (forward-char -1)
			      (point))
			    0 9 nil nil)))
      (set-goal-column goal))))

(defun stupidity-mode (&optional (arg nil sv))
  (interactive "p")
  (ed::toggle-mode '*stupidity-mode* arg sv)
  (if *stupidity-mode*
      (setq *post-command-hook* #'stupidity)
    (progn
      (clear-all-text-colors)
      (setq *post-command-hook* nil))))

(defun real-stupidity-mode (&optional (arg nil sv))
  (interactive "p")
  (ed::toggle-mode '*real-stupidity-mode* arg sv)
  (if *real-stupidity-mode*
      (setq *post-command-hook* #'real-stupidity)
    (progn
      (clear-all-text-colors)
      (setq *post-command-hook* nil))))


| # って自分が作れって言われそうですが..
| # 実はやってみようとおもったのですが,symbol 数のあまりの多さに速攻で
| # 挫折してしまいました.

私も。っていうか、端から作る気がないんですが(^^;

--
亀井哲弥(Tetsuya Kamei)
kamei@xxxxxxxxxxxx/JCA00343@xxxxxxxxxxx

Index Home