elisp debugging and elc files - emacs

I have installed the persp-mode and workspaces packages from the elpa repository. persp-mode depends on workspaces.
I was unable to get persp-mode working until the workspace.elc file was deleted. I have made a backup of this file for troubleshooting.
What could have been the cause of error?
How can I debug this problem systematically?

Without you giving us the error message it's hard to know what caused this, but generally the easiest way to debug compilation issues is to restart Emacs (so you have a fresh image), go back to the source file and recompile it with M-x emacs-lisp-byte-compile-and-load. This will show you any errors or warnings that occur when the file is compiled. Look for the following:
undefined variables and functions, which often indicate
features that have not been required by the package
simple typing errors
unexpected end of input errors, which indicate unbalanced parens
general usage errors, such as
function calls with incorrect argument counts
macro expansion errors
These sorts of issues are usually pretty easy to fix. Remember, you can always redefine the package's functions and vars yourself if they are broken.

Related

Passing macros with coverity exe files while using them through cmd

I am new to Coverity,I am using it from the command prompt with it's .exe files.So I want to pass specific macros in coverity cov-build.exe so that those macros will be implemented when cov-emit.exe(when it is called by cov-build.exe) is parsing the .c files.Till now I have tried the below stated configurations.
code-build.exe Intermediate_folder --delete-stale-tus --preprocessor-first --return-emit-failure "My_bat_file" -- -D My_macro_name=my_macro_body
So any help will be much be appreciated.I am stuck on this.
Thanks and regards,
Newbie_in
cov-build wraps your existing build command, monitors it and spawns parallel compiler invocations in order to understand your code. These parallel compiler invocations will see the same command line being passed to your own compiler.
So if you want this define to take effect for your compiler as well as Coverity's then you should simply just add it to your build the way you would normally and Coverity will see it.
If you want to add a define that only Coverity's compiler can see, this is best done with within the config for your compiler.
You can either edit the config directly (add
<append_arg>-Dmy_macro_name=my_macro_body</append_arg>
after the <begin_command_line_config> line), or re-configure using --xml-option.
For example, if you're using the shortcut gcc config this would look like this:
$ cov-configure --gcc --xml-option=append_arg>-Dmy_macro_name=my_macro_body.
I noticed you're using --preprocess-first on the cov-build command line - I recommend against this, as it destroys XREFs making it much more difficult to browse defect information, as well as makes the analysis unable to find some defects (i.e. ones that are due to macros). --preprocess-next behaves like --preprocess-first and will only fire if the initial compilation attempt fails, so if you're using --preprocess-first to work around compilation issues, I strongly recommend using --preprocess-next instead.
If you do have compilation issues, it's always good to report them (along with a reproducer) to Coverity support so that they can be fixed in future releases.

How do I disable warnings at initialization in Emacs?

Ever since I installed emacs24 some tiny insignificant piece of my configuration files stopped working. Since I don't really care about this error and It does not affect me I just want Emacs to shut up about initialization warnings and just open the scratch buffer (as it is it opens a second buffer with some error stuff).
Is there a way to do this without having to sit hours to debug lisp code I don't understand?
I really can't post the configuration file because it's really really big and messy, but this is the warning I get:
Warning (initialization): An error occurred while loading `/home/sofia/.emacs':
Symbol's function definition is void: plist-to-alist
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with the
`--debug-init' option to view a complete error backtrace.
In a nutshell, I don't want to ensure normal operation, I just want one buffer when opening emacs
I'm not saying that it's a good idea to do this (in fact I very much agree with #Carl Groner and #rashimoto that masking errors instead of fixing them is usually a Bad Idea™), but at your own risk try adding the following to the top of your .emacs file:
(setq warning-minimum-level :emergency)
This tells Emacs not to warn you about anything except problems
that will seriously impair Emacs operation soon if you do not attend to [them] promptly.
By contrast, the default value of warning-minimum-level is :warning, which causes Emacs to warn you about
data or circumstances that are not inherently wrong, but raise suspicion of a possible problem.
More info about warnings and options for dealing with them here and here.

Recompile doesn't correct typo in function call

I've been seeing this a lot lately and am not sure if it is an SBCL issue, an Emacs problem, a SLIME problem, or my own understanding of what it means to "compile" a lisp file.
I will have a function, say this:
(defun some-function (x) (call-this-funcshun))
I will compile and run this, and I'll get an error that my function call-this-funcshun is not defined. Then I realize that is because there is a typo. So change it:
(defun some-function (x) (call-this-function))
In Emacs, I recompile the entire file with Control-C Control-K (Emacs saves automatically before the compile as well). Emacs then reports Compilation finished. I move to the REPL. I try it again, type (some-function whatever) and I get the same error. I search through the small lisp file and see that call-this-funcshun is clearly nowhere in it. Yet I have an error that this function is not defined.
Is there some sort of caching that Emacs or SBCL is doing that causes this to hang around? It's driving me nuts. Worth noting that if I quit SLIME and then launch it again, the issue is resolved. Also worth noting that this does not affect all my code edits, just occasionally.
Maybe the file is not loaded for some reason.
I would set *load-verbose* to T and watch that LOAD actually gets called.
Setting *load-print* to T would then also cause the printing of information about definitions loaded.
I've seen two conditions that can lead to behavior that looks like what you saw:
When the symbol in the file is not the same as the symbol at the REPL. The symbol's name is only a shorthand for identifying the symbol, and the same shorthand can identify different symbols based on which package you use it in. There are some ways to be surprised about which symbol you are referring to, so it can be worth checking with SYMBOL-PACKAGE even when you are pretty sure that they are the same.
When the buffer isn't saved. I'm not sure how C-c C-k deals with this now (because I edited it to auto-save for me), but in general compiling and loading tools tend to work from the file not the buffer.

CLOCK_MONOTONIC not found

I am attempting to use clock_gettime( CLOCK_MONOTONIC, ts ). I have included time.h, and linked to librt (I think). I still get the error that CLOCK_MONOTONIC is undefined. (EDIT: error text added)
Symbol 'CLOCK_MONOTONIC' could not be resolved ... Semantic Error
c++ in eclipse. In myrojname->properties->C/C++ Build->GCC C++ Linker->libraries I added "rt". The resulting command line includes -lrt.
I tried a much simpler scratch program and compiled from the command line with g++ -o mytest mytest.cpp -lrt and it works great.
So, what am I missing?
I think that's actually an error message coming out of the CDT static analyser, not something from the compiler itself.
And I think it's complaining about the code itself rather than something missing from the linkage objects, so whether you link with rt or not is not relevant (for this particular issue anyway).
You should go into the C++ settings, specifically the include paths, and ensure that all needed directories are listed there.

How to generate and set up annotation for Ocaml in Emacs?

I am writing a compiler in Ocaml with Emacs. I am told that with -annot a file .annot could be generated while compiling, which could help Emacs to show the type of my code. But it is odd that no .annot is generated after running this makefile. Could anyone tell me what is wrong with that?
Also, once i have got .annot, do I need to set up anything (for instance .emacs?) so that my Emacs read it and show the type of my code?
Thank you very much!
Edit1: after make clean and make, I have got the .annot... But I still do not know how to make use of this .annot in Emacs.
Edit2: actually it is necessary to follow this link, copy the files in a local folder, then update .emacs. Then when a .ml is edited in Emacs, C-c C-t returns its type from .annot.
Regarding your emacs inquiry --I don't use emacs--, this is from the man-pages for ocamlc,
-annot Dump detailed information about the compilation (types, bindings, tail-calls, etc). The information for file src.ml is put into file src.annot. In case of a type error, dump all the information inferred by the type-checker before the error. The src.annot file can be used with the emacs commands given in emacs/caml-types.el to display types and other annotations interactively.
There are also other tools from the thread I mentioned previously.
As for the Makefile not creating the .annot files, I made a mock directory and successfully had .annot files created. I also don't see anything wrong with your Makefile. You may want to clean the directory and try again, or switch to another way to build your tool like ocamlbuild --which would require minimal setup, although, I haven't used it with menhir.
I will also note that -annot is new since OCaml 3.11.0, and prior the flag was -dtypes.