* purecopying strings in add-hook?
@ 2019-04-30 19:59 Stefan Monnier
0 siblings, 0 replies; only message in thread
From: Stefan Monnier @ 2019-04-30 19:59 UTC (permalink / raw
To: Dan Nicolaescu; +Cc: emacs-devel
Hi Dan,
Do you remember why we purecopy the "function" argument of `add-hook`
when it's a string(!)?
This was introduced by commit ff917d632134b76be4c764dd6cf3ac1984b371a4,
appended below,
Stefan
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1f0ddc1217..3b58fe1125 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,8 @@
2009-11-11 Dan Nicolaescu <dann@ics.uci.edu>
+ * subr.el (add-hook): Purecopy strings.
+ (eval-after-load): Purecopy load-history-regexp and the form.
+
* custom.el (custom-declare-group): Purecopy load-file-name.
* subr.el (menu-bar-separator): New defconst.
diff --git a/lisp/subr.el b/lisp/subr.el
index bb3b37ebbf..fb832608cd 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1218,6 +1218,8 @@ add-hook
(setq hook-value (list hook-value)))
;; Do the actual addition if necessary
(unless (member function hook-value)
+ (when (stringp function)
+ (setq function (purecopy function)))
(setq hook-value
(if append
(append hook-value (list function))
@@ -1660,14 +1662,14 @@ eval-after-load
;; Add this FORM into after-load-alist (regardless of whether we'll be
;; evaluating it now).
(let* ((regexp-or-feature
- (if (stringp file) (load-history-regexp file) file))
+ (if (stringp file) (setq file (purecopy (load-history-regexp file))) file))
(elt (assoc regexp-or-feature after-load-alist)))
(unless elt
(setq elt (list regexp-or-feature))
(push elt after-load-alist))
;; Add FORM to the element unless it's already there.
(unless (member form (cdr elt))
- (nconc elt (list form)))
+ (nconc elt (purecopy (list form))))
;; Is there an already loaded file whose name (or `provide' name)
;; matches FILE?
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-04-30 19:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-30 19:59 purecopying strings in add-hook? Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.