(mode-local-map-file-buffers
(lambda ()
;; Make sure variables are set up for this mode.
- (activate-mode-local-bindings)
+ (mode-local--activate-bindings)
(run-hooks 'mode-local-init-hook))
(lambda ()
(not (mode-local-initialized-p)))
\f
;;; Mode lineage
;;
-(defsubst set-mode-local-parent (mode parent)
+(define-obsolete-function-alias 'set-mode-local-parent
+ #'mode-local--set-parent "27.1")
+(defsubst mode-local--set-parent (mode parent)
"Set parent of major mode MODE to PARENT mode.
To work properly, this function should be called after PARENT mode
local variables have been defined."
;; Refresh mode bindings to get mode local variables inherited from
;; PARENT. To work properly, the following should be called after
;; PARENT mode local variables have been defined.
- (mode-local-map-mode-buffers #'activate-mode-local-bindings mode))
+ (mode-local-map-mode-buffers #'mode-local--activate-bindings mode))
(defmacro define-child-mode (mode parent &optional _docstring)
"Make major mode MODE inherit behavior from PARENT mode.
DOCSTRING is optional and not used.
To work properly, this should be put after PARENT mode local variables
definition."
- `(set-mode-local-parent ',mode ',parent))
+ (declare (obsolete define-derived-mode "27.1"))
+ `(mode-local--set-parent ',mode ',parent))
(defun mode-local-use-bindings-p (this-mode desired-mode)
"Return non-nil if THIS-MODE can use bindings of DESIRED-MODE."
(defvar mode-local-active-mode nil
"Major mode in which bindings are active.")
-(defsubst new-mode-local-bindings ()
+(define-obsolete-function-alias 'new-mode-local-bindings
+ #'mode-local--new-bindings "27.1")
+(defsubst mode-local--new-bindings ()
"Return a new empty mode bindings symbol table."
- (make-vector 13 0))
+ (obarray-make 13))
(defun mode-local-bind (bindings &optional plist mode)
"Define BINDINGS in the specified environment.
;; Install in given MODE symbol table. Create a new one if
;; needed.
(setq table (or (get mode 'mode-local-symbol-table)
- (new-mode-local-bindings)))
+ (mode-local--new-bindings)))
(put mode 'mode-local-symbol-table table))
;; Fail if trying to bind mode variables in local context!
(if (plist-get plist 'mode-variable-flag)
;; needed.
(setq table (or mode-local-symbol-table
(setq mode-local-symbol-table
- (new-mode-local-bindings)))))
+ (mode-local--new-bindings)))))
(while bindings
(setq binding (car bindings)
bindings (cdr bindings)
\f
;;; Mode local variables
;;
-(defun activate-mode-local-bindings (&optional mode)
+(define-obsolete-function-alias 'activate-mode-local-bindings
+ #'mode-local--activate-bindings "27.1")
+(defun mode-local--activate-bindings (&optional mode)
"Activate variables defined locally in MODE and its parents.
That is, copy mode local bindings into corresponding buffer local
variables.
table)))
old-locals)))
-(defun deactivate-mode-local-bindings (&optional mode)
+(define-obsolete-function-alias 'deactivate-mode-local-bindings
+ #'mode-local--deactivate-bindings "27.1")
+(defun mode-local--deactivate-bindings (&optional mode)
"Deactivate variables defined locally in MODE and its parents.
That is, kill buffer local variables set from the corresponding mode
local bindings.
)
(unwind-protect
(progn
- (deactivate-mode-local-bindings ,old-mode)
+ (mode-local--deactivate-bindings ,old-mode)
(setq mode-local-active-mode ,new-mode)
;; Save the previous value of buffer-local variables
- ;; changed by `activate-mode-local-bindings'.
- (setq ,old-locals (activate-mode-local-bindings ,new-mode))
+ ;; changed by `mode-local--activate-bindings'.
+ (setq ,old-locals (mode-local--activate-bindings ,new-mode))
,@body)
- (deactivate-mode-local-bindings ,new-mode)
+ (mode-local--deactivate-bindings ,new-mode)
;; Restore the previous value of buffer-local variables.
(dolist (,local ,old-locals)
(set (car ,local) (cdr ,local)))
;; Restore the mode local variables.
(setq mode-local-active-mode ,old-mode)
- (activate-mode-local-bindings ,old-mode)))))
+ (mode-local--activate-bindings ,old-mode)))))
(defmacro with-mode-local (mode &rest body)
"With the local bindings of MODE, evaluate BODY.
(defun make-obsolete-overload (old new when)
"Mark OLD overload as obsoleted by NEW overload.
WHEN is a string describing the first release where it was made obsolete."
- (put old 'overload-obsoleted-by new)
- (put old 'overload-obsoleted-since when)
+ (put old 'mode-local--overload-obsoleted-by new)
+ (put old 'mode-local--overload-obsoleted-since when)
(put old 'mode-local-overload t)
- (put new 'overload-obsolete old))
+ (put new 'mode-local--overload-obsolete old))
-(defsubst overload-obsoleted-by (overload)
+(define-obsolete-function-alias 'overload-obsoleted-by
+ #'mode-local--overload-obsoleted-by "27.1")
+(defsubst mode-local--overload-obsoleted-by (overload)
"Get the overload symbol obsoleted by OVERLOAD.
Return the obsolete symbol or nil if not found."
- (get overload 'overload-obsolete))
+ (get overload 'mode-local--overload-obsolete))
-(defsubst overload-that-obsolete (overload)
+(define-obsolete-function-alias 'overload-that-obsolete
+ #'mode-local--overload-that-obsolete "27.1")
+(defsubst mode-local--overload-that-obsolete (overload)
"Return the overload symbol that obsoletes OVERLOAD.
Return the symbol found or nil if OVERLOAD is not obsolete."
- (get overload 'overload-obsoleted-by))
+ (get overload 'mode-local--overload-obsoleted-by))
(defsubst fetch-overload (overload)
"Return the current OVERLOAD function, or nil if not found.
in those bound in current `major-mode' and its parents."
(or (mode-local-symbol-value overload nil 'override-flag)
;; If an obsolete overload symbol exists, try it.
- (and (overload-obsoleted-by overload)
+ (and (mode-local--overload-obsoleted-by overload)
(mode-local-symbol-value
- (overload-obsoleted-by overload) nil 'override-flag))))
+ (mode-local--overload-obsoleted-by overload) nil 'override-flag))))
(defun mode-local--override (name args body)
"Return the form that handles overloading of function NAME.
(define-obsolete-function-alias 'define-overload
'define-overloadable-function "27.1")
-(defsubst function-overload-p (symbol)
+(define-obsolete-function-alias 'function-overload-p
+ #'mode-local--function-overload-p "27.1")
+(defsubst mode-local--function-overload-p (symbol)
"Return non-nil if SYMBOL is a function which can be overloaded."
(and symbol (symbolp symbol) (get symbol 'mode-local-overload)))
(defun mode-local-read-function (prompt &optional initial hist default)
"Interactively read in the name of a mode-local function.
PROMPT, INITIAL, HIST, and DEFAULT are the same as for `completing-read'."
- (completing-read prompt obarray 'function-overload-p t initial hist default))
+ (declare (obsolete nil "27.1"))
+ (completing-read prompt obarray #'mode-local--function-overload-p t initial hist default))
\f
;;; Help support
;;
-(defun overload-docstring-extension (overload)
+(define-obsolete-function-alias 'overload-docstring-extension
+ #'mode-local--overload-docstring-extension "27.1")
+(defun mode-local--overload-docstring-extension (overload)
"Return the doc string that augments the description of OVERLOAD."
(let ((doc "\nThis function can be overloaded\
with `define-mode-local-override'.")
- (sym (overload-obsoleted-by overload)))
+ (sym (mode-local--overload-obsoleted-by overload)))
(when sym
(setq doc (format "%s\nIt has made the overload `%s' obsolete since %s."
- doc sym (get sym 'overload-obsoleted-since))))
- (setq sym (overload-that-obsolete overload))
+ doc sym
+ (get sym 'mode-local--overload-obsoleted-since))))
+ (setq sym (mode-local--overload-that-obsolete overload))
(when sym
- (setq doc (format "%s\nThis overload is obsolete since %s;\nUse `%s' instead."
- doc (get overload 'overload-obsoleted-since) sym)))
+ (setq doc (format
+ "%s\nThis overload is obsolete since %s;\nUse `%s' instead."
+ doc (get overload 'mode-local--overload-obsoleted-since) sym)))
doc))
(defun mode-local-augment-function-help (symbol)
(beginning-of-line)
(forward-line -1))
(let ((inhibit-read-only t))
- (insert (substitute-command-keys (overload-docstring-extension symbol))
+ (insert (substitute-command-keys (mode-local--overload-docstring-extension symbol))
"\n")
;; NOTE TO SELF:
;; LIST ALL LOADED OVERRIDES FOR SYMBOL HERE
;; We are called from describe-function in help-fns.el, where this is defined.
(defvar describe-function-orig-buffer)
-(defun describe-mode-local-overload (symbol)
+(defun mode-local--describe-overload (symbol)
"For `help-fns-describe-function-functions'; add overloads for SYMBOL."
- (when (function-overload-p symbol)
+ (when (mode-local--function-overload-p symbol)
(let ((default (or (intern-soft (format "%s-default" (symbol-name symbol)))
symbol))
(override (with-current-buffer describe-function-orig-buffer
(fetch-overload symbol)))
modes)
- (insert (substitute-command-keys (overload-docstring-extension symbol))
+ (insert (substitute-command-keys (mode-local--overload-docstring-extension symbol))
"\n\n")
(insert (format-message "default function: `%s'\n" default))
(if override
)))
)))
-(add-hook 'help-fns-describe-function-functions #'describe-mode-local-overload)
+(add-hook 'help-fns-describe-function-functions #'mode-local--describe-overload)
(declare-function xref-item-location "xref" (xref) t)
(defun xref-mode-local-overload (symbol)
"For `elisp-xref-find-def-functions'; add overloads for SYMBOL."
;; Current buffer is the buffer where xref-find-definitions was invoked.
- (when (function-overload-p symbol)
+ (when (mode-local--function-overload-p symbol)
(let* ((symbol-file (find-lisp-object-file-name
symbol (symbol-function symbol)))
(default (intern-soft (format "%s-default" (symbol-name symbol))))