2

I prefer to use the older version of find-tag, instead of the xref library. I wrote a function to build the tag database, but I'm having trouble locating a good place to plug it in. The default behavior when a TAGS file cannot be located is for visit-tags-table-buffer to generate an error message "File %s does not exist". By the time we get to that message, however, it is the end of the function and too late to build a new tags file. I would like to do this without breaking visit-tags-table-buffer.

Q:  Where can I plug-in tags-build so that I can call find-tag and be on my merry way with a new TAGS file if one does not already exist?

(defun tags-build ()
"Build the TAGS datbase and set the default `tags-file-name'."
(interactive)
  (let ((default-directory (file-name-as-directory (expand-file-name
                             (read-directory-name ".../src directory:  ")))))
    (set-process-sentinel
      (start-process "build-tags" nil
        "/bin/bash" "-c" "find . -iname \"*.c\" -or -iname \"*.h\" | xargs etags")
      `(lambda (p e) (when (= 0 (process-exit-status p))
        (setq-default tags-file-name (expand-file-name "TAGS" ,default-directory))
        (message "tags-file-name:  %s" tags-file-name)
        tags-file-name)))))
0

Check https://github.com/redguardtoo/counsel-etags

It has everything you need.

  • The library you suggested relies upon (require 'xref nil t), which is something that I wish to avoid. Other users, however, undoubtedly enjoy it. It also relies upon a ton of stuff written by abo-abo (not built-in to Emacs), which is fine, but it just adds a whole layer of extra libraries and complication that seems unnecessary for this simple feature of adding a TAGS file if it does not already exist when calling find-tag. – lawlist Nov 9 '17 at 19:19
  • (require 'xref nil t) means xref is OPTIONAL. The core functionalities are not dependent on xref – chen bin Nov 9 '17 at 22:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.