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

[xyzzy:04273] クリップボードとローカルバッファが同期した Copy/Kill



仁泉と申します。たびたびお世話になっています。

私事ですが、カットバッファとクリップボードとの同期ですが、クリップボー
ドをメインとして利用し、ローカルなカットバッファを同期させるように設定
してみました。

ご参考まで、投稿します。# 見よう見まねですが

(defun copy-selection-region-to-clipboard ()
  (interactive)
  (setq is-selected nil)
  (if (and *shodat-copy-mode*
	   (pre-selection-p))
      (let ((type (get-selection-type)))
	(selection-start-end (start end)
	  (copy-region-as-kill start end)
	  (copy-region-to-clipboard start end)
	  (setq is-selected t)
	  (start-selection type t end)))
    (selection-start-end (start end)
      (copy-region-as-kill start end)
      (copy-region-to-clipboard start end)
      (setq is-selected t)))
  (if (eq is-selected nil)
      (progn
	(copy-region-as-kill (mark) (point))
	(copy-region-to-clipboard (mark) (point))))
  t)

(defun kill-selection-region-to-clipboard ()
  (interactive "*")
  (setq is-selected nil)
  (selection-start-end (start end)
    (copy-region-as-kill start end)
    (kill-region-to-clipboard start end)
    (setq is-selected t))
  (if (eq is-selected nil)
      (progn
	(copy-region-as-kill (mark) (point))
	(kill-region-to-clipboard (mark) (point))))
 t)

(defun kill-line-to-clipboard ()
  "kill line to clipboard"
  (interactive)
  (setq kill-line-to-clipboard-start (point))
  (end-of-line)
  (if (eq kill-line-to-clipboard-start (point))
      (delete-char)
    (progn
      (copy-region-as-kill kill-line-to-clipboard-start (point))
      (kill-region-to-clipboard kill-line-to-clipboard-start (point)))))

(define-key   *global-keymap* #\C-w
	      'kill-selection-region-to-clipboard )
(define-key   *global-keymap* #\M-w
	      'copy-selection-region-to-clipboard )
(define-key   *global-keymap* #\C-y
	      'paste-from-clipboard )
(define-key   *global-keymap* #\C-k
	      'kill-line-to-clipboard )

--
Daisuke Niizumi <nizumi@xxxxxxxxxxxx>

Index Home