emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] remove-prog-indentation-context 8309d44: Remove prog-inden


From: Dmitry Gutov
Subject: [Emacs-diffs] remove-prog-indentation-context 8309d44: Remove prog-indentation-context
Date: Mon, 28 Mar 2016 00:56:28 +0000

branch: remove-prog-indentation-context
commit 8309d442e682974d6299bd9dc746f9cf7310a29d
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Remove prog-indentation-context
    
    * lisp/progmodes/prog-mode.el: (prog-indentation-context)
    (prog-first-column, prog-widen): Remove, as discussed in
    http://lists.gnu.org/archive/html/emacs-devel/2016-03/msg01425.html.
    
    * doc/lispref/text.texi (Mode-Specific Indent): Remove references
    to them.
    
    * etc/NEWS: Ditto.
    
    * lisp/progmodes/python.el: (prog-widen, prog-first-column):
    Remove the compatibility aliases and all uses.
---
 doc/lispref/text.texi       |   77 -------------------------------------------
 etc/NEWS                    |   12 -------
 lisp/progmodes/prog-mode.el |   68 --------------------------------------
 lisp/progmodes/python.el    |   36 +++++++-------------
 4 files changed, 12 insertions(+), 181 deletions(-)

diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index 4c3a1a0..6b93e51 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -2365,83 +2365,6 @@ already indented, it calls @code{completion-at-point} to 
complete the
 text at point (@pxref{Completion in Buffers}).
 @end defopt
 
address@hidden literate programming
address@hidden multi-mode indentation
-  Some major modes need to support embedded regions of text whose
-syntax belongs to a different major mode.  Examples include
address@hidden 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(@var{start} . @var{end})} @code{prev-chunk})}.  The members of 
the
-list have the following meaning:
-
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 start
address@hidden end
-The region of the code chunk to be indented by the sub-mode.  The
-value of @var{end} can be @code{nil}, which stands for the value of
address@hidden
address@hidden prev-chunk
-If this is address@hidden, it should provide the sub-mode's
-indentation engine with a virtual context of the code chunk.  Valid
-values include:
-
address@hidden @minus
address@hidden
-A string whose contents is the text the sub-mode's indentation engine
-should consider to precede the code chunk.  The sub-mode's indentation
-engine can add text properties to that string, to be reused in
-repeated calls with the same string, thus using it as a cache.  An
-example where this is useful is code chunks that need to be indented
-as function bodies, but lack the function's preamble---the string
-could then include that missing preamble.
address@hidden
-A function.  It is expected to be called with the start position of
-the current chunk, and should return a cons cell
address@hidden@code{(@var{prev-start} . @var{prev-end})}} that specifies the
-region of the previous code chunk, or @code{nil} if there is no previous
-chunk.  This is useful in literate-programming sources, where code is
-split into chunks, and correct indentation needs to access previous
-chunks.
address@hidden itemize
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 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 prog-widen
-Call this function instead of @code{widen} to remove any restrictions
-imposed by the mode's indentation engine and restore the restrictions
-recorded in @code{prog-indentation-context}.  This prevents the
-indentation engine of a sub-mode from inadvertently operating on text
-outside of the chunk it was supposed to indent, and preserves the
-restriction imposed by the superior mode.  When no superior mode is in
-effect, this function just calls @code{widen}.
address@hidden defun
-
 
 @node Region Indent
 @subsection Indenting an Entire Region
diff --git a/etc/NEWS b/etc/NEWS
index 96ec1f1..5599bd9 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -396,18 +396,6 @@ the ordering of object keys by default.
 'json-pretty-print-buffer-ordered' pretty prints JSON objects with
 object keys sorted alphabetically.
 
-+++
-** Prog mode has some support for multi-mode indentation.
-This allows better indentation support in modes that support multiple
-programming languages in the same buffer, like literate programming
-environments or ANTLR programs with embedded Python code.
-
-A major mode can provide indentation context for a sub-mode through
-the 'prog-indentation-context' variable.  To support this, modes that
-provide indentation should use 'prog-widen' instead of 'widen' and
-'prog-first-column' instead of a literal zero.  See the node
-"Mode-Specific Indent" in the ELisp manual for more details.
-
 ** Prettify Symbols mode
 
 +++
diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el
index 718b339..3f25a0c 100644
--- a/lisp/progmodes/prog-mode.el
+++ b/lisp/progmodes/prog-mode.el
@@ -49,53 +49,6 @@
     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 (START . END) PREVIOUS-CHUNKS)
-
-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.")
-
 (defun prog-indent-sexp (&optional defun)
   "Indent the expression after point.
 When interactively called with prefix, indent the enclosing defun
@@ -109,27 +62,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))
-
-(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
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 5aeefe4..90097df 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -283,18 +283,6 @@
   :version "24.3"
   :link '(emacs-commentary-link "python"))
 
-
-;;; 24.x Compat
-
-
-(unless (fboundp 'prog-widen)
-  (defun prog-widen ()
-    (widen)))
-
-(unless (fboundp 'prog-first-column)
-  (defun prog-first-column ()
-    0))
-
 
 ;;; Bindings
 
@@ -761,7 +749,7 @@ work on `python-indent-calculate-indentation' instead."
   (interactive)
   (save-excursion
     (save-restriction
-      (prog-widen)
+      (widen)
       (goto-char (point-min))
       (let ((block-end))
         (while (and (not block-end)
@@ -860,7 +848,7 @@ keyword
  - Point is on a line starting a dedenter block.
  - START is the position where the dedenter block starts."
   (save-restriction
-    (prog-widen)
+    (widen)
     (let ((ppss (save-excursion
                   (beginning-of-line)
                   (syntax-ppss))))
@@ -1007,10 +995,10 @@ current context or a list of integers.  The latter case 
is only
 happening for :at-dedenter-block-start context since the
 possibilities can be narrowed to specific indentation points."
   (save-restriction
-    (prog-widen)
+    (widen)
     (save-excursion
       (pcase (python-indent-context)
-        (`(:no-indent . ,_) (prog-first-column)) ; usually 0
+        (`(:no-indent . ,_) 0)
         (`(,(or :after-line
                 :after-comment
                 :inside-string
@@ -1048,7 +1036,7 @@ possibilities can be narrowed to specific indentation 
points."
          (let ((opening-block-start-points
                 (python-info-dedenter-opening-block-positions)))
            (if (not opening-block-start-points)
-               (prog-first-column) ; if not found default to first column
+               0  ; if not found default to first column
              (mapcar (lambda (pos)
                        (save-excursion
                          (goto-char pos)
@@ -1066,7 +1054,7 @@ integers.  Levels are returned in ascending order, and in 
the
 case INDENTATION is a list, this order is enforced."
   (if (listp indentation)
       (sort (copy-sequence indentation) #'<)
-    (nconc (number-sequence (prog-first-column) (1- indentation)
+    (nconc (number-sequence 0 (1- indentation)
                             python-indent-offset)
            (list indentation))))
 
@@ -1091,7 +1079,7 @@ minimum."
         (python-indent--previous-level levels (current-indentation))
       (if levels
           (apply #'max levels)
-        (prog-first-column)))))
+        0))))
 
 (defun python-indent-line (&optional previous)
   "Internal implementation of `python-indent-line-function'.
@@ -4479,7 +4467,7 @@ Optional argument INCLUDE-TYPE indicates to include the 
type of the defun.
 This function can be used as the value of `add-log-current-defun-function'
 since it returns nil if point is not inside a defun."
   (save-restriction
-    (prog-widen)
+    (widen)
     (save-excursion
       (end-of-line 1)
       (let ((names)
@@ -4662,7 +4650,7 @@ likely an invalid python file."
   (let ((point (python-info-dedenter-opening-block-position)))
     (when point
       (save-restriction
-        (prog-widen)
+        (widen)
         (message "Closes %s" (save-excursion
                                (goto-char point)
                                (buffer-substring
@@ -4683,7 +4671,7 @@ statement."
 With optional argument LINE-NUMBER, check that line instead."
   (save-excursion
     (save-restriction
-      (prog-widen)
+      (widen)
       (when line-number
         (python-util-goto-line line-number))
       (while (and (not (eobp))
@@ -4699,7 +4687,7 @@ With optional argument LINE-NUMBER, check that line 
instead."
 Optional argument LINE-NUMBER forces the line number to check against."
   (save-excursion
     (save-restriction
-      (prog-widen)
+      (widen)
       (when line-number
         (python-util-goto-line line-number))
       (when (python-info-line-ends-backslash-p)
@@ -4716,7 +4704,7 @@ When current line is continuation of another return the 
point
 where the continued line ends."
   (save-excursion
     (save-restriction
-      (prog-widen)
+      (widen)
       (let* ((context-type (progn
                              (back-to-indentation)
                              (python-syntax-context-type)))



reply via email to

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