Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMIE mode not being applied properly #68

Closed
Tracked by #218
rneatherway opened this issue Apr 6, 2016 · 4 comments · Fixed by #219
Closed
Tracked by #218

SMIE mode not being applied properly #68

rneatherway opened this issue Apr 6, 2016 · 4 comments · Fixed by #219

Comments

@rneatherway
Copy link
Member

@m00nlight I found when trying to debug/enhance the SMIE configuration that the function fsharp-smie-rules was never being called. I managed to get it to be called by either invoking (fsharp-mode-indent-smie-setup) manually or moving the call to the end of the definition of fsharp-mode. When it is working the indentation becomes different, probably worse. I don't know a lot about SMIE so would appreciate your input here.

@m00nlight
Copy link
Contributor

@rneatherway I also find the problem for the new version. So in the issue #59, I use my local old version to see whether SMIE will affect the save functionality. But I have some personal thing to do recently(until to the end of this month), so I will try to take a look of the problem when I have more time. Sorry for the inconvenience. I will try to see the problem ASAP.

@m00nlight
Copy link
Contributor

m00nlight commented May 1, 2016

@rneatherway It seems that SMIE now already work quite properly on the most recent source, so is the problem solved already or is it still there?

@rneatherway
Copy link
Member Author

I don't think it is being applied actually. If I open a new F# file and type the following it is indented as:

let x = 1

let y =
    let z = (
        1 + 2)

where as if I move (fsharp-mode-indent-smie-setup) to the end of the definition of fsharp-mode then it becomes active and entering the same text yields:

let x = 1

            let y =
                let z = (
                          1 + 2)

In case it isn't clear you can do this with the following patch:

diff --git a/fsharp-mode.el b/fsharp-mode.el
index 94f182c..5b82a47 100644
--- a/fsharp-mode.el
+++ b/fsharp-mode.el
@@ -193,7 +193,6 @@

   (require 'company)

-  (fsharp-mode-indent-smie-setup)

   (use-local-map fsharp-mode-map)

@@ -273,6 +272,7 @@
     (when file
       (setq compile-command (fsharp-mode-choose-compile-command file))
       (fsharp-mode--load-with-binding file)))
+  (fsharp-mode-indent-smie-setup)

   (turn-on-fsharp-doc-mode)
   (run-hooks 'fsharp-mode-hook))

@m00nlight
Copy link
Contributor

Sorry for the late reply since I have some personal issue.

I am also very new to smie mode, and could not found out what is the actual reason. What I can figure out is that if the (fsharp-mode-indent-smie-setup) is before

  (setq major-mode               'fsharp-mode
        mode-name                "fsharp"
        local-abbrev-table       fsharp-mode-abbrev-table
        paragraph-start          (concat "^$\\|" page-delimiter)
        paragraph-separate       paragraph-start
        require-final-newline    t
        indent-tabs-mode         nil
        comment-start            "//"
        comment-end              ""
        comment-column           40
        comment-start-skip       "///* *"
        comment-indent-function  'fsharp-comment-indent-function
        indent-region-function   'fsharp-indent-region
        indent-line-function     'fsharp-indent-line
        underline-minimum-offset  4

        paragraph-ignore-fill-prefix   t
        add-log-current-defun-function 'fsharp-current-defun
        fsharp-last-noncomment-pos     nil
        fsharp-last-comment-start      (make-marker)
        fsharp-last-comment-end        (make-marker))

It will work fine, any place after that will have some problem.

So my assumption is that, smie only define the simple grammar structure of the language, but still deligate the indent function to basic emacs indentation functionality. So we need to define the grammar before any indent related function.

Sorry for not being able offer much help. But I think we can still try to improve the F# indent without totally understanding the issue behind this, since what we need to do is to proper define the grammar for smie mode. If there is anything I can help, please let me know. I will have more time to contribute this project from now on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants