mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
Several amendments to scratch/correct-warning-pos.
The position return by read-positioning-symbols is now the position in the buffer, rather than the offset from the start of a form, enabling warning positions in other parts of the buffer to be output. * src/lisp.h (lisp_h_EQ): Add XLI casts so that it compiles cleanly. * src/data.c (Fremove_pos_from_symbol): New DEFUN. * src/lread.c (readchar_count): renamed to readchar_offset. (read_internal_start) Initialize readchar_offset to the buffer's point when STREAM is a buffer. * lisp/emacs-lisp/bytecomp.el (byte-compile-warning-prefix): Amend to use OFFSET as a buffer position, not an offset from the start of a form. (byte-compile-warn): Remove symbol positions from any shape of ARGS, not just a symbol with position. * lisp/emacs-lisp/cconv.c (cconv-convert): In the :unused case, position the new IGNORE symbol with the VAR it has replaced. * lisp/emacs-lisp/macroexp.el (macroexp--warn-wrap, macroexp-warn-and-return): Add an extra position parameter to each. * lisp/emacs-lisp/bindat.el (bindat-type), lisp/emacs-lisp/byte-run.el (defmacro, defun), lisp/emacs-lisp/cconv.el (cconv--convert-func-body) (cconv-convert), lisp/emacs-lisp/cl-generic.el (cl-defmethod), lisp/emacs-lisp/cl-macs.el (cl-symbol-macrolet, cl-defstruct), lisp/emacs-lisp/easy-mmode.el (define-minor-mode), lisp/emacs-lisp/eieio-core.el (eieio-oref, eieio-oref-default) (eieio-oset-default), lisp/emacs-lisp/eieio.el (defclass), lisp/emacs-lisp/gv.el (gv-ref), lisp/emacs-lisp/macroexp.el (macroexp-macroexpand, macroexp--unfold-lambda, macroexp--expand-all), lisp/emacs-lisp/pcase.el (pcase-compile-patterns, pcase--u1): Add an extra position argument to each call of macroexp-warn-and-return.
This commit is contained in:
parent
368570b3fd
commit
8f1106ddf2
15 changed files with 66 additions and 47 deletions
|
|
@ -258,11 +258,11 @@ Returns a form where all lambdas don't have any free variables."
|
|||
;; unused vars.
|
||||
(not (intern-soft var))
|
||||
(eq ?_ (aref (symbol-name var) 0))
|
||||
;; As a special exception, ignore "ignore".
|
||||
;; As a special exception, ignore "ignored".
|
||||
(eq var 'ignored))
|
||||
(let ((suggestions (help-uni-confusable-suggestions (symbol-name var))))
|
||||
(format "Unused lexical %s `%S'%s"
|
||||
varkind var
|
||||
varkind (bare-symbol var)
|
||||
(if suggestions (concat "\n " suggestions) "")))))
|
||||
|
||||
(define-inline cconv--var-classification (binder form)
|
||||
|
|
@ -286,7 +286,7 @@ of converted forms."
|
|||
(let (and (pred stringp) msg)
|
||||
(cconv--warn-unused-msg arg "argument")))
|
||||
(if (assq arg env) (push `(,arg . nil) env)) ;FIXME: Is it needed?
|
||||
(push (lambda (body) (macroexp--warn-wrap msg body 'lexical)) wrappers))
|
||||
(push (lambda (body) (macroexp--warn-wrap body msg body 'lexical)) wrappers))
|
||||
(_
|
||||
(if (assq arg env) (push `(,arg . nil) env)))))
|
||||
(setq funcbody (mapcar (lambda (form)
|
||||
|
|
@ -414,11 +414,14 @@ places where they originally did not directly appear."
|
|||
;; Declared variable is unused.
|
||||
(if (assq var new-env)
|
||||
(push `(,var) new-env)) ;FIXME:Needed?
|
||||
(let ((newval
|
||||
`(ignore ,(cconv-convert value env extend)))
|
||||
(msg (cconv--warn-unused-msg var "variable")))
|
||||
(let* ((Ignore (if (symbol-with-pos-p var)
|
||||
(position-symbol 'ignore var)
|
||||
'ignore))
|
||||
(newval `(,Ignore
|
||||
,(cconv-convert value env extend)))
|
||||
(msg (cconv--warn-unused-msg var "variable")))
|
||||
(if (null msg) newval
|
||||
(macroexp--warn-wrap msg newval 'lexical))))
|
||||
(macroexp--warn-wrap var msg newval 'lexical))))
|
||||
|
||||
;; Normal default case.
|
||||
(_
|
||||
|
|
@ -517,7 +520,7 @@ places where they originally did not directly appear."
|
|||
(newprotform (cconv-convert protected-form env extend)))
|
||||
`(condition-case ,var
|
||||
,(if msg
|
||||
(macroexp--warn-wrap msg newprotform 'lexical)
|
||||
(macroexp--warn-wrap var msg newprotform 'lexical)
|
||||
newprotform)
|
||||
,@(mapcar
|
||||
(lambda (handler)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue