From 7e9eef0ffd90cd7e39f15b003e4a9770be27b0ce Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Thu, 14 Dec 2017 11:18:51 +0200 Subject: 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. --- lisp/indent.el | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lisp/indent.el') diff --git a/lisp/indent.el b/lisp/indent.el index d5ba0bd8491..ccf0e99c08b 100644 --- a/lisp/indent.el +++ b/lisp/indent.el @@ -69,6 +69,8 @@ variable is `indent-relative' or `indent-relative-maybe', handle it specially (since those functions are used for tabbing); in that case, indent by aligning to the previous non-blank line." (interactive) + (save-restriction + (widen) (syntax-propertize (line-end-position)) (if (memq indent-line-function '(indent-relative indent-relative-maybe)) @@ -84,7 +86,7 @@ that case, indent by aligning to the previous non-blank line." (indent-line-to column) (save-excursion (indent-line-to column)))) ;; The normal case. - (funcall indent-line-function))) + (funcall indent-line-function)))) (defun indent--default-inside-comment () (unless (or (> (current-column) (current-indentation)) @@ -144,7 +146,9 @@ prefix argument is ignored." (indent--default-inside-comment) (when (or (<= (current-column) (current-indentation)) (not (eq tab-always-indent 'complete))) - (funcall (default-value 'indent-line-function)))) + (save-restriction + (widen) + (funcall (default-value 'indent-line-function))))) (cond ;; If the text was already indented right, try completion. @@ -538,7 +542,9 @@ column to indent to; if it is nil, use one of the three methods above." (forward-line 1))))) ;; Use indent-region-function is available. (indent-region-function - (funcall indent-region-function start end)) + (save-restriction + (widen) + (funcall indent-region-function start end))) ;; Else, use a default implementation that calls indent-line-function on ;; each line. (t (indent-region-line-by-line start end))) -- cgit v1.2.3 From b9fbc03b862413bfee2728b1760f959bfc912e56 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Wed, 20 Dec 2017 01:42:49 +0200 Subject: Widen in indent-for-tab-command in the normal case, too Fixing this obvious omission. * lisp/indent.el (indent--funcall-widened): New function. (indent-for-tab-command): Use it. --- lisp/indent.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lisp/indent.el') diff --git a/lisp/indent.el b/lisp/indent.el index ccf0e99c08b..400280f615a 100644 --- a/lisp/indent.el +++ b/lisp/indent.el @@ -142,13 +142,11 @@ prefix argument is ignored." (old-indent (current-indentation))) ;; Indent the line. - (or (not (eq (funcall indent-line-function) 'noindent)) + (or (not (eq (indent--funcall-widened indent-line-function) 'noindent)) (indent--default-inside-comment) (when (or (<= (current-column) (current-indentation)) (not (eq tab-always-indent 'complete))) - (save-restriction - (widen) - (funcall (default-value 'indent-line-function))))) + (indent--funcall-widened (default-value 'indent-line-function)))) (cond ;; If the text was already indented right, try completion. @@ -170,6 +168,11 @@ prefix argument is ignored." (< (point) end-marker)) (indent-rigidly (point) end-marker indentation-change)))))))))) +(defun indent--funcall-widened (func) + (save-restriction + (widen) + (funcall func))) + (defun insert-tab (&optional arg) (let ((count (prefix-numeric-value arg))) (if (and abbrev-mode -- cgit v1.2.3