(c++-mode): Doc fix.
[bpt/emacs.git] / lisp / progmodes / cpp.el
index 2320a77..78a11ac 100644 (file)
@@ -47,6 +47,9 @@
 
 ;;; Customization:
 
+(defvar cpp-config-file (convert-standard-filename ".cpp.el")
+  "*File name to save cpp configuration.")
+
 (defvar cpp-known-face 'invisible
   "*Face used for known cpp symbols.")
 
@@ -332,7 +335,8 @@ A prefix arg suppresses display of that buffer."
   (overlay-put overlay 'intangible t)
   ;; Unfortunately `intangible' is not implemented for overlays yet,
   ;; so we make is read-only instead.
-  (overlay-put overlay 'modification-hooks '(cpp-signal-read-only)))
+  (overlay-put overlay 'modification-hooks '(cpp-signal-read-only))
+  (overlay-put overlay 'insert-in-front-hooks '(cpp-signal-read-only)))
 
 (defun cpp-make-overlay-read-only (overlay)
   ;; Make overlay read only.
@@ -345,18 +349,20 @@ A prefix arg suppresses display of that buffer."
   (overlay-put overlay 'insert-in-front-hooks '(cpp-grow-overlay))
   (overlay-put overlay 'insert-behind-hooks '(cpp-grow-overlay)))
 
-(defun cpp-signal-read-only (overlay start end)
+(defun cpp-signal-read-only (overlay after start end &optional len)
   ;; Only allow deleting the whole overlay.
   ;; Trying to change a read-only overlay.
-  (if (or (< (overlay-start overlay) start)
-         (> (overlay-end overlay) end))
+  (if (and (not after)
+          (or (< (overlay-start overlay) start)
+              (> (overlay-end overlay) end)))
       (error "This text is read only")))
 
-(defun cpp-grow-overlay (overlay start end)
+(defun cpp-grow-overlay (overlay after start end &optional len)
   ;; Make OVERLAY grow to contain range START to END.
-  (move-overlay overlay
-               (min start (overlay-start overlay))
-               (max end (overlay-end overlay))))
+  (if after
+      (move-overlay overlay
+                   (min start (overlay-start overlay))
+                   (max end (overlay-end overlay)))))
 
 ;;; Edit Buffer:
 
@@ -483,7 +489,7 @@ You can also use the keyboard accelerators indicated like this: [K]ey."
            (setq cpp-edit-list (delq entry cpp-edit-list)
                  entry nil))
        
-       (if (> (length symbol) 29)
+       (if (> (length symbol) 39)
            (insert (substring symbol 0 39) ": ")
          (insert (format "%39s: " symbol)))
 
@@ -503,10 +509,10 @@ You can also use the keyboard accelerators indicated like this: [K]ey."
 (defun cpp-edit-load ()
   "Load cpp configuration."
   (interactive)
-  (cond ((file-readable-p ".cpp.el")
-        (load-file ".cpp.el"))
-       ((file-readable-p "~/.cpp.el")
-        (load-file ".cpp.el")))
+  (cond ((file-readable-p cpp-config-file)
+        (load-file cpp-config-file))
+       ((file-readable-p (concat "~/" cpp-config-file))
+        (load-file cpp-config-file)))
   (if (eq major-mode 'cpp-edit-mode)
       (cpp-edit-reset)))
 
@@ -516,7 +522,7 @@ You can also use the keyboard accelerators indicated like this: [K]ey."
   (require 'pp)
   (save-excursion
     (set-buffer cpp-edit-buffer)
-    (let ((buffer (find-file-noselect ".cpp.el")))
+    (let ((buffer (find-file-noselect cpp-config-file)))
       (set-buffer buffer)
       (erase-buffer)
       (pp (list 'setq 'cpp-known-face
@@ -531,7 +537,7 @@ You can also use the keyboard accelerators indicated like this: [K]ey."
                (list 'quote cpp-unknown-writable)) buffer)
       (pp (list 'setq 'cpp-edit-list
                (list 'quote cpp-edit-list)) buffer)
-      (write-file ".cpp.el"))))
+      (write-file cpp-config-file))))
 
 (defun cpp-edit-home ()
   "Switch back to original buffer."