Annotation of mdee/idl-docindex.el, revision 1.1

1.1     ! kevin       1:  ;;; idl-docindex.el --- 
        !             2: 
        !             3: ;; $Id: idl-docindex.el,v 1.1.1.1 2003/01/14 01:53:31 burton Exp $
        !             4: 
        !             5: ;; Copyright (C) 2003 Free Software Foundation, Inc.
        !             6: ;; Copyright (C) 2003 Kevin A. Burton (burton@openprivacy.org)
        !             7: 
        !             8: ;; Author: Kevin A. Burton (burton@peerfear.org)
        !             9: ;; Maintainer: Kevin A. Burton (burton@peerfear.org)
        !            10: ;; Location: http://www.peerfear.org/el
        !            11: ;; Keywords: 
        !            12: ;; Version: 1.0.1
        !            13: 
        !            14: ;; This file is [not yet] part of GNU Emacs.
        !            15: 
        !            16: ;; This program is free software; you can redistribute it and/or modify it under
        !            17: ;; the terms of the GNU General Public License as published by the Free Software
        !            18: ;; Foundation; either version 2 of the License, or any later version.
        !            19: ;;
        !            20: ;; This program is distributed in the hope that it will be useful, but WITHOUT
        !            21: ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
        !            22: ;; FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
        !            23: ;; details.
        !            24: ;;
        !            25: ;; You should have received a copy of the GNU General Public License along with
        !            26: ;; this program; if not, write to the Free Software Foundation, Inc., 59 Temple
        !            27: ;; Place - Suite 330, Boston, MA 02111-1307, USA.
        !            28: 
        !            29: ;;; Commentary:
        !            30: 
        !            31: (defvar idl-docindex--token-alist '() "Buffer name -> file associated list.")
        !            32: 
        !            33: (defvar idl-docindex-data-file "~/.idl-docindex.el" "File for `idl-docindex' file.")
        !            34: 
        !            35: (defun idl-docindex-build-index(path &optional no-save)
        !            36:   "Build a index starting with the given path."
        !            37:   (interactive
        !            38:    (list
        !            39:     (read-file-name "Build idl-docindex from: ")))
        !            40: 
        !            41:   (let((current-path nil)
        !            42:        (files (directory-files path)))
        !            43: 
        !            44:     (dolist(file files)
        !            45: 
        !            46:       (setq current-path (concat path "/" file))
        !            47:       
        !            48:       ;;go into subdirectories
        !            49: 
        !            50:       (when (and (file-directory-p current-path)
        !            51:                  (not (string-equal file "."))
        !            52:                  (not (string-equal file "..")))
        !            53: 
        !            54:         (idl-docindex-build-index current-path t))
        !            55: 
        !            56:       (when (string-match "\\.idl$" file)
        !            57:         (add-to-list 'idl-docindex--token-alist (cons file current-path)))))
        !            58: 
        !            59:   (message "Found %i tokens... " (length idl-docindex--token-alist))
        !            60:   
        !            61:   (when (not no-save)
        !            62:     (idl-docindex-save)
        !            63: 
        !            64:     (message "Found %i tokens... done" (length idl-docindex--token-alist))))
        !            65: 
        !            66: (defun idl-docindex-save()
        !            67:   "Save the docindex information to disk."
        !            68:   (interactive)
        !            69:   
        !            70:   (save-excursion
        !            71: 
        !            72:     (let((find-file-hooks nil))    
        !            73:     
        !            74:       (set-buffer (find-file-noselect idl-docindex-data-file))
        !            75:       
        !            76:       ;;whatever is in this buffer is now obsolete
        !            77:       (erase-buffer)
        !            78: 
        !            79:       (insert "(setq idl-docindex--token-alist '")
        !            80:       (prin1 idl-docindex--token-alist (current-buffer))
        !            81:       (insert ")")
        !            82:       (save-buffer)
        !            83:       (kill-buffer (current-buffer))
        !            84:       
        !            85:       (message "Wrote %s" idl-docindex-data-file))))
        !            86: 
        !            87: (defun idl-docindex-load()
        !            88:   "Read the idl-docindex data file from disk"
        !            89:   (when (file-readable-p idl-docindex-data-file)
        !            90:     (message "Reading %s..." idl-docindex-data-file)
        !            91:     
        !            92:     (load-file idl-docindex-data-file)
        !            93:     
        !            94:     (message "Reading %s...done" idl-docindex-data-file)))
        !            95: 
        !            96: (defun idl-docindex-find-file(name)
        !            97:   "Use completion (when in an interactive clause) to find the given buffer and
        !            98: load it."
        !            99:   (interactive
        !           100: 
        !           101:    (let*((thing (concat (thing-at-point 'word) ".idl"))
        !           102:          (entry (assoc thing idl-docindex--token-alist)))
        !           103: 
        !           104:      (list
        !           105:       ;;we don't have an entry... use completion to find what we want from the token list.
        !           106:       (completing-read "IDL name: "
        !           107:                        idl-docindex--token-alist
        !           108:                        nil
        !           109:                        nil
        !           110:                        entry))))
        !           111: 
        !           112:   (find-file (cdr (assoc name idl-docindex--token-alist))))
        !           113: 
        !           114: (idl-docindex-load)
        !           115: 
        !           116: (when (boundp 'idl-mode-map)
        !           117:   (define-key idl-mode-map [C-return] 'idl-docindex-find-file))
        !           118: 
        !           119: (provide 'idl-docindex)
        !           120: 
        !           121: ;;; idl-docindex.el ends here

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>