Is it possible to change the default comment string in Octave GUI? - octave

In Octave GUI Editor the Ctrl+R shortcut comments the selected lines out with the Octave default string ##. But I share my code with other colleagues who use MATLAB. I was wondering if I could change the above keyboard shortcut and the Ctrl+Shift+R to use the MATLAB commenting character % by default? I'm aware of the Ctrl+Alt+R shortcut where one can choose the string, but that is not very handy given the muscle memory and the extra step.
P.S. I posted this question also here on the unofficial Octave Discord channel.

OK, I think I found the solution, and it was way easier than what I had anticipated. Basically, the Octave GUI team had already thought of that. Just go to Edit > Preference, and then in the Comments (Octave) section, select the % option:

Related

Setting `sql-mysql-program` in emacs

There are at least three major overviews that come up when searching for information on using sql with emacs (due to my insufficient reputation I can't 'afford' to link to them here).
I can find no mention in any of them of the need to set the variable sql-mysql-program when working with mysql servers. Yet I could not get M-x sql-mysql to work without following the advice from this SO question to set this variable as follows:
(setq sql-mysql-program "/path/to/your/mysql")
In fact, the only tutorials/documentation I've seen highlighting this variable are in the above SO question and another SO question about "emacs-how-to-use-ssh-tunnel-to-connect-to-remote-mysql" (which again I can't link to because of insufficient reputation.)
An alternate solution seems to be suggested here How to work with emacs and mysql, which suggests changing the value of the emacs exec-path.
The question is, which of these options is preferable, or is it simply a matter of taste?
And what is the significance of the fact that none of the above-linked overviews of sql/emacs mentions the need to get emacs to recognize the binary? Is there something wrong with my emacs?
I spent a long time combing the sql.el source to try to understand what was going on and I do see a (defcustom sql-mysql-program "mysql"…)but in my case at least that did not seem to do the trick (perhaps because I'm starting emacs up with -q option?).
PS. In case it matters, my M-x emacs-version is GNU Emacs 24.5.1 (x86_64-apple-darwin12.5.0, NS apple-appkit-1187.40) of 2015-05-01, which I am running on an older Mac (10.8.5)
Note that this can be generalised to a question of:
What do I do if Emacs can't find an executable?
which is where the exec-path list comes into play.
As noted in C-hig (emacs) Shell RET, the exec-path list is initialised from the environment variable PATH when Emacs is started (see also (emacs) General Variables), so there are multiple ways to populate that list with the values you need.
Using an absolute path to sql-mysql-program is also fine, but potentially less portable. It's up to you, really.

How to edit built in command behavior

I want to edit find_under_expand (ctrl+d) to consider hyphenated words, as single words. So when I try to replace all instance of var a, it shouldn't match substrings of "a" in words like a-b, which it currently does.
I'm assuming find_under_expand wraps your current selection in regex boundaries like this: \ba\b
I need it to wrap in something like this: \b(?<!-)a(?!-)\b
Is the find_under_expand command's source available to edit? Or do I have to rewrite the whole thing? I'm not sure where to begin.
Sublime's commands are implemented in one of several ways: as macros, as plugins, and internally as part of the compiled program (probably as C++). The default macros and plugins can be found in the Packages/Default directory in ST2 (where Packages is the directory opened when selecting Preferences -> Browse Packages...), or zipped in the Installed Packages/Default.sublime-package file in ST3, extractable using #skuroda's excellent PackageResourceViewer plugin, available via Package Control. Macros have .sublime-macro extensions, while plugins are written in Python and have .py extensions.
I searched all through the Defaults package in ST3 (things are generally the same as in ST2), and was unable to find a macro or .py file that included the find_under_expand command, or FindUnderExpand, which is the convention when naming command classes in plugins. Therefore, I strongly suspect that this command is internal to Sublime, probably written in C++ and linked into the executable or in a .dll|.dylib|.so library.
So, it doesn't look like there's an existing file that you could easily modify to adjust for your negative lookahead/lookbehind patterns (I assume that's what those are, my regex is a bit rusty...). Instead, you'll have to implement your own plugin from scratch that reads the "word_separators" value in your settings file, which the current implementation of find_under_expand doesn't seem to be doing, judging from your previous question and my own testing. Theoretically, this shouldn't be too terribly difficult - you can just open up a quick panel where the user enters the pattern/regex to be searched for, and you can just iterate through the current view looking for matches and highlighting/selecting them.
Good luck!

Refactor keyboard shortcuts in MonoDevelop

Are there keyboard bindings to the refactoring commands in MonoDevelop?
A direct answer: Yes, there are.
A bit more useful answer: depending on what you're looking for, quick examples:
Alt+Return is quick fix (given you've got source analysis turned on)
Alt+Insert is code generation (properties, overrides, etc.)
F2 is rename
And, in case you're not aware, all the refactorings for the symbol you got under your cursor are available in the right-click context menu (available by pressing the relevant keyboard key, so it also kind of counts as a keyboard binding ;) )
Apart from that, you can look up and/or change all (or at least many, I'm not exactly sure) the bindings in Options > Preferences > Key Bindings.
Does the above answer your question?
It depends which version of MonoDevelop you are using. With the late 2.x series then there were individual key bindings for "Create Method", "Extract Local Variable" and a few others (see the documentation).
Renaming (including renaming files in the explorer view and renaming variables, classes or anything else in the text editor) is a separate key binding under the "Edit" section and defaults to shortcut key F2.
As of v3.x, these key-bindings seem to have disappeared. Edit > Preferences > Key Bindings still has a "Refactoring" section, but it now only lists Import Symbol, Quick Fix and Show Fixes (none of which I'd necessarily even call refactoring - they're more code completion features). Instead, the refactoring methods are all available as "Quick Fixes" (default: Alt+Enter when Source Analysis is turned on from Edit > Preferences > Other > Source Analysis).
The reason for the change appears to be that the refactoring mechanism has been overhauled and now relies on source analysis, but this isn't quite perfect yet and so isn't enabled by default. As they're part of the Quick Fix system then they've not been given separate key bindings (as I believe there are more of them now).
For me, Source Analysis menu is:
Tools>Option>Source Anyalysis (Under Text Editor) > Enable
Well it does make some changes to the Editor screen, it doesn't really give me useful suggestion for correction (auto fix) like Eclipse, regardless of whether I've press Alt+Enter.

Programmatically configure MATLAB

Since MathWorks release a new version of MATLAB every six months, it's a bit of hassle having to set up the latest version each time. What I'd like is an automatic way of configuring MATLAB, to save wasting time on administrative hassle. The sorts of things I usually do when I get a new version are:
Add commonly used directories to the path.
Create some toolbar shortcuts.
Change some GUI preferences.
The first task is easy to accomplish programmatically with addpath and savepath. The next two are not so simple.
Details of shortcuts are stored in the file 'shortcuts.xml' in the folder given by prefdir. My best idea so far is to use one of the XML toolboxes in the MATLAB Central File Exchange to read in this file, add some shortcut details and write them back to file. This seems like quite a lot of effort, and that usually means I've missed an existing utility function. Is there an easier way of (programmatically) adding shortcuts?
Changing the GUI preferences seems even trickier. preferences just opens the GUI preference editor (equivalent to File -> Preferences); setpref doesn't seems to cover GUI options.
The GUI preferences are stored in matlab.prf (again in prefdir); this time in traditional name=value config style. I could try overwriting values in this directly, but it isn't always clear what each line does, or how much the names differ between releases, or how broken MATLAB will be if this file contains dodgy values. I realise that this is a long shot, but are the contents of matlab.prf documented anywhere? Or is there a better way of configuring the GUI?
For extra credit, how do you set up your copy of MATLAB? Are there any other tweaks I've missed, that it is possible to alter via a script?
shortcuts - read here and here
preferences - read http://undocumentedmatlab.com/blog/changing-system-preferences-programmatically/
At the moment, I'm not using scripts, though this sounds like a very interesting idea.
Unless there are new features that you also want to configure, you can simply copy-paste the old preferences into the new prefdir. I guess this should be doable programmatically, though you might have to select the old prefdir via uigetdir. So far, this has not created major problems for me. Note also that in case of a major change in the structure of preferences, any programmatic version would have to be rewritten as well.
I'm adding paths at each startup, so that I don't need to think of manually adding new directories every time I change something in my code base (and I don't want to have to update directory structures for each user). Thus, I also need to copy-paste startup.m for each installation.
If I had to do everything manually, I'd also want to change the autosave options to store the files in an autosave directory. If I recall correctly, Matlab reads the colors and fonts from previous installations, so I don't have to do that.

What have you done to customize your IDE? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
What tweaks / addins / themes do you have rigged up to make your IDE awesome? For example, in Visual Studio I color themes, CodeRush draws lines between braces, I always install and use the Consolas font and I have it setup to sync my settings across computers for when I change hotkeys and whatnot with the help of FolderShare.
Also, this isn't Visual Studio specific, please feel free to mention what you do with Emacs or Eclipse or whatnot as many of us use a few.
ReSharper 4.1 for Visual Studio 2008. It's a beautiful thing. It looks for all kinds of code errors, optimizations, etc. My code is cleaner thanks to this handy Visual Studio plugin.
Optimizing the IDE will be the first step. Resharper helps a lot but sometimes some simple macros are more than enough.
First things first. Change the font from the default crappy one. Then start fiddling with the 'Options' dialog box.
At the recommendation of a friend, I installed Visual Assist for Visual Studio 2008 -- it is awesome. I swear it can read my mind.
[Note: I have no affiliation with them -- just a very happy customer]
I've done a lot, but I really shouldn't have. So in the last few years, I've toned down the number of macros, custom key mappings, custom toolbars, etc. For the most part, I'm of the opinion that developers should get used to the default behavior and appearance of their IDE. Then when you need to work on your colleague's machine, you still know how to get around and manage to help them out. Not to mention that a whole slew of customizations will get broken or rearranged or otherwise reset when an update comes out.
That said, there are a few things that I still do every time I set up an IDE to work on... for example, setting the number of concurrent builds in Visual Studio to be 1, because that feature is so broken that nothing will compile correctly with any greater setting. Apart from that, being an ace with the default behavior will ultimately make you more efficient than spending hours tweaking the software to make it just a little more fluid.
I like CodeSmart VB6 and CodeSmart VS.NET from Axtools http://www.axtools.com/
for advanced syntax highlighting, drawing lines between parts of If..then..else..endif, Do While ... loop and all other constructs. It also has great code auditors and many add-in functions.
Vi plugin!!
I use Emacs. My .emacs file is only a few hundred lines long, but does customize settings based on my machine's hostname and operating system, so that I can use the same config file pretty much anywhere.
Colorization - Custom - White Text on GreyishBlack, Consolas Font
HotKeys - CTRL+SHIFT+ALT+Z (Attach to Process) probably some others too...
Addins - DPack, Coderush, GhostDoc.
Toolbars Off
All Windows set to collapsed
I am not doing presentations with this machine - If I was it would be barebones.
eclipse plugins make my ide exactly the way I want it of course.
eclipse plugin central
I kinda like the default setup of VS, I only make sure about Consolas as the editor font, and tabsize 2 (tabs to spaces), and change the color of numbers (red).
For Java development using Eclipse I have a few plugins that are indispensable. The MyEclipse Workbench adds a lot of functionality to most of the built-in modules. It makes it very easy to deploy an application to multiple application servers, and enhances a lot of the built-in editors. The PMD plugin is great for searching for potential code issues. As mentioned in a previous post today, the Ganymede plugin really helps to highlight log entries.
I dont care much for fancy visual addons, so I left my IDE (Visiual Studio) in the standard look (other than MS Reference Sans Serif font).
I usually change the color scheme to have a black background instead of white.
I use the Zenburn color scheme with Proggy Clean for a font. It's like a comfy chair for my eyes.
Nothing. I hate dealing with all the breakages that inevitably result from updates, etc. So, I adapt myself to my IDE instead.
I've using a combination of ViEmu and ReSharper with a dark theme.
Oh, and I also hide most of the toolbars and turn off the animations to try to speed things up.
Silver background, 8pt Consolas, disable all toolbars and set tab spacing to 3 spaces. :)
For Visual Studio
Most important - Resharper - I bought my own copy so I don't have to badger my employer about it.
Change the colourisation/font - choose whatever suits you
Optimisation (vote up Gulzar's post with the link in it)
Don't try and make the IDE do everything, just because you can. (Kind of ironic seeing I use emacs as well). I personally really dislike integrated source code management.
Change some defaut file associations so double clicking certain file types doesn't kick off Visual Studio
Aside from Resharper I've actually found most other beneficial thing is not customising the IDE, but customising yourself to learn the keyboard shortcuts. Start with the big gains like Ctrl -, Ctrl Shift -, Ctrl Shift V, Ctrl Alt L etc. etc. and then gradually learn the rest of the shortcuts in order of how often you'd use them
Rather than customizing the IDE, I customized my error messages. I have a macro that expands to a #pragma warning statement that generates a compile-time message in the same format as MSVC++. Visual Studio can parse the resulting warning, so a double-click on the message opens the offending file in the IDE and takes me right to the line in question.
I've used the macro:
To "bookmark" a section of code, so developers will be nagged to fix it each time they build.
Within #if blocks to test for various compile-time conditions.
In headers, to see who #includes them, and where.
From vim you can set the makeprg (make program) variable to a command that will build your project, and the errorformat variable to a scanf-style string that describes the format of the build errors. From there:
:make will build your project
:cl lists all of the errors that match errorformat
:cc takes to you the current error
:cn takes you to the next error
:cp takes you to the previous error.
Out of the box, vim sets makeprg and errorformat to work with make and gcc, and all of the commands are documented within vim's built-in help.
I do Java development in Eclipse. Here are some of the plug ins I find useful:
Mylyn - hides project elements not relevant to the current context.
eUML2 - UML editor.
FindBugs - Static analysis tool to find common bugs in Java.
Crap4J - Another static analysis tool.
EclEmma - Code coverage plug-in for unit tests.
Edit: I forgot one:
Disable the spellchecker. :)
In visual studio 2005 I do these:
Bind F11 to fullscreen mode
Enable a vertical line at 80 characters: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\Text Editor\Guides = "RGB(196,196,196) 80" (Guides won't be present in the registry.)
Add the "Start Debugging", "Break All" and "Stop Debugging" buttons after the "Help" menu.
I am using Vim Cscope plugin.
Cscope is like 'ctags' on steroids and makes traversing code much easier.
I usually use it along with tags to find where a function is declared and then go directly to whatever code is calling this function.
I also use Vim's Rgrep plugin (recursive search) to search for files in the code hierarchy.
Create some basic macro such as printing bug fix code comments:
Public Sub WriteBugFix()
Dim TS As TextSelection = DTE.ActiveDocument.Selection
TS.Text = "'Edited for Bug Fixed By JK - " & Date.Now.ToShortDateString
End Sub
(This answer assumes the workstation is a GNU/Linux computer.)
Emacs makes an excellent IDE specifically because it can be greatly customized.
You customize Emacs by editing the .emacs file in your home directory. My .emacs is a symbolic link:
$ ln -s /home/bzimmerly/bin/emacs/emacs24/wbz.emacs.el .emacs
Since Emacs offers a variety of specialized major modes for program development and debugging, you can easily "roll your own" IDE design that works best for you. For example, when I'm programming in C or assembler, I like to have the left side running GDB mode, with the right side displaying the source being traced.
A little bit of LISP skill goes a long way to turning Emacs into a very powerful IDE. It is well worth the investment of time to learn how to use this powerful tool!
Finally, tools like Youtube are valuable places for learning how to do this. Just entering "Emacs as an IDE" on the Youtube search form will show videos of how people have modified Emacs for just such a purpose. There are videos on editing Python code, Javascript, Java, C, etc.