all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* best practices for TAGS
@ 2011-12-04 23:29 Xavier Noria
  2011-12-04 23:36 ` Xavier Noria
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Xavier Noria @ 2011-12-04 23:29 UTC (permalink / raw
  To: help-gnu-emacs

I would basically like to have a workflow for the TAGS file that makes
some assumptions, and thanks to them it works out of the box and it is
always in sync.

For example, define the current tags file as the first one you find
from the current directory up the hierarchy, nil if none found.

I'd like to define my own version of find-tag that looks for the
current tags file as defined above.

If the tags file is outdated, I'd like to run some shell command
automatically and revisit it, then do the find-tag.

No prompts whatsoever. If I find myself in a situation where the
conventions do not hold, I'll resort to the builtin functions.

You see, I'd like that find-tag and friends do automatically what
makes sense in 99% of my projects and be always in sync without my
intervention.

Does anybody work use a worflow like that?



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: best practices for TAGS
  2011-12-04 23:29 best practices for TAGS Xavier Noria
@ 2011-12-04 23:36 ` Xavier Noria
  2011-12-06  2:20   ` Philipp Haselwarter
  2011-12-05  6:28 ` Peter Münster
  2011-12-05 18:39 ` Bastian Beischer
  2 siblings, 1 reply; 5+ messages in thread
From: Xavier Noria @ 2011-12-04 23:36 UTC (permalink / raw
  To: help-gnu-emacs

On Mon, Dec 5, 2011 at 12:29 AM, Xavier Noria <fxn@hashref.com> wrote:

> If the tags file is outdated, I'd like to run some shell command
> automatically and revisit it, then do the find-tag.

Easier: regenerate and revisit always. Every invocation of find-tag
should do that.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: best practices for TAGS
  2011-12-04 23:29 best practices for TAGS Xavier Noria
  2011-12-04 23:36 ` Xavier Noria
@ 2011-12-05  6:28 ` Peter Münster
  2011-12-05 18:39 ` Bastian Beischer
  2 siblings, 0 replies; 5+ messages in thread
From: Peter Münster @ 2011-12-05  6:28 UTC (permalink / raw
  To: help-gnu-emacs

On Mon, Dec 05 2011, Xavier Noria wrote:

> For example, define the current tags file as the first one you find
> from the current directory up the hierarchy, nil if none found.
>
> If the tags file is outdated, I'd like to run some shell command
> automatically and revisit it, then do the find-tag.

--8<---------------cut here---------------start------------->8---
(defun pm/find-tags-file ()
  "Recursively searches each parent directory for a file named `TAGS'
   and returns the path to that file or nil if a tags file is not found.
   Returns nil if the buffer is not visiting a file.
   (from jds-find-tags-file in the emacs-wiki)"
  (labels ((find-tags-file-r
            (path)
            (let* ((parent (if path (file-name-directory path)
                             default-directory))
                   (possible-tags-file (concat parent "TAGS")))
              (cond
               ((file-exists-p possible-tags-file)
                (shell-command (concat "make -C" parent " TAGS"))
                (throw 'found-it possible-tags-file))
               ((string= "/TAGS" possible-tags-file)
                (error "no tags file found"))
               (t
                (find-tags-file-r (directory-file-name parent)))))))
    (catch 'found-it 
      (find-tags-file-r (buffer-file-name)))))

(defadvice find-tag (before pm/before-find-tag activate)
  (setq tags-file-name (pm/find-tags-file)))
--8<---------------cut here---------------end--------------->8---

-- 
           Peter




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: best practices for TAGS
  2011-12-04 23:29 best practices for TAGS Xavier Noria
  2011-12-04 23:36 ` Xavier Noria
  2011-12-05  6:28 ` Peter Münster
@ 2011-12-05 18:39 ` Bastian Beischer
  2 siblings, 0 replies; 5+ messages in thread
From: Bastian Beischer @ 2011-12-05 18:39 UTC (permalink / raw
  To: Xavier Noria; +Cc: help-gnu-emacs

I use etags-table which assigns TAGS files to my projects and GNU Make
rules to update the TAGS file when I run make... The suggested
algorithms to update it always might work better, though.

On Mon, Dec 5, 2011 at 12:29 AM, Xavier Noria <fxn@hashref.com> wrote:
> I would basically like to have a workflow for the TAGS file that makes
> some assumptions, and thanks to them it works out of the box and it is
> always in sync.
>
> For example, define the current tags file as the first one you find
> from the current directory up the hierarchy, nil if none found.
>
> I'd like to define my own version of find-tag that looks for the
> current tags file as defined above.
>
> If the tags file is outdated, I'd like to run some shell command
> automatically and revisit it, then do the find-tag.
>
> No prompts whatsoever. If I find myself in a situation where the
> conventions do not hold, I'll resort to the builtin functions.
>
> You see, I'd like that find-tag and friends do automatically what
> makes sense in 99% of my projects and be always in sync without my
> intervention.
>
> Does anybody work use a worflow like that?
>



-- 
Bastian Beischer

I. Physikalisches Institut B (RWTH Aachen)
Sommerfeldstr. 14
52074 Aachen
GERMANY

Office: 28-C-203
Phone: +49 241 - 8027205



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: best practices for TAGS
  2011-12-04 23:36 ` Xavier Noria
@ 2011-12-06  2:20   ` Philipp Haselwarter
  0 siblings, 0 replies; 5+ messages in thread
From: Philipp Haselwarter @ 2011-12-06  2:20 UTC (permalink / raw
  To: help-gnu-emacs

I'd make a buffer local variable for the tags file name on your
`cc-mode-hook' or something suitable, using for example

(let ((dir (locate-dominating-file default-directory "TAGS")))
  (if dir
      (set (make-local-variable 'my-local-tags-fn)
        (expand-file-name "TAGS" dir))
    (message "TAGS not found")))

then call etags on your after-save-hook if the variable is set

(if (bound-and-true-p my-buffer-local-tags-filename)
 (start-process "regen-TAGS" nil "etags.emacs" "-o" my-buffer-local-tags-filename "-a"
  (buffer-file-name)))

-- 
Philipp Haselwarter




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-12-06  2:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-04 23:29 best practices for TAGS Xavier Noria
2011-12-04 23:36 ` Xavier Noria
2011-12-06  2:20   ` Philipp Haselwarter
2011-12-05  6:28 ` Peter Münster
2011-12-05 18:39 ` Bastian Beischer

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.