emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] scratch/widen-less d013ad4 3/3: Replace prog-indentation-c


From: Dmitry Gutov
Subject: [Emacs-diffs] scratch/widen-less d013ad4 3/3: Replace prog-indentation-context with prog-first-column
Date: Fri, 1 Dec 2017 18:56:32 -0500 (EST)

branch: scratch/widen-less
commit d013ad493caaa8500451c425042feea81cc1d7ae
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Replace prog-indentation-context with prog-first-column
---
 doc/lispref/text.texi       | 55 ++++++++++++++++++---------------------------
 lisp/progmodes/prog-mode.el | 30 ++++---------------------
 2 files changed, 26 insertions(+), 59 deletions(-)

diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index 5a63e5b..32c7f47 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -2396,41 +2396,30 @@ text at point (@pxref{Completion in Buffers}).
 syntax belongs to a different major mode.  Examples include
 @dfn{literate programming} source files that combine documentation and
 snippets of source code, Yacc/Bison programs that include snippets of
-plain C code, etc.  To correctly indent the embedded chunks, the major
-mode needs to delegate the indentation to another mode's indentation
-engine (e.g., call @code{c-indent-defun} for C code or
address@hidden for Python), while providing it with some
-context to guide the indentation.  The following facilities support
-such multi-mode indentation.
-
address@hidden prog-indentation-context
-This variable, when address@hidden, holds the indentation context for
-the sub-mode's indentation engine provided by the superior major mode.
-The value should be a list of the form @code{(@var{first-column}
address@hidden)}.  The members of the list have the following meaning:
+plain C code, web programming HTML templates, etc.  To correctly
+indent the embedded chunks, the major mode needs to delegate the
+indentation to another mode's indentation engine (e.g., call
address@hidden for C code or @code{python-indent-line} for
+Python), while providing it with some guidance.  Same for syntax
+highlighting and similar features.  Major modes that are supposed to
+work correctly in embedded contexts, should adhere to the following
+rules:
 
address@hidden @var
address@hidden first-column
-The column to be used for top-level constructs.  This replaces the
-default value of the top-level column used by the sub-mode, usually
-zero.
address@hidden rest
-Reserved for future use.  The intent is to provide the sub-mode's
-indentation engine with a virtual context of the code chunk.  Working
-patches that use this in a significant fashion are welcome.
address@hidden table
address@hidden defvar
-
-The following convenience functions should be used by major mode's
-indentation engine in support of invocations as sub-modes of another
-major mode.
address@hidden @bullet
address@hidden
address@hidden,
address@hidden,
address@hidden and
address@hidden should not call @code{widen}
+in their implementations.  They should obey the narrowing bounds set
+by their caller to the best of their ability.
 
address@hidden prog-first-column
-Call this function instead of using a literal value (usually, zero) of
-the column number for indenting top-level program constructs.  The
-function's value is the column number to use for top-level constructs.
-When no superior mode is in effect, this function returns zero.
address@hidden defun
address@hidden
+Indentation code should use the value of @code{prog-first-column} as
+the indentation offset.  In practice, it usually means to simply
+indent the top-level constructs to this column, if indentation of
+their contents is relative.
address@hidden itemize
 
 
 @node Region Indent
diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el
index 16662e5..f6dabef 100644
--- a/lisp/progmodes/prog-mode.el
+++ b/lisp/progmodes/prog-mode.el
@@ -49,28 +49,10 @@
     map)
   "Keymap used for programming modes.")
 
-(defvar prog-indentation-context nil
-  "When non-nil, provides context for indenting embedded code chunks.
-
-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
-main language to use the indentation engine of the sub-mode for
-lines in code chunks written in the sub-mode's language.
-
-When a major mode of such a main language decides to delegate the
-indentation of a line/region to the indentation engine of the sub
-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 ...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).
-
-REST is currently unused, but can be defined in future versions.")
+(defvar prog-first-column 0
+  "The column that should be used for top-level constructs.
+Indentation functions that are supposed to work correctly in
+embedded code chunks should use this value instead of 0.")
 
 (defun prog-indent-sexp (&optional defun)
   "Indent the expression after point.
@@ -85,10 +67,6 @@ instead."
          (end (progn (forward-sexp 1) (point))))
       (indent-region start end nil))))
 
-(defun prog-first-column ()
-  "Return the indentation column normally used for top-level constructs."
-  (or (car prog-indentation-context) 0))
-
 (defvar-local prettify-symbols-alist nil
   "Alist of symbol prettifications.
 Each element looks like (SYMBOL . CHARACTER), where the symbol



reply via email to

[Prev in Thread] Current Thread [Next in Thread]