aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim F. Storm2003-01-19 19:53:34 +0000
committerKim F. Storm2003-01-19 19:53:34 +0000
commit965440e65bcafa4dd86972bc2703a2a07a7caa03 (patch)
treed11f2f7cc5c5567652b537a431fb9ee2ff30d361
parent67006b44b4b59c8f4696670a75a891a1586a735b (diff)
downloademacs-965440e65bcafa4dd86972bc2703a2a07a7caa03.tar.gz
emacs-965440e65bcafa4dd86972bc2703a2a07a7caa03.zip
Use `dir' instead of `path' everywhere.
-rw-r--r--lisp/msb.el82
1 files changed, 41 insertions, 41 deletions
diff --git a/lisp/msb.el b/lisp/msb.el
index ab881761246..5c318420376 100644
--- a/lisp/msb.el
+++ b/lisp/msb.el
@@ -496,13 +496,13 @@ If the argument is left out or nil, then the current buffer is considered."
496 (file-name-directory (directory-file-name dir))) 496 (file-name-directory (directory-file-name dir)))
497 497
498;; Create an alist with all buffers from LIST that lies under the same 498;; Create an alist with all buffers from LIST that lies under the same
499;; directory will be in the same item as the directory string. 499;; directory will be in the same item as the directory name.
500;; ((PATH1 . (BUFFER-1 BUFFER-2 ...)) (PATH2 . (BUFFER-K BUFFER-K+1...)) ...) 500;; ((DIR1 . (BUFFER-1 BUFFER-2 ...)) (DIR2 . (BUFFER-K BUFFER-K+1...)) ...)
501(defun msb--init-file-alist (list) 501(defun msb--init-file-alist (list)
502 (let ((buffer-alist 502 (let ((buffer-alist
503 ;; Make alist that looks like 503 ;; Make alist that looks like
504 ;; ((PATH-1 BUFFER-1) (PATH-2 BUFFER-2) ...) 504 ;; ((DIR-1 BUFFER-1) (DIR-2 BUFFER-2) ...)
505 ;; sorted on PATH-x 505 ;; sorted on DIR-x
506 (sort 506 (sort
507 (apply #'nconc 507 (apply #'nconc
508 (mapcar 508 (mapcar
@@ -514,37 +514,37 @@ If the argument is left out or nil, then the current buffer is considered."
514 list)) 514 list))
515 (lambda (item1 item2) 515 (lambda (item1 item2)
516 (string< (car item1) (car item2)))))) 516 (string< (car item1) (car item2))))))
517 ;; Now clump buffers together that have the same path 517 ;; Now clump buffers together that have the same directory name
518 ;; Make alist that looks like 518 ;; Make alist that looks like
519 ;; ((PATH1 . (BUFFER-1 BUFFER-2 ...)) (PATH2 . (BUFFER-K)) ...) 519 ;; ((DIR1 . (BUFFER-1 BUFFER-2 ...)) (DIR2 . (BUFFER-K)) ...)
520 (let ((path nil) 520 (let ((dir nil)
521 (buffers nil)) 521 (buffers nil))
522 (nconc 522 (nconc
523 (apply 523 (apply
524 #'nconc 524 #'nconc
525 (mapcar (lambda (item) 525 (mapcar (lambda (item)
526 (cond 526 (cond
527 ((equal path (car item)) 527 ((equal dir (car item))
528 ;; The same path as earlier: Add to current list of 528 ;; The same dir as earlier:
529 ;; buffers. 529 ;; Add to current list of buffers.
530 (push (cdr item) buffers) 530 (push (cdr item) buffers)
531 ;; This item should not be added to list 531 ;; This item should not be added to list
532 nil) 532 nil)
533 (t 533 (t
534 ;; New path 534 ;; New dir
535 (let ((result (and path (cons path buffers)))) 535 (let ((result (and dir (cons dir buffers))))
536 (setq path (car item)) 536 (setq dir (car item))
537 (setq buffers (list (cdr item))) 537 (setq buffers (list (cdr item)))
538 ;; Add the last result the list. 538 ;; Add the last result the list.
539 (and result (list result)))))) 539 (and result (list result))))))
540 buffer-alist)) 540 buffer-alist))
541 ;; Add the last result to the list 541 ;; Add the last result to the list
542 (list (cons path buffers)))))) 542 (list (cons dir buffers))))))
543 543
544(defun msb--format-title (top-found-p path number-of-items) 544(defun msb--format-title (top-found-p dir number-of-items)
545 "Format a suitable title for the menu item." 545 "Format a suitable title for the menu item."
546 (format (if top-found-p "%s... (%d)" "%s (%d)") 546 (format (if top-found-p "%s... (%d)" "%s (%d)")
547 (abbreviate-file-name path) number-of-items)) 547 (abbreviate-file-name dir) number-of-items))
548 548
549;; Variables for debugging. 549;; Variables for debugging.
550(defvar msb--choose-file-menu-list) 550(defvar msb--choose-file-menu-list)
@@ -559,32 +559,32 @@ If the argument is left out or nil, then the current buffer is considered."
559 msb-max-file-menu-items 559 msb-max-file-menu-items
560 10)) 560 10))
561 (top-found-p nil) 561 (top-found-p nil)
562 (last-path nil) 562 (last-dir nil)
563 first rest path buffers old-path) 563 first rest dir buffers old-dir)
564 ;; Prepare for looping over all items in buffer-alist 564 ;; Prepare for looping over all items in buffer-alist
565 (setq first (car buffer-alist) 565 (setq first (car buffer-alist)
566 rest (cdr buffer-alist) 566 rest (cdr buffer-alist)
567 path (car first) 567 dir (car first)
568 buffers (cdr first)) 568 buffers (cdr first))
569 (setq msb--choose-file-menu-list (copy-sequence rest)) 569 (setq msb--choose-file-menu-list (copy-sequence rest))
570 ;; This big loop tries to clump buffers together that have a 570 ;; This big loop tries to clump buffers together that have a
571 ;; similar name. Remember that buffer-alist is sorted based on the 571 ;; similar name. Remember that buffer-alist is sorted based on the
572 ;; path for the buffers. 572 ;; directory name of the buffers' visited files.
573 (while rest 573 (while rest
574 (let ((found-p nil) 574 (let ((found-p nil)
575 (tmp-rest rest) 575 (tmp-rest rest)
576 result 576 result
577 new-path item) 577 new-dir item)
578 (setq item (car tmp-rest)) 578 (setq item (car tmp-rest))
579 ;; Clump together the "rest"-buffers that have a path that is 579 ;; Clump together the "rest"-buffers that have a dir that is
580 ;; a subpath of the current one. 580 ;; a subdir of the current one.
581 (while (and tmp-rest 581 (while (and tmp-rest
582 (<= (length buffers) max-clumped-together) 582 (<= (length buffers) max-clumped-together)
583 (>= (length (car item)) (length path)) 583 (>= (length (car item)) (length dir))
584 ;; `completion-ignore-case' seems to default to t 584 ;; `completion-ignore-case' seems to default to t
585 ;; on the systems with case-insensitive file names. 585 ;; on the systems with case-insensitive file names.
586 (eq t (compare-strings path 0 nil 586 (eq t (compare-strings dir 0 nil
587 (car item) 0 (length path) 587 (car item) 0 (length dir)
588 completion-ignore-case))) 588 completion-ignore-case)))
589 (setq found-p t) 589 (setq found-p t)
590 (setq buffers (append buffers (cdr item))) ;nconc is faster than append 590 (setq buffers (append buffers (cdr item))) ;nconc is faster than append
@@ -594,7 +594,7 @@ If the argument is left out or nil, then the current buffer is considered."
594 ((> (length buffers) max-clumped-together) 594 ((> (length buffers) max-clumped-together)
595 ;; Oh, we failed. Too many buffers clumped together. 595 ;; Oh, we failed. Too many buffers clumped together.
596 ;; Just use the original ones for the result. 596 ;; Just use the original ones for the result.
597 (setq last-path (car first)) 597 (setq last-dir (car first))
598 (push (cons (msb--format-title top-found-p 598 (push (cons (msb--format-title top-found-p
599 (car first) 599 (car first)
600 (length (cdr first))) 600 (length (cdr first)))
@@ -603,33 +603,33 @@ If the argument is left out or nil, then the current buffer is considered."
603 (setq top-found-p nil) 603 (setq top-found-p nil)
604 (setq first (car rest) 604 (setq first (car rest)
605 rest (cdr rest) 605 rest (cdr rest)
606 path (car first) 606 dir (car first)
607 buffers (cdr first))) 607 buffers (cdr first)))
608 (t 608 (t
609 ;; The first pass of clumping together worked out, go ahead 609 ;; The first pass of clumping together worked out, go ahead
610 ;; with this result. 610 ;; with this result.
611 (when found-p 611 (when found-p
612 (setq top-found-p t) 612 (setq top-found-p t)
613 (setq first (cons path buffers) 613 (setq first (cons dir buffers)
614 rest tmp-rest)) 614 rest tmp-rest))
615 ;; Now see if we can clump more buffers together if we go up 615 ;; Now see if we can clump more buffers together if we go up
616 ;; one step in the file hierarchy. 616 ;; one step in the file hierarchy.
617 ;; If path isn't changed by msb--strip-dir, we are looking 617 ;; If dir isn't changed by msb--strip-dir, we are looking
618 ;; at the machine name component of an ange-ftp filename. 618 ;; at the machine name component of an ange-ftp filename.
619 (setq old-path path) 619 (setq old-dir dir)
620 (setq path (msb--strip-dir path) 620 (setq dir (msb--strip-dir dir)
621 buffers (cdr first)) 621 buffers (cdr first))
622 (if (equal old-path path) 622 (if (equal old-dir dir)
623 (setq last-path path)) 623 (setq last-dir dir))
624 (when (and last-path 624 (when (and last-dir
625 (or (and (>= (length path) (length last-path)) 625 (or (and (>= (length dir) (length last-dir))
626 (eq t (compare-strings 626 (eq t (compare-strings
627 last-path 0 nil path 0 627 last-dir 0 nil dir 0
628 (length last-path) 628 (length last-dir)
629 completion-ignore-case))) 629 completion-ignore-case)))
630 (and (< (length path) (length last-path)) 630 (and (< (length dir) (length last-dir))
631 (eq t (compare-strings 631 (eq t (compare-strings
632 path 0 nil last-path 0 (length path) 632 dir 0 nil last-dir 0 (length dir)
633 completion-ignore-case))))) 633 completion-ignore-case)))))
634 ;; We have reached the same place in the file hierarchy as 634 ;; We have reached the same place in the file hierarchy as
635 ;; the last result, so we should quit at this point and 635 ;; the last result, so we should quit at this point and
@@ -642,7 +642,7 @@ If the argument is left out or nil, then the current buffer is considered."
642 (setq top-found-p nil) 642 (setq top-found-p nil)
643 (setq first (car rest) 643 (setq first (car rest)
644 rest (cdr rest) 644 rest (cdr rest)
645 path (car first) 645 dir (car first)
646 buffers (cdr first))))))) 646 buffers (cdr first)))))))
647 ;; Now take care of the last item. 647 ;; Now take care of the last item.
648 (when first 648 (when first