all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: npostavs@users.sourceforge.net
To: Bob Proulx <bob@proulx.com>
Cc: Phil <p.stephani2@gmail.com>,
	Oleksandr Gavenko <gavenkoa@gmail.com>,
	21751@debbugs.gnu.org
Subject: bug#21751: 24.5; Undesirable sh-mode indent
Date: Wed, 30 Aug 2017 19:50:30 -0400	[thread overview]
Message-ID: <87y3q07gzd.fsf@users.sourceforge.net> (raw)
In-Reply-To: <874lsua5fi.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net's message of "Sat, 26 Aug 2017 08:18:09 -0400")

[-- Attachment #1: Type: text/plain, Size: 168 bytes --]

tags 21751 + patch
quit

npostavs@users.sourceforge.net writes:

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

Here's a patch


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 4133 bytes --]

From 2205b597476083579bd3e50b20bc2ce42ca54520 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@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


  reply	other threads:[~2017-08-30 23:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-24 19:04 bug#21751: 24.5; Undesirable sh-mode indent Bob Proulx
2017-08-26 12:18 ` npostavs
2017-08-30 23:50   ` npostavs [this message]
2017-09-02 12:57     ` Eli Zaretskii
2017-09-25 23:43       ` Noam Postavsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y3q07gzd.fsf@users.sourceforge.net \
    --to=npostavs@users.sourceforge.net \
    --cc=21751@debbugs.gnu.org \
    --cc=bob@proulx.com \
    --cc=gavenkoa@gmail.com \
    --cc=p.stephani2@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.