APPROVE COMMIT
NOTE: This patch has been committed.
# HG changeset patch
# User Aidan Kehoe <kehoea(a)parhasard.net>
# Date 1377108179 -3600
# Node ID dbd8305e13cb9a6c21902aab3214fb11fb15fb99
# Parent 70a3f4ff8da87bd643770856e4ef0e437abc056e
Warn about non-string non-integer ARG to #'gensym, bytecomp.el.
lisp/ChangeLog addition:
2013-08-21 Aidan Kehoe <kehoea(a)parhasard.net>
* bytecomp.el:
* bytecomp.el (gensym):
* bytecomp.el (byte-compile-gensym): New.
Warn that gensym called in a for-effect context is unlikely to be
useful.
Warn about non-string non-integer ARGs, this is incorrect.
Am not changing the function to error with same, most code that
makes the mistake is has no problems, which is why it has survived
so long.
* window-xemacs.el (save-window-excursion/mapping):
* window.el (save-window-excursion):
Call #'gensym with a string, not a symbol.
diff -r 70a3f4ff8da8 -r dbd8305e13cb lisp/ChangeLog
--- a/lisp/ChangeLog Mon Aug 05 17:20:16 2013 +0100
+++ b/lisp/ChangeLog Wed Aug 21 19:02:59 2013 +0100
@@ -1,3 +1,18 @@
+2013-08-21 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * bytecomp.el:
+ * bytecomp.el (gensym):
+ * bytecomp.el (byte-compile-gensym): New.
+ Warn that gensym called in a for-effect context is unlikely to be
+ useful.
+ Warn about non-string non-integer ARGs, this is incorrect.
+ Am not changing the function to error with same, most code that
+ makes the mistake is has no problems, which is why it has survived
+ so long.
+ * window-xemacs.el (save-window-excursion/mapping):
+ * window.el (save-window-excursion):
+ Call #'gensym with a string, not a symbol.
+
2013-08-05 Aidan Kehoe <kehoea(a)parhasard.net>
* isearch-mode.el (isearch-pre-command-hook):
diff -r 70a3f4ff8da8 -r dbd8305e13cb lisp/bytecomp.el
--- a/lisp/bytecomp.el Mon Aug 05 17:20:16 2013 +0100
+++ b/lisp/bytecomp.el Wed Aug 21 19:02:59 2013 +0100
@@ -4111,6 +4111,7 @@
(byte-defop-compiler-1 integerp)
(byte-defop-compiler-1 eql)
(byte-defop-compiler-1 fillarray)
+(byte-defop-compiler-1 gensym)
(defun byte-compile-progn (form)
(byte-compile-body-do-effect (cdr form)))
@@ -4399,6 +4400,19 @@
(byte-compile-out-tag donetag))
(byte-compile-subr-wrong-args form 2)))
+(defun byte-compile-gensym (form)
+ (when for-effect
+ (byte-compile-warn "%s: %S: called for-effect, unlikely to be useful"
+ (car form) form))
+ (when (and (cdr form) (cl-const-expr-p (nth 1 form))
+ (not (typep (cl-const-expr-val (nth 1 form) '#:not-constant)
+ '(or string integer))))
+ (byte-compile-warn "%s: %s: only strings and integers valid for ARG"
+ (car form)
+ (let ((print-readably t))
+ (prin1-to-string (nth 1 form)))))
+ (byte-compile-normal-call form))
+
;;(byte-defop-compiler-1 /= byte-compile-negated)
(byte-defop-compiler-1 atom byte-compile-negated)
(byte-defop-compiler-1 nlistp byte-compile-negated)
diff -r 70a3f4ff8da8 -r dbd8305e13cb lisp/window-xemacs.el
--- a/lisp/window-xemacs.el Mon Aug 05 17:20:16 2013 +0100
+++ b/lisp/window-xemacs.el Wed Aug 21 19:02:59 2013 +0100
@@ -355,8 +355,8 @@
to them in the restored configuration. It does not include entries for
windows that have not changed identity.
Does not restore the value of point in current buffer."
- (let ((window-config (gensym 'window-config))
- (mapping (gensym 'mapping)))
+ (let ((window-config (gensym "window-config"))
+ (mapping (gensym "mapping")))
`(let ((,window-config (current-window-configuration))
(,mapping))
(unwind-protect
diff -r 70a3f4ff8da8 -r dbd8305e13cb lisp/window.el
--- a/lisp/window.el Mon Aug 05 17:20:16 2013 +0100
+++ b/lisp/window.el Wed Aug 21 19:02:59 2013 +0100
@@ -202,7 +202,7 @@
Restores which buffer appears in which window, where display starts,
as well as the current buffer.
Does not restore the value of point in current buffer."
- (let ((window-config (gensym 'window-config)))
+ (let ((window-config (gensym "window-config")))
`(let ((,window-config (current-window-configuration)))
(unwind-protect
(progn ,@body)
--
‘Liston operated so fast that he once accidentally amputated an assistant’s
fingers along with a patient’s leg, […] The patient and the assistant both
died of sepsis, and a spectator reportedly died of shock, resulting in the
only known procedure with a 300% mortality.’ (Atul Gawande, NEJM, 2012)
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches