comparison lisp/simple.el @ 49491:c52c622747ca

(kill-new): Improve doc string for yank-handler. Signal args-out-of-range error if yank-handler is specified for an empty string.
author Kim F. Storm <storm@cua.dk>
date Mon, 27 Jan 2003 21:44:48 +0000
parents 25243a7167f4
children 8b39a07c5213
comparison
equal deleted inserted replaced
49490:567f8c656a28 49491:c52c622747ca
1762 If `interprogram-cut-function' is non-nil, apply it to STRING. 1762 If `interprogram-cut-function' is non-nil, apply it to STRING.
1763 Optional second argument REPLACE non-nil means that STRING will replace 1763 Optional second argument REPLACE non-nil means that STRING will replace
1764 the front of the kill ring, rather than being added to the list. 1764 the front of the kill ring, rather than being added to the list.
1765 1765
1766 Optional third arguments YANK-HANDLER controls how the STRING is later 1766 Optional third arguments YANK-HANDLER controls how the STRING is later
1767 inserted into a buffer; see `insert-for-yank' for details." 1767 inserted into a buffer; see `insert-for-yank' for details.
1768 (when (> (length string) 0) 1768 When a yank handler is specified, STRING must be non-empty (the yank
1769 (if yank-handler 1769 handler is stored as a `yank-handler'text property on STRING).
1770 (put-text-property 0 1 'yank-handler yank-handler string) 1770
1771 (remove-text-properties 0 1 '(yank-handler nil) string))) 1771 When the yank handler has a non-nil PARAM element, the original STRING
1772 (and (fboundp 'menu-bar-update-yank-menu) 1772 argument is not used by `insert-for-yank'. However, since Lisp code
1773 (menu-bar-update-yank-menu string (and replace (car kill-ring)))) 1773 may access and use elements from the kill-ring directly, the STRING
1774 argument should still be a \"useful\" string for such uses."
1775 (if (> (length string) 0)
1776 (if yank-handler
1777 (put-text-property 0 1 'yank-handler yank-handler string)
1778 (remove-list-of-text-properties 0 1 '(yank-handler) string))
1779 (if yank-handler
1780 (signal 'args-out-of-range
1781 (list string "yank-handler specified for empty string"))))
1782 (if (fboundp 'menu-bar-update-yank-menu)
1783 (menu-bar-update-yank-menu string (and replace (car kill-ring))))
1774 (if (and replace kill-ring) 1784 (if (and replace kill-ring)
1775 (setcar kill-ring string) 1785 (setcar kill-ring string)
1776 (setq kill-ring (cons string kill-ring)) 1786 (setq kill-ring (cons string kill-ring))
1777 (if (> (length kill-ring) kill-ring-max) 1787 (if (> (length kill-ring) kill-ring-max)
1778 (setcdr (nthcdr (1- kill-ring-max) kill-ring) nil))) 1788 (setcdr (nthcdr (1- kill-ring-max) kill-ring) nil)))