From 8fcd5369775dcb4b825f6728c9df93369539a853 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Thu, 24 Sep 2015 22:47:45 +0200 Subject: Initial rewrite of posts for pelican --- gedit-changelog-line-snippet.rst | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 gedit-changelog-line-snippet.rst (limited to 'gedit-changelog-line-snippet.rst') diff --git a/gedit-changelog-line-snippet.rst b/gedit-changelog-line-snippet.rst new file mode 100644 index 0000000..098ab33 --- /dev/null +++ b/gedit-changelog-line-snippet.rst @@ -0,0 +1,37 @@ +gedit snippet generating RPM spec %changelog line +################################################# + +:date: 2015-08-01T00:26:00 +:category: computer + +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[0].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. + +.. _snippets: + https://wiki.gnome.org/Apps/Gedit/Plugins/Snippets -- cgit