I am using emacs for programming, and recently also gdb.
The "locals" window does show local variables but not arguments to a function, which in a way also could be considered local variables. For example, if I have
void foo(char *bar)
{
int n;
....
}
then n is shown in the "locals" but not bar. Of course, I can print bar but it is not automatically updated while I step through the code and I have to print all the time.
Is there a way to add expressions that are shown in a window and constantly updated as I execute the code?
The display command will certainly fulfill your needs:
If you find that you want to print the value of an expression frequently (to see how it changes), you might want to add it to the
automatic display list so that GDB prints its value each time your
program stops.
By example, once that your are in foo body (under gdb), type:
display bar
The interactive command gud-watch will watch the expression at point and display its value in the speedbar. Prefix it with C-u to be able to enter an expression.
See the manual page Watch Expressions for more details.
At the moment there doesn't seem to be a way to display watched expressions in the locals window.
Related
Whenever I run a source block in emacs org mode, the whole block executes and then I see the results. Is there a way to see the output of the program in real time?
For instance, when installing packages with pip install, the progress bars appear all at once, and they appear one after another (so org mode is not interpreting carriage returns correctly). Is there a header argument or some variable I can set to fix this? If not, where could I insert a filter function to achieve the same result?
I am learning scala in my free time. When I was programming in python with Pycharm, Pycharm provides a very handy tool called debug console which, if I set a breakpoint at line L, would store the value of the variables by the time of L, and I can freely explore some operations on those variables.
I know scala has a REPL tool and I am wondering if scala in Intellij IDEA has the similar debug console. I know I can use evaluate expression tool but it is a little difficult to use because
I can't see the previous calculated expression values and I have to retype every time to see the values.
I can't store the result of the expression on one variable and continue using that variable.
Thanks!
If you set a breakpoint on a line (click in left margin to get a red dot) and then Debug rather than Run (bug icon rather than play icon) then IntelliJ will stop at the first breakpoint and show a very comprehensive debugging window. You can evaluate an expression (calculator icon) and create a watch expression which is evaluated each time a breakpoint is hit (watch panel on the right).
Is there any way to display the current TTY when using Emacs shell mode? Right now I get around by having tty displayed as part of the prompt but this requires scrolling back
You can display it on the mode line.
Look at the documentation , in elisp manual, section 23.4 -- Mode Line Format. In subsection 23.4.2 there is written how you do it: you write a form that returns the value you are interested about.
`(:eval FORM)'
A list whose first element is the symbol `:eval' says to evaluate
FORM, and use the result as a string to display. Make sure this
evaluation cannot load any files, as doing so could cause infinite
recursion.
While trying to autocomplete a file (e.g. to open a file with C-x C-f) Emacs-helm shows a list of possible candidates.
If I then press Tab (which I would hope it would help me choose the first/closest match), I get the following in the minibuffer:
It looks like the minibuffer gets confused with escape characters, and it does not choose the file that I actually want to open (the top choice).
Helm requires this conceptual jump from the default Emacs completion, which is not so obvious:
You don't need to press a key to complete. The completion buffer refreshes
with new results after every input.
This is called "incremental" completion.
The normal tab functionality is not needed in "incremental"
completion. So tab was rebound to helm-select-action, which allows you to
choose an alternative action with the selection. But there is only one action
in read-file-name.
The error you're seeing could be clearer though, I've filed this issue on github.
Additionally, note Helm treats each space separated term as a filtering
regular expression. So, pressing space foo will filter
the current list down to those that contain foo in the name.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How do you retrieve the selected text in MATLAB?
I want to implement and add some features to the function "Evaluate Selections", where you can highlight code and then "Evaluate Selections" by right click your mouse (or F9).
In the editor environment, this is how it is done:
editorObject = matlab.desktop.editor.getActive;
eval([editorObject.SelectedText ';']);
How can I implement this from the command line window, or the help window?
EDIT:
Maybe I didn't express my question clearly.
Imagining that we already have this function called eva_select(), I can use function this way:
I wrap the function as the Shortcuts button.
Use mouse to select a variable at command line window, maybe I entered before, say var_a
Then I click that Shortcuts button, the text which I selected before will be executed. This is exactly as press F9 key or choose right mouse menu -- "Evaluate Selections".
But if we really have that function, we can do more! We can modified eva_select() to eva_select_size(), in this way, we can select a variable, say var_a at command line window or help window, click eva_select_size() shortcuts button, then, we will get size(var_a) at command line window!
EDIT:
Thanks, I can retrieve the text in the command window, but I can't do the same thing in the help window, is it possible to do that?
The command window, like other GUI components in the MATLAB desktop, is Java-based. Therefore it can be accessed programmatically, but it is completely undocumented and its use is not officially supported.
Exploring around, here is a solution that seems to work in both R2012a and R2012b. It involves obtaining a handle to the underlying JTextArea of the command window, which is used to get the selected text (to evaluate size of selected variable name)
Create a shortcut with the following code:
x = com.mathworks.mde.cmdwin.XCmdWndView.getInstance();
s = char(x.getSelectedText());
if isvarname(s) && exist(s,'var')
eval( sprintf('size(%s)',s) );
end
Next highlight a variable name in the command window and execute the shortcut. The size will be immediately printed as shown in the screenshot below:
It is not very nice as it is an external solution, but this is how it could work:
Assuming you are in the command window and want to evaluate size(var_a) by selecting it, you can probably do this with a keyboard macro. Defind the appropriate function of var_a
f(x) = eval('size(' x ')'
%This could be done in the macro, but nicer to do it here for easy editing.
Then make sure your macro does this:
Copy 'var_a'
Turn it into 'f(var_a)'
Paste the result
Hit enter
Like i said, it's not pretty, but it should do the trick.