From: Blady <p.p11@orange.fr>
Subject: GPS bookmarks and pragma Title.
Date: Mon, 12 Jan 2015 22:42:42 +0100
Date: 2015-01-12T22:42:42+01:00 [thread overview]
Message-ID: <m91f4h$rll$1@shakotay.alphanet.ch> (raw)
[-- Attachment #1: Type: text/plain, Size: 1130 bytes --]
Hello,
I was not so happy with bookmarks proposed by GPS.
I had difficulties to get the good bookmark based on its name and there
are not automatically created on useful locations.
But bookmarks are useful with plenty of big source files.
So I propose a combination of pragma Title (GNAT legacy use with DEC Ada
83) and bookmarks in GPS:
GPS could parse all Ada files in an open project searching for pragma
Title and fill bookmark list with the results.
Thus it could be very easy to navigate safely into many Ada files as
bookmarks are in Ada code.
Thus Adacore team has suggested to implement it as a GPS Python pug-in.
Here is the result in attached Python source file.
Put title.py in ~/.gps/plug-ins, add pramas Title wherever you want in
Ada source as:
procedure Essai23 is
pragma Title ("T1");
pragma
Title
(
"T2"
)
;
pragma title ("T3");
begin
null;
pragma TITLE ("T4");
end;
and select menu "/Navigate/pragma Title->Mark", bookmarks are displayed
with menu "/Tools/Views/Bookmarks".
What is your feedback?
HTH, Pascal.
http://blady.pagesperso-orange.fr
[-- Attachment #2: title.py --]
[-- Type: text/x-python-script, Size: 1970 bytes --]
import GPS, gps_utils
# This plug-in parses and creates BookMarks at lines like:
# pragma Title ("Parse and create");
# A menu is added to parse the current source file:
# /Navigate/pragma Title->Mark
# FILE : title.py
# LAST UPDATE : 20150112
# COPYRIGHT : (c) Pascal Pignard 2015 (except parts with named authors)
# LICENCE : CeCILL V2 (http://www.cecill.info)
# CONTACT : http://blady.pagesperso-orange.fr
# Cursor position saved, from Emmanuel Briot
@gps_utils.with_save_excursion
def create_bookmark_at_location(loc, name):
loc.buffer().current_view().goto(loc)
bm = GPS.Bookmark.create(name)
bm.filename = loc.buffer().current_view().title()
return bm
def parse(menu):
#print "Parse02"
source = GPS.EditorBuffer.get()
view = source.current_view()
#print "view title", view.title()
for bm in GPS.Bookmark.list():
if "filename" in dir(bm):
#print "filename", bm.filename
if bm.filename == view.title():
bm.delete()
#print bm, "deleted"
start = source.beginning_of_buffer()
pragma_loc = start.search("pragma[\ \t\n\r\f]*title", regexp=True, dialog_on_failure=False)
while pragma_loc != None:
#print pragma_loc
pragma_name = pragma_loc[0].search('pragma[\ \t\n\r\f]*title[\ \t\n\r\f]*[(][\ \t\n\r\f]*"[^"\n\r]*"', regexp=True, dialog_on_failure=False)
#print pragma_name
if pragma_name != None:
pragma_mark_name = source.get_chars(pragma_name[0], pragma_name[1]-2)
pragma_mark_name = pragma_mark_name[pragma_mark_name.find('"')+1:]
#print pragma_mark_name
bm = create_bookmark_at_location(pragma_name[0], pragma_mark_name)
#print bm, "created"
start = pragma_name[1]
else:
start = pragma_loc[1]
pragma_loc = start.search("pragma[\ \t\n\r\f]*title", regexp=True, dialog_on_failure=False)
#parse("dummy")
GPS.Menu.create ("/Navigate/pragma Title->Mark", parse)
reply other threads:[~2015-01-12 21:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox