Stavros.Macrakis@crg.bull.fr (03/31/89)
I suggest that kill-region ALWAYS do copy-region-as-kill, even if the kill itself fails (because in a read-only buffer). I'm so used to using C-w for cut-and-paste (and it's easier to type on my keyboard), that it comes naturally....
mcgrath@paris.Berkeley.EDU (Roland McGrath) (04/02/89)
In article <8903311121.AA02388@vega.crg.bull.fr> Stavros.Macrakis@crg.bull.fr writes:
I suggest that kill-region ALWAYS do copy-region-as-kill, even if the
kill itself fails (because in a read-only buffer).
I have written a function to modify the `interactive' specs of functions so
they can be used in read-only buffers:
(defun deepcopy-cons (object)
"Return a copy of a cons. Each element that is a cons is copied via this
function, so there are no shallow copies of conses anywhere."
(let ((car (car object))
(cdr (cdr object)))
(cons (if (consp car) (deepcopy-cons car) car)
(if (consp cdr) (deepcopy-cons cdr) cdr))))
(defun make-command-work-for-read-only (command)
"Modify the definition of COMMAND so that it will work in read-only buffers."
(let* ((func (deepcopy-cons (symbol-function command)))
(interactive (assq 'interactive func))
(string (if interactive (car (setq interactive (cdr interactive)))
(signal 'wrong-type-argument
(cons 'commandp (cons command nil)))))
(star (string-match "\\*" string)))
(and star
(setcar interactive
(concat (substring string 0 star)
(substring string (1+ star))))
(fset command func))
))
(make-command-work-for-read-only 'kill-region)
(make-command-work-for-read-only 'kill-line)
(make-command-work-for-read-only 'kill-word)
(make-command-work-for-read-only 'kill-sexp)
(make-command-work-for-read-only 'kill-sentence)
(make-command-work-for-read-only 'kill-paragraph)
(make-command-work-for-read-only 'backward-kill-word)
(make-command-work-for-read-only 'backward-kill-sexp)
(make-command-work-for-read-only 'backward-kill-sentence)
(make-command-work-for-read-only 'backward-kill-paragraph)
--
Roland McGrath
Free Software Foundation, Inc.
roland@wheaties.ai.mit.edu, mit-eddie!wheaties.ai.mit.edu!roland