;;; Based somewhat and inspired by the etags package ;;; Not nearly as complete, though ;;;###autoload (defvar gnome-tag-repository "http://developer.gnome.org/doc/API" "The default location of the GNOME reference documentation.") ;;;###autoload (defvar gnome-tag-browser-command "gnome-moz-remote" "The command used to view the reference doc.") ;;;###autoload (defvar gnome-tags-file-name "/home/jrb/GNOME-TAGS" "*File name of gnome tags table.") (defvar gnome-tags-buffer nil "The buffer used to store the gnome-tags in.") (defun gnome-tag-find-default () (save-excursion (while (looking-at "\\sw\\|\\s_") (forward-char 1)) (if (or (re-search-backward "\\sw\\|\\s_" (save-excursion (beginning-of-line) (point)) t) (re-search-forward "\\(\\sw\\|\\s_\\)+" (save-excursion (end-of-line) (point)) t)) (progn (goto-char (match-end 0)) (buffer-substring (point) (progn (forward-sexp -1) (while (looking-at "\\s'") (forward-char 1)) (point)))) nil))) (defun tags-verify-table (file) "Read FILE into a buffer and verify that it is a valid tags table. Sets the current buffer to one visiting FILE (if it exists). Returns non-nil iff it is a valid table." (if (get-file-buffer file) ;; The file is already in a buffer. Check for the visited file ;; having changed since we last used it. (let (win) (set-buffer (get-file-buffer file)) (setq win (or verify-tags-table-function (initialize-new-tags-table))) (if (or (verify-visited-file-modtime (current-buffer)) ;; Decide whether to revert the file. ;; revert-without-query can say to revert ;; or the user can say to revert. (not (or (let ((tail revert-without-query) (found nil)) (while tail (if (string-match (car tail) buffer-file-name) (setq found t)) (setq tail (cdr tail))) found) tags-revert-without-query (yes-or-no-p (format "Tags file %s has changed, read new contents? " file))))) (and verify-tags-table-function (funcall verify-tags-table-function)) (revert-buffer t t) (initialize-new-tags-table))) (and (file-exists-p file) (progn (set-buffer (find-file-noselect file)) (or (string= file buffer-file-name) ;; find-file-noselect has changed the file name. ;; Propagate the change to tags-file-name and tags-table-list. (let ((tail (member file tags-table-list))) (if tail (setcar tail buffer-file-name)) (if (eq file tags-file-name) (setq tags-file-name buffer-file-name)))) (initialize-new-tags-table))))) (defun find-tag-in-buffer (tag) (save-excursion (set-buffer "GNOME-TAGS") (let* ((tag-regexp (format "^%s:" tag))) (message tag-regexp) (goto-char (point-min)) (let ((tag-point (search-forward-regexp tag-regexp))) (if tag-point (buffer-substring tag-point (progn (end-of-line)(point)))))))) (defun load-tag-buffers () (if (or (not gnome-tags-buffer) (save-excursion (get-buffer gnome-tags-buffer))) (save-excursion (if (get-buffer "GNOME-TAGS") (kill-buffer "GNOME-TAGS")) (set-buffer (find-file-noselect gnome-tags-file-name)) (rename-buffer "GNOME-TAGS") (setq gnome-tags-buffer (get-buffer "GNOME-TAGS"))))) (defun confirm-tag (tag) (if (and tag (load-tag-buffers)) (find-tag-in-buffer tag) nil)) (defun create-name (tag) (format "\"%s/%s.html\"" gnome-tag-repository tag)) ;;;###autoload (defun send-gnome-function () (interactive) "Lookup the GtkWidget at point and attempt to look it up" (let* ((tag (gnome-tag-find-default)) (location (confirm-tag tag))) (if location (message (format "%s %s/%s" gnome-tag-browser-command gnome-tag-repository location)))))