source: release/1.3/source/cocoa-ide/hemlock/unused/archive/lisp-lib.lisp

Last change on this file was 6569, checked in by Gary Byers, 18 years ago

Move more (currently unused, often unlikely to ever be used) stuff to an
archive directory.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.8 KB
Line 
1;;; -*- Log: hemlock.log; Package: Hemlock -*-
2;;;
3;;; **********************************************************************
4;;; This code was written as part of the CMU Common Lisp project at
5;;; Carnegie Mellon University, and has been placed in the public domain.
6;;;
7#+CMU (ext:file-comment
8 "$Header$")
9;;;
10;;; **********************************************************************
11;;;
12;;; This file contains code to peruse the CMU Common Lisp library of hacks.
13;;;
14;;; Written by Blaine Burks.
15;;;
16
17(in-package :hemlock)
18
19
20(defmode "Lisp-Lib" :major-p t)
21
22;;; The library should be in *lisp-library-directory*
23
24(defvar *lisp-library-directory* "/afs/cs.cmu.edu/project/clisp/library/")
25
26(defvar *selected-library-buffer* nil)
27
28
29
30;;;; Commands.
31
32(defcommand "Lisp Library" (p)
33 "Goto buffer in 'Lisp-Lib' mode, creating one if necessary."
34 "Goto buffer in 'Lisp-Lib' mode, creating one if necessary."
35 (declare (ignore p))
36 (when (not (and *selected-library-buffer*
37 (member *selected-library-buffer* *buffer-list*)))
38 (when (getstring "Lisp Library" *buffer-names*)
39 (editor-error "There is already a buffer named \"Lisp Library\"."))
40 (setf *selected-library-buffer*
41 (make-buffer "Lisp Library" :modes '("Lisp-Lib")))
42 (message "Groveling library ...")
43 (let ((lib-directory (directory *lisp-library-directory*))
44 (lib-entries ()))
45 (with-output-to-mark (s (buffer-point *selected-library-buffer*))
46 (dolist (lib-spec lib-directory)
47 (let* ((path-parts (pathname-directory lib-spec))
48 (last (elt path-parts (1- (length path-parts))))
49 (raw-pathname (merge-pathnames last lib-spec)))
50 (when (and (directoryp lib-spec)
51 (probe-file (merge-pathnames
52 (make-pathname :type "catalog")
53 raw-pathname)))
54 (push raw-pathname lib-entries)
55 (format s "~d~%" last)))))
56 (defhvar "Library Entries"
57 "Holds a list of library entries for the 'Lisp Library' buffer"
58 :buffer *selected-library-buffer*
59 :value (coerce (nreverse lib-entries) 'simple-vector))))
60 (setf (buffer-writable *selected-library-buffer*) nil)
61 (setf (buffer-modified *selected-library-buffer*) nil)
62 (change-to-buffer *selected-library-buffer*)
63 (buffer-start (current-point)))
64
65(defcommand "Describe Pointer Library Entry" (p)
66 "Finds the file that describes the lisp library entry indicated by the
67 pointer."
68 "Finds the file that describes the lisp library entry indicated by the
69 pointer."
70 (declare (ignore p))
71 (unless (hemlock-bound-p 'library-entries :buffer (current-buffer))
72 (editor-error "Not in a Lisp Library buffer."))
73 (describe-library-entry (array-element-from-pointer-pos
74 (value library-entries) "No entry on current line")))
75
76(defcommand "Describe Library Entry" (p)
77 "Find the file that describes the lisp library entry on the current line."
78 "Find the file that describes the lisp library entry on the current line."
79 (declare (ignore p))
80 (unless (hemlock-bound-p 'library-entries :buffer (current-buffer))
81 (editor-error "Not in a Lisp Library buffer."))
82 (describe-library-entry (array-element-from-mark (current-point)
83 (value library-entries) "No entry on current line")))
84
85(defun describe-library-entry (pathname)
86 (let ((lisp-buf (current-buffer))
87 (buffer (view-file-command
88 nil
89 (merge-pathnames (make-pathname :type "catalog") pathname))))
90 (push #'(lambda (buffer)
91 (declare (ignore buffer))
92 (setf lisp-buf nil))
93 (buffer-delete-hook lisp-buf))
94 (setf (variable-value 'view-return-function :buffer buffer)
95 #'(lambda () (if lisp-buf
96 (change-to-buffer lisp-buf)
97 (lisp-library-command nil))))))
98
99(defcommand "Load Library Entry" (p)
100 "Loads the current library entry into the current slave."
101 "Loads the current library entry into the current slave."
102 (declare (ignore p))
103 (unless (hemlock-bound-p 'library-entries :buffer (current-buffer))
104 (editor-error "Not in a Lisp Library buffer."))
105 (string-eval (format nil "(load ~S)"
106 (namestring (library-entry-load-file nil)))))
107
108(defcommand "Load Pointer Library Entry" (p)
109 "Loads the library entry indicated by the mouse into the current slave."
110 "Loads the library entry indicated by the mouse into the current slave."
111 (declare (ignore p))
112 (unless (hemlock-bound-p 'library-entries :buffer (current-buffer))
113 (editor-error "Not in a Lisp Library buffer."))
114 (string-eval (format nil "(load ~S)"
115 (namestring (library-entry-load-file t)))))
116
117(defcommand "Editor Load Library Entry" (p)
118 "Loads the current library entry into the editor Lisp."
119 "Loads the current library entry into the editor Lisp."
120 (declare (ignore p))
121 (unless (hemlock-bound-p 'library-entries :buffer (current-buffer))
122 (editor-error "Not in a Lisp Library buffer."))
123 (in-lisp (load (library-entry-load-file nil))))
124
125(defcommand "Editor Load Pointer Library Entry" (p)
126 "Loads the library entry indicated by the mouse into the editor Lisp."
127 "Loads the library entry indicated by the mouse into the editor Lisp."
128 (declare (ignore p))
129 (unless (hemlock-bound-p 'library-entries :buffer (current-buffer))
130 (editor-error "Not in a Lisp Library buffer."))
131 (in-lisp (load (library-entry-load-file t))))
132
133;;; LIBRARY-ENTRY-LOAD-FILE uses the mouse's position or the current point,
134;;; depending on pointerp, to return a file that will load that library entry.
135;;;
136(defun library-entry-load-file (pointerp)
137 (let* ((lib-entries (value library-entries))
138 (error-msg "No entry on current-line")
139 (base-name (if pointerp
140 (array-element-from-pointer-pos lib-entries error-msg)
141 (array-element-from-mark (current-point) lib-entries
142 error-msg)))
143 (parts (pathname-directory base-name))
144 (load-name (concatenate 'simple-string
145 "load-" (elt parts (1- (length parts)))))
146 (load-pathname (merge-pathnames load-name base-name))
147 (file-to-load
148 (or
149 (probe-file (compile-file-pathname load-pathname))
150 (probe-file (merge-pathnames (make-pathname :type "fasl")
151 load-pathname))
152 (probe-file (merge-pathnames (make-pathname :type "lisp")
153 load-pathname))
154 (probe-file (compile-file-pathname base-name))
155 (probe-file (merge-pathnames (make-pathname :type "fasl")
156 base-name))
157 (probe-file (merge-pathnames (make-pathname :type "lisp")
158 base-name)))))
159 (unless file-to-load (editor-error "You'll have to load it yourself."))
160 file-to-load))
161
162(defcommand "Exit Lisp Library" (p)
163 "Exit Lisp-Lib Mode, deleting the buffer when possible."
164 "Exit Lisp-Lib Mode, deleting the buffer when possible."
165 (declare (ignore p))
166 (unless (hemlock-bound-p 'library-entries :buffer (current-buffer))
167 (editor-error "Not in a Lisp Library buffer."))
168 (delete-buffer-if-possible (getstring "Lisp Library" *buffer-names*)))
169
170(defcommand "Lisp Library Help" (p)
171 "Show this help."
172 "Show this help."
173 (declare (ignore p))
174 (describe-mode-command nil "Lisp-Lib"))
175
Note: See TracBrowser for help on using the repository browser.