[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Orgmode] Re: Integrating ctags & org mode (patch)
From: |
Paul Sexton |
Subject: |
[Orgmode] Re: Integrating ctags & org mode (patch) |
Date: |
Tue, 15 Dec 2009 19:58:03 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Carsten Dominik <carsten.dominik <at> gmail.com> writes:
>
> Hi Paul,
>
> I like this very much. But I would like to change the implementation
> so that
> there will be a hook. Then people can do different things, including
> matching tags in source code files etc.
>
> Would you be interested to turn your way of doing things into a little
> add-on
> that people could load? I realize that it would be a very small file
> because the heavy lifting is done by the tags creating file and Emacs
> ctags searches. But it would keep the way open for other ideas.
>
> If you agree I will make a new hook and interface for this.
>
> I would be very interested to include the new module (if you write it)
> at least as a contributed package, or, if you are willing
> to sign the papers with the FSF, in the core.
>
I'm glad you like it. I would be happy for it to be included in the core.
Re your followup to this post: I have written a function which takes a tag name
and returns the file where it is found:
(defun get-filename-for-tag (tag)
"TAG is a string. Search the active TAGS file for a matching tag,
and if found, return a list containing the filename, line number, and
buffer position where the tag is found."
(unless tags-file-name
(visit-tags-file-buffer))
(with-current-buffer (get-file-buffer tags-file-name)
(beginning-of-buffer)
(cond
;; In the following line, the special characters on either side of
;; the %s should be ASCII 127 (^?) and ASCII 1 (^A)
((re-search-forward (format "^.*%s\\([0-9]+\\),\\([0-9]+\\)$"
(regexp-quote tag)) nil t)
(let ((line (string-to-number (match-string 1)))
(pos (string-to-number (match-string 2))))
(cond
((re-search-backward "\n\\(.*\\),[0-9]+\n")
(list (match-string 1) line pos))
(t ; can't find a file name preceding the matched tag??
(error "Malformed TAGS file: %s" (buffer-name))))))
(t ; tag not found
nil))))