Comments (9)
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.
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.
I just installed from melpa and got fsharp-mode-20130117.1805
in my .emacs.d/elpa
directory.
- Launched Emacs
- C-x C-f test.fs (visit a new file)
- No error
So, are we using the same version of the mode? Or are we doing something different?
from zarchive-fsharpbinding.
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.
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.
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 set
fsharp-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.
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.
OK, it seems that fsharp-mode.el
should have been require
ing 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.
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)
- [github] Escaped double quotes in verbatim strings conflict with triple-quoted strings HOT 3
- NRE when creating an .fsx file in XS HOT 1
- Atom.io support? HOT 20
- fsharpbinding is not available as the default package in SublimeText package control HOT 4
- could not import MSBuildExtensionPath32 in Monodevelop HOT 11
- Can't compile code in Windows HOT 6
- Syntax highlighting doesn't cope with international chars HOT 3
- Emacs autocomplete with .net 4.5 references HOT 12
- Documentation comments in MonoDevelop are broken since new ToolTip on Linux HOT 1
- Adding Glyph to Completion output in fsautocomplete HOT 8
- Syntax highlighting: Strange output HOT 5
- [emacs] Symbol's function definition is void: -any HOT 1
- Tutorial creates empty project HOT 2
- fsharpbinding does not parse ProjectReferences? HOT 1
- fsautocomplete will not start under mono 3.2.8 in Ubuntu/Linux Trusty HOT 1
- FSX script crashing fsautocomplete. HOT 1
- fsautocomplete.exe not run with mono 3.2.8 HOT 1
- Question on error HOT 3
- Missing type info tooltips in Lubuntu 14.04 HOT 2
- Auto-completion for fsx files stops working HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zarchive-fsharpbinding.