emacs-devel
[Top][All Lists]
Advanced

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

Re: 23.0.50; delete-seletion-mode and read-only text


From: martin rudalics
Subject: Re: 23.0.50; delete-seletion-mode and read-only text
Date: Mon, 21 Jan 2008 23:03:10 +0100
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

In delete-seletion-mode, trying to self insert in read-only text when
there is a selection signals an error that clears pre-command-hook.

emacs -Q

    (delete-selection-mode 1)
    (insert (propertize "12345" 'read-only t))

Select read only text with C-SPC + moving. Press a self-inserting key ("x").

=> pre-command-hook is cleared.

delete-selection-mode does check buffer-read-only, but it does not
protect against read-only text.

Does the attached patch fix it?

*** delsel.el.~1.43.~   Wed Oct 31 01:30:54 2007
--- delsel.el   Mon Jan 21 23:01:08 2008
***************
*** 80,86 ****
  
  (defun delete-selection-pre-hook ()
    (when (and delete-selection-mode transient-mark-mode mark-active
!            (not buffer-read-only))
      (let ((type (and (symbolp this-command)
                     (get this-command 'delete-selection))))
        (condition-case data
--- 80,90 ----
  
  (defun delete-selection-pre-hook ()
    (when (and delete-selection-mode transient-mark-mode mark-active
!            (not buffer-read-only)
!            (let ((from (min (point) (mark)))
!                  (to (max (point) (mark))))
!              (not (or (get-text-property from 'read-only)
!                       (< (next-single-property-change from 'read-only nil to) 
to)))))
      (let ((type (and (symbolp this-command)
                     (get this-command 'delete-selection))))
        (condition-case data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]