0

I am interested in trying out objed, but I find that out of the box it gets blocks and expressions wrong in ruby mode. For example, I notice that in identifying a defun it includes any comments and blank lines above the current method:

# Convert the val to a Numeric if is already a Numeric or is a String that
# looks like one. Any Float is promoted to a BigDecimal. Otherwise return
# nil.
def convert_to_numeric(val)
  return BigDecimal(val, Float::DIG) if val.is_a?(Float)
  return val if val.is_a?(Numeric)
  # Eliminate any commas, $'s (or other currency symbol), or _'s.
  cursym = Regexp.quote(FatTable.currency_symbol)
  clean_re = /[,_#{cursym}]/
  val = val.to_s.clean.gsub(clean_re, '')
  return nil if val.blank?
  case val
  when /(\A[-+]?\d+\.\d*\z)|(\A[-+]?\d*\.\d+\z)/
    BigDecimal(val.to_s.clean)
  when /\A[-+]?[\d]+\z/
    val.to_i
  when %r{\A([-+]?\d+)\s*[:/]\s*([-+]?\d+)\z}
    Rational($1, $2)
  end
end

The defun starts with the blank line above the lead-in comment, includes the comment, and ends after the 'end' keyword. The ending looks right, but not the start of the object.

Has anyone worked out an appropriate configuration that avoides these problems for ruby-mode?

  • This site is about specific Q&A, particularly how-to questions. Your question is too broad. Please post one or more specific questions, e.g., providing a recipe for whatever blockages you encounter and specifics about what behavior you want instead. – Drew Aug 25 at 15:50
  • Please try and reword your question so that "yes" or "no" is not a valid answer (e.g. ask "how" to fix your problem). Also, clarify what you mean by "wrong", i.e. give specific example(s) of the behavior you see that you want changed. – Stefan Aug 25 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.