emacs-devel
[Top][All Lists]
Advanced

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

kill-rectangle and kill-read-only-ok.


From: Michael Cadilhac
Subject: kill-rectangle and kill-read-only-ok.
Date: Tue, 04 Apr 2006 20:24:43 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

  Hi !

  Isn't `kill-rectangle' not supposed to barf on a read-only text if
  kill-read-only-ok is set ?

  I propose the following change:

Index: lisp/rect.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/rect.el,v
retrieving revision 1.51
diff -c -r1.51 rect.el
*** lisp/rect.el        6 Feb 2006 14:33:35 -0000       1.51
--- lisp/rect.el        4 Apr 2006 18:17:10 -0000
***************
*** 141,148 ****
        ;; else
        (setq pt (point))
        (move-to-column endcol t)
!       (setcdr lines (cons (buffer-substring pt (point)) (cdr lines)))
!       (delete-region pt (point)))
      ))
  
  ;; ### NOTE: this is actually the only function that needs to do complicated
--- 141,147 ----
        ;; else
        (setq pt (point))
        (move-to-column endcol t)
!       (setcdr lines (cons (filter-buffer-substring pt (point) t) (cdr 
lines))))
      ))
  
  ;; ### NOTE: this is actually the only function that needs to do complicated
***************
*** 233,244 ****
  You might prefer to use `delete-extract-rectangle' from a program.
  
  With a prefix (or a FILL) argument, also fill lines where nothing has to be
! deleted."
!   (interactive "*r\nP")
!   (when buffer-read-only
!     (setq killed-rectangle (extract-rectangle start end))
!     (barf-if-buffer-read-only))
!   (setq killed-rectangle (delete-extract-rectangle start end fill)))
  
  ;; this one is untouched --dv
  ;;;###autoload
--- 232,253 ----
  You might prefer to use `delete-extract-rectangle' from a program.
  
  With a prefix (or a FILL) argument, also fill lines where nothing has to be
! deleted.
! 
! If the buffer is read-only, Emacs will beep and refrain from deleting
! the rectangle, but put it in the kill ring anyway.  This means that
! you can use this command to copy text from a read-only buffer.
! \(If the variable `kill-read-only-ok' is non-nil, then this won't
! even beep.)"
!   (interactive "r\nP")
!   (condition-case nil
!       (setq killed-rectangle (delete-extract-rectangle start end fill))
!     ((buffer-read-only text-read-only)
!      (setq killed-rectangle (extract-rectangle start end))
!      (if kill-read-only-ok
!        (progn (message "Read only text copied to kill ring") nil)
!        (barf-if-buffer-read-only)
!        (signal 'text-read-only (list (current-buffer)))))))
  
  ;; this one is untouched --dv
  ;;;###autoload
Index: lisp/ChangeLog
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.9347
diff -c -r1.9347 ChangeLog
*** lisp/ChangeLog      4 Apr 2006 16:46:03 -0000       1.9347
--- lisp/ChangeLog      4 Apr 2006 18:17:12 -0000
***************
*** 1,3 ****
--- 1,9 ----
+ 2006-04-04  Michael Cadilhac  <address@hidden> (tiny change)
+ 
+       * rect.el (kill-rectangle): Don't barf if `kill-read-only-ok' is set.
+       (delete-extract-rectangle-line): Use `filter-buffer-substring' instead
+       of `buffer-substring' and `delete-region'.
+ 
  2006-04-04  Dan Nicolaescu  <address@hidden>
  
        * man.el (Man-mode-map): Restore the \r binding.
  The code is taken from `kill-region', mainly.

-- 
      Michael `Micha' Cadilhac |   Un certain Blaise Pascal
         Epita/LRDE Promo 2007 |      etc... etc...
 http://www.lrde.org/~cadilh_m |    -- Prévert (Les paris stupides)
        JID: address@hidden |

Attachment: pgpfbEELChH6c.pgp
Description: PGP signature


reply via email to

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