how to tell emacs to actually use the ctags file I created - emacs

Not finding what i'm looking for.
Want to enable/start using Ctags with emacs & Vim (setting this up for a team, some use vi some use emacs)
I can: Run "ctags -e -f ./.ctags LONG_LIST_OF_FILES (I do this in a Makefile)
note: I need to do it this way, because I need to control what is and is not scanned.
A recursive search will be a problem - as there are C files in sub directories that
do not apply to this situation
Result: the file exists, it seems happy but .. how do I tell emacs - yea, there is a ctags file here..
Actually - its more like this:
PROJECT_DOG=/home/foobar/dog
$(CTAG_FILE) = $(PROJECT_DOG)/.ctags
Then I have a number of subdirectories - sort of like this:
$(PROJECT_DOG)/libtail/src
$(PROJECT_DOG)/libtail/include
$(PROJECT_DOG)/liblegs/src
$(PROJECT_DOG)/liblegs/include
$(PROJECT_DOG)/libtail/src
$(PROJECT_DOG)/libtail/include
$(PROJECT_DOG)/libnose/src
$(PROJECT_DOG)/libnose/include
.. and numerous other "lib" like directories ..
The single top level .ctags file covers the entire project... (all "lib directories")
Problem statement:
I "visit" a file in emacs - I'm expecting ctags to appear.. but it is not
Same problem with VI and GVIM.
It seems that both tools do not know the tags file exist...
Tried looking here:
Google finds plenty of examples of how to install ctags, and run ctags
but - nothing about how to "activate?" (if that is the correct word) the tags.
https://www.emacswiki.org/emacs/BuildTags
Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctags
http://timothypratley.blogspot.com/2008/07/ctags.html
And a number of other places - no luck.
MY HOPE IS THIS:
When I visit a file in a directory - the tool (emacs/vi) automatically discovers the "tags" file in that directory, or one of the several parent directories up unto the root. The example being: I open the file: $(PROJECT_DOG)/libtail/src, but the ctags file is 2 levels up.
Or something like that..

Related

Opening all files of a certain filetype in vscode

For my website, I have one "root" folder with a bunch of subfolders containing many different types of files. Example:
root folder
subfolder
subfolder
HTML file
other files...
subfolder
HTML file
other files...
Many of these subfolders have HTML files in them. I am wondering if there are any commands I can run to open all of the HTML files in vscode, or of any filetype for that matter.
I am aware that cmd+control+p allows the selection of a specific file by search, but is there any modification of that for all files of a file type? It is probably possible to write a bash script to do this, but I am not well versed in bash and I am wondering if there are any built-in ways to do this on vscode or plugins I can install to do this.
It also should be noted I am on a mac.
Here's on option to find all files that match a given filename specification (in*.html in my example) and send that list of files to VS Code via xargs:
find . -iname "in*\.html" -print0 | xargs -0 code

Ctags not working with .inc-files

I would love to use tags inside Emacs, like Vim does. However, I have some problems to set it ## Setup:
GNU Emacs GUI version 25.0.5.1 (x86_64-w64-mingw32)
Compiled from Harroogan Emacs.
Projectile and Helm, using the latest version of Projectile/Helm from MELPA
Exuberant Ctags binary 58 for Windows
Windows 7 x64 bit.
Actions:
The binary ctags.exe is in the PATH, and respons when I call it from command line in Windows with ctags --help.
I tried various things to create a TAGS file, without any result. One thing that I seem to have results, is with the help of the package projectile. But it gives me weird results.
When I'm inside a project, currently the buffer index.php is being opened. Inside that buffer, I regenate tags file with projectile-regenate-tags, with C-c p R.
The messages buffer gives me the following:
Starting a new list of tags tables
Making tags-file-name local to Dev/digiloket3/TAGS while let-bound!
I see the file TAGS is being created in the project root.
The directory root structure is like this:
index.php
.projectile
|- INCLUDE
|- AJAX
|- SCRIPTS
|- PHP
Issue:
Then I visit the tag list with find-tag (g C-]). When I notice I don't get all variables and class/functions that are defined in the project.
When I call the helm-etags-select, I see the directory/file next to the tag. And what confuses me, is that only functions/classes and variables from files in the directory AJAX are being visible in the tag list, and not the variables/classes/functions from the files in the directory PHP.
Then I manually creating the TAGS file with in the command prompt with the right directory on ctags -R.
With no help.
All files in the folder PHP are called ****.inc.
When I renamed one of the files to ****.php, then they're popping up in my ctags table.
So the real issue here is how I could tell projectile/ctags to recognize .inc files as PHP-files, or index it
But I'm also open for another things to create a TAGS table on Windows platform with the ctags available on command line.
Any suggestion?
man ctags for starters (if you can do so in Windows? There is documentation available in any case.)
Assigning file extensions for a language is done with --langmap. Run the following command to see how that argument works:
ctags --langmap=php:+.inc.foo.bar --list-maps=php
So in your case, you would probably use something like this to generate your TAGS file:
ctags -e -R --langmap=php:+.inc
Tangentially, note also the options listed when you run ctags --list-kinds=php. You can then control which of those will be used: ctags --php-kinds=-v-j --list-kinds=php

Force AUCTeX to parse the whole document

I'm using AUCTeX 11.87 along with emacs 24.3 for writing my LaTeX documents. This is working nicely with one exception: The parsing.
My document structure is as follows:
./
Master.tex
Chapter_1.tex
Chapter_2.tex
...
header/
header/header.tex
header/packages.tex
header/options.tex
...
Where Master.tex \inputs header.tex which in turn inputs all files in header/. Furthermore Master.tex includes the Chapter_N.tex files within the document environment.
Here comes the problem: AUCTeX does not generate the parse files (the ones in the auto folder) until I have actually opened the file. Meaning that until I have not opened and saved the header/packages.tex and header/header.tex files AUCTeX does not know about the loaded packages and thus their commands/environments.
An now the question: Can I force AUCTeX to (re)parse the whole source-tree (and then reload the style hooks for all open documents)?
If all files are in the same directory, or in subdirectories under it, open the master file and issue M-x TeX-auto-generate RET and as TeX file or directory insert the directory of the master file and as AUTO lisp directory the auto/ subdirectory of the previous directory.
For instance, if your master file is placed in ~/my-document/, insert ~/my-document/ at the first prompt and ~/my-document/auto at the second one (you can also use relative paths if you prefer them).

loading cscope database in emacs

I want to use cscope in emacs. Due to my directory structure i only want to use files from certain subdirectories in the tree.
In the shell i create my cscope.files list (includes a listing of all the source files i want)
the i do:
cscope -q -R -b -i cscope.files
This will create the cscope.out file i want. Now i want to read this file into emacs to use it for source code parsing etc ...
So the question is:
How do i have emacs load it? It seems that all the options i get (ie M-x cscope-wahtever) are for creating a new cscope.out file.
Ok,
i guess i am answering my own question.
So the problem was not exactly with cscope.
First, in order to point cscope to the database file one set the initial directory:
M-x cscope-set-initial-directory
to where the cscope database is located.
However, it appears that the input file from which the database is constructed needs to have relative paths in it (or the initial directory need to be pointing to '/'). I had absolute paths in it and thus nothing was found after setting the initial directory to the source root.

How do I "source" something in my .vimrc file?

I've been working on expanding my vim-foo lately and I've run across a couple of plugins (autotag.vim for example) that require them to be "sourced" in my .vimrc file. What exactly does this mean and how do I do it?
Sourcing a file is 'executing' it. Essentially, each line of the file is considered a command. Sourcing it is the same as typing each command in order. You source with the command :source (usually shortened to :so).
So if you source myStuff.vim
:so myStuff.vim
and if myStuff.vim contained these lines
set xx iI just intersted this<C-]>
set yy bbbb4dw
It's the same as if you typed those commands into Vim
:set xx iI just intersted this<C-]>
:set yy bbbb4dw
The only file sourced by default is the .vimrc(_vimrc on windows) so that's a place you can keep all the commands you use to set up Vim every time.
Where it gets interesting is the fact that since a sourced file is just a series of commands, and sourcing is a command, you can source files from your source files. So plugins you use every time could be sourced when you start up Vim by adding a line to your .vimrc like this
so myPlugin.vim
Files in your .vim/plugin directory are sourced (loaded) automatically.
There is always the :source file command. I usually write .vimrc that contains custom commands and what not for the console application and then a .gvimrc that contains additional goodies that are appropriate for a windowed version. My .gvimrc starts with source $HOME/.vimrc to pick up everything from the console version before adding in new stuff.
There are normally two vimrc files, one is _vimrc and the other _gvimrc (in the first one are the things for vim, and in the second for gvim - graphical things) - although most people I know just put everything in _vimrc.
A good practice is to keep all your extra files (plugins, colorschemes, snippets ...) in a separate (your own) vimfiles directory (which you can take with you).
If you do
:help vimfiles
vim will tell your vimfiles directory should be located. It depends somewhat on the platform (win, unix). On windows the usual is in your user folder (documents and settings, then user ...).
In vimfiles directory there are a couple of subdirectories. Amongst them is the "plugin" subdirectory. Plugins put in that dir will be loaded automatically (also plugins put in subdirectories of "plugin").
If you do not wish to load it automatically, just put it in your "vimfiles", or some other directory, and
:so plugin_name.vim (with the appropriate path)
(you can use the $vim, $vimfiles, and $home as shortcuts when defining path to plugin)