Excuse my emacs newbiness here, but does anybody know how to get around this? When coding in emacs, in ruby-mode, it indents to the correct level (i.e. by 2 spaces) after all the keywords, like def, class, module, begin etc, but when breaking parameter lists across multiple lines, it indents to a seemingly random position, like 40 or so columns over.
I've been reading around emacs tab settings and seem to just be going around in circles and not getting to information I'm looking for, so I figured I'd ask here.
Here's a screenshot of where it is placing the cursor in a parameter list. I've tried indenting inside of curly braces (e.g. for a block, or a hash) and that is working ok, it's the parentheses that are messing it up.
http://compgroups.net/comp.emacs/Ruby-mode-indentation-of-continuation-lines
(setq ruby-deep-indent-paren nil)
Or temporarily, within the current session:
M-x set-variable RET ruby-deep-indent-paren RET nil RET
Inside of a parentheses it will now indent like it does everywhere else. There is still a minor bug in the case of what I posted above. It indents 2 spaces further than I want it to, because I'm confusing it with the combination of ( and {.
ruby-deep-indent-paren and related vars have no effect for me because ruby-use-smie is t. Setting both to nil didn't seem to help either :-(
But switching to enh-ruby-mode, it's working!
Setting enh-ruby-deep-indent-paren to nil had an effect.
Setting enh-ruby-bounce-deep-indent to t allows me to press Tab again to toggle between the styles!
Basically it's trying to line up the args in a multi-line list of parenthesized arguments, like:
function_call (arg1,
arg2);
Setting the ruby-deep-indent-paren to nil as above changes the behvaior to the annoying double-indenting for mixed braces, e.g.:
if (cond) then
do_stuff
end
function_call (&proc {
do_stuff
})
The indenting wierdness is really bothering me. I edited Mats' original ruby-mode.el code to try and indent more sanely. But I can't get it cleaned up for the life of me.
Related
(Very new to AHK, so sorry if this sounds very stupid/trivial)
I have a small AHK script (see below) with a variable called var. I would like to call and modify this variable from within multiple hotkeys. However, even when trying to "yield" its value (with the F8 hotkey) the value doesn't get printed. How can I go about with this?
#SingleInstance, force
+Escape::ExitApp
!r::Reload
!p::Suspend
var := 42
F8::
MsgBox % "Var value is " . var . "."
Return
;F12::
;blabla not relevant yet
Your variable declaration is unreachable code.
The code execution stops when the first hotkey label is encountered. This is called the Auto-execute Section.
Move your hotkey definition to be at the very bottom.
(All hotkeys defined by hotkey labels always get created regardless of being in the auto-execute section or not)
And as a bonus, the concatenation operator . is redundant, you don't need to use it, you can just leave it out.
(Unless you prefer to use it, of course)
SO...
Sublime Text has the built in ability to fold methods, but as soon as the method declaration spans multiple lines it loses this ability. Does anyone know about a plugin or a way to make this work? Specifically I am running into this with ruby (and my team adheres to a strict style guide regarding line length), but the language shouldn't matter.
Instead of clicking on the down arrow that appears in the gutter next to the first line of the function definition, all you need to do is put your cursor on one of the function's indented lines (not the indented function parameters, but in the function definition itself) and use the CtrlShift[ key binding (on OS X use ⌘Alt[) to fold the function and its parameters. Use CtrlShift] (⌘Alt] on OS X) to unfold, or you can click the sideways arrow next to the def line.
So, this:
becomes this:
Try this formatting
def example( # <--- folds parameters here
param,
param
) # <--- folds method body here
foo
bar
qux
end
The language does matter as far as I know, method folding is part of the language specific configuration. At least it used to be in previous versions.
Some Ruby code won't fold correctly in Geany.
For example, if I have
def validate(arr)
if arr.any?(&:empty?)
fail
end
end
validate(["a", "b", "c"])
validate([""])
then folding the if folds too much:
Whereas if I use quotation marks around the text and question mark of the Ruby symbol (that is, change :empty? into :"empty?", then it folds correctly:
How can I make Geany fold the code correctly, without having to change :empty? into :"empty?"? Is this a configuration thing, or a bug?
Current consensus, based on the comments, is that it's just a bug in Geany.
I've created a bug report at https://bugs.launchpad.net/ubuntu/+source/geany/+bug/1337015
I am using ReSharper to refactor my code, and one of the suggestions of ReSharper is to use a respective branch instead a if statement that is always true.
If I have
if (myVar != null){
//code
}
And I apply the respective branch the code is like the following
{
//code
}
Is this a short cut of an if statement?
What is this used for?
What is the difference between the cutely brackets and nothing?
Thanks in advance.
The block is required to stay there, or semantics would change.
The scope of variables declared inside the branch block would change when you remove the braces. Potentially with conflicting/hiding (lambda) variables this would lead to surprises.
To remove the braces, position the cursor on either one and hit Alt-Enter, 'Remove Braces'
Reintroduce braces: select block of code, Ctrl-Alt-J, 7 to surround with block :)
In ReSharper 6.0 this command also removes braces if you don't have variable declarations inside.
I don't know why I'm having so much trouble groking the documentation for the elisp debugger.
I see it has a commands to "step-into" (d). But for the life of me, I cannot see a step-out or step-over.
Can anyone help?
If I have this in the Backtrace buffer:
Debugger entered--returning value: 5047
line-beginning-position()
* c-parse-state()
* byte-code("...")
* c-guess-basic-syntax()
c-show-syntactic-information(nil)
call-interactively(c-show-syntactic-information)
...where do I put the cursor, and what key do I type, to step out of the parse-state() fn ? by that I mean, run until that fn returns, and then stop in the debugger again.
When debugging, I press ? and I see:
o edebug-step-out
f edebug-forward-sexp
h edebug-goto-here
I believe o (it is step-out) and f (like step over) are what you're looking for, though I also find h extremely useful.
'c' and 'j' work kind of like a step-out and step-over. When a flagged frame (indicated by "*") is encountered (the docs say "exited" but this doesn't seem to be how the debugger behaves), the debugger will be re-entered. When the top frame is flagged, they work like step-over; when it isn't, they work like step-out.
In your example backtrace, typing either will step out of line-beginning-position into c-parse-state. The frame flag should clear, so typing either a second time should step out of c-parse-state.
Hm. I, for one, prefer debug to edebug, but to each her own...
As to debug, I use d, c, e, and q.
If you do use debug, one thing to keep in mind, which can save time and effort, is that when you see a macro call (starts with#) you can just hit c to expand the macro -- there is normally no sense in digging into the macro expansion code (unless you wrote the macro and you are trying to debug it).
In particular, for dolist, there are two levels of macroexpansion to skip over using c: one for dolist and one for block.
HTH.