-
-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1658 from lem-project/read-only-sources
open the source code of the sbcl as read-only
- Loading branch information
Showing
5 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
(uiop:define-package :lem-lisp-mode/read-only-sources | ||
(:use :cl) | ||
(:import-from :lem/read-only-sources | ||
:define-read-only-source)) | ||
(in-package :lem-lisp-mode/read-only-sources) | ||
|
||
(define-read-only-source sbcl-source (directory) | ||
(alexandria:when-let (connection (lem-lisp-mode/internal:current-connection)) | ||
(dolist (pattern (lem-lisp-mode/connection:connection-system-file-patterns connection)) | ||
(when (pathname-match-p directory pattern) | ||
(return t))))) | ||
|
||
(define-read-only-source quicklisp-dists (directory) | ||
(search "/dists/quicklisp/software/" directory)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
(uiop:define-package :lem/read-only-sources | ||
(:use :cl :lem) | ||
(:export :read-only-sources | ||
:define-read-only-source)) | ||
(in-package :lem/read-only-sources) | ||
|
||
(define-editor-variable read-only-sources t) | ||
|
||
(defvar *patterns* (make-hash-table :test 'equal)) | ||
|
||
(defun register-pattern (name function) | ||
(setf (gethash name *patterns*) function)) | ||
|
||
(defmacro define-read-only-source (name (directory) &body body) | ||
`(register-pattern ',name (lambda (,directory) ,@body))) | ||
|
||
(defun read-only-source-p (directory) | ||
(maphash (lambda (name pattern) | ||
(declare (ignore name)) | ||
(when (funcall pattern directory) | ||
(return-from read-only-source-p t))) | ||
*patterns*)) | ||
|
||
(defun on-switch-to-buffer (buffer) | ||
(when (and (variable-value 'read-only-sources :default buffer) | ||
(read-only-source-p (buffer-directory buffer))) | ||
(setf (buffer-read-only-p buffer) t))) | ||
|
||
(add-hook *switch-to-buffer-hook* 'on-switch-to-buffer) |