module Editors::Helpers::EditorSyntax

Helpers for generating editor invocation commands

@author Jeff Sandberg

Public Instance Methods

blocking_flag_for_editor(blocking) click to toggle source

The blocking flag for this particular editor.

@param blocking [Boolean] If false, returns nothing

@return [String, Nil]

# File lib/editors/helpers/editor_syntax.rb, line 15
def blocking_flag_for_editor(blocking)
  case editor_name
  when /^emacsclient/
    '--no-wait'
  when /^[gm]vim/
    '--nofork'
  when /^jedit/
    '-wait'
  when /^mate/, /^subl/, /^redcar/
    '-w'
  end if blocking
end
editor_name() click to toggle source
# File lib/editors/helpers/editor_syntax.rb, line 7
def editor_name
  File.basename(default_editor).split(' ').first
end
start_line_syntax_for_editor(file_name, line_number) click to toggle source

The starting line syntax for the user’s editor @param file_name [String] File name/path @param line_number [Fixnum]

@return [String] rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength

# File lib/editors/helpers/editor_syntax.rb, line 34
def start_line_syntax_for_editor(file_name, line_number)
  return file_name if line_number <= 1

  case editor_name
  when /^[gm]?vi/, /^emacs/, /^nano/, /^pico/, /^gedit/, /^kate/
    "+#{line_number} #{file_name}"
  when /^mate/, /^geany/
    "-l #{line_number} #{file_name}"
  when /^subl/
    "#{file_name}:#{line_number}"
  when /^uedit32/
    "#{file_name}/#{line_number}"
  when /^jedit/
    "#{file_name} +line:#{line_number}"
  when /^redcar/
    "-l#{line_number} #{file_name}"
  else
    if windows?
      "#{file_name}"
    else
      "+#{line_number} #{file_name}"
    end
  end
end