comparison lisp/speedbar.el @ 68942:cb07d3843e81

(speedbar-frame-width): Make an inline function instead of a macro. Use frame-width. (speedbar-try-completion, speedbar-update-contents) (speedbar-timer-fn): Use consp. (speedbar-update-localized-contents): Try to preserve point.
author Nick Roberts <nickrob@snap.net.nz>
date Fri, 17 Feb 2006 00:26:14 +0000
parents 3bd95f4f2941
children 4d9d30d2a347 9e490faa9f6b
comparison
equal deleted inserted replaced
68941:b41d1af1839d 68942:cb07d3843e81
1017 (speedbar-reset-scanners) 1017 (speedbar-reset-scanners)
1018 (dframe-get-focus 'speedbar-frame 'speedbar-frame-mode 1018 (dframe-get-focus 'speedbar-frame 'speedbar-frame-mode
1019 (lambda () (let ((speedbar-update-flag t)) 1019 (lambda () (let ((speedbar-update-flag t))
1020 (speedbar-timer-fn))))) 1020 (speedbar-timer-fn)))))
1021 1021
1022 (defmacro speedbar-frame-width () 1022 (defsubst speedbar-frame-width ()
1023 "Return the width of the speedbar frame in characters. 1023 "Return the width of the speedbar frame in characters.
1024 nil if it doesn't exist." 1024 nil if it doesn't exist."
1025 '(window-width (get-buffer-window speedbar-buffer))) 1025 (frame-width speedbar-frame))
1026 1026
1027 (defun speedbar-mode () 1027 (defun speedbar-mode ()
1028 "Major mode for managing a display of directories and tags. 1028 "Major mode for managing a display of directories and tags.
1029 \\<speedbar-key-map> 1029 \\<speedbar-key-map>
1030 The first line represents the default directory of the speedbar frame. 1030 The first line represents the default directory of the speedbar frame.
2121 2121
2122 (defun speedbar-try-completion (string alist) 2122 (defun speedbar-try-completion (string alist)
2123 "A wrapper for `try-completion'. 2123 "A wrapper for `try-completion'.
2124 Passes STRING and ALIST to `try-completion' if ALIST 2124 Passes STRING and ALIST to `try-completion' if ALIST
2125 passes some tests." 2125 passes some tests."
2126 (if (and (listp alist) (not (null alist)) 2126 (if (and (consp alist)
2127 (listp (car alist)) (stringp (car (car alist)))) 2127 (listp (car alist)) (stringp (car (car alist))))
2128 (try-completion string alist) 2128 (try-completion string alist)
2129 nil)) 2129 nil))
2130 2130
2131 (defun speedbar-prefix-group-tag-hierarchy (lst) 2131 (defun speedbar-prefix-group-tag-hierarchy (lst)
2421 ;; Check for special modes 2421 ;; Check for special modes
2422 (speedbar-maybe-add-localized-support (current-buffer)) 2422 (speedbar-maybe-add-localized-support (current-buffer))
2423 2423
2424 ;; Choose the correct method of doodling. 2424 ;; Choose the correct method of doodling.
2425 (if (and speedbar-mode-specific-contents-flag 2425 (if (and speedbar-mode-specific-contents-flag
2426 (listp speedbar-special-mode-expansion-list) 2426 (consp speedbar-special-mode-expansion-list)
2427 speedbar-special-mode-expansion-list
2428 (local-variable-p 2427 (local-variable-p
2429 'speedbar-special-mode-expansion-list 2428 'speedbar-special-mode-expansion-list
2430 (current-buffer))) 2429 (current-buffer)))
2431 ;;(eq (get major-mode 'mode-class 'special))) 2430 ;;(eq (get major-mode 'mode-class 'special)))
2432 (speedbar-update-special-contents) 2431 (speedbar-update-special-contents)
2461 ;; Else, we can do a short cut. No text cache. 2460 ;; Else, we can do a short cut. No text cache.
2462 (let ((cbd (expand-file-name default-directory)) 2461 (let ((cbd (expand-file-name default-directory))
2463 ) 2462 )
2464 (set-buffer speedbar-buffer) 2463 (set-buffer speedbar-buffer)
2465 (speedbar-with-writable 2464 (speedbar-with-writable
2466 (erase-buffer) 2465 (let* ((window (get-buffer-window speedbar-buffer 0))
2467 (dolist (func funclst) 2466 (p (window-point window)))
2468 (setq default-directory cbd) 2467 (erase-buffer)
2469 (funcall func cbd 0)) 2468 (dolist (func funclst)
2470 (speedbar-reconfigure-keymaps) 2469 (setq default-directory cbd)
2471 (goto-char (point-min))) 2470 (funcall func cbd 0))
2471 (speedbar-reconfigure-keymaps)
2472 (set-window-point window p)))
2472 )))) 2473 ))))
2473 2474
2474 (defun speedbar-update-directory-contents () 2475 (defun speedbar-update-directory-contents ()
2475 "Update the contents of the speedbar buffer based on the current directory." 2476 "Update the contents of the speedbar buffer based on the current directory."
2476 2477
2570 (speedbar-with-writable 2571 (speedbar-with-writable
2571 (dolist (func funclst) 2572 (dolist (func funclst)
2572 ;; We do not erase the buffer because these functions may 2573 ;; We do not erase the buffer because these functions may
2573 ;; decide NOT to update themselves. 2574 ;; decide NOT to update themselves.
2574 (funcall func specialbuff))) 2575 (funcall func specialbuff)))
2575
2576 (goto-char (point-min)))) 2576 (goto-char (point-min))))
2577 (speedbar-reconfigure-keymaps)) 2577 (speedbar-reconfigure-keymaps))
2578 2578
2579 (defun speedbar-set-timer (timeout) 2579 (defun speedbar-set-timer (timeout)
2580 "Set up the speedbar timer with TIMEOUT. 2580 "Set up the speedbar timer with TIMEOUT.
2612 nil 2612 nil
2613 ;; Check for special modes 2613 ;; Check for special modes
2614 (speedbar-maybe-add-localized-support (current-buffer)) 2614 (speedbar-maybe-add-localized-support (current-buffer))
2615 ;; Update for special mode all the time! 2615 ;; Update for special mode all the time!
2616 (if (and speedbar-mode-specific-contents-flag 2616 (if (and speedbar-mode-specific-contents-flag
2617 (listp speedbar-special-mode-expansion-list) 2617 (consp speedbar-special-mode-expansion-list)
2618 speedbar-special-mode-expansion-list
2619 (local-variable-p 2618 (local-variable-p
2620 'speedbar-special-mode-expansion-list 2619 'speedbar-special-mode-expansion-list
2621 (current-buffer))) 2620 (current-buffer)))
2622 ;;(eq (get major-mode 'mode-class 'special))) 2621 ;;(eq (get major-mode 'mode-class 'special)))
2623 (progn 2622 (progn