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

[xyzzy:04927] クリップボード関数 (2)



こんにちは、八木と申します。

コピー+ペーストでcopy-region-to-clipboardを使っていました。
マーク付けした領域はO.Kですが、(マウスで)選択した領域については
copy-selection-to-clipboardが必要なことに気が付きました。で、
どっちでも同じように行けるのを作りました。

亀井さんがせっかく分けてあるのに一緒にするのはどうかとも思いますが、
ご参考に。lispをよく分かってないので、変なところはご指摘ください。

;; 選択領域またはマーク付け領域をクリップボードに設定
(defun copy-region-or-selection-to-clipboard ()
  (interactive)
  (let ((type (get-selection-type)))
     (if (eql type 2)
	 (selection-start-end (start end)
	   (copy-to-clipboard (buffer-substring start end))
	   (stop-selection))
       (let ((line (current-virtual-line-number)))
	 (start-selection 1)
	 (exchange-point-and-mark)
	 (selection-start-end (start end)
	   (copy-to-clipboard (buffer-substring start end))
	   (stop-selection)
	   (goto-virtual-line line))))))

;; 選択領域またはマーク付け領域を削除してクリップボードに設定
(defun kill-region-or-selection-to-clipboard ()
  (interactive)
  (let ((type (get-selection-type)))
     (if (eql type 2)
	 (selection-start-end (start end)
	   (copy-to-clipboard (buffer-substring start end))
	   (delete-region start end)
	   (stop-selection))
       (let ((line (current-virtual-line-number)))
	 (start-selection 1)
	 (exchange-point-and-mark)
	 (selection-start-end (start end)
	   (copy-to-clipboard (buffer-substring start end))
	   (delete-region start end)
	   (stop-selection))))))
--------------------------------------------------------
   |  ^|^  |         八木 稔   Minoru Yagi
   |   @   | (株)東芝 医用システム社
             医用機器・システム開発センター開発第3担当
                    minoru2.yagi@xxxxxxxxxxxxx

Index Home