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: Wed, 23 Jan 2008 10:19:12 +0100
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

> I think it is clearer to catch the error than to check the property by
> hand.  But the question is where to do this?  Where you did it, in
> delete-selection-pre-hook, or where I did it, in delete-active-region?

Honestly, mine was a simple-minded attempt to handle read-only buffers
and read-only text analogously.

> The question is, if you type a self-inserting character, is it right
> to skip just the deletion done by delete-active-region and do the
> insertion, or should it skip both?  My patch does the former, yours
> does the latter.

I suppose your patch has the flaw that when `overwrite-mode' is on, the
following part

                 (if (and overwrite-mode (eq this-command 'self-insert-command))
                   (let ((overwrite-mode nil))
                     (self-insert-command (prefix-numeric-value 
current-prefix-arg))
                     (setq this-command 'ignore)))))

will still cause an error and clear `pre-command-hook'.

Maybe just add buffer-read-only and text-read-only to the handler in
`delete-selection-pre-hook' as in the attached patch?
*** delsel.el.~1.43.~   Wed Oct 31 01:30:54 2007
--- delsel.el   Wed Jan 23 08:42:28 2008
***************
*** 79,86 ****
    t)
  
  (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
--- 79,85 ----
    t)
  
  (defun delete-selection-pre-hook ()
!   (when (and delete-selection-mode transient-mark-mode mark-active)
      (let ((type (and (symbolp this-command)
                     (get this-command 'delete-selection))))
        (condition-case data
***************
*** 113,119 ****
         ;; stop safe_run_hooks from clearing out pre-command-hook.
         (and (eq inhibit-quit 'pre-command-hook)
              (setq inhibit-quit 'delete-selection-dummy))
!        (signal 'file-supersession (cdr data)))))))
  
  (put 'self-insert-command 'delete-selection t)
  (put 'self-insert-iso 'delete-selection t)
--- 112,120 ----
         ;; stop safe_run_hooks from clearing out pre-command-hook.
         (and (eq inhibit-quit 'pre-command-hook)
              (setq inhibit-quit 'delete-selection-dummy))
!        (signal 'file-supersession (cdr data)))
!       ((buffer-read-only text-read-only)
!        (message "Text is read-only"))))))
  
  (put 'self-insert-command 'delete-selection t)
  (put 'self-insert-iso 'delete-selection t)

reply via email to

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