I don't know where to find and adjust the configuration file to have Mathematica insert ClearAll["Global`*"]
at the beginning of every new notebook. How can I do this, rather than having to type it everytime I open a new notebook?
AFAIK there is no way to change the default new Notebook. But it is possible to add custom keyboard shortcut and/or menu command which will create new Notebook which will contain whatever you need. For example, you can add menu item "New my Notebook" under the "File -> New" submenu and assign Ctrl+Shift+N keyboard shortcut to evaluate it (this modification will only persist during current FrontEndSession) by evaluating the following (taken from here and here):
FrontEndExecute[
FrontEnd`AddMenuCommands[
"New", {MenuItem["My new Notebook",
System`KernelExecute[
CreateDocument[ExpressionCell[Defer#ClearAll["Global`*"], "Input"]]],
FrontEnd`MenuKey["N", FrontEnd`Modifiers -> {"Control", "Shift"}],
System`MenuEvaluator -> Automatic]}]]
Now pressing Ctrl+Shift+N will open new Notebook window with "Input" cell already containing ClearAll["Global`*"]. If you replace FrontEnd`Modifiers -> {"Control", "Shift"} with FrontEnd`Modifiers -> {"Command"}, the keyboard combination will be Alt+N.
Information on how to make this change permanent can be found in this MathGroups post:
You can completely reset the menus using...
FrontEndExecute[FrontEnd`ResetMenusPacket[{Automatic}]]
You'll get some ugly flicker, but that would work. You can also put
the AddMenuCommands function in a front end init.m which can be found
someplace on the path specified in the ConfigurationPath option. In
that case, the init.m file will get executed by the FE as it starts,
not the kernel, and so it won't matter how many kernels you start or
quit.
So you need to create the init.m file in one of the paths given by the ConfigurationPath option:
Options[$FrontEnd, ConfigurationPath][[1, 2]]
{FrontEnd`FileName[{$InstallationDirectory, "Configuration", "FrontEnd"}],
FrontEnd`FileName[{$UserBaseDirectory, "Autoload", _, "Configuration", "FrontEnd"}],
FrontEnd`FileName[{$BaseDirectory, "Autoload", _, "Configuration", "FrontEnd"}],
FrontEnd`FileName[{$InstallationDirectory, "AddOns", "Autoload", _, "Configuration", "FrontEnd"}]}
Some of these paths contain blank (_) which is undocumented but seemingly means any name (I have not not checked this).
Another way to make this change permanent is to edit your MenuSetup.tr file, but it is not recommended.
P.S. I recommend you in future to ask your Mathematica-related questions on dedicated site, where they will receive more attention:
https://mathematica.stackexchange.com/
Related
Is there a manner in which one can convert the spectrum type, for instance to EELS, by DM scripting? This screenshot represents what I'm referring to. I'd like to import a dataset using the GMS 3.4 Python interface, and then turn that into a EELS dataset for further processing (ideally without having to manually interface with the screenshotted menu bar).
Yes there is.
The "type" is simply a meta-data tag
which you can easily set with the TagGroup commands.
There is, however, one complication:
Data "registers" itself with DM when it first appears. Changing the meta-tags manually doesn't change this registration. (The menu command, however, does.)
Thus, you will only see effect of the type change when
either:
You save, close and reopen the data
You clone the data, throw away the original, and display the clone
The second option might cause issues with data-linkage though, as the unique image ID of the data is newly created.
Example using the first method (requires save & load):
image img:=GetFrontImage()
TagGroup tg = img.ImageGetTagGroup()
tg.TagGroupSetTagAsString("Meta Data:Signal","EELS")
imageDocument doc = img.ImageGetOrCreateImageDocument()
doc.ImageDocumentSave(0)
string path = doc.ImageDocumentGetCurrentFile()
doc.ImageDocumentClose(0)
doc = NewImageDocumentFromFile(path)
doc.ImageDocumentShow()
An alternative option is to rely on the menu command. If it is present, then you can simply use the ChoseMenuItem() command to invoke it.
However, the command will only be available with the UI when the data you want to change is front-most (i.e. not a script window!) You will need to ensure by script, that this is the case. A simple ShowWindow() will do.
image img:=GetFrontImage()
img.ShowImage()
if ( !ChooseMenuItem("Spectrum","Convert Data To","None") )
Throw( "Conversion to none failed.")
if ( !ChooseMenuItem("Spectrum","Convert Data To","EDS") )
Throw( "Conversion to none failed.")
Disadvantage of this solution: You will get the user-prompts.
I want to change the header name of the ABAP program. What can I do or where can I find the option to edit the header?
Two ways for this:
Set it in program options. Select the program and check menu Goto / Attributes.
Or you can create a GUI title and set it via ABAP. This overwrites attributes' setting.
More about how to achieve: here.
To change the program header is more easier than it seems.
Just open you program via SE38 -> Goto -> Properties -> Check the title field and change -> Save
And you are done. :)
I have this.
Usually is changing the name in atributes with transaction se38, but sometimes this don't work, you need in the transaction se80, create a title GUI, if yuou don't have a title created, righ clic in the program name, create -> GUI title.
And put your name and code.
and in your program (se38) in PBO, you have to call the title with
SET TITLEBAR '100' (Put your title code)
(100 is the title code), but this instruction have to need inside of a moodle, if is outside don't will work.
I use the first moodle that i have in my PBO (i don't know if is the best decition or the right form, but is a way and works).
finally the title change
The path is SE38 -> (Put Program Name) -> Now open the program in edit mode -> Select the option GOTO -> select Properties Change the program title.
I am fairly advanced with my LOTRO scripting, but sadly, have not figured out a way to capture data from the chatbox. I am trying to write an external mapping application and would like to have autohotkey automatically grab data from the screen, particularly the location data that has the heading, by typing:
/loc
inside of the chat box.
This image is linked to imgur with the areas I am trying to capture highlighted.
I find it very odd as I can highlight the text in the window easily, and copy and paste it to notepad or any other wordpad editor.
I have tried to following methods to attempt to gather the text from the window, but I cannot seem to find any controls or text, even when running the script as administrator.
WinGet, cList, ControlList, A
Loop, Parse, cList, `n, `r
{
ControlGetText, cText, % A_LoopField, A
if cText
res.="Control: " A_LoopField "`tText: " cText "`n"
}
MsgBox % res
WinGetText, text ; The window found above will be used.
MsgBox, The text is:`n%text%
Any ideas?
Games have non conventional GUIs and you can't just get there controls and use them.
For getting information from screen for nonconventional GUIs you can use following commands: ImageSearch, PixelGetColor, PixelSearch.
You can also try to get information from registry (maybe information that you need is stored in registry) with RegRead command.
Some information can be stored in text files and you can read them with FileRead, FileReadLine, LoopReadFile.
Also you can try to get information from memory. For scripts and guides about reading memory with AutoHotkey just google "AutoHotkey read memory".
Also be aware of that.
All is in the title.
If a have opened the three files:
/some/relatively/long/path/dir1/file_a
/some/relatively/long/path/dir1/file_b
/some/relatively/long/path/dir2/file_a
The file dropdown contains:
file_a (/some/relatively/long/path/dir1)
file_a (/some/relatively/long/path/dir2)
file_b (/some/relatively/long/path/dir1)
And that bother me because I have to look on the right to differentiate the two file_a, and on the left for the others. This happens a lot to me mostly because I code in python, and thus I often have several __init__.py files opened.
How do I get jedit to display
/some/relatively/long/path/dir1/file_a
/some/relatively/long/path/dir1/file_b
/some/relatively/long/path/dir2/file_a
config:
jedit 5.1.0
java 1.6.0_26
mac osx 10.6
Unfortunately this is not easily possible currently, I just had a look at the source and this is not configurable.
You can:
Submit a Feature Request to make this configurable (good idea in any case)
Create or let create a startup macro that
registers an EBComponent with the EditBus that listens for new EditPanes getting created
retrieve the BufferSwitcher from the EditPane
retrieve the ListCellRenderer from the BufferSwitcher
set a new ListCellRenderer to the BufferSwitcher that first calls the retrieved ListCellRenderer and then additionally sets the text to value.getPath()
Try the Buffer List plugin as to whether it maybe suits your needs
Now follows code that implements the work-part of option two, runnable as BeanShell code which does this manipulation for the current edit pane. The third line is not necessary when done in an EBComponent, this is just that the on-the-fly manipulation is shown immediately.
r = editPane.getBufferSwitcher().getRenderer();
editPane.getBufferSwitcher().setRenderer(
new ListCellRenderer() {
public Component getListCellRendererComponent(list, value, index, isSelected, cellHasFocus) {
rc = r.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
rc.setText(value.getPath());
return rc;
}
});
editPane.repaint();
There are times in Sublime Text when I want to reveal the current file in the side bar and then navigate around the folder structure.
This can be achieved using the commands reveal_in_side_bar and focus_side_bar however they have to be bound to two separate key combinations so I have to do 2 keyboard combinations to achieve my goal when ideally I'd like just one (I'm lazy).
Is there any way to bind multiple commands to a single key combination? e.g. something like this:
{
"keys": ["alt+shift+l"],
"commands": ["reveal_in_side_bar", "focus_side_bar"]
},
Solution
Based on #artem-ivanyk's and #d_rail's answers
1) Tools → New Plugin
import sublime, sublime_plugin
class RevealInSideBarAndFocusCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.run_command("reveal_in_side_bar")
self.window.run_command("focus_side_bar")
Save as RevealInSideBarAndFocus.py
2) Sublime Text 2 → Preferences → Key Bindings — User
Bind it to shortcut:
{ "keys": ["alt+shift+l"], "command": "reveal_in_side_bar_and_focus" }
Although the question is a year old, this might help people that are still looking for an answer.
Recently, a new package was developed by jisaacks, called Chain of command. It has the primary task to do exactly what you request, to chain several commands at once.
The package can be found here:
https://github.com/jisaacks/ChainOfCommand
An example of the working can be found below.
Let's say you wanted a key binding to duplicate the current file. You could set this key binding:
{
"keys": ["super+shift+option+d"],
"command": "chain",
"args": {
"commands": [
["select_all"],
["copy"],
["new_file"],
["paste"],
["save"]
]
}
}
This would select all the text, copy it, create a new file, paste the text, then open the save file dialog.
Source: https://sublime.wbond.net/packages/Chain%20of%20Command.
Updating #Artem Ivanyk's answer. I do not know what changed in Sublime, but that solution did not work for me, but I got this to work:
import sublime, sublime_plugin
class RevealInSideBarAndFocusCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.run_command("reveal_in_side_bar")
self.window.run_command("focus_side_bar")
.
{ "keys": ["ctrl+shift+8"], "command": "reveal_in_side_bar_and_focus" }
Btw, I'm using Build 2220
Stumbled upon similar problem. When trying to record macros, which involved „Save“ command, console threw at me „Unknown macros command save“ message.
Worked my way around with elementary plugin.
1) Tools → New Plugin
import sublime, sublime_plugin
class MyChainedActionsCommand():
def run(self):
self.view.run_command("reveal_in_side_bar")
self.view.run_command("focus_side_bar")
You need to use upper camel case notation for the class name. ST2 exposes this class for the command name with „Command“ suffix removed and the rest converted into the lowercase-underscore notation. I.e. in this example MyChainedActionsCommand could be run in sublime's console typing: view.run_command("my_chained_actions")
2) Sublime Text 2 → Preferences → Key Bindings — User
Bind it to shortcut:
{ "keys": ["alt+shift+l"], "command": "my_chained_actions" }
Heed commas.
Take a look at this gist.
I've been trying to implement this in a long time and found this by accident.
Don't forget to read the "documentation" provided. I kept trying to make this work, until I reallized I was not passing the "context" key.
You can create a macro to do this. For Sublime Text, macros are essentially just chained commands. You then create a keybinding for that macro. You can create a macro by using Tools > Record Macro, then executing your commands (beware that macros record keystrokes as well, so you'll want to use the commands from the menu bar to not cause conflicts), then Stop Recording, then Save Macro. After you save the macro, you can open it back up in Sublime Text to make sure that it recorded only what you want.
Building on Artem Ivanyk reply, here is a version of ChainedActions that works with arguments. It takes two arguments for actions and args. Both are lists and each command in the list gets executed with the corresponding arguments. This admittedly stupid example inserts two snippets: view.run_command("chained_actions", {"actions":["insert_snippet","insert_snippet"],"args":[{"contents": "($0)"},{"contents": "1($0)"}]})`
import sublime
import sublime_plugin
class ChainedActionsCommand(sublime_plugin.TextCommand):
def run(self, edit, actions, args):
for i, action in enumerate(actions):
self.view.run_command(action, args[i])
I've tried to use the same command but I ended up with a bug that when the file's folder was already unfolded sublime moved my focus sidebar's top, where I can see the open files. To improve this behavior I've wrote a new plugin that ensures it'll behave as I want to, here it is https://github.com/miguelgraz/FocusFileOnSidebar
I am using Sublime text3 build - 3083. It solves the problem just by 'Reveal it in side bar', the focus comes automatically.
I have added a custom keyboard shortcut for 'Reveal in sidebar' by adding the following statement under Preferences->Key Bindings-User :
[
{ "keys": ["ctrl+shift+r"], "command": "reveal_in_side_bar"}
]
The option - 'Reveal in sidebar' was missing for image file types, since the context menu doesn't appear with the right click of the mouse. The custom keyboard shortcut comes handy in this situation.
Starting from Sublime Text Build 4103 the feature is supported natively:
"Added the chain command, which accepts a list of commands to run in its "commands" argument. This allows binding a key to run multiple commands without having to use a macro"
See Changelog on https://www.sublimetext.com/dev