Sat 01 August 2015
I have done a little bit of work to make gedit fully working in RHEL-7 (appropriate packages with almost all my fixes will be most likely available in the next minor release of RHEL-7). Generally my feeling is that gedit is a way less powerful (and writing Python plugins more complicated) than the similar stuff in vim. However, there are some things which are shockingly powerful. One of the things which quite surprised me are snippets. They are a way more powerful than just simple text replacements. With this functionality I can create even something so crazy as this snippet generating %changelog line in the RPM spec files.:
$< import rpm import datetime spec = rpm.spec($GEDIT_CURRENT_DOCUMENT_PATH) date = datetime.date.today().strftime("%a %b %d %Y") headers = spec.packages.header version = headers['Version'] release = ".".join(headers['Release'].split(".")[:-1]) packager = headers['Packager'] newheader = "* %s %s - %s-%s\n- " % (date, packager, version, release) return newheader >
To install this snippet, open Manage Snippets.. in the gedit application menu and in the RPM Spec section create a new snippet and copy the code above to the text box on the right side. Give to this snippet some TAB trigger (I have chi there) or a key shortcut and be done. Then activate this snippet in the top of the %changelog section.