emacs-devel
[Top][All Lists]
Advanced

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

Two bugs in remove-yank-excluded-properties: Patch.


From: Luc Teirlinck
Subject: Two bugs in remove-yank-excluded-properties: Patch.
Date: Fri, 27 Sep 2002 21:06:56 -0500 (CDT)

The following ielm run (in emacs-21.3.50 -q), illustrates two bugs in
`remove-yank-excluded-properties'.  This function is supposed to first
replace all category properties by their defined properties and then
remove all properties in the list `yank-excluded-properties'.  The
first bug is that only "odd-numbered" category properties get
replaced, as the first ielm run shows.  Also, those category
properties that do get replaced, override properties they should not
be overriding, as the same run shows.  (Look at the "importance"
property.)

The second ielm run shows the correct behavior after applying the
patch at the end of this message.

Ielm run before patch:

===File ~/yank-bug==========================================
*** Welcome to IELM ***  Type (describe-mode) for help.
ELISP> (setplist 'cat1 '(prop1 t))
(prop1 t)

ELISP> (setplist 'cat2 '(prop2 t))
(prop2 t)

ELISP> (setplist 'cat3 '(prop3 t importance low))
(prop3 t importance low)

ELISP> (setplist 'cat4 '(prop4 t))
(prop4 t)

ELISP> (set-buffer "*scratch*")
#<buffer *scratch*>
ELISP> (put-text-property 1 5 'importance 'high)
nil
ELISP> (put-text-property 1 2 'category 'cat1)
nil
ELISP> (put-text-property 2 3 'category 'cat2)
nil
ELISP> (put-text-property 3 4 'category 'cat3)
nil
ELISP> (put-text-property 4 5 'category 'cat4)
nil

;; visit buffer *scratch*, drag the mouse over ";; This" and yank it
;; right below the header.  Check the position of the first yanked
;; character, say with C-x =. In my case, was 191.

ELISP> (text-properties-at 191)
(prop1 t importance high)

ELISP> (text-properties-at 192)
(category cat2 importance high)

ELISP> (text-properties-at 193)
(prop3 t importance low)

ELISP> (text-properties-at 194)
(category cat4 importance high)

ELISP> (emacs-version)
"GNU Emacs 21.3.50.2 (i686-pc-linux-gnu, X toolkit)\n of 2002-09-27 on 
swt40.swt.com"
ELISP> yank-excluded-properties
(read-only invisible intangible field mouse-face help-echo local-map keymap)

ELISP> 
============================================================

Same run after patch:


===File ~/yank-bug-2========================================
*** Welcome to IELM ***  Type (describe-mode) for help.
ELISP> (setplist 'cat1 '(prop1 t))
(prop1 t)

ELISP> (setplist 'cat2 '(prop2 t))
(prop2 t)

ELISP> (setplist 'cat3 '(prop3 t importance low))
(prop3 t importance low)

ELISP> (setplist 'cat4 '(prop4 t))
(prop4 t)

ELISP> (set-buffer "*scratch*")
#<buffer *scratch*>
ELISP> (put-text-property 1 5 'importance 'high)
nil
ELISP> (put-text-property 1 2 'category 'cat1)
nil
ELISP> (put-text-property 2 3 'category 'cat2)
nil
ELISP> (put-text-property 3 4 'category 'cat3)
nil
ELISP> (put-text-property 4 5 'category 'cat4)
nil
ELISP> (text-properties-at 191)
(importance high prop1 t)

ELISP> (text-properties-at 192)
(importance high prop2 t)

ELISP> (text-properties-at 193)
(prop3 t importance high)

ELISP> (text-properties-at 194)
(importance high prop4 t)

ELISP> ============================================================

Change log:

2002-09-27  Luc Teirlinck  <address@hidden>

        * subr.el (remove-yank-excluded-properties): Fix bugs in
          handling of category properties.

Patch:

===File ~/subrdiff==========================================
cd /usr/local/share/emacs/21.3.50/lisp/
diff -c /usr/local/share/emacs/21.3.50/lisp/subrold.el 
/usr/local/share/emacs/21.3.50/lisp/subr.el
*** /usr/local/share/emacs/21.3.50/lisp/subrold.el      Fri Sep 27 18:28:45 2002
--- /usr/local/share/emacs/21.3.50/lisp/subr.el Fri Sep 27 20:15:18 2002
***************
*** 1431,1449 ****
        (while (< (point) end)
          (let ((cat (get-text-property (point) 'category))
                run-end)
-           (when cat
-             (setq run-end
-                   (next-single-property-change (point) 'category nil end))
-             (remove-list-of-text-properties (point) run-end '(category))
-             (add-text-properties (point) run-end (symbol-plist cat))
-             (goto-char (or run-end end)))
            (setq run-end
                  (next-single-property-change (point) 'category nil end))
!           (goto-char (or run-end end))))))
      (if (eq yank-excluded-properties t)
        (set-text-properties start end nil)
!       (remove-list-of-text-properties start end
!                                     yank-excluded-properties))))
  
  (defun insert-for-yank (&rest strings)
    "Insert STRINGS at point, stripping some text properties.
--- 1431,1451 ----
        (while (< (point) end)
          (let ((cat (get-text-property (point) 'category))
                run-end)
            (setq run-end
                  (next-single-property-change (point) 'category nil end))
!           (when cat
!             (let (run-end2 original)
!               (remove-list-of-text-properties (point) run-end '(category))
!               (while (< (point) run-end)
!                 (setq run-end2 (next-property-change (point) nil run-end))
!                 (setq original (text-properties-at (point)))
!                 (set-text-properties (point) run-end2 (symbol-plist cat))
!                 (add-text-properties (point) run-end2 original)
!                 (goto-char run-end2))))
!           (goto-char run-end)))))
      (if (eq yank-excluded-properties t)
        (set-text-properties start end nil)
!       (remove-list-of-text-properties start end yank-excluded-properties))))
  
  (defun insert-for-yank (&rest strings)
    "Insert STRINGS at point, stripping some text properties.

Diff finished at Fri Sep 27 20:33:53
============================================================




reply via email to

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