Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Can not get sh-mode working with smart-tabs-mode #11

Closed
baby-gnu opened this Issue August 02, 2012 · 5 comments

2 participants

Daniel Dehennin Joel C. Salomon
Daniel Dehennin

Hello,

I tried to get sh mode working with the following:

(add-hook 'sh-mode-hook (lambda ()
                          (smart-tabs-mode-enable)
                          (smart-tabs-advice sh-indent-line sh-indentation)))

But it does not work, is there a way to debug this?

Regards.

Joel C. Salomon
Owner

I’d ask @jacius, who wrote that part of the code.

Daniel Dehennin

Hello,

Any news on this request?

Joel C. Salomon
Owner

Sorry; no.

Does your #15 patch help at all with this?

Daniel Dehennin

No, #15 permit to ease the setup for users.

I just find the answer, use sh-basic-offset instead of sh-indentation, with a condition, if I do the following:

(add-hook 'sh-mode-hook
      (lambda ()
        (smart-tabs-mode-enable)
        (smart-tabs-advice sh-indent-line sh-basic-offset)
        ))

Then I create a buffer and run sh-script-mode(), I got:

Debugger entered--Lisp error: (error "Don't know how to make a localized variable an alias")
  defvaralias(sh-basic-offset tab-width)
  (progn (defvaralias (quote sh-basic-offset) (quote tab-width)) (defadvice sh-indent-line (around smart-tabs activate) (cond (smart-tabs-mode (save-excursion (beginning-of-line) (while (looking-at " *\\( +\\)   +") (replace-match "" nil nil nil 1))) (setq tab-width tab-width) (let ((indent-tabs-mode t) (tab-width fill-column) (sh-basic-offset fill-column)) (unwind-protect (progn ad-do-it)))) (t ad-do-it))))
  (smart-tabs-advice sh-indent-line sh-basic-offset)
  (lambda nil (smart-tabs-mode-enable) (smart-tabs-advice sh-indent-line sh-basic-offset))()
  run-hooks(change-major-mode-after-body-hook prog-mode-hook sh-mode-hook)
  apply(run-hooks (change-major-mode-after-body-hook prog-mode-hook sh-mode-hook))
  run-mode-hooks(sh-mode-hook)
  shell-script-mode()
  call-interactively(shell-script-mode record nil)
  command-execute(shell-script-mode record)
  execute-extended-command(nil "shell-script-mode")
  call-interactively(execute-extended-command nil nil)

The solution seems to be:

(setq sh-make-vars-local nil)

(add-hook 'sh-mode-hook
      (lambda ()
        (smart-tabs-mode-enable)
        (smart-tabs-advice sh-indent-line sh-basic-offset)
        ))

I thought about applying the following patch:

diff --git a/smart-tabs-mode.el b/smart-tabs-mode.el
index b2d0968..87e1529 100644
--- a/smart-tabs-mode.el
+++ b/smart-tabs-mode.el
@@ -138,6 +141,13 @@
                         (lambda ()
                           (smart-tabs-mode-enable)
                           (smart-tabs-advice nxml-indent-line nxml-child-indent)))))
+    (sh-script . (lambda ()
+          (setq sh-make-vars-local nil)
+          (add-hook 'sh-mode-hook
+                (lambda ()
+                  (smart-tabs-mode-enable)
+                  (smart-tabs-advice sh-indent-line sh-basic-offset)
+                  ))))
     )
   "Alist of language name and their activation code.
 Smarttabs is enabled in mode hook.")

But sh indentation seems too complex, with it, continuation lines are are indented with tabs instead of spaces :-/

test {
    echo "foo" \
        && echo "bar"
    echo "quux"
}
Joel C. Salomon
Owner

It seems you’re saying sh-mode indentation is too complex for smarttabs. I’m marking this issue Won’t fix and closing it; if someone offers working code we can revisit the issue. Sound good to you?

Joel C. Salomon jcsalomon closed this November 27, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.