Giter Site home page Giter Site logo

Comments (9)

rneatherway avatar rneatherway commented on July 20, 2024

Hi Ralph,

This shouldn't be related to whether or not you have started fsi yet. The offset guess is just some elisp that inspects the buffer you are opening to try and work out how many spaces you are using for indentation. It defaults to 2, and that's what you get if the offset guess fails.

Please try checking the file you had the message with to make sure it is in fact independent of the fsi status.

from zarchive-fsharpbinding.

r-moeritz avatar r-moeritz commented on July 20, 2024

Here's my scenario:

    1. Launch Emacs
    2. Visit a new F# file. Bam! Error: "Sorry, couldn't guess a value for fsharp-indent-offset"
    3. Close Emacs
    4. Launch Emacs
    5. M-x run-fsharp
    6. Visit a new F# file. No error.

Date: Wed, 23 Jan 2013 02:41:28 -0800
From: [email protected]
To: [email protected]
CC: [email protected]
Subject: Re: [fsharpbinding] Sorry, couldn't guess a value for
fsharp-indent-offset (#80)

Hi Ralph,

This shouldn't be related to whether or not you have started fsi yet.
The offset guess is just some elisp that inspects the buffer you are
opening to try and work out how many spaces you are using for
indentation. It defaults to 2, and that's what you get if the offset
guess fails.

Please try checking the file you had the message with to make sure it
is in fact independent of the fsi status.


Reply to this email directly or view it on
GitHubhttps://github.com//issues/80#issuecomment-12590052.

from zarchive-fsharpbinding.

rneatherway avatar rneatherway commented on July 20, 2024

I just installed from melpa and got fsharp-mode-20130117.1805 in my .emacs.d/elpa directory.

  1. Launched Emacs
  2. C-x C-f test.fs (visit a new file)
  3. No error

So, are we using the same version of the mode? Or are we doing something different?

from zarchive-fsharpbinding.

r-moeritz avatar r-moeritz commented on July 20, 2024

Checked in .emacs.d/elpa and I have the same version of fsharp-mode as you. Running Emacs 24.2 on Windows 7 x64. Followed the same steps as you and got:

  signal(error ("Sorry, couldn't guess a value for fsharp-indent-offset"))
  error("Sorry, couldn't guess a value for fsharp-indent-offset")
  fsharp-guess-indent-offset()
  fsharp-mode()
  set-auto-mode-0(fsharp-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(t t)
  find-file-noselect-1(#<buffer test.fs> "c:/test.fs" nil nil "c:/test.fs" nil)
  find-file-noselect("c:/test.fs" nil nil t)
  find-file("c:/test.fs" t)
  call-interactively(find-file nil nil)

I've tried using Edebug to debug the code but can't seem to get it to stop execution; I'm probably doing it wrong since I've never used Edebug before.

from zarchive-fsharpbinding.

r-moeritz avatar r-moeritz commented on July 20, 2024

Okay, I've managed to debug fsharp-guess-indent-offset. Observations as inline comments below:

   (while (not (or found (eobp)))
      ;; This is not executed because (eobp) evaluates to t since the buffer is empty.
      (when (and (re-search-forward fsharp-block-opening-re nil 'move)
                 (not (fsharp-in-literal restart)))
        (setq restart (point))
        (fsharp-goto-initial-line)
        (if (fsharp-statement-opens-block-p)
            (setq found t)
          (goto-char restart))))
    (unless found
      ;; Execution continues here.
      (goto-char start)
      (fsharp-goto-initial-line)
      (while (not (or found (bobp)))
        ;; Execution doesn't reach here because (bobp) evaluates to t.
        (setq found (and
                     (re-search-backward fsharp-block-opening-re nil 'move)
                     (or (fsharp-goto-initial-line) t) ; always true -- side effect
                     (fsharp-statement-opens-block-p)))))
    (setq colon-indent (current-indentation)
          found (and found (zerop (fsharp-next-statement 1))) ;; nil - (fsharp-next-statement 1) evaluates to 1
          new-value (- (current-indentation) colon-indent))
    (goto-char start)
    (if (not found)
        ;; Execution continues here.
        (error "Sorry, couldn't guess a value for fsharp-indent-offset")

from zarchive-fsharpbinding.

rneatherway avatar rneatherway commented on July 20, 2024

I also did a bit of debugging and I found that it ends up calling
parse-partial-sexp to try and find the nesting level. It then uses the
number of encountered parentheses to decide whether it is in a continuation
line. I can't see why I don't also get the error as a result -- this code
predates my involvement.

For now, I recommend following the advice in the docstring of
fsharp-smart-indentation:

Note that both these settings occur after fsharp-mode-hook' is run, so if you want to defeat the automagic configuration, you must also setfsharp-smart-indentation' to nil in your `fsharp-mode-hook'.

On Wed, Jan 23, 2013 at 12:15 PM, Ralph Möritz [email protected]:

Okay, I've managed to debug fsharp-guess-indent-offset. Observations as
inline comments below:

(while (not (or found (eobp)))
;; This is not executed because (eobp) evaluates to t since the buffer is empty.
(when (and (re-search-forward fsharp-block-opening-re nil 'move)
(not (fsharp-in-literal restart)))
(setq restart (point))
(fsharp-goto-initial-line)
(if (fsharp-statement-opens-block-p)
(setq found t)
(goto-char restart))))
(unless found
;; Execution continues here.
(goto-char start)
(fsharp-goto-initial-line)
(while (not (or found (bobp)))
;; Execution doesn't reach here because (bobp) evaluates to t.
(setq found (and
(re-search-backward fsharp-block-opening-re nil 'move)
(or (fsharp-goto-initial-line) t) ; always true -- side effect
(fsharp-statement-opens-block-p)))))
(setq colon-indent (current-indentation)
found (and found (zerop (fsharp-next-statement 1))) ;; nil - (fsharp-next-statement 1) evaluates to 1
new-value (- (current-indentation) colon-indent))
(goto-char start)
(if (not found)
;; Execution continues here.
(error "Sorry, couldn't guess a value for fsharp-indent-offset")


Reply to this email directly or view it on GitHubhttps://github.com//issues/80#issuecomment-12592987.

from zarchive-fsharpbinding.

rneatherway avatar rneatherway commented on July 20, 2024

More information: at fsharp-mode.el:221, the call:

  (if (and (fsharp-safe (fsharp-guess-indent-offset))

is wrapped with the macro fsharp-safe, which is defined at fsharp-mode-indent.el:218:

(defmacro fsharp-safe (&rest body)
  "Safely execute BODY, return nil if an error occurred."
  `(condition-case nil
       (progn ,@ body)
     (error nil)))

When the files are byte-compiled (as the packaged versions end up being), it doesn't seem to catch the error. I think that the fsharp-guess-indent-offset function has not worked for a long time, but I never noticed because it is always just caught by this macro. I am not an elisp expert, and I don't know why this behaviour is occuring. Installing the package and then deleting the .elc files leaves me in a situation where this error is not thrown, but a) it should work without intervention and b) I want to understand why there is this difference between compiled and interpreted code.

from zarchive-fsharpbinding.

rneatherway avatar rneatherway commented on July 20, 2024

OK, it seems that fsharp-mode.el should have been requireing fsharp-mode-indent so that it had access to this macro. Strange that the require further down was not sufficient. Anyway, this is now fixed in the repository. Next time melpa updates, you should be able to install a version of the package without this bad behaviour. The guessing code still needs investigating to find out if it ever worked though! I'll leave this issue open until we have observed the melpa package behaving better.

from zarchive-fsharpbinding.

r-moeritz avatar r-moeritz commented on July 20, 2024

Great, it seems after upgrading to the latest MELPA fsharp-mode visiting a new F# file no longer leads to this error. Thanks!

Date: Wed, 23 Jan 2013 10:32:09 -0800
From: [email protected]
To: [email protected]
CC: [email protected]
Subject: Re: [fsharpbinding] Sorry, couldn't guess a value for fsharp-indent-offset (#80)

OK, it seems that fsharp-mode.el should have been requireing fsharp-mode-indent so that it had access to this macro. Strange that the require further down was not sufficient. Anyway, this is now fixed in the repository. Next time melpa updates, you should be able to install a version of the package without this bad behaviour. The guessing code still needs investigating to find out if it ever worked though! I'll leave this issue open until we have observed the melpa package behaving better.

          —

          Reply to this email directly or view it on GitHub.

from zarchive-fsharpbinding.

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.