[Geany] [PATCH] Command-line line/column specification

Daniel Richard G. skunk at xxxxx
Mon Feb 11 07:25:08 UTC 2008


Hello list,

Recent convert to Geany here! I love how it runs fast (*cough*Kate*cough), 
doesn't have any desktop-environment dependencies (*cough*Bluefish*koff), 
and uses a modern GUI toolkit (*cough*NEdit*hack). Please keep on trucking.

I would like to submit a patch (against SVN) to add two features that I've 
found very useful:

1. Allow specifying the line number in a document on the command line using
   traditional Unix "+NNN" syntax. This makes Geany compatible with tools 
   like Cscope, and countless others.

2. Allow specifying the line number---and optionally the column---in a
   document on the command line using a ":NNN" or ":NNN:NN" suffix. This is 
   not so traditional, but it means that you can (for example) 
   cut-and-paste part of a typical GCC warning line...

	foo/bar/baz.h:340:6: warning: "_MSC_VER" is not defined

   ...and very quickly have a usable command line:

	$ geany foo/bar/baz.h:340:6:

   (The trailing ":" is ignored. Yes, I know, you can invoke the compiler 
   via the IDE, which parses the warnings... I often work with 
   nightly-build log excerpts, however, so this is convenient for that.)


Implementation notes:

* GLib's option-parsing facilities can't handle "+" options. What I did was 
  pull those out before GLib gets to them, replacing each with a new 
  "--dummy" option that does nothing. This is better than handling the 
  option after the fact, because then you have to write your own logic to 
  remove the option from argv[]. (Or handle it as a special case when you 
  parse the non-option arguments.)

* cl_options needs to be initialized before we look at the "+" option, lest 
  we blow away the user's specified line number.

* get_line_and_column_from_filename() tries to be strict about the syntax 
  of the line/column-number suffix, to help avoid unfortunate cases like

	$ touch ifconf.08:00:69:02:10:05
	$ geany ifconf.08:00:69:02:10:05

  At most, it allows a trailing ":", for cut-and-paste friendliness.


--Daniel


-- 
NAME   = Daniel Richard G.       ##  Remember, skunks       _\|/_  meef?
EMAIL1 = skunk at iskunk.org        ##  don't smell bad---    (/o|o\) /
EMAIL2 = skunk at alum.mit.edu      ##  it's the people who   < (^),>
WWW    = http://www.******.org/  ##  annoy them that do!    /   \
--
(****** = site not yet online)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: line-col.patch
Type: text/x-diff
Size: 3456 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/users/attachments/20080211/b7ec3ba1/attachment.patch>


More information about the Users mailing list