Author Topic: Using Ctags with AutoLisp  (Read 2014 times)

0 Members and 1 Guest are viewing this topic.

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Using Ctags with AutoLisp
« on: August 08, 2011, 01:24:50 PM »
A while back someone (sorry, I don't remember who or when) asked if you can use Ctags with AutoLisp; I was doing some snooping around with ctags today when I thought about that request. After some internet searches turned up nothing, I finally decided that it would be easier to just "create a user-defined language" (refer to the Ctags docs).

Here is a command you can use to find Definitions (defun) and Sets (setq).

Code: [Select]
ctags --langdef=alisp --langmap=alisp:.lsp --regex-alisp="/.defun[ \t]*([a-zA-Z0-9_[:punct:]]+)/\1/d,definition/" --regex-alisp="/.setq[ \t]*([a-zA-Z0-9_[:punct:]]+)/\1/d,set/" --language-force=alisp
I have this entry in my vimrc file (Vim configuration file).
Code: [Select]
augroup ALisp
  au! BufRead,BufNewFile,BufEnter *lsp :map <silent> <F12> :silent !ctags --langdef=alisp --langmap=alisp:.lsp --regex-alisp="/.defun[ \t]*([a-zA-Z0-9_[:punct:]]+)/\1/d,definition/" --regex-alisp="/.setq[ \t]*([a-zA-Z0-9_[:punct:]]+)/\1/d,set/" --language-force=alisp -R .<cr>
augroup END

TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

gskelly

  • Newt
  • Posts: 185
Re: Using Ctags with AutoLisp
« Reply #1 on: August 09, 2011, 10:24:34 AM »
Oooo... that is cool. Thanks for that tidbit!
Bricscad v12

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Re: Using Ctags with AutoLisp
« Reply #2 on: August 09, 2011, 05:50:11 PM »
You are very welcome.

I was `creating a (different) user-defined language' when I remembered the request. I was actually really happy I did it because when and if I do get back into using AutoLisp this will help me tag my current project and LiFP's standard library of files. -i.e. Extending the Lisp tags this way and the use of the "append" option in ctags will allow me to not be tied down to the current directory(ies) (I can jump back and forth all over the place). I am going to look a bit more into tweaking my vimrc file and my tagging system when I get the chance (but that is pretty low on my TODO list).

I am glad this was of some use to you though. Oh and let me know if you expand this.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Harrie

  • Guest
Re: Using Ctags with AutoLisp
« Reply #3 on: August 10, 2011, 07:11:47 AM »
How I make start?
Is it to download gvim72.x.exe at http://vi-improved.org/index.php

Regards

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Re: Using Ctags with AutoLisp
« Reply #4 on: August 10, 2011, 12:48:12 PM »
There are several editors that can use CTAGS: Vim, Emacs, UltraEdit, Boxer to name a few so you do not need to install Vim to use the ctags command I posted.

The first snip I posted was a command to generate a tag file that contains "defuns" and "setqs". CTAGS already handles the Lisp language but there are problems -e.g. ctags does not find defuns that are indented ( local functions ). And CTAGS doesn't support variables -i.e. "setq". The first snip-it I posted corrected these issues.

I know a lot of people don't use a text editor, or don't even know what one is, so if you don't understand how this ctags command can help you, I'm sorry but this post may not be for you. That was not meant as an insult; a lot of people don't understand what a good text editor is or why some of them have been around for 30 years. A good text editor like Vim, Emacs, UltraEdit, and Boxer do a lot of the time wasting stuff for you. I see people ask questions or waste time on areas or things that a good editor will do for them automatically. CTAGS is a tool which Vim uses to know where functions or variables can be found so it can "jump to" or "list" them. To give you an example of how Vim uses CTAGS: When I open a file a menu is automatically generated that contains all the function definitions for the file/programming language. I can easily navigate to those functions by using that menu or I can generate a more complete list with the second snip-it in which i can use navigate around my file in another method.

Having said that:
If you don't already have Vim and would like to try it I highly recommend that you plan to invest the time and effort (It doesn't take a lot of time but Vim isn't one of those types of editors you can "use" without setting it up first either). The current version of Vim is 7.3 and can be found here:
[ http://www.vim.org/download.php#pc ]

My recommendations:
1. Install Vim to "C:\Vim" not "C:\Program Files\Vim"
2. Do to the tutorial (C:\Vim\vim73\vimtutor.bat) It takes about 20-30 minutes (in several languages) and it's well worth it.
3. Place your "_vimrc" file here: "C:\Vim\_vimrc".
  (Technically speaking you need a "vimrc" and a "gvimrc" file but we can address that detail later if you decide to continue trying/learning Vim).
4. The second snip-it i posted goes in that "_vimrc" file and the command to issue it is the F12 key.

I hope this post helps. Again, I don't mean to insult anyone; if I did, I'm sorry.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org