diff options
author | Dmitry Gutov <dgutov@yandex.ru> | 2017-12-14 11:18:51 +0200 |
---|---|---|
committer | Dmitry Gutov <dgutov@yandex.ru> | 2017-12-14 11:18:51 +0200 |
commit | 7e9eef0ffd90cd7e39f15b003e4a9770be27b0ce (patch) | |
tree | 65c46eac3785849457ba9d989ed4acf19b3e8fac /lisp/progmodes/prog-mode.el | |
parent | 6067f0c702e3652a9d489852752f038320cb91ae (diff) | |
download | emacs-7e9eef0ffd90cd7e39f15b003e4a9770be27b0ce.tar.gz emacs-7e9eef0ffd90cd7e39f15b003e4a9770be27b0ce.tar.bz2 emacs-7e9eef0ffd90cd7e39f15b003e4a9770be27b0ce.zip |
Consolidate 'widen' calls
* lisp/progmodes/prog-mode.el (prog-indentation-context):
Un-document all elements but the first.
(prog-widen): Remove.
(http://lists.gnu.org/archive/html/emacs-devel/2017-12/msg00321.html)
* doc/lispref/text.texi (Mode-Specific Indent): Update.
* lisp/progmodes/ruby-mode.el (ruby-calculate-indent):
Don't call widen.
* lisp/progmodes/python.el
(python-indent-guess-indent-offset)
(python-info-current-defun): Replace prog-widen with widen;
these functions are not called during indentation.
(python-indent-context)
(python-indent--calculate-indentation)
(python-info-dedenter-opening-block-message)
(python-info-line-ends-backslash-p)
(python-info-beginning-of-backslash)
(python-info-continuation-line-p)
(python-info-current-defun): Remove 'widen' calls.
* lisp/indent.el (indent-according-to-mode)
(indent-for-tab-command, indent-region): Move them here.
* lisp/textmodes/mhtml-mode.el (mhtml-indent-line):
Bind prog-indentation-context to one-element list.
Diffstat (limited to 'lisp/progmodes/prog-mode.el')
-rw-r--r-- | lisp/progmodes/prog-mode.el | 47 |
1 files changed, 3 insertions, 44 deletions
diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index f727e458b2b..4efe443fba8 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -54,7 +54,7 @@ There are languages where part of the code is actually written in a sub language, e.g., a Yacc/Bison or ANTLR grammar also consists -of plain C code. This variable enables the major mode of the +of plain C code. This variable enables the primary mode of the main language to use the indentation engine of the sub-mode for lines in code chunks written in the sub-mode's language. @@ -64,37 +64,13 @@ mode, it should bind this variable to non-nil around the call. The non-nil value should be a list of the form: - (FIRST-COLUMN (START . END) PREVIOUS-CHUNKS) + (FIRST-COLUMN . REST) FIRST-COLUMN is the column the indentation engine of the sub-mode should use for top-level language constructs inside the code chunk (instead of 0). -START and END specify the region of the code chunk. END can be -nil, which stands for the value of `point-max'. The function -`prog-widen' uses this to restore restrictions imposed by the -sub-mode's indentation engine. - -PREVIOUS-CHUNKS, if non-nil, provides the indentation engine of -the sub-mode with the virtual context of the code chunk. Valid -values are: - - - A string containing text which the indentation engine can - consider as standing in front of the code chunk. To cache the - string's calculated syntactic information for repeated calls - with the same string, the sub-mode can add text-properties to - the string. - - A typical use case is for grammars with code chunks which are - to be indented like function bodies -- the string would contain - the corresponding function preamble. - - - A function, to be called with the start position of the current - chunk. It should return either the region of the previous chunk - as (PREV-START . PREV-END), or nil if there is no previous chunk. - - A typical use case are literate programming sources -- the - function would successively return the previous code chunks.") +REST is currently unused.") (defun prog-indent-sexp (&optional defun) "Indent the expression after point. @@ -113,23 +89,6 @@ instead." "Return the indentation column normally used for top-level constructs." (or (car prog-indentation-context) 0)) -(defun prog-widen () - "Remove restrictions (narrowing) from current code chunk or buffer. -This function should be used instead of `widen' in any function used -by the indentation engine to make it respect the value of -`prog-indentation-context'. - -This function (like `widen') is useful inside a -`save-restriction' to make the indentation correctly work when -narrowing is in effect." - (let ((chunk (cadr prog-indentation-context))) - (if chunk - ;; No call to `widen' is necessary here, as narrow-to-region - ;; changes (not just narrows) the existing restrictions - (narrow-to-region (car chunk) (or (cdr chunk) (point-max))) - (widen)))) - - (defvar-local prettify-symbols-alist nil "Alist of symbol prettifications. Each element looks like (SYMBOL . CHARACTER), where the symbol |