Function: change-log-next-buffer

change-log-next-buffer is a byte-compiled function defined in add-log.el.gz.

Signature

(change-log-next-buffer &optional BUFFER WRAP)

Documentation

Return the next buffer in the series of ChangeLog file buffers.

This function is used for multiple buffers isearch. A sequence of buffers is formed by ChangeLog files with decreasing numeric file name suffixes in the directory of the initial ChangeLog file were isearch was started.

Source Code

;; Defined in /usr/src/emacs/lisp/vc/add-log.el.gz
(defun change-log-next-buffer (&optional buffer wrap)
  "Return the next buffer in the series of ChangeLog file buffers.
This function is used for multiple buffers isearch.
A sequence of buffers is formed by ChangeLog files with decreasing
numeric file name suffixes in the directory of the initial ChangeLog
file were isearch was started."
  (let* ((name (change-log-name))
	 (files (append
                 (and (file-exists-p name) (list name))
                 (sort (file-expand-wildcards
                        (concat name "[-.][0-9]*"))
                       (lambda (a b)
                         ;; The file's extension may not have a valid
                         ;; version form (e.g. VC backup revisions).
                         (ignore-errors
                           (version< (substring b (length name))
                                     (substring a (length name))))))))
	 (files (if isearch-forward files (reverse files)))
	 (file (if wrap
		   (car files)
		 (cadr (member (file-name-nondirectory (buffer-file-name buffer))
			       files)))))
    ;; If there are no files that match the default pattern ChangeLog.[0-9],
    ;; return the current buffer to force isearch wrapping to its beginning.
    ;; If file is nil, multi-isearch-search-fun will signal "end of multi".
    (cond
     ;; Wrapping doesn't catch errors from the nil arg of file-exists-p,
     ;; so handle it explicitly.
     ((and wrap (null file))
      (current-buffer))
     ;; When there is no next file, file-exists-p raises the error to be
     ;; catched by the search function that displays the error message.
     ((file-exists-p file)
      (find-file-noselect file))
     (t
      (current-buffer)))))