mode-local: Revert the deprecation of buffer-local overrides
Obviously, I did not understand how the <foo>--install-parser was invoked. Revert "mode-local: Deprecate buffer-local overrides" Revert "semantic-install-function-overrides: Declare obsolete" Revert "wisent.el: Prefer `define-mode-local-override`" This reverts commits91bc24c467,d2e0d1452b, and3294ad44eb.
This commit is contained in:
parent
8c153047e7
commit
be0cf9e299
7 changed files with 40 additions and 53 deletions
4
etc/NEWS
4
etc/NEWS
|
|
@ -827,10 +827,6 @@ so automatically.
|
|||
|
||||
* Changes in Specialized Modes and Packages in Emacs 29.1
|
||||
|
||||
** CEDET
|
||||
---
|
||||
*** Deprecate buffer-local function overrides for mode-local functions
|
||||
|
||||
** Enriched Mode
|
||||
|
||||
+++
|
||||
|
|
|
|||
|
|
@ -38,12 +38,10 @@
|
|||
;; 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:
|
||||
|
||||
|
|
@ -189,7 +187,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).
|
||||
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.
|
||||
|
|
@ -197,15 +195,13 @@ 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 and exactly one of the two must be non-nil.
|
||||
exclusive.
|
||||
|
||||
Argument MODE must be a major mode symbol.
|
||||
BINDINGS will be defined globally for this major mode.
|
||||
|
||||
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)
|
||||
|
|
@ -221,7 +217,6 @@ this use is deprecated and will be removed."
|
|||
;; 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
|
||||
|
|
@ -417,7 +412,6 @@ 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)
|
||||
|
|
@ -604,7 +598,6 @@ 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
|
||||
|
|
|
|||
|
|
@ -277,19 +277,18 @@ If optional argument MODE is non-nil, it must be a major mode symbol.
|
|||
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)))
|
||||
|
||||
;;; User Interrupt handling
|
||||
;;
|
||||
|
|
|
|||
|
|
@ -880,7 +880,7 @@ Lisp code."
|
|||
(unless (derived-mode-p 'emacs-lisp-mode)
|
||||
(emacs-lisp-mode))
|
||||
|
||||
;; Header + Prologue
|
||||
;;;; Header + Prologue
|
||||
|
||||
(insert header
|
||||
"\n;;; Prologue\n;;\n"
|
||||
|
|
@ -892,7 +892,7 @@ Lisp code."
|
|||
|
||||
(save-excursion
|
||||
|
||||
;; Declarations
|
||||
;;;; Declarations
|
||||
|
||||
(insert "\n;;; Declarations\n;;\n")
|
||||
|
||||
|
|
@ -927,12 +927,12 @@ Lisp code."
|
|||
(semantic-grammar-setup-data))
|
||||
"Setup the Semantic Parser.")
|
||||
|
||||
;; Analyzers
|
||||
;;;; Analyzers
|
||||
(insert "\n;;; Analyzers\n;;\n")
|
||||
|
||||
(semantic-grammar-insert-defanalyzers)
|
||||
|
||||
;; Epilogue & Footer
|
||||
;;;; Epilogue & Footer
|
||||
|
||||
(insert "\n;;; Epilogue\n;;\n"
|
||||
epilogue
|
||||
|
|
@ -967,7 +967,7 @@ Lisp code."
|
|||
;; 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.
|
||||
|
|
|
|||
|
|
@ -422,6 +422,8 @@
|
|||
|
||||
(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"
|
||||
|
|
|
|||
|
|
@ -154,25 +154,17 @@ and will be collected in `semantic-lex' form: (SYMBOL START . END)."
|
|||
;; 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:
|
||||
|
|
@ -275,7 +267,10 @@ Optional arguments GOAL is a nonterminal symbol to start parsing at,
|
|||
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))
|
||||
|
|
|
|||
|
|
@ -295,7 +295,9 @@ Return the expanded expression."
|
|||
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\
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue