\f
* Changes in Specialized Modes and Packages in Emacs 29.1
-** CEDET
----
-*** Deprecate buffer-local function overrides for mode-local functions
-
** Enriched Mode
+++
;; 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:
(defun mode-local-bind (bindings &optional plist mode)
"Define BINDINGS in the specified environment.
BINDINGS is a list of (VARIABLE . VALUE).
-Argument PLIST is a property list each VARIABLE symbol will
+Optional 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.
- `override-flag' if non-nil, define override functions.
The `override-flag' and `mode-variable-flag' properties are mutually
-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.
+exclusive.
-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"))
+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."
;; Check plist consistency
(and (plist-get plist 'mode-variable-flag)
(plist-get plist 'override-flag)
;; 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
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)
(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
OVERRIDES will be installed globally for this major mode. If MODE is
nil, OVERRIDES will be installed locally in the current buffer. This
later installation should be done in MODE hook."
- (declare (obsolete define-mode-local-override "29.1"))
- (with-suppressed-warnings ((callargs mode-local-bind))
- (mode-local-bind
- ;; Add the semantic- prefix to OVERLOAD short names.
- (mapcar
- (lambda (e)
- (let ((name (symbol-name (car e))))
- (if (string-match "^semantic-" name)
- e
- (cons (intern (format "semantic-%s" name)) (cdr e)))))
- overrides)
- (list 'constant-flag (not transient)
- 'override-flag t))))
+ (mode-local-bind
+ ;; Add the semantic- prefix to OVERLOAD short names.
+ (mapcar
+ (lambda (e)
+ (let ((name (symbol-name (car e))))
+ (if (string-match "^semantic-" name)
+ e
+ (cons (intern (format "semantic-%s" name)) (cdr e)))))
+ overrides
+ nil)
+ (list 'constant-flag (not transient)
+ 'override-flag t)))
\f
;;; User Interrupt handling
;;
(unless (derived-mode-p 'emacs-lisp-mode)
(emacs-lisp-mode))
- ;; Header + Prologue
+;;;; Header + Prologue
(insert header
"\f\n;;; Prologue\n;;\n"
(save-excursion
- ;; Declarations
+;;;; Declarations
(insert "\f\n;;; Declarations\n;;\n")
(semantic-grammar-setup-data))
"Setup the Semantic Parser.")
- ;; Analyzers
+;;;; Analyzers
(insert "\f\n;;; Analyzers\n;;\n")
(semantic-grammar-insert-defanalyzers)
- ;; Epilogue & Footer
+;;;; Epilogue & Footer
(insert "\f\n;;; Epilogue\n;;\n"
epilogue
;; have created this language for, and force them to call our
;; setup function again, refreshing all semantic data, and
;; enabling them to work with the new code just created.
- ;; FIXME?
+;;;; FIXME?
;; At this point, I don't know any user's defined setup code :-(
;; At least, what I can do for now, is to run the generated
;; parser-install function.
(defun semantic-grammar-wy--install-parser ()
"Setup the Semantic Parser."
+ (semantic-install-function-overrides
+ '((semantic-parse-stream . wisent-parse-stream)))
(setq semantic-parser-name "LALR"
semantic--parse-table semantic-grammar-wy--parse-table
semantic-debug-parser-source "grammar.wy"
;; Maybe the latter is faster because it eliminates a lot of function
;; call.
;;
-;; Emacs<29 generated grammars which manually setup `wisent-parse-stream'
-;; as a buffer-local overload for `semantic-parse-stream', but we don't
-;; need that now that we define a mode-local overload instead.
-(define-obsolete-function-alias 'wisent-parse-stream
- #'wisent--parse-stream "29.1"
- "Recompile your grammars so they don't call `wisent-parse-stream' any more.")
-(define-mode-local-override semantic-parse-stream semantic-grammar-mode
- (stream goal)
- "Parse STREAM using the Wisent LALR parser.
-See `wisent--parse-stream'."
- (wisent--parse-stream stream goal))
-(defun wisent--parse-stream (stream goal)
+(defun wisent-parse-stream (stream goal)
"Parse STREAM using the Wisent LALR parser.
GOAL is a nonterminal symbol to start parsing at.
Return the list (STREAM SEMANTIC-STREAM) where STREAM are those
elements of STREAM that have not been used. SEMANTIC-STREAM is the
list of semantic tags found.
The LALR parser automaton must be available in buffer local variable
-`semantic--parse-table'."
+`semantic--parse-table'.
+
+Must be installed by `semantic-install-function-overrides' to override
+the standard function `semantic-parse-stream'."
(let (wisent-lex-istream wisent-lex-lookahead la-elt cache)
;; IMPLEMENTATION NOTES:
DEPTH is the lexical depth to scan, and RETURNONERROR is a flag to
stop parsing on syntax error, when non-nil.
The LALR parser automaton must be available in buffer local variable
-`semantic--parse-table'."
+`semantic--parse-table'.
+
+Must be installed by `semantic-install-function-overrides' to override
+the standard function `semantic-parse-region'."
(if (or (< start (point-min)) (> end (point-max)) (< end start))
(error "Invalid bounds [%s %s] passed to `wisent-parse-region'"
start end))
wisent-grammar-mode ()
"Return the parser setup code."
(format
- "(setq semantic-parser-name \"LALR\"\n\
+ "(semantic-install-function-overrides\n\
+ '((semantic-parse-stream . wisent-parse-stream)))\n\
+ (setq semantic-parser-name \"LALR\"\n\
semantic--parse-table %s\n\
semantic-debug-parser-source %S\n\
semantic-flex-keywords-obarray %s\n\