From mboxrd@z Thu Jan 1 00:00:00 1970
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me
X-Spam-Level:
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM
autolearn=unavailable autolearn_force=no version=3.4.4
Path:
eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!feeder.erje.net!eu.feeder.erje.net!news.alphanet.ch!alphanet.ch!.POSTED!not-for-mail
From: Blady
Newsgroups: comp.lang.ada
Subject: GPS bookmarks and pragma Title.
Date: Mon, 12 Jan 2015 22:42:42 +0100
Organization: Posted through ALPHANET (http://www.alphanet.ch/)
Sender: blady@anantes-656-1-188-57.w90-59.abo.wanadoo.fr
Message-ID:
NNTP-Posting-Host: anantes-656-1-188-57.w90-59.abo.wanadoo.fr
Mime-Version: 1.0
Content-Type: multipart/mixed;
boundary="------------090205090602070101030900"
X-Trace: shakotay.alphanet.ch 1421098962 28341 90.59.11.57 (12 Jan 2015
21:42:42 GMT)
X-Complaints-To: usenet@alphanet.ch
NNTP-Posting-Date: Mon, 12 Jan 2015 21:42:42 +0000 (UTC)
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9;
rv:31.0) Gecko/20100101 Thunderbird/31.3.0
Xref: news.eternal-september.org comp.lang.ada:24553
Date: 2015-01-12T22:42:42+01:00
List-Id:
This is a multi-part message in MIME format.
--------------090205090602070101030900
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
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
--------------090205090602070101030900
Content-Type: text/x-python-script;
name="title.py"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="title.py"
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)
--------------090205090602070101030900--