Add MAJOR-MODE-LOCKED feature.
authorChris Hanson <org/chris-hanson/cph>
Tue, 29 Sep 1992 21:11:24 +0000 (21:11 +0000)
committerChris Hanson <org/chris-hanson/cph>
Tue, 29 Sep 1992 21:11:24 +0000 (21:11 +0000)
v7/src/edwin/bufcom.scm
v7/src/edwin/buffer.scm

index a7fdeeac5c2338f465eca94d2039458d64994abe..d993205c50ae0efd7056ccf7356db98582443b1b 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;;    $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/bufcom.scm,v 1.93 1992/04/16 22:30:13 cph Exp $
+;;;    $Id: bufcom.scm,v 1.94 1992/09/29 21:11:24 cph Exp $
 ;;;
 ;;;    Copyright (c) 1986, 1989-92 Massachusetts Institute of Technology
 ;;;
@@ -177,7 +177,7 @@ thus, the least likely buffer for \\[switch-to-buffer] to select by default."
                        (create-buffer initial-buffer-name)
                        (kill-buffer dummy)))))
            (buffer-list)))
-
+\f
 (define-command rename-buffer
   "Change the name of the current buffer.
 Reads the new name in the echo area."
@@ -194,6 +194,20 @@ Uses the visited file name, the -*- line, and the local variables spec."
   ()
   (lambda ()
     (normal-mode (current-buffer) false)))
+
+(define-command toggle-mode-lock
+  "Change whether this buffer has its major mode locked.
+When locked, the buffer's major mode may not be changed."
+  ()
+  (lambda ()
+    (let ((buffer (current-buffer)))
+      (if (buffer-get buffer 'MAJOR-MODE-LOCKED)
+         (begin
+           (buffer-remove! buffer 'MAJOR-MODE-LOCKED)
+           (message "Major mode unlocked"))
+         (begin
+           (buffer-put! buffer 'MAJOR-MODE-LOCKED true)
+           (message "Major mode locked"))))))
 \f
 (define (save-buffer-changes buffer)
   (if (and (buffer-pathname buffer)
index b8d5374b63d96400eba5029dc7bff026729028d4..b8e0d7f9b8dc8a0e1bd3cc5a8decbd258d8a30e8 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;;    $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/buffer.scm,v 1.155 1992/04/07 12:30:21 cph Exp $
+;;;    $Id: buffer.scm,v 1.156 1992/09/29 21:08:56 cph Exp $
 ;;;
 ;;;    Copyright (c) 1986, 1989-92 Massachusetts Institute of Technology
 ;;;
@@ -483,6 +483,8 @@ The buffer is guaranteed to be deselected at that time."
 (define (set-buffer-major-mode! buffer mode)
   (if (not (and (mode? mode) (mode-major? mode)))
       (error:wrong-type-argument mode "major mode" 'SET-BUFFER-MAJOR-MODE!))
+  (if (buffer-get buffer 'MAJOR-MODE-LOCKED)
+      (editor-error "The major mode of this buffer is locked: " buffer))
   (without-interrupts
    (lambda ()
      (let ((modes (buffer-modes buffer)))