Source

speedbar / sb-info.el

Diff from to

File sb-info.el

 ;;; sb-info --- Speedbar support for Info
 
-;; Copyright (C) 1997, 1998, 2000 Free Software Foundation
+;; Copyright (C) 1997, 1998, 2000, 2001, 2002 Free Software Foundation
 ;;
 ;; Author: Eric M. Ludlam <zappo@gnu.ai.mit.edu>
 ;; Version: 0.3
     (define-key Info-speedbar-key-map "+" 'speedbar-expand-line)
     (define-key Info-speedbar-key-map "=" 'speedbar-expand-line)
     (define-key Info-speedbar-key-map "-" 'speedbar-contract-line)
+    (define-key Info-speedbar-key-map " " 'speedbar-toggle-line-expansion)
     )
 
   (speedbar-add-expansion-list '("Info" Info-speedbar-menu-items
   (speedbar-change-initial-expansion-list "Info")
   )
 
+(defvar Info-speedbar-image-button-alist
+  '(("<+>" . speedbar-document-plus)
+    ("<->" . speedbar-document-minus)
+    ("[+]" . speedbar-page-plus)
+    ("[-]" . speedbar-page-minus)
+    ("[?]" . speedbar-page)
+    ("[ ]" . speedbar-page)
+    )
+  "Image buttons used for Info mode.")
+
 (defun Info-speedbar-hierarchy-buttons (directory depth &optional node)
   "Display an Info directory hierarchy in speedbar.
 DIRECTORY is the current directory in the attached frame.
     ;; being known at creation time.
     (if (not node)
 	(speedbar-with-writable (insert "Info Nodes:\n")))
-    (let ((completions nil))
+    (let ((completions nil)
+	  (speedbar-expand-image-button-alist
+	   Info-speedbar-image-button-alist))
       (dframe-select-attached-frame speedbar-frame)
       (save-window-excursion
 	(setq completions
       (if completions
 	  (speedbar-with-writable
 	   (while completions
-	     (speedbar-make-tag-line 'bracket ?+ 'Info-speedbar-expand-node
+	     (speedbar-make-tag-line (if (= depth 0)
+					 'angle
+				       'bracket)
+				     ?+ 'Info-speedbar-expand-node
 				     (cdr (car completions))
 				     (car (car completions))
 				     'Info-speedbar-goto-node
 TEXT is the text of the button we clicked on, a + or - item.
 TOKEN is data related to this node (NAME . FILE).
 INDENT is the current indentation depth."
-  (cond ((string-match "+" text)	;we have to expand this file
-	 (speedbar-change-expand-button-char ?-)
-	 (if (speedbar-with-writable
-	       (save-excursion
-		 (end-of-line) (forward-char 1)
-		 (Info-speedbar-hierarchy-buttons nil (1+ indent) token)))
-	     (speedbar-change-expand-button-char ?-)
-	   (speedbar-change-expand-button-char ??)))
-	((string-match "-" text)	;we have to contract this node
-	 (speedbar-change-expand-button-char ?+)
-	 (speedbar-delete-subblock indent))
-	(t (error "Ooops... not sure what to do")))
-  (speedbar-center-buffer-smartly))
-
+  (let ((speedbar-expand-image-button-alist Info-speedbar-image-button-alist))
+    (cond ((string-match "+" text)	;we have to expand this file
+	   (speedbar-change-expand-button-char ?-)
+	   (if (speedbar-with-writable
+		 (save-excursion
+		   (end-of-line) (forward-char 1)
+		   (Info-speedbar-hierarchy-buttons nil (1+ indent) token)))
+	       (speedbar-change-expand-button-char ?-)
+	     (speedbar-change-expand-button-char ??)))
+	  ((string-match "-" text)	;we have to contract this node
+	   (speedbar-change-expand-button-char ?+)
+	   (speedbar-delete-subblock indent))
+	  (t (error "Ooops... not sure what to do")))
+    (speedbar-center-buffer-smartly)))
+  
 (defun Info-speedbar-fetch-file-nodes (nodespec)
   "Fetch the subnodes from the info NODESPEC.
 NODESPEC is a string of the form: (file)node.
       (nreverse completions))))
 
 ;;; Info mode node listing
+;;;###autoload
 (defun Info-speedbar-buttons (buffer)
   "Create a speedbar display to help navigation in an Info file.
 BUFFER is the buffer speedbar is requesting buttons for."