emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 91bc24c467: mode-local: Deprecate buffer-local overrides


From: Stefan Monnier
Subject: master 91bc24c467: mode-local: Deprecate buffer-local overrides
Date: Sun, 22 May 2022 12:52:52 -0400 (EDT)

branch: master
commit 91bc24c46768aab4a851c87edaea05c7476ff779
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    mode-local: Deprecate buffer-local overrides
    
    * lisp/cedet/mode-local.el (mode-local-bind): Make all args mandatory.
    Deprecate the use of a nil `mode` argument.
---
 etc/NEWS                 |  4 ++++
 lisp/cedet/mode-local.el | 25 ++++++++++++++++---------
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 4331968ba7..0295fbf1f1 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -827,6 +827,10 @@ so automatically.
 
 * Changes in Specialized Modes and Packages in Emacs 29.1
 
+** CEDET
+---
+*** Deprecate buffer-local function overrides for mode-local functions
+
 ** Enriched Mode
 
 +++
diff --git a/lisp/cedet/mode-local.el b/lisp/cedet/mode-local.el
index ce37a28c35..0b24f71dc0 100644
--- a/lisp/cedet/mode-local.el
+++ b/lisp/cedet/mode-local.el
@@ -38,10 +38,12 @@
 ;; user might wish to customize a given variable or function then
 ;; the existing customization mechanism should be used.
 
+;; NOTE: `define-overloadable-function' and `define-mode-local-override' are
+;; nowadays advantageously replaced by `cl-defgeneric' and `cl-defmethod'
+;; (with a `&context (derived-mode <MODE>)').
+
 ;; To Do:
 ;; Allow customization of a variable for a specific mode?
-;;
-;; Add macro for defining the '-default' functionality.
 
 ;;; Code:
 
@@ -187,7 +189,7 @@ behaviors.  Use the function `mode-local-bind' to define 
new bindings.")
 (defun mode-local-bind (bindings &optional plist mode)
   "Define BINDINGS in the specified environment.
 BINDINGS is a list of (VARIABLE . VALUE).
-Optional argument PLIST is a property list each VARIABLE symbol will
+Argument PLIST is a property list each VARIABLE symbol will
 be set to.  The following properties have special meaning:
 
 - `constant-flag' if non-nil, prevent rebinding variables.
@@ -195,13 +197,15 @@ be set to.  The following properties have special meaning:
 - `override-flag' if non-nil, define override functions.
 
 The `override-flag' and `mode-variable-flag' properties are mutually
-exclusive.
+exclusive and exactly one of the two must be non-nil.
+
+Argument MODE must be a major mode symbol.
+BINDINGS will be defined globally for this major mode.
 
-If optional argument MODE is non-nil, it must be a major mode symbol.
-BINDINGS will be defined globally for this major mode.  If MODE is
-nil, BINDINGS will be defined locally in the current buffer, in
-variable `mode-local-symbol-table'.  The later should be done in MODE
-hook."
+For backward compatibility, If MODE is nil, BINDINGS will be defined locally
+in the current buffer, in variable `mode-local-symbol-table', but
+this use is deprecated and will be removed."
+  (declare (advertised-calling-convention (bindings plist mode) "29.1"))
   ;; Check plist consistency
   (and (plist-get plist 'mode-variable-flag)
        (plist-get plist 'override-flag)
@@ -217,6 +221,7 @@ hook."
       ;; Fail if trying to bind mode variables in local context!
       (if (plist-get plist 'mode-variable-flag)
           (error "Mode required to bind mode variables"))
+      (message "Obsolete use of nil MODE arg to mode-local-bind!")
       ;; Install in buffer local symbol table.  Create a new one if
       ;; needed.
       (setq table (or mode-local-symbol-table
@@ -412,6 +417,7 @@ Set each SYM to the value of its VAL, locally in buffers 
already in
 MODE, or in buffers switched to that mode.
 Return the value of the last VAL."
   (declare (debug (symbolp &rest symbolp form)))
+  (unless mode (error "Argument mode should be a major mode"))
   (when args
     (let (i ll bl sl tmp sym val)
       (setq i 0)
@@ -598,6 +604,7 @@ BODY is the implementation of this function."
   (declare (doc-string 4)
            (indent defun)
            (debug (&define name symbolp lambda-list stringp def-body)))
+  (unless mode (error "Argument mode should be a major mode"))
   (let ((newname (intern (format "%s-%s" name mode))))
     `(progn
        (eval-and-compile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]