aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love1999-07-28 16:46:30 +0000
committerDave Love1999-07-28 16:46:30 +0000
commit492bd7587de29d4a79f65181a8657c0d38bab2eb (patch)
treefab757e9cf20ae3ea360a5b97a95b229c078ffb9
parent87f0532f1139f933caefa84bc950c086d226db81 (diff)
downloademacs-492bd7587de29d4a79f65181a8657c0d38bab2eb.tar.gz
emacs-492bd7587de29d4a79f65181a8657c0d38bab2eb.zip
Require cl only when compiling.
(msb--home-dir): Deleted. (msb--format-title): Use abbreviate-file-name. (msb--choose-file-menu): Simplify string comparison.
-rw-r--r--lisp/msb.el31
1 files changed, 10 insertions, 21 deletions
diff --git a/lisp/msb.el b/lisp/msb.el
index 9d523a666a5..866a5c3dddc 100644
--- a/lisp/msb.el
+++ b/lisp/msb.el
@@ -75,10 +75,11 @@
75;; Richard Stallman <rms@gnu.ai.mit.edu> 75;; Richard Stallman <rms@gnu.ai.mit.edu>
76;; Steve Fisk <fisk@medved.bowdoin.edu> 76;; Steve Fisk <fisk@medved.bowdoin.edu>
77 77
78;; This version turned into a global minor mode by Dave Love. 78;; This version turned into a global minor mode and subsequently
79;; hacked on by Dave Love.
79;;; Code: 80;;; Code:
80 81
81(require 'cl) 82(eval-when-compile (require 'cl))
82 83
83;;; 84;;;
84;;; Some example constants to be used for `msb-menu-cond'. See that 85;;; Some example constants to be used for `msb-menu-cond'. See that
@@ -399,13 +400,6 @@ This is instead of the groups in `msb-menu-cond'."
399;;; Internal variables 400;;; Internal variables
400;;; 401;;;
401 402
402;; Home directory for the current user
403(defconst msb--home-dir
404 (condition-case nil
405 (substitute-in-file-name "$HOME")
406 ;; If $HOME isn't defined, use nil
407 (error nil)))
408
409;; The last calculated menu. 403;; The last calculated menu.
410(defvar msb--last-buffer-menu nil) 404(defvar msb--last-buffer-menu nil)
411 405
@@ -565,13 +559,8 @@ If the argument is left out or nil, then the current buffer is considered."
565 559
566(defun msb--format-title (top-found-p path number-of-items) 560(defun msb--format-title (top-found-p path number-of-items)
567 "Format a suitable title for the menu item." 561 "Format a suitable title for the menu item."
568 (let ((new-path path)) 562 (format (if top-found-p "%s... (%d)" "%s (%d)")
569 (when (and msb--home-dir 563 (abbreviate-file-name path) number-of-items))
570 (string-match (concat "^" msb--home-dir) path))
571 (setq new-path (concat "~"
572 (substring path (match-end 0)))))
573 (format (if top-found-p "%s... (%d)" "%s (%d)")
574 new-path number-of-items)))
575 564
576;; Variables for debugging. 565;; Variables for debugging.
577(defvar msb--choose-file-menu-list) 566(defvar msb--choose-file-menu-list)
@@ -608,7 +597,7 @@ If the argument is left out or nil, then the current buffer is considered."
608 (while (and tmp-rest 597 (while (and tmp-rest
609 (<= (length buffers) max-clumped-together) 598 (<= (length buffers) max-clumped-together)
610 (>= (length (car item)) (length path)) 599 (>= (length (car item)) (length path))
611 (string= path (substring (car item) 0 (length path)))) 600 (compare-strings path 0 nil (car item) 0 (length path)))
612 (setq found-p t) 601 (setq found-p t)
613 (setq buffers (append buffers (cdr item))) ;nconc is faster than append 602 (setq buffers (append buffers (cdr item))) ;nconc is faster than append
614 (setq tmp-rest (cdr tmp-rest) 603 (setq tmp-rest (cdr tmp-rest)
@@ -646,11 +635,11 @@ If the argument is left out or nil, then the current buffer is considered."
646 (setq last-path path)) 635 (setq last-path path))
647 (when (and last-path 636 (when (and last-path
648 (or (and (>= (length path) (length last-path)) 637 (or (and (>= (length path) (length last-path))
649 (string= last-path 638 (compare-strings last-path 0 nil
650 (substring path 0 (length last-path)))) 639 path 0 (length last-path)))
651 (and (< (length path) (length last-path)) 640 (and (< (length path) (length last-path))
652 (string= path 641 (compare-strings path 0 nil
653 (substring last-path 0 (length path)))))) 642 last-path 0 (length path)))))
654 ;; We have reached the same place in the file hierarchy as 643 ;; We have reached the same place in the file hierarchy as
655 ;; the last result, so we should quit at this point and 644 ;; the last result, so we should quit at this point and
656 ;; take what we have as result. 645 ;; take what we have as result.