Giter VIP home page Giter VIP logo

Comments (7)

rrthomas avatar rrthomas commented on June 26, 2024 1

@hrehfeld as far as I can tell, you're experiencing a problem with CSS mode and desktop.el when you have dtrt-indent active? (I made a quick test, of opening a CSS file, quitting Emacs and restarting; the css-mode buffer was loaded fine by desktop.el with no error.) That's not the same as this issue (which was a request for SMIE support), so please file a new issue, with a way to repro and some evidence that the problem is caused by dtrt.

from dtrt-indent.

PythonNut avatar PythonNut commented on June 26, 2024

In fact, this would be trivial. All you need to do is detect if SMIE is supported and fire off a (smie-config-guess).
Here's a snippet from my init.el:

(defun smie-auto-guess ()
  (when (featurep 'smie)
    (unless (eq smie-grammar 'unset)
      (smie-config-guess))))

(add-hook 'after-change-major-mode-hook 'smie-auto-guess)

from dtrt-indent.

rrthomas avatar rrthomas commented on June 26, 2024

I believe this now works: dtrt-indent-find-file-hook now uses smie-config-guess if SMIE is available and the mode supports it. I have tested this with sh-mode (for bug #31), but would appreciate some confirmation that it works before I make a new release.

Thanks @PythonNut for the bug report and example code.

from dtrt-indent.

jgeerds avatar jgeerds commented on June 26, 2024

Thanks @rrthomas ! I've also tested it with sh-mode and it works fine for me.

TBH, I don't understand how smie works. Let's take the following file as an example:

test_function() {
    if test; then
        echo lol
    fi
}

Indentation works fine with your recent changes, but sh-basic-offset and sh-indentation are set to 2 (and not 4). I guess smie uses a different variable for this. Let's say I want to change the indentation from 4 to 2 and indent-region the whole buffer. How can I do that? Changing sh-indentation, sh-basic-offset and smie-indent-basic make no difference.

from dtrt-indent.

rrthomas avatar rrthomas commented on June 26, 2024

Thanks for confirming. Good luck sussing out SMIE; I don't know much about it either.

from dtrt-indent.

hrehfeld avatar hrehfeld commented on June 26, 2024

I still run into this, whenever a css-mode file is in the desktop file -- seems related. Reopen?

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  smie-next-sexp(#f(compiled-function () #<bytecode 0xd5cec9>) #f(compiled-function (n) #<bytecode 0x1b0d2f9>) #<subr car> #f(compiled-function (x) "Return the car of the cdr of X." #<bytecode 0x1a49b3>) "}")
  smie-backward-sexp("}")
  smie-indent-keyword()
  run-hook-with-args-until-success(smie-indent-keyword)
  smie-indent-calculate()
  smie-config--get-trace()
  smie-config--guess(1 6439)
  smie-config-guess()
  dtrt-indent-mode(t)
  (lambda nil (dtrt-indent-mode t))()
  run-hooks(change-major-mode-after-body-hook prog-mode-hook css-mode-hook)
  apply(run-hooks (change-major-mode-after-body-hook prog-mode-hook css-mode-hook))
  run-mode-hooks(css-mode-hook)
  css-mode()
  set-auto-mode-0(css-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil nil)
  find-file-noselect-1(#<buffer style.css> "style.css" :nowarn nil "style.css" (1738062 66309))
  find-file-noselect("style.css" :nowarn)
  desktop-restore-file-buffer("style.css" "style.css" nil)
  desktop-create-buffer(208 "style.css" "style.css" css-mode nil 1 (nil nil) nil nil ((tab-width . 4) (indent-tabs-mode . t) (buffer-display-time) (buffer-file-coding-system . utf-8-unix)) ((mark-ring nil)))
  eval-buffer(#<buffer  *load*> nil ".desktop" nil t)  ; Reading at buffer position 140676
  load-with-code-conversion(".desktop" ".desktop" t t)
  load(".desktop" t t t)
  desktop-read()

from dtrt-indent.

hrehfeld avatar hrehfeld commented on June 26, 2024

Will try, but time is limited atm, currently i'm just not using dtrt-indent on css-mode as a quick workaround.

from dtrt-indent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.