Plan 9: Code Assist
Jump to definition with ctags
Use ctags for jump-to-defintion. Also, you can use Button3 in acme to jump to include files - both system and local headers.
readtags uses binary search. So it makes jump to symbol faster on a large codebase.
Note:
- Use sig command for signature lookup.
- Use src command for jumping to Plan 9 command sources.
If you have mounted contrib sources, use this. Alternatively, download tar from https://ctags.sourceforge.net/ .
Make following changes:
- in Makefile, add '-DHAVE_REMOVE' (remove() instead of unlink()) and '-DHAVE_OPENDIR' (for directory recursion option) to DEFS
- in config.h, remove or comment out the definition of INT_MAX
mv configure.new configure
readtags also support prefix (-p) and ignorecase (-i) match. -e includes extended fields in the output.
c classes
d macro definitions
e enumerators (values inside an enumeration)
f function definitions
g enumeration names
l local variables [off]
m class, struct, and union members
n namespaces
p function prototypes [off]
s structure names
t typedefs
u union names
v variable definitions
x external and forward variable declarations [off]
Tag file
sym=$1
res=`{readtags $sym}
if(~ $#res 0){echo no tag: $sym >[1=2]; exit 1}
file=$res(2); addr=$res(3)
plumb -d edit $file:$addr
Code Outline with ctags
Use ctags extended format (-x) to create code outline.
main.c:47 macro ANCHOR_BUF_SIZE
main.c:48 macro ANCHOR_SIZE
main.c:404 macro CLOCKS_PER_SEC
main.c:408 macro CLOCKS_PER_SEC
main.c:402 macro CLOCK_AVAILABLE
main.c:407 macro CLOCK_AVAILABLE
main.c:57 macro boolean
main.c:63 macro boolean
main.c:417 macro clock
main.c:89 macro plural
main.c:485 macro timeStamp
main.c:518 macro timeStamp
main.c:94 member bytes
main.c:94 member files
main.c:94 member lines
main.c:94 variable Totals
main.c:98 variable VERsion
main.c:116 function addTotals
main.c:409 function clock
main.c:220 function createTagsForAmigaWildcard
main.c:335 function createTagsForArgs
main.c:286 function createTagsForEntry
main.c:311 function createTagsForWildcardArg
main.c:172 function createTagsForWildcardEntry
main.c:189 function createTagsForWildcardUsingFindfirst
main.c:358 function createTagsFromFileInput
main.c:384 function createTagsFromListFile
main.c:464 function etagsInclude
main.c:125 function isDestinationStdout
main.c:525 function main
main.c:469 function makeTags
main.c:420 function printTotals
main.c:247 function recurseIntoDirectory
main.c:142 function recurseUsingOpendir
outline -i will print Font Awesome icons instead of kind. If the font is not available, you'll see notdef symbols.
Call Hierarchy
Print call hierarchy of function main. This is similar to cflow on UNIX. You can pass multiple files. If the a function definition is missing in the input files, it shows up as [external].
Options:
p Add include paths
w Indent width
D,I,U Define, Include and Undefine flags are passed to cpp
Source: https://9p.io/sources/plan9/sys/src/cmd/calls.c
1 main
2 cat
3 read [external]
4 write [external]
5 sysfatal [external]
6 open [external]
7 sysfatal [external]
8 close [external]
9 exits [external]
Font
Change the font for a window.
Acme Scripting
"The environment of such commands contains the variable $% with value set to the filename of the window in which the command is run, and $winid set to the window's id number."
echo 2,5 > /mnt/acme/$winid/addr
echo dot=addr > /mnt/acme/$winid/ctl
echo show > /mnt/acme/$winid/ctl
Lessons Learnt
- Use ctags --excmd=number for maximum compatibility across editors i.e. use line number instead of regex patterns generated for tag search.
Troubleshooting
This makes pooldel and free check every block on each operation, so it aborts at the corrupting write's neighbourhood, not much later.
mainmem->flags |= POOL_PARANOIA | POOL_ANTAGONISM;
Code
- https://gitlab.com/atamariya/plan9front/-/blob/front/rc/bin/code/gentags
- https://gitlab.com/atamariya/plan9front/-/blob/front/rc/bin/code/outline
- https://gitlab.com/atamariya/plan9front/-/blob/front/rc/bin/code/jump
- https://gitlab.com/atamariya/plan9front/-/blob/front/sys/src/cmd/calls.c
Comments
Post a Comment