Emacsã§ãã¦ã¹ãæå¹æ´»ç¨ããæ¹æ³
Emacs使ãã¨ããã¨ãã©ããã¦ããã¼ãã¼ãæä½ã«åã£ã¦ãã¾ãããã¦ã¹æä½ããªããããã«ããã¦ããæ°ããã¾ãã Emacsã§ããã¦ã¹æä½ã¯ããããã§ããã®ã§ãã ãã¦ã¹ãæå¹ã«ä½¿ã£ã¦ãã¾ããï¼
Emacsã¯ã¤ã³ã¯ãªã¡ã³ã¿ã«ãµã¼ããå¼·åãªã®ã§ãç®ã«ã¤ããå ´æã¸ä¸ç¬ã§ã¸ã£ã³ãã§ãã¾ãã ããããæç« ãèªãå ´åã«ç®ã«ã¤ããåèªãç¯å²ã«ã¤ãã¦ã³ãã³ããå®è¡ããå ´åã¯ãã¦ã¹ãåªå¢ã§ãã
ããã§ããã¦ã¹ã«ã³ãã³ããå²ãå½ã¦ãæ¹æ³ã¤ãã¦å°ã解説ãã¦ã¿ã¾ãã
ãã¦ã¹ã¤ãã³ãã®ã·ã³ãã«
ãã¦ã¹ã¤ãã³ãã¯ãæ¥é è¾-mouse-çªå·ãã¨ããå½¢ã®ã·ã³ãã«ã§è¡¨ããã¾ãã æ¥é è¾ã¯ãªããã¨ãããã¾ãã ãã¨ãã°ãmouse-1ã¯å·¦ã¯ãªãã¯ããdouble-mouse-3ã¯å³ããã«ã¯ãªãã¯ã§ãã
ãã¦ã¹ãã¿ã³ã®çªå·
ãã¦ã¹ãã¿ã³ã¨çªå·ã¯ä»¥ä¸ã®ãããªå¯¾å¿ã«ãªã£ã¦ãã¾ãã 3以éã¯ç°å¢ã«ä¾åããããããã¾ããããåã®ã¨ããã§ã¯ãããªã£ã¦ãã¾ãã
1 | å·¦ |
2 | å³ |
3 | ãã¤ã¼ã«ãã¾ãã¯å·¦å³åæ |
4 | ãã¤ã¼ã«ä¸ |
5 | ãã¤ã¼ã«ä¸ |
Emacsãèªèã§ãããã¦ã¹ã¤ãã³ã
Emacsãèªèã§ãããã¦ã¹ã¤ãã³ãã¯ãã¯ãªãã¯ããã©ãã°ããã¿ã³æ¼ãä¸ããã¢ã¼ã·ã§ã³ãããã¾ãã ã¯ãªãã¯ã¤ãã³ãã¨ã¯ããã¿ã³ãæ¼ãä¸ãã¦ããã®å ´ã§é¢ãã¨ãã«çºçãã¾ãã ãã¿ã³ãæ¼ãä¸ãã¦ãã移åããããã©ãã°ã¤ãã³ããçºçãã¾ãã ã¾ãããã¿ã³ãæ¼ãä¸ããç¬éã«ãã¿ã³æ¼ãä¸ãã¤ãã³ããçºçãã¾ãã ã¢ã¼ã·ã§ã³ã¤ãã³ãã¯æ®æ®µã¯ä½¿ãã¾ããã®ã§ããã§ã¯çç¥ãã¾ãã
ã¤ãã³ã | èµ·ããã¨ã | å·¦ãã¿ã³ã§ã®ã·ã³ãã« |
---|---|---|
ã¯ãªã㯠| ãã¿ã³ãæ¼ãã¦ããã®å ´ã§é¢ãã¨ã | mouse-1 |
ãã©ãã° | ãã¿ã³ãæ¼ãã¦ãããã¦ã¹ã移åããã¨ã | drag-mouse-1 |
ãã¿ã³æ¼ãä¸ã | ãã¿ã³ãæ¼ããç¬é | down-mouse-1 |
ã¾ããããã«ã¯ãªãã¯ãããªãã«ã¯ãªãã¯ãããã«ãã©ãã°ãããªãã«ãã©ãã°ãæ±ããã¨ãã§ãã¾ãã ãããããdouble-ãtriple-ã¨ããæ¥é è¾ãã¤ãã¾ãã
ãã¦ã¹ã使ãã³ãã³ããä½æãã
ãã¦ã¹ã使ãã³ãã³ããä½æããã®ã¯ããã»ã©é£ããããã¾ããã é常ã®ã³ãã³ããå®ç¾©ããã¼ã«å²ãå½ã¦ãç¥èã®å»¶é·ç·ä¸ã«ããã¾ãã
ã³ãã³ãå®ç¾©æã«(interactive "e")ãæå®ãã
ãã¦ã¹ã使ãã³ãã³ããå®ç¾©ããã«ã¯ã次ã®ãããªå½¢ã«ãªãã¾ãã
(defun function (click)
(interactive "e")
...)
ãããããã¨ã§ããã¦ã¹ã¤ãã³ãã®æ å ±ãclickããå¾ããã¨ãã§ãã¾ãã
ãã¦ã¹ã§ãã©ãã°ããç¯å²ãå¾ãã«ã¯
ãã¦ã¹ã¤ãã³ãã§æ¬²ããæ å ±ã®å ¸åã¯ããã©ãã°ããç¯å²ã§ãããã ãã©ãã°ã¯ããã©ãã°éå§ã¨ãã©ãã°çµäºã®ã¤ãã³ãããæãã¾ãã ãããã (event-start click) ã (event-end click) ã§å¾ããã¾ãã ããã¦ãã¤ãã³ãããä½ç½®ãå¾ãã«ã¯ãposn-pointé¢æ°ã使ãã¾ãã
ãã©ãã°éå§ä½ç½® | (posn-point (event-start click)) |
ãã©ãã°çµäºä½ç½® | (posn-point (event-end click)) |
ãã¦ã¹ã«æ©è½ãå²ãå½ã¦ã
ãã¦ã¹æä½ããã¼æä½åæ§ global-set-key é¢æ°ã define-key é¢æ°ã§å²ãå½ã¦ããã¾ãã
;;; å®ç¾©ä¾
;; å·¦ã¯ãªãã¯
(global-set-key [mouse-1] 'test-click)
;; å·¦ãã©ãã°
(global-set-key [drag-mouse-1] 'test-drag-mouse)
ããã©ã«ãã§ã¯ã次ã®ããã«å²ãå½ã¦ããã¦ãã¾ãã
<mouse-1> | mouse-set-point |
<double-mouse-1> | mouse-set-point |
<triple-mouse-1> | mouse-set-point |
<down-mouse-1> | mouse-drag-region |
<drag-mouse-1> | mouse-set-region |
<mouse-2> | mouse-yank-at-click |
<mouse-3> | mouse-save-then-kill |
<mouse-4> | mwheel-scroll |
<mouse-5> | mwheel-scroll |
ãã¨ãã°ã double-drag-mouse-1 çã«ã¯å²ãå½ã¦ããã¦ãã¾ããã ãã¦ã¹ã§ç¯å²é¸æãããããã«å¯¾å¿ããã³ãã³ããå®ç¾©ããã«ã¯ã double-drag-mouse-1 çãé©ãã¦ãã¾ãã
CtrlãMetaãShiftã¨ä½µç¨ãããã¨ãã§ãã¾ãã
<C-down-mouse-1> | mouse-buffer-menu |
<C-down-mouse-2> | facemenu-menu |
<C-mouse-4> | mwheel-scroll |
<C-mouse-5> | mwheel-scroll |
<M-down-mouse-1> | mouse-drag-secondary |
<M-drag-mouse-1> | mouse-set-secondary |
<M-mouse-1> | mouse-start-secondary |
<M-mouse-2> | mouse-yank-secondary |
<M-mouse-3> | mouse-secondary-save-then-kill |
<S-down-mouse-1> | mouse-appearance-menu |
<S-mouse-3> | kmacro-end-call-mouse |
<S-mouse-4> | mwheel-scroll |
<S-mouse-5> | mwheel-scroll |
ãã¦ã¹ã¤ãã³ããã¹ãããã°ã©ã
以ä¸ã®ã³ã¼ãã¯ããã¦ã¹ãã©ãã°ã¤ãã³ãã®ãã¢ã³ã¹ãã¬ã¼ã·ã§ã³ã§ãã ãã©ãã°ãããã«ãã©ãã°ãããªãã«ãã©ãã°ã試ãã¦ã¿ã¦ãã ããã ç¯å²å ã®ããã¹ãã表示ããã¾ãã
;; (save-window-excursion (shell-command (format "emacs-test -l test-minimum -l %s %s &" buffer-file-name buffer-file-name))) (global-set-key [drag-mouse-1] 'test-drag-mouse) (global-set-key [double-drag-mouse-1] 'test-double-drag-mouse) (global-set-key [triple-drag-mouse-1] 'test-triple-drag-mouse) (defun test-drag-mouse (click) (interactive "e") (mouse-message-region click "test-drag-mouse")) (defun test-double-drag-mouse (click) (interactive "e") (mouse-message-region click "test-double-drag-mouse")) (defun test-triple-drag-mouse (click) (interactive "e") (mouse-message-region click "test-triple-drag-mouse")) (defun mouse-message-region (click comment) (interactive "e") (mouse-set-region click) (message "%s\n%s" comment (buffer-substring-no-properties (posn-point (event-start click)) (posn-point (event-end click)))))
auto-install.elã使ãã¨ã以ä¸ã®ã³ãã³ãã§ããã«è©¦ããã¨ãã§ãã¾ãã
M-x install-elisp http://www.rubyist.net/~rubikitch/archive/2010-11-09-110928.mouse.drag.el
ãã¦ã¹ã§ç¯å²é¸æããå¾ã§å ã®ãã¤ã³ãã«æ»ãã«ã¯
é常ã¯ããã¦ã¹ãã©ãã°ã§ç¯å²é¸æããããããã®ä½ç½®ã«ã¾ã§ã«ã¼ã½ã«ã移åãã¾ãã ããããã«ã¼ã½ã«ä½ç½®ã復å ãã¦ã»ããã¨ããããã¾ãã
ãã®ã¨ãã¯ã以ä¸ã®å 容ã®mouse-excursion.elãå©ç¨ãã¾ãã
(eval-when-compile (require 'cl)) (lexical-let (start-point start-window) (defun mouse-drag-region-excursion (click) (interactive "e") (setq start-point (point)) (setq start-window (selected-window)) (mouse-drag-region click)) (defun mouse-funcall-region-excursion (func click) (funcall func (posn-point (event-start click)) (posn-point (event-end click))) (select-window start-window) (goto-char start-point))) (provide 'mouse-excursion)
M-x install-elisp http://www.rubyist.net/~rubikitch/archive/mouse-excursion.el
ãã¢ã³ã¹ãã¬ã¼ã·ã§ã³ã¯ä»¥ä¸ã®å 容ã§ãã
;; (save-window-excursion (shell-command (format "emacs-test -l test-minimum -l %s %s &" buffer-file-name buffer-file-name))) (require 'mouse-excursion) (global-set-key [down-mouse-1] 'mouse-drag-region-excursion) (global-set-key [drag-mouse-1] 'test-drag-mouse-excursion) (defun test-drag-mouse-excursion (click) (interactive "e") (mouse-message-region-excursion click "test-drag-mouse-excursion")) (defun mouse-message-region-excursion (click comment) (interactive "e") (mouse-funcall-region-excursion (lambda (s e) (message "%s\n%s" comment (buffer-substring-no-properties s e))) click))
M-x install-elisp http://www.rubyist.net/~rubikitch/archive/2010-11-09-225132.mouse-excursion.el
å·¦ãã©ãã°ã§è©¦ãã¦ã¿ã¦ãã ããã ç¯å²é¸æããå¾ã§ã«ã¼ã½ã«ä½ç½®ãæ»ã£ã¦ãããã¨ã«æ°ä»ãã§ãããã
ãªããããã«ãã©ãã°ã§ã¯åãã¾ããã ãªããªããããã«ãã©ãã°ããã«ã¯ä¸åº¦ãã¦ã¹ãé¢ããããå·¦ã¯ãªãã¯ã¤ãã³ããçºçããããã§ãã ããã©ã«ãã§ã¯å·¦ã¯ãªãã¯ã¤ãã³ã㯠mouse-set-point ã«å²ãå½ã¦ããã¦ãã¾ãã
åã®å ´åããã®æ©è½ã使ã£ã¦ãç¯å²å ã®ããã¹ããã¡ã¢ã«æ¾ãè¾¼ã¿ããã¨æã£ã¦ãã¾ãã