add guile-2.2 feature
[bpt/guile.git] / emacs / guile-c.el
index bbf75e9..1ccfd4d 100644 (file)
@@ -1,29 +1,30 @@
 ;;; guile-c.el --- Guile C editing commands
 
-;; Copyright (C) 2001 Keisuke Nishida <kxn30@po.cwru.edu>
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Copyright (C) 2001, 2006 Free Software Foundation, Inc.
+
+;;;; This library is free software; you can redistribute it and/or
+;;;; modify it under the terms of the GNU Lesser General Public
+;;;; License as published by the Free Software Foundation; either
+;;;; version 3 of the License, or (at your option) any later version.
+;;;; 
+;;;; This library is distributed in the hope that it will be useful,
+;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;;;; Lesser General Public License for more details.
+;;;; 
+;;;; You should have received a copy of the GNU Lesser General Public
+;;;; License along with this library; if not, write to the Free
+;;;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+;;;; 02111-1307 USA
 
 ;;; Commentary:
 
 ;; (add-hook 'c-mode-hook
 ;;   (lambda ()
 ;;     (require 'guile-c)
-;;     (define-key c-mode-map "\C-c\C-g\C-e" 'guile-c-edit-docstring)
 ;;     (define-key c-mode-map "\C-c\C-g\C-p" 'guile-c-insert-define)
+;;     (define-key c-mode-map "\C-c\C-g\C-e" 'guile-c-edit-docstring)
+;;     (define-key c-mode-map "\C-c\C-g\C-d" 'guile-c-deprecate-region)
 ;;     ))
 
 ;;; Code:
@@ -32,6 +33,7 @@
 
 (defvar guile-c-prefix "scm_")
 
+\f
 ;;;
 ;;; Insert templates
 ;;;
   (while (string-match "[-:]" name) (setq name (replace-match "_" t t name)))
   (concat guile-c-prefix name))
 
+\f
 ;;;
 ;;; Edit docstrings
 ;;;
 
+(defvar guile-c-window-configuration nil)
+
 (defun guile-c-edit-docstring ()
   (interactive)
   (let* ((region (guile-c-find-docstring))
         (doc (if region (buffer-substring (car region) (cdr region)))))
     (if (not doc)
        (error "No docstring!")
+      (setq guile-c-window-configuration (current-window-configuration))
       (with-current-buffer (get-buffer-create "*Guile Docstring*")
        (erase-buffer)
        (insert doc)
        (if global-font-lock-mode
            (font-lock-fontify-buffer))
        (local-set-key "\C-c\C-c" 'guile-c-edit-finish)
+       (setq fill-column 63)
        (switch-to-buffer-other-window (current-buffer))
         (message "Type `C-c C-c' to finish")))))
 
       (forward-line 1)))
   (let ((doc (buffer-string)))
     (kill-buffer (current-buffer))
-    (delete-window (selected-window))
+    (set-window-configuration guile-c-window-configuration)
     (let ((region (guile-c-find-docstring)))
       (goto-char (car region))
       (delete-region (car region) (cdr region)))
            (forward-line 1))
          (cons start (- (point) 2))))))
 
+\f
+;;;
+;;; Others
+;;;
+
+(defun guile-c-deprecate-region (start end)
+  (interactive "r")
+  (save-excursion
+    (let ((marker (make-marker)))
+      (set-marker marker end)
+      (goto-char start)
+      (insert "#if (SCM_DEBUG_DEPRECATED == 0)\n\n")
+      (goto-char marker)
+      (insert "\n#endif /* (SCM_DEBUG_DEPRECATED == 0) */\n"))))
+
 (provide 'guile-c)
 
 ;; guile-c.el ends here