comparison lisp/subr.el @ 5631:5e256f495401

Don't error with a non-list plist, #'copy-symbol lisp/ChangeLog addition: 2011-12-30 Aidan Kehoe <kehoea@parhasard.net> * subr.el (copy-symbol): Don't error with a non-list plist, as happens with symbols in abbrev tables.
author Aidan Kehoe <kehoea@parhasard.net>
date Fri, 30 Dec 2011 13:55:07 +0000
parents b908c7265a2b
children bd80d9103fc8
comparison
equal deleted inserted replaced
5630:f5315ccbf005 5631:5e256f495401
464 464
465 (defun copy-symbol (symbol &optional copy-properties) 465 (defun copy-symbol (symbol &optional copy-properties)
466 "Return a new uninterned symbol with the same name as SYMBOL. 466 "Return a new uninterned symbol with the same name as SYMBOL.
467 If COPY-PROPERTIES is non-nil, the new symbol will have a copy of 467 If COPY-PROPERTIES is non-nil, the new symbol will have a copy of
468 SYMBOL's value, function, and property lists." 468 SYMBOL's value, function, and property lists."
469 (let ((new (make-symbol (symbol-name symbol)))) 469 (let ((new (make-symbol (symbol-name symbol))) plist)
470 (when copy-properties 470 (when copy-properties
471 ;; This will not copy SYMBOL's chain of forwarding objects, but 471 ;; This will not copy SYMBOL's chain of forwarding objects, but
472 ;; I think that's OK. Callers should not expect such magic to 472 ;; I think that's OK. Callers should not expect such magic to
473 ;; keep working in the copy in the first place. 473 ;; keep working in the copy in the first place.
474 (and (boundp symbol) 474 (and (boundp symbol)
475 (set new (symbol-value symbol))) 475 (set new (symbol-value symbol)))
476 (and (fboundp symbol) 476 (and (fboundp symbol)
477 (fset new (symbol-function symbol))) 477 (fset new (symbol-function symbol)))
478 (setplist new (copy-list (symbol-plist symbol)))) 478 (setq plist (symbol-plist symbol)
479 plist (if (consp plist) (copy-list plist) plist))
480 (setplist new plist))
479 new)) 481 new))
480 482
481 (defun set-symbol-value-in-buffer (sym val buffer) 483 (defun set-symbol-value-in-buffer (sym val buffer)
482 "Set the value of SYM to VAL in BUFFER. Useful with buffer-local variables. 484 "Set the value of SYM to VAL in BUFFER. Useful with buffer-local variables.
483 If SYM has a buffer-local value in BUFFER, or will have one if set, this 485 If SYM has a buffer-local value in BUFFER, or will have one if set, this