X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/5762abecd390e960b2a15bc58b5ed6a07af5955f..f52154007f41abe6857acab91e31ab4a7d18210d:/lisp/msb.el diff --git a/lisp/msb.el b/lisp/msb.el index cb1706fdf7..ebdee96515 100644 --- a/lisp/msb.el +++ b/lisp/msb.el @@ -523,7 +523,7 @@ If the argument is left out or nil, then the current buffer is considered." ;; Make alist that looks like ;; ((PATH-1 BUFFER-1) (PATH-2 BUFFER-2) ...) ;; sorted on PATH-x - (sort (mapcan + (sort (mapcar (lambda (buffer) (let ((file-name (expand-file-name (buffer-file-name buffer)))) (when file-name @@ -537,7 +537,7 @@ If the argument is left out or nil, then the current buffer is considered." (let ((path nil) (buffers nil)) (nconc - (mapcan (lambda (item) + (mapcar (lambda (item) (cond ((and path (string= path (car item))) @@ -582,7 +582,7 @@ If the argument is left out or nil, then the current buffer is considered." rest (cdr buffer-alist) path (car first) buffers (cdr first)) - (setq msb--choose-file-menu-list (copy-list rest)) + (setq msb--choose-file-menu-list (apply #'list rest)) ;; This big loop tries to clump buffers together that have a ;; similar name. Remember that buffer-alist is sorted based on the ;; path for the buffers. @@ -597,8 +597,11 @@ If the argument is left out or nil, then the current buffer is considered." (while (and tmp-rest (<= (length buffers) max-clumped-together) (>= (length (car item)) (length path)) + ;; `completion-ignore-case' seems to default to t + ;; on the systems with case-insensitive file names. (eq t (compare-strings path 0 nil - (car item) 0 (length path)))) + (car item) 0 (length path) + completion-ignore-case))) (setq found-p t) (setq buffers (append buffers (cdr item))) ;nconc is faster than append (setq tmp-rest (cdr tmp-rest) @@ -636,13 +639,14 @@ If the argument is left out or nil, then the current buffer is considered." (setq last-path path)) (when (and last-path (or (and (>= (length path) (length last-path)) - (eq t (compare-strings last-path 0 nil - path 0 (length - last-path)))) + (eq t (compare-strings + last-path 0 nil path 0 + (length last-path) + completion-ignore-case))) (and (< (length path) (length last-path)) - (eq t (compare-strings path 0 nil - last-path 0 (length - path)))))) + (eq t (compare-strings + path 0 nil last-path 0 (length path) + completion-ignore-case))))) ;; We have reached the same place in the file hierarchy as ;; the last result, so we should quit at this point and ;; take what we have as result. @@ -752,9 +756,8 @@ to the buffer-list variable in function-info." (save-excursion (set-buffer buffer) ;; Menu found. Add to this menu - (mapc (lambda (function-info) - (msb--add-to-menu buffer function-info max-buffer-name-length)) - (msb--collect function-info-vector))) + (dolist (info (msb--collect function-info-vector)) + (msb--add-to-menu buffer info max-buffer-name-length))) (error (unless msb--error (setq msb--error (format @@ -788,13 +791,13 @@ SAME-PREDICATE) are aggregated together. The alist is first sorted by SORT-PREDICATE. Example: -(msb--aggregate-alist +\(msb--aggregate-alist '((a . a1) (a . a2) (b . b1) (c . c3) (a . a4) (a . a3) (b . b3) (b . b2)) (function string=) (lambda (item1 item2) (string< (symbol-name item1) (symbol-name item2)))) results in -((a a1 a2 a4 a3) (b b1 b3 b2) (c c3))" +\((a a1 a2 a4 a3) (b b1 b3 b2) (c c3))" (when (not (null alist)) (let (result same @@ -803,7 +806,7 @@ results in (first-time-p t) old-car) (nconc - (mapcan (lambda (item) + (mapcar (lambda (item) (cond (first-time-p (push (cdr item) same) @@ -833,14 +836,13 @@ results in (concat (cdr item) " (%d)"))) (sort (let ((mode-list nil)) - (mapc (lambda (buffer) - (save-excursion - (set-buffer buffer) - (when (and (not (msb-invisible-buffer-p)) - (not (assq major-mode mode-list)) - (push (cons major-mode mode-name) - mode-list))))) - (cdr (buffer-list))) + (dolist (buffer (cdr (buffer-list))) + (save-excursion + (set-buffer buffer) + (when (and (not (msb-invisible-buffer-p)) + (not (assq major-mode mode-list))) + (push (cons major-mode mode-name) + mode-list)))) mode-list) (lambda (item1 item2) (string< (cdr item1) (cdr item2))))))) @@ -877,14 +879,11 @@ It takes the form ((TITLE . BUFFER-LIST)...)." file-buffers function-info-vector) ;; Calculate the longest buffer name. - (mapc - (lambda (buffer) - (if (or msb-display-invisible-buffers-p - (not (msb-invisible-buffer-p))) - (setq max-buffer-name-length - (max max-buffer-name-length - (length (buffer-name buffer)))))) - (buffer-list)) + (dolist (buffer (buffer-list)) + (when (or msb-display-invisible-buffers-p + (not (msb-invisible-buffer-p))) + (setq max-buffer-name-length + (max max-buffer-name-length (length (buffer-name buffer)))))) ;; Make a list with elements of type ;; (BUFFER-LIST-VARIABLE ;; CONDITION @@ -900,19 +899,18 @@ It takes the form ((TITLE . BUFFER-LIST)...)." (append msb-menu-cond (msb--mode-menu-cond))))) ;; Split the buffer-list into several lists; one list for each ;; criteria. This is the most critical part with respect to time. - (mapc (lambda (buffer) - (cond ((and msb-files-by-directory - (buffer-file-name buffer) - ;; exclude ange-ftp buffers - ;;(not (string-match "\\/[^/:]+:" - ;; (buffer-file-name buffer))) - ) - (push buffer file-buffers)) - (t - (msb--choose-menu buffer - function-info-vector - max-buffer-name-length)))) - (buffer-list)) + (dolist (buffer (buffer-list)) + (cond ((and msb-files-by-directory + (buffer-file-name buffer) + ;; exclude ange-ftp buffers + ;;(not (string-match "\\/[^/:]+:" + ;; (buffer-file-name buffer))) + ) + (push buffer file-buffers)) + (t + (msb--choose-menu buffer + function-info-vector + max-buffer-name-length)))) (when file-buffers (setq file-buffers (mapcar (lambda (buffer-list) @@ -1038,7 +1036,7 @@ variable `msb-menu-cond'." sorted-list) (t (let ((last-key nil)) - (mapcan + (mapcar (lambda (item) (cond ((and msb-separator-diff