2

私はGNUEmacs-24を使用しています。私はこのようなボタンを作ります:

(defun go-click (button)
  (print (button-get button 'point))
  (let ((win (get-buffer-window (button-get button 'buffer))))
    (if win
        (progn
          (select-window win)
          (goto-char (button-get button 'point)))
      (message "open a window with the location"))))

(let ((p (point)) (buf (current-buffer)))
  (with-current-buffer (get-buffer "yyy")
    (insert-button "go" 'action #'go-click
                   'follow-link t
                   'point p
                   'buffer buf)))

私はこのコードをonwウィンドウの*scratch*バッファーと、buffferyyyのある別のウィンドウに持っています。ポイントが#'go-click位置にある間、私はeval-current-bufferを実行します。そして、yyyに入るボタンが表示れます。

ここでボタンをクリックすると、期待どおりに数値が出力され、想定どおりに*スクラッチ*がアクティブになりますが、#'go-click位置のポイントは移動しません。

しかし、カーソルキーで移動ボタンにポイントを置き、 Enterキーを押すと、期待どおりに機能します(以前に*スクラッチ*に置いた場所に関係なく、ポイントを#'go-click positoinに移動します)。

キーボード入力とマウスクリックの両方のシナリオで機能させるにはどうすればよいですか?

4

1 に答える 1

2

これが小さなパッチです:

(defun go-click (button)
  (print (button-get button 'point))
  (let ((win (get-buffer-window (button-get button 'buffer)))
        (cur-win (get-buffer-window (current-buffer))))
    (select-window cur-win)
    (if win
        (progn
          (select-window win)
          (goto-char (button-get button 'point)))
      (message "open a window with the location"))))
于 2013-01-24T13:10:14.977 に答える