derived.el: Delete old code (bug#68625)

* lisp/emacs-lisp/derived.el (derived-mode-setup-function-name)
(derived-mode-init-mode-variables, derived-mode-set-keymap)
(derived-mode-set-syntax-table, derived-mode-set-abbrev-table)
(derived-mode-run-hooks, derived-mode-merge-keymaps)
(derived-mode-merge-syntax-tables, derived-mode-merge-abbrev-tables):
Delete functions.
This commit is contained in:
Stefan Monnier 2024-01-29 19:04:59 -05:00
parent e625f2044a
commit c385e966e1
2 changed files with 10 additions and 131 deletions

View file

@ -1370,6 +1370,16 @@ files and save the changes.
* Incompatible Lisp Changes in Emacs 30.1
---
** Old 'derived.el' functions removed.
The following functions have been deleted because they were only used
by code compiled with Emacs<21:
'derived-mode-setup-function-name', 'derived-mode-init-mode-variables',
'derived-mode-set-keymap', 'derived-mode-set-syntax-table',
'derived-mode-set-abbrev-table', 'derived-mode-run-hooks',
'derived-mode-merge-keymaps', 'derived-mode-merge-syntax-tables',
'derived-mode-merge-abbrev-tables'.
+++
** 'M-TAB' now invokes 'completion-at-point' also in Text mode.
By default, Text mode no longer binds 'M-TAB' to

View file

@ -365,137 +365,6 @@ which more-or-less shadow%s %s's corresponding table%s."
docstring))
;;; OBSOLETE
;; The functions below are only provided for backward compatibility with
;; code byte-compiled with versions of derived.el prior to Emacs-21.
(defsubst derived-mode-setup-function-name (mode)
"Construct a setup-function name based on a MODE name."
(declare (obsolete nil "28.1"))
(intern (concat (symbol-name mode) "-setup")))
;; Utility functions for defining a derived mode.
;;;###autoload
(defun derived-mode-init-mode-variables (mode)
"Initialize variables for a new MODE.
Right now, if they don't already exist, set up a blank keymap, an
empty syntax table, and an empty abbrev table -- these will be merged
the first time the mode is used."
(if (boundp (derived-mode-map-name mode))
t
(eval `(defvar ,(derived-mode-map-name mode)
(make-sparse-keymap)
,(format "Keymap for %s." mode)))
(put (derived-mode-map-name mode) 'derived-mode-unmerged t))
(if (boundp (derived-mode-syntax-table-name mode))
t
(eval `(defvar ,(derived-mode-syntax-table-name mode)
;; Make a syntax table which doesn't specify anything
;; for any char. Valid data will be merged in by
;; derived-mode-merge-syntax-tables.
(make-char-table 'syntax-table nil)
,(format "Syntax table for %s." mode)))
(put (derived-mode-syntax-table-name mode) 'derived-mode-unmerged t))
(if (boundp (derived-mode-abbrev-table-name mode))
t
(eval `(defvar ,(derived-mode-abbrev-table-name mode)
(progn
(define-abbrev-table (derived-mode-abbrev-table-name ',mode) nil)
(make-abbrev-table))
,(format "Abbrev table for %s." mode)))))
;; Utility functions for running a derived mode.
(defun derived-mode-set-keymap (mode)
"Set the keymap of the new MODE, maybe merging with the parent."
(let* ((map-name (derived-mode-map-name mode))
(new-map (eval map-name))
(old-map (current-local-map)))
(and old-map
(get map-name 'derived-mode-unmerged)
(derived-mode-merge-keymaps old-map new-map))
(put map-name 'derived-mode-unmerged nil)
(use-local-map new-map)))
(defun derived-mode-set-syntax-table (mode)
"Set the syntax table of the new MODE, maybe merging with the parent."
(let* ((table-name (derived-mode-syntax-table-name mode))
(old-table (syntax-table))
(new-table (eval table-name)))
(if (get table-name 'derived-mode-unmerged)
(derived-mode-merge-syntax-tables old-table new-table))
(put table-name 'derived-mode-unmerged nil)
(set-syntax-table new-table)))
(defun derived-mode-set-abbrev-table (mode)
"Set the abbrev table for MODE if it exists.
Always merge its parent into it, since the merge is non-destructive."
(let* ((table-name (derived-mode-abbrev-table-name mode))
(old-table local-abbrev-table)
(new-table (eval table-name)))
(derived-mode-merge-abbrev-tables old-table new-table)
(setq local-abbrev-table new-table)))
(defun derived-mode-run-hooks (mode)
"Run the mode hook for MODE."
(let ((hooks-name (derived-mode-hook-name mode)))
(if (boundp hooks-name)
(run-hooks hooks-name))))
;; Functions to merge maps and tables.
(defun derived-mode-merge-keymaps (old new)
"Merge an OLD keymap into a NEW one.
The old keymap is set to be the last cdr of the new one, so that there will
be automatic inheritance."
;; ?? Can this just use `set-keymap-parent'?
(let ((tail new))
;; Scan the NEW map for prefix keys.
(while (consp tail)
(and (consp (car tail))
(let* ((key (vector (car (car tail))))
(subnew (lookup-key new key))
(subold (lookup-key old key)))
;; If KEY is a prefix key in both OLD and NEW, merge them.
(and (keymapp subnew) (keymapp subold)
(derived-mode-merge-keymaps subold subnew))))
(and (vectorp (car tail))
;; Search a vector of ASCII char bindings for prefix keys.
(let ((i (1- (length (car tail)))))
(while (>= i 0)
(let* ((key (vector i))
(subnew (lookup-key new key))
(subold (lookup-key old key)))
;; If KEY is a prefix key in both OLD and NEW, merge them.
(and (keymapp subnew) (keymapp subold)
(derived-mode-merge-keymaps subold subnew)))
(setq i (1- i)))))
(setq tail (cdr tail))))
(setcdr (nthcdr (1- (length new)) new) old))
(defun derived-mode-merge-syntax-tables (old new)
"Merge an OLD syntax table into a NEW one.
Where the new table already has an entry, nothing is copied from the old one."
(set-char-table-parent new old))
;; Merge an old abbrev table into a new one.
;; This function requires internal knowledge of how abbrev tables work,
;; presuming that they are obarrays with the abbrev as the symbol, the expansion
;; as the value of the symbol, and the hook as the function definition.
(defun derived-mode-merge-abbrev-tables (old new)
(if old
(mapatoms
(lambda (symbol)
(or (intern-soft (symbol-name symbol) new)
(define-abbrev new (symbol-name symbol)
(symbol-value symbol) (symbol-function symbol))))
old)))
(provide 'derived)
;;; derived.el ends here