GNU bug report logs - #21751
24.5; Undesirable sh-mode indent

Previous Next

Package: emacs;

Reported by: Bob Proulx <bob <at> proulx.com>

Date: Sat, 24 Oct 2015 19:06:02 UTC

Severity: normal

Tags: confirmed, fixed, patch

Merged with 23004, 24337

Found in versions 24.5, 25.1

Fixed in version 26.1

Done: Noam Postavsky <npostavs <at> users.sourceforge.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: npostavs <at> users.sourceforge.net
To: Bob Proulx <bob <at> proulx.com>
Cc: Phil <p.stephani2 <at> gmail.com>, 21751 <at> debbugs.gnu.org, Oleksandr Gavenko <gavenkoa <at> gmail.com>
Subject: bug#21751: 24.5; Undesirable sh-mode indent
Date: Wed, 30 Aug 2017 19:50:30 -0400
[Message part 1 (text/plain, inline)]
tags 21751 + patch
quit

npostavs <at> users.sourceforge.net writes:

> I guess sh-indentation should be made into an obsolete alias for
> sh-basic-offset?

Here's a patch

[v1-0001-Make-sh-indentation-into-an-alias-for-sh-basic-of.patch (text/x-diff, inline)]
From 2205b597476083579bd3e50b20bc2ce42ca54520 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Wed, 30 Aug 2017 19:42:47 -0400
Subject: [PATCH v1] Make sh-indentation into an alias for sh-basic-offset
 (Bug#21751)

* lisp/progmodes/sh-script.el (sh-indentation): Redefine as obsolete
variable alias for `sh-basic-offset'.
(sh-mode, sh-smie--indent-continuation)
(sh-smie-rc-rules, sh-basic-indent-line): Replace `sh-indentation'
with `sh-basic-offset'.
---
 lisp/progmodes/sh-script.el | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index ca31635dbc..2cf7e15540 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -593,11 +593,7 @@ sh-assignment-regexp
 			       (sexp :format "Evaluate: %v"))))
   :group 'sh-script)
 
-
-(defcustom sh-indentation 4
-  "The width for further indentation in Shell-Script mode."
-  :type 'integer
-  :group 'sh-script)
+(define-obsolete-variable-alias 'sh-indentation 'sh-basic-offset "26.1")
 (put 'sh-indentation 'safe-local-variable 'integerp)
 
 (defcustom sh-remember-variable-min 3
@@ -1623,7 +1619,7 @@ sh-mode
   (setq-local skeleton-pair-alist '((?` _ ?`)))
   (setq-local skeleton-pair-filter-function 'sh-quoted-p)
   (setq-local skeleton-further-elements
-	      '((< '(- (min sh-indentation (current-column))))))
+	      '((< '(- (min sh-basic-offset (current-column))))))
   (setq-local skeleton-filter-function 'sh-feature)
   (setq-local skeleton-newline-indent-rigidly t)
   (setq-local defun-prompt-regexp
@@ -2018,7 +2014,7 @@ sh-smie--indent-continuation
       (forward-line -1)
       (if (sh-smie--looking-back-at-continuation-p)
           (current-indentation)
-        (+ (current-indentation) sh-indentation))))
+        (+ (current-indentation) sh-basic-offset))))
    (t
     ;; Just make sure a line-continuation is indented deeper.
     (save-excursion
@@ -2039,13 +2035,13 @@ sh-smie--indent-continuation
                        ;; check the line before that one.
                        (> ci indent))
                       (t ;Previous line is the beginning of the continued line.
-                       (setq indent (min (+ ci sh-indentation) max))
+                       (setq indent (min (+ ci sh-basic-offset) max))
                        nil)))))
           indent))))))
 
 (defun sh-smie-sh-rules (kind token)
   (pcase (cons kind token)
-    (`(:elem . basic) sh-indentation)
+    (`(:elem . basic) sh-basic-offset)
     (`(:after . "case-)") (- (sh-var-value 'sh-indent-for-case-alt)
                              (sh-var-value 'sh-indent-for-case-label)))
     (`(:before . ,(or `"(" `"{" `"[" "while" "if" "for" "case"))
@@ -2254,8 +2250,8 @@ sh-smie-rc-backward-token
 
 (defun sh-smie-rc-rules (kind token)
   (pcase (cons kind token)
-    (`(:elem . basic) sh-indentation)
-    ;; (`(:after . "case") (or sh-indentation smie-indent-basic))
+    (`(:elem . basic) sh-basic-offset)
+    ;; (`(:after . "case") (or sh-basic-offset smie-indent-basic))
     (`(:after . ";")
      (if (smie-rule-parent-p "case")
          (smie-rule-parent (sh-var-value 'sh-indent-after-case))))
@@ -2496,7 +2492,7 @@ sh-modify
 
 (defun sh-basic-indent-line ()
   "Indent a line for Sh mode (shell script mode).
-Indent as far as preceding non-empty line, then by steps of `sh-indentation'.
+Indent as far as preceding non-empty line, then by steps of `sh-basic-offset'.
 Lines containing only comments are considered empty."
   (interactive)
   (let ((previous (save-excursion
@@ -2520,9 +2516,9 @@ sh-basic-indent-line
 		     (delete-region (point)
 				    (progn (beginning-of-line) (point)))
 		     (if (eolp)
-			 (max previous (* (1+ (/ current sh-indentation))
-					  sh-indentation))
-		       (* (1+ (/ current sh-indentation)) sh-indentation))))))
+			 (max previous (* (1+ (/ current sh-basic-offset))
+					  sh-basic-offset))
+		       (* (1+ (/ current sh-basic-offset)) sh-basic-offset))))))
     (if (< (current-column) (current-indentation))
 	(skip-chars-forward " \t"))))
 
-- 
2.14.1


This bug report was last modified 7 years and 242 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.