aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/lispref/variables.texi10
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/emacs-lisp/byte-run.el1
-rw-r--r--lisp/emacs-lisp/bytecomp.el30
-rw-r--r--lisp/emacs-lisp/gv.el15
5 files changed, 48 insertions, 13 deletions
diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi
index 242b1a3be93..ed119a709c5 100644
--- a/doc/lispref/variables.texi
+++ b/doc/lispref/variables.texi
@@ -2822,6 +2822,16 @@ expression manipulating @var{place} via @var{getter} and @var{setter}.
2822 2822
2823Consult the source file @file{gv.el} for more details. 2823Consult the source file @file{gv.el} for more details.
2824 2824
2825@defun make-obsolete-generalized-variable obsolete-name current-name when
2826This function makes the byte compiler warn that the generalized
2827variable @var{obsolete-name} is obsolete. If @var{current-name} is a
2828symbol, then the warning message says to use @var{current-name}
2829instead of @var{obsolete-name}. If @var{current-name} is a string,
2830this is the message. @var{when} should be a string indicating when
2831the variable was first made obsolete (usually a version number
2832string).
2833@end defun
2834
2825@cindex CL note---no @code{setf} functions 2835@cindex CL note---no @code{setf} functions
2826@quotation 2836@quotation
2827@b{Common Lisp note:} Common Lisp defines another way to specify the 2837@b{Common Lisp note:} Common Lisp defines another way to specify the
diff --git a/etc/NEWS b/etc/NEWS
index c41b7ac6e82..2f68472163e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2589,6 +2589,11 @@ patcomp.el, pc-mode.el, pc-select.el, s-region.el, and sregex.el.
2589* Lisp Changes in Emacs 29.1 2589* Lisp Changes in Emacs 29.1
2590 2590
2591+++ 2591+++
2592** New function 'make-obsolete-generalized-variable'.
2593This can be used to mark setters used by 'setf' as obsolete, and the
2594byte-compiler will then warn about using them.
2595
2596+++
2592** New functions 'pos-eol' and 'pos-bol'. 2597** New functions 'pos-eol' and 'pos-bol'.
2593These are like 'line-end-position' and 'line-beginning-position' 2598These are like 'line-end-position' and 'line-beginning-position'
2594(respectively), but ignore fields (and are more efficient). 2599(respectively), but ignore fields (and are more efficient).
diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el
index 4a2860cd43d..9a56ba0f7ad 100644
--- a/lisp/emacs-lisp/byte-run.el
+++ b/lisp/emacs-lisp/byte-run.el
@@ -568,7 +568,6 @@ ACCESS-TYPE if non-nil should specify the kind of access that will trigger
568 (purecopy (list current-name access-type when))) 568 (purecopy (list current-name access-type when)))
569 obsolete-name) 569 obsolete-name)
570 570
571
572(defmacro define-obsolete-variable-alias ( obsolete-name current-name when 571(defmacro define-obsolete-variable-alias ( obsolete-name current-name when
573 &optional docstring) 572 &optional docstring)
574 "Make OBSOLETE-NAME a variable alias for CURRENT-NAME and mark it obsolete. 573 "Make OBSOLETE-NAME a variable alias for CURRENT-NAME and mark it obsolete.
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 1115ce391d4..5dde2d2bfbb 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1355,16 +1355,22 @@ FORMAT and ARGS are as in `byte-compile-warn'."
1355 (let ((byte-compile-form-stack (cons arg byte-compile-form-stack))) 1355 (let ((byte-compile-form-stack (cons arg byte-compile-form-stack)))
1356 (apply #'byte-compile-warn format args))) 1356 (apply #'byte-compile-warn format args)))
1357 1357
1358(defun byte-compile-warn-obsolete (symbol) 1358(defun byte-compile-warn-obsolete (symbol type)
1359 "Warn that SYMBOL (a variable or function) is obsolete." 1359 "Warn that SYMBOL (a variable, function or generalized variable) is obsolete.
1360TYPE is a string that say which one of these three types it is."
1360 (when (byte-compile-warning-enabled-p 'obsolete symbol) 1361 (when (byte-compile-warning-enabled-p 'obsolete symbol)
1361 (let* ((funcp (get symbol 'byte-obsolete-info)) 1362 (byte-compile-warn-x
1362 (msg (macroexp--obsolete-warning 1363 symbol "%s"
1363 symbol 1364 (macroexp--obsolete-warning
1364 (or funcp (get symbol 'byte-obsolete-variable)) 1365 symbol
1365 (if funcp "function" "variable")))) 1366 (pcase type
1366 (unless (and funcp (memq symbol byte-compile-not-obsolete-funcs)) 1367 ("function"
1367 (byte-compile-warn-x symbol "%s" msg))))) 1368 (get symbol 'byte-obsolete-info))
1369 ("variable"
1370 (get symbol 'byte-obsolete-variable))
1371 ("generalized variable"
1372 (get symbol 'byte-obsolete-generalized-variable)))
1373 type))))
1368 1374
1369(defun byte-compile-report-error (error-info &optional fill) 1375(defun byte-compile-report-error (error-info &optional fill)
1370 "Report Lisp error in compilation. 1376 "Report Lisp error in compilation.
@@ -1468,8 +1474,8 @@ when printing the error message."
1468 1474
1469(defun byte-compile-function-warn (f nargs def) 1475(defun byte-compile-function-warn (f nargs def)
1470 (when (and (get f 'byte-obsolete-info) 1476 (when (and (get f 'byte-obsolete-info)
1471 (byte-compile-warning-enabled-p 'obsolete f)) 1477 (not (memq f byte-compile-not-obsolete-funcs)))
1472 (byte-compile-warn-obsolete f)) 1478 (byte-compile-warn-obsolete f "function"))
1473 1479
1474 ;; Check to see if the function will be available at runtime 1480 ;; Check to see if the function will be available at runtime
1475 ;; and/or remember its arity if it's unknown. 1481 ;; and/or remember its arity if it's unknown.
@@ -3604,7 +3610,7 @@ lambda-expression."
3604 ('set (not (eq access-type 'reference))) 3610 ('set (not (eq access-type 'reference)))
3605 ('get (eq access-type 'reference)) 3611 ('get (eq access-type 'reference))
3606 (_ t)))) 3612 (_ t))))
3607 (byte-compile-warn-obsolete var)))) 3613 (byte-compile-warn-obsolete var "variable"))))
3608 3614
3609(defsubst byte-compile-dynamic-variable-op (base-op var) 3615(defsubst byte-compile-dynamic-variable-op (base-op var)
3610 (let ((tmp (assq var byte-compile-variables))) 3616 (let ((tmp (assq var byte-compile-variables)))
diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el
index 54ddc7ac757..4618a349262 100644
--- a/lisp/emacs-lisp/gv.el
+++ b/lisp/emacs-lisp/gv.el
@@ -92,6 +92,9 @@ DO must return an Elisp expression."
92 (t 92 (t
93 (let* ((head (car place)) 93 (let* ((head (car place))
94 (gf (function-get head 'gv-expander 'autoload))) 94 (gf (function-get head 'gv-expander 'autoload)))
95 (when (and (symbolp head)
96 (get head 'byte-obsolete-generalized-variable))
97 (byte-compile-warn-obsolete head "generalized variable"))
95 (if gf (apply gf do (cdr place)) 98 (if gf (apply gf do (cdr place))
96 (let ((me (macroexpand-1 place 99 (let ((me (macroexpand-1 place
97 ;; (append macroexpand-all-environment 100 ;; (append macroexpand-all-environment
@@ -616,6 +619,18 @@ REF must have been previously obtained with `gv-ref'."
616 619
617;;; Generalized variables. 620;;; Generalized variables.
618 621
622(defun make-obsolete-generalized-variable (obsolete-name current-name when)
623 "Make byte-compiler warn that generalized variable OBSOLETE-NAME is obsolete.
624The warning will say that CURRENT-NAME should be used instead.
625
626If CURRENT-NAME is a string, that is the `use instead' message.
627
628WHEN should be a string indicating when the variable was first
629made obsolete, for example a date or a release number."
630 (put obsolete-name 'byte-obsolete-generalized-variable
631 (purecopy (list current-name when)))
632 obsolete-name)
633
619;; Some Emacs-related place types. 634;; Some Emacs-related place types.
620(gv-define-simple-setter buffer-file-name set-visited-file-name t) 635(gv-define-simple-setter buffer-file-name set-visited-file-name t)
621(gv-define-setter buffer-modified-p (flag &optional buf) 636(gv-define-setter buffer-modified-p (flag &optional buf)