m00natic / vlfi

View Large Files in Emacs
457 stars 25 forks source link

VLF makes find-tag malfunctioned #15

Closed tuhdo closed 10 years ago

tuhdo commented 10 years ago

If I set vlf-application to dont-ask, then using find-tag causes the TAGS file (created by the program Exuberant Ctags: http://ctags.sourceforge.net/) to open in inside a buffer instead of going to the symbol at point. This happens only if the TAGS file exceeds large-file-warning-threshold.

There should be a mechanism to exclude VLF in certain functions (i.e. find-tags) or any function that uses file content without opening any buffer. Currently I have to set to vlf-application to ask and cannot use the dont-ask option because of this bug.

m00natic commented 10 years ago

I don't use TAGS files, but probably what happens with ebrowse is similar. Can you see what major mode the TAGS file gets when opened? (M-: major-mode). If it is somewhat special, try to add it to the vlf-forbidden-modes-list list like this (replace ebrowse-tree-mode with what you get from the TAGS buffer):

(add-to-list 'vlf-forbidden-modes-list 'ebrowse-tree-mode nil 'eq)

This is how it gets fixed for BROWSE files. If you can make it work this way - I'll add it to vlf-forbidden-modes-list. If not, I'll look further.

P.S. I've made VLF not activate in case of buffer without file under any setting. In this case though, obviously TAGS file exists and is loaded.

m00natic commented 10 years ago

I checked it, fundamental-mode is used for TAGS so the vlf-forbidden-modes-list mechanism is not useful. Right now I don't have idea how to distinguish this case from regular file load. Something that worked for me is after loading the TAGS file, switch to it and disable vlf-mode (M-x vlf-mode) which reloads the whole file. M-. worked again.

tuhdo commented 10 years ago

Yes it's fundamental mode. Is it possible to make VLF such that even if a default action is chosen for vlf-application (i.e. dont-ask), we can select some specific major modes to act differently; for example, I can set Fundamental Mode (and maybe a few other special modes) to ask, but the default for every other major modes is dont-ask, as I set.

m00natic commented 10 years ago

Using defadvice for selected functions and locally neutralizing vlf-application seems to work. Have a try.

P.S. I experiment with the 'always setting as well and see that jumping to tags (or in my case ebrowse positions) doesn't work. Just to warn you ;-) I have some idea, but this will wait other changes.

tuhdo commented 10 years ago

Still doesn't work. VLF opens the TAGS file in buffer.

I don't use the etags program included with Emacs but the ctags here: http://ctags.sourceforge.net/

After installing, you can find a sufficiently large source code or adjust large-file-warning-threshold to a really small value depend on your source code size.

Then you generate source code from the root directory by invoking the command: ctags -e -R (-e is for Emacs, -R for recursive processing sub-directories).

Then you can invoke M-. at the root directory (or any symbol at point in your project directory). Usually you will have a Find tag: prompt in the minibuffer, or it jumps to the definition of symbol at point. However, if I set vlf-application to always or dont-ask, it simply opens the TAGS file and not doing any of desired actions :( . Even with the latest commit.

But yes, take your time. You can work on this later as there are more important features. Currently I set to ask.

m00natic commented 10 years ago

Hm, I use etags.ctags in Fedora which identifies itself with the sourceforge page and pass the same parameters and over project that generates large enough TAGS file. It works OK with GNU Emacs 23, 24.3 and today's trunk (emacs -Q -l ..../vlf.el). I restarted Emacs after upgrading VLF from Melpa. TAGS file is loaded normally (after size warning but no vlf as option), M-. jumps where asked with vlf-application set to 'always or 'dont-ask.

What version of Emacs do you use? Do you observe any errors, strange messages in the Messages buffer?

tuhdo commented 10 years ago

I know what the problem is. For the regular find-tags function, it works fine with the latest commit. But I am using a package called Helm for many things, include finding tags. I bound M-. to helm-etags-select function and still having the same problem. However, after load the TAGS file with normal find-tags, helm-etags-select becomes functional again. It's inconvenient to have to load the TAGS with find-tags first. Maybe I should find similar package to helm-etags-select while this got fixed.

m00natic commented 10 years ago

Aaargh, that's it indeed. Here something to try:

(eval-after-load "helm-tags" '(defadvice helm-etags-create-buffer (around vlf-helm-etags-create-buffer compile activate) "Temporarily disable `vlf-mode'." (let ((vlf-application nil)) ad-do-it)))

I won't commit it immediately because will later try to make this mechanism easier. By the way I use helm too, but did not know of this nice tags integration, thanks for pointing it out.

m00natic commented 10 years ago

This is now in the code as well. Disabling VLF within a concrete function now looks like this:

(vlf-disable-for-function helm-etags-create-buffer "helm-tags")