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

Re: `insert' deactivates active region



>>>>> In <20050708.094430.111207525.jet@gyve.org> Masatake YAMATO wrote:

> I could reproduce this bug with your example.

Thanks for the confirmation.

> Here is a work-around:

[...]

>   (set (make-local-variable 'mark-even-if-inactive) t)

It enables users to copy or kill the region.  However, that the
region is not highlighted does not satisfy those who use the
transient-mark-mode.  The solution I'm testing now is:

(let ((buffer (get-buffer-create "*testing*")))
  (pop-to-buffer buffer)
  (erase-buffer)
  (insert "Hello World\n")
  (goto-char (point-min))
  (set (make-local-variable 'transient-mark-mode) t)
  (add-hook 'post-command-hook
	    (lambda nil
	      (let ((mk (when (and transient-mark-mode mark-active)
			  (mark))))
		(prog1
		    (with-temp-buffer
		      (insert "foo")
		      )
		  (when mk
		    (run-at-time 1e-9 nil #'push-mark mk t t)))))
	    nil t))