From: Luc Teirlinck <teirllm@dms.auburn.edu>
Subject: Two bugs in remove-yank-excluded-properties: Patch.
Date: Fri, 27 Sep 2002 21:06:56 -0500 (CDT) [thread overview]
Message-ID: <200209280206.VAA20470@eel.dms.auburn.edu> (raw)
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 <teirllm@mail.auburn.edu>
* 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
============================================================
next reply other threads:[~2002-09-28 2:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-28 2:06 Luc Teirlinck [this message]
2002-09-29 3:12 ` Two bugs in remove-yank-excluded-properties: Patch Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200209280206.VAA20470@eel.dms.auburn.edu \
--to=teirllm@dms.auburn.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).