[slime-cvs] CVS update: slime/swank-cmucl.lisp

Luke Gorrie lgorrie at common-lisp.net
Sat Mar 12 01:49:20 UTC 2005


Update of /project/slime/cvsroot/slime
In directory common-lisp.net:/tmp/cvs-serv4938

Modified Files:
	swank-cmucl.lisp 
Log Message:
Source file cache is now moved into swank-source-file-cache.lisp

Date: Sat Mar 12 02:49:20 2005
Author: lgorrie

Index: slime/swank-cmucl.lisp
diff -u slime/swank-cmucl.lisp:1.140 slime/swank-cmucl.lisp:1.141
--- slime/swank-cmucl.lisp:1.140	Tue Mar  1 00:32:06 2005
+++ slime/swank-cmucl.lisp	Sat Mar 12 02:49:19 2005
@@ -695,8 +695,7 @@
 (defun location-in-file (filename code-location debug-source)
   "Resolve the source location for CODE-LOCATION in FILENAME."
   (let* ((code-date (di:debug-source-created debug-source))
-         (source-code (or (source-cache-get filename code-date)
-                          (read-file filename))))
+         (source-code (get-source-code filename code-date)))
     (make-location (list :file (unix-truename filename)) nil)
     (with-input-from-string (s source-code)
       (make-location (list :file (unix-truename filename))
@@ -722,23 +721,6 @@
                       (file-position s position)
                       (read-snippet s))))))
 
-(defun read-file (filename)
-  "Return the entire contents of FILENAME as a string."
-  (with-open-file (s filename :direction :input)
-    (let ((string (make-string (file-length s))))
-      (read-sequence string s)
-      string)))
-
-(defun read-snippet (stream)
-  "Read a string of upto *SOURCE-SNIPPET-SIZE* characters from STREAM."
-  (read-upto-n-chars stream *source-snippet-size*))
-
-(defun read-upto-n-chars (stream n)
-  "Return a string of upto N chars from STREAM."
-  (let* ((string (make-string n))
-         (chars  (read-sequence string stream)))
-    (subseq string 0 chars)))
-
 ;;;;; Function-name locations
 ;;;
 (defun debug-info-function-name-location (debug-info)
@@ -802,69 +784,6 @@
 See CODE-LOCATION-STREAM-POSITION."
   (with-input-from-string (s string)
     (code-location-stream-position code-location s)))
-
-;;;;; Source-file cache
-;;;
-;;; To robustly find source locations it's useful to have the exact
-;;; source code that the loaded code was compiled from. In this source
-;;; we can accurately find the right location, and from that location
-;;; we can extract a "snippet" of code to show what the definition
-;;; looks like. Emacs can use this snippet in a best-match search to
-;;; locate the right definition, which works well even if the buffer
-;;; has been modified.
-;;;
-;;; The idea is that if a definition previously started with
-;;; `(define-foo bar' then it probably still does.
-;;;
-;;; Whenever we see that the file on disk has the same
-;;; `file-write-date' as a location we're looking for, we cache the
-;;; whole file inside Lisp. That way we will still have the matching
-;;; version even if the file is later modified on disk. If the file is
-;;; later recompiled and reloaded then we replace our cache entry.
-
-(defvar *cache-sourcecode* t
-  "When true complete source files are cached.
-The cache is used to keep known good copies of the source text which
-correspond to the loaded code. Finding definitions is much more
-reliable when the exact source is available, so we cache it in case it
-gets edited on disk later.")
-
-(defvar *source-file-cache* (make-hash-table :test 'equal)
-  "Cache of source file contents.
-Maps from truename to source-cache-entry structure.")
-
-(defstruct (source-cache-entry
-             (:conc-name source-cache-entry.)
-             (:constructor make-source-cache-entry (text date)))
-  text date)
-
-(defun source-cache-get (filename date)
-  "Return the source code for FILENAME as written on DATE in a string.
-Return NIL if the right version cannot be found."
-  (let ((entry (gethash filename *source-file-cache*)))
-    (cond ((and entry (equal date (source-cache-entry.date entry)))
-           ;; Cache hit.
-           (source-cache-entry.text entry))
-          ((or (null entry)
-               (not (equal date (source-cache-entry.date entry))))
-           ;; Cache miss.
-           (if (equal (file-write-date filename) date)
-               ;; File on disk has the correct version.
-               (let ((source (read-file filename)))
-                 (setf (gethash filename *source-file-cache*)
-                       (make-source-cache-entry source date))
-                 source)
-               nil)))))
-
-(defun source-cached-p (filename)
-  "Is any version of FILENAME in the source cache?"
-  (if (gethash filename *source-file-cache*) t))
-
-(defimplementation buffer-first-change (filename)
-  "Load a file into the cache when the user modifies its buffer.
-This is a win if the user then saves the file and tries to M-. into it."
-  (unless (source-cached-p filename)
-    (ignore-errors (source-cache-get filename (file-write-date filename)))))
 
 
 ;;;; Finding definitions




More information about the slime-cvs mailing list