Mercurial > hg > xemacs-beta
changeset 5753:dbd8305e13cb
Warn about non-string non-integer ARG to #'gensym, bytecomp.el.
lisp/ChangeLog addition:
2013-08-21 Aidan Kehoe <kehoea@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.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Wed, 21 Aug 2013 19:02:59 +0100 |
parents | 70a3f4ff8da8 |
children | b09e3b1b7424 |
files | lisp/ChangeLog lisp/bytecomp.el lisp/window-xemacs.el lisp/window.el |
diffstat | 4 files changed, 32 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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@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@parhasard.net> * isearch-mode.el (isearch-pre-command-hook):
--- 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)
--- 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
--- 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)