Restore variables in ipython - ipython

I use the options "remove all variables before execution" in Spyder, that uses the magic %reset -sf.
Now I would like to have the default setting back (the variables are kept in memory) but I can't (I used the Spyder reset to factory default).

To modify the Remove all variables before execution you probably will need to go to Run > Configuration per file.. and uncheck the option there for the file you are working on. The thing is that there are some default options available but also per file options which maybe are not being reset even when you do a reset to factory (those are created if you modify the config the first time you run a file).

Related

Extention OmniPascal (vscode) using too much CPU - How to resolve?

Every time I start vscode, OminiPascalServer.exe start to use 35 to 50% of CPU process.
This appears not only in my computer, but with every person I know who use this extention.
Exist some configuration to fix it?
Thanks!
This usually happens at the start as OmniPascal probably need to scan through the entire workspace. So one way to quicken the process is to reduce the amount of things it need to scan.
This is how I do it and I notices a drastic improvement:
Create a new VSCode workspace that only focuses on Pascal files
In your VSCode workspace, add relevant folders
In Settings > Files > Exclude, exclude all irrelevant items in your Pascal project. (I don't know if this actually matters, but it seems to help)
In the case that you want to add external library, rather than adding them as part of your workspace, you can add them in Settings > OmniPascal > Search Path. You might also need to change the Symbol Index to select "searchPath"

What "local rules" have been set in Emacs?

I have been trying to solve a sh-mode indentation issue in Emacs (I get a double indent after a then) and found that I can set the indentation by hand and then run C-c > to automatically configure the indentation.
However, this configuration only applies to my current session and I can't seem to find any variables that have been modified as a result of the auto-configuration. (It worked though: the indentation is consistently what I want.) When it has run, it says "Local rules set" but doesn't tell me what local rules have been set.
And of course, when I restart Emacs, the local configuration is lost and I have to run the auto-config command again.
I've found a number of questions on this site about listing variables and their values, but I can't find out how to list ones that have only been changed for the current session. I even used this post to dump variables before and after running the C-c > command and comparing the output; nothing obviously different.
So I suppose my question is twofold:
If session variables are what's meant by "local rules" then how do I find out which ones were set?
If "local rules" means something else, then what is that and how can I somehow transfer those changes to my ~/.emacs file?
I think the result depends on your version of Emacs, but with a recent version, this is handled by SMIE, so the personal settings are kept in the smie-config variable.
The local settings in use in the current buffer are kept in an internal variable (smie-config--buffer-local). You can move them over to smie-config and save them into your ~/.emacs by calling smie-config-save.
One more detail: smie-config-save doesn't in itself save the settings to ~/.emacs. It only transfers them from the transient buffer-local variable smie-config--buffer-local to the global smie-config variable which is under the control of Customize and can have be saved to your ~/.emacs via something like M-x customize-save-customized. This should arguably be improved in smie-config-save. I suggest M-x report-emacs-bug to ask for this improvement.
This is more of an incomplete workaround than an answer, but it's a start!
The idea is to trigger sh-learn-buffer-indent as soon as a shell script is loaded. Add the following to your ~/.emacs file:
(add-hook 'sh-set-shell-hook 'sh-learn-buffer-indent)
A couple of important notes:
It assumes that your shell script is already correctly formatted when it's loaded.
It can be slow for large files.
(This is apparently mentioned in sh-script.el and was brought to my attention by Noam Postavsky via the bug report I filed.)

editing objects from MongoDB with an external editor doesn't update the object

I'm using the Mongo shell. I've set my EDITOR to my notepad++ path. I create an object and then I use the EDIT command to edit the obeject using notepad++ but it doesn't update the object.
// mongo shell
var pow = { name: "teest" };
edit pow
// notepad++ opens a document called 'mongo_edit141225123.js' that resides
// in C:\users\...\Appdata\local\temp
// I edit the object, save and close notepad++
pow // object isn't updated :(
what am I missing?
There seem to be a few caveats here. But I can describe how I got this working:
Set the PATH environment variable to include the path to the notepad++ executable. Note to both "apply" this change and not have an existing command line window when doing so. Or at least open a new one once this step is complete.
Specify an EDITOR variable in your command shell window, or otherwise set that under the same system properties as setting the PATH environment variable. Since the program directory is in the PATH just set the executable name:
set EDITOR="notepad++"
Launch your mongo shell and go to edit a variable:
> edit something
This will launch the specified editor, with an "undefined" variable at first. Type in something "valid", as any invalid JavaScript declaration will be discarded. Now for the important part. After your edit and when "closing" click the "tab close" icon and do not close the entire editor as shown:
That last part seems to be the most important. If you are prompted to save (and you likely will be ) then do so. Only "after" the tab has been closed (and saved) should you then close the editor itself.
If you then subsequently issue the same edit something from the mongo shell, then the editor will open with the content that you edited before.
If you don't follow this and just close the editor window first, then you should see an additional tab opened and the original tab with the content that you had before. But subsequent changes will be lost as the shell is now tracking a different temporary file.
So follow those steps and you should be right. I would expect there are similar issues with other external editors that will actually resolve in a similar way.

save settings with customize when running --no-init-file option

I'm running my own emacs config that resides in non-default place. So I use -Q -l startup options. I've defined place for saving customization and set custom-file variable accordingly.
Unfortunately emacs refuses to save my custom options motivating it with possible harm to original options. But I know what I do, and I what to have separate custom file filled with current session variables?
How can I overcome emacs restrictions?
emacs manual says:
If Emacs was invoked with the -q or --no-init-file options (see Initial Options), it will not let you save your customizations in your initialization file. This is because saving customizations from such a session would wipe out all the other customizations you might have on your initialization file.
Don't use -Q. That implies -q, and I trust that if your config resides elsewhere, you do not also have any of the default init filenames for Emacs to find and use.
Instead, use the combination of options that you actually need. Refer to:
C-hig (emacs) Initial Options RET
`-Q'
`--quick'
Start emacs with minimum customizations. This is similar to using
`-q', `--no-site-file', `--no-site-lisp', and `--no-splash'
together. This also stops Emacs from processing X resources by
setting `inhibit-x-resources' to `t' (*note Resources::).
Edit:
I'm really not sure I understand why you need to retain your default init files when you claim that you don't want to use them. It would help if you clarified why --no-init-file is critical? Are you trying to provide a secondary configuration of Emacs which does not conflict with how people usually run it?
You might work around it by setting the HOME environment variable in your start-up script.
See C-hig (emacs) Find Init RET
Also see the init-file-user variable and, for the gory details, the command-line function.
(Perhaps setting the likes of init-file-user, user-init-file, & custom-file with --eval might work.)

How do I setup p4.el on emacs?

I tried the basic setup as given in the sourceforge page and set
P4CONFIG, P4USER, P4PORT.
and after opening emacs I load p4.el and try to set the client name
using p4-set-client-name and it throws out this error:
Click <mouse-2> on a completion to select it.
In this buffer, type RET to select the completion near point.
Possible completions are:
Can't create a new user - over license quota.
License count: 1000 users used of 1000 licensed.
Try deleting old users with 'user -d'.
But when I try opening it using p4v it opens up just fine.
What am I doing wrong ?
I'd make sure that your P4USER environment variable is set properly in your emacs process (M-x getenv). For sure, it looks like p4 procs spawned from your emacs are using an incorrect P4USER.
Also note that on Windows, you can "p4 set P4USER=username" rather than using an environment variable; this will take effect right away.