diff options
Diffstat (limited to 'lisp/add-log.el')
-rw-r--r-- | lisp/add-log.el | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/lisp/add-log.el b/lisp/add-log.el index a58d6318670..3ca1b613955 100644 --- a/lisp/add-log.el +++ b/lisp/add-log.el @@ -760,7 +760,33 @@ Runs `change-log-mode-hook'. 'change-log-resolve-conflict) (set (make-local-variable 'adaptive-fill-regexp) "\\s *") (set (make-local-variable 'font-lock-defaults) - '(change-log-font-lock-keywords t nil nil backward-paragraph))) + '(change-log-font-lock-keywords t nil nil backward-paragraph)) + (set (make-local-variable 'isearch-buffers-next-buffer-function) + 'change-log-next-buffer) + (set (make-local-variable 'beginning-of-defun-function) + 'change-log-beginning-of-defun) + (set (make-local-variable 'end-of-defun-function) + 'change-log-end-of-defun) + (isearch-buffers-minor-mode)) + +(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 (cons name (sort (file-expand-wildcards + (concat name "[-.][0-9]*")) + (lambda (a b) + (version< (substring b (length name)) + (substring a (length name))))))) + (files (if isearch-forward files (reverse files)))) + (find-file-noselect + (if wrap + (car files) + (cadr (member (file-name-nondirectory (buffer-file-name buffer)) + files)))))) ;; It might be nice to have a general feature to replace this. The idea I ;; have is a variable giving a regexp matching text which should not be @@ -1073,11 +1099,13 @@ Has a preference of looking backwards." (change-log-get-method-definition-1 "")) (concat change-log-get-method-definition-md "]")))))) +(defconst change-log-start-entry-re "^\\sw.........[0-9:+ ]*") + (defun change-log-sortable-date-at () "Return date of log entry in a consistent form for sorting. Point is assumed to be at the start of the entry." (require 'timezone) - (if (looking-at "^\\sw.........[0-9:+ ]*") + (if (looking-at change-log-start-entry-re) (let ((date (match-string-no-properties 0))) (if date (if (string-match "\\(....\\)-\\(..\\)-\\(..\\)\\s-+" date) @@ -1164,6 +1192,32 @@ old-style time formats for entries are supported." (goto-char (point-max))) (insert-buffer-substring other-buf start))))))) +(defun change-log-beginning-of-defun () + (re-search-backward change-log-start-entry-re nil 'move)) + +(defun change-log-end-of-defun () + ;; Look back and if there is no entry there it means we are before + ;; the first ChangeLog entry, so go forward until finding one. + (unless (save-excursion (re-search-backward change-log-start-entry-re nil t)) + (re-search-forward change-log-start-entry-re nil t)) + + ;; In case we are at the end of log entry going forward a line will + ;; make us find the next entry when searching. If we are inside of + ;; an entry going forward a line will still keep the point inside + ;; the same entry. + (forward-line 1) + + ;; In case we are at the beginning of an entry, move past it. + (when (looking-at change-log-start-entry-re) + (goto-char (match-end 0)) + (forward-line 1)) + + ;; Search for the start of the next log entry. Go to the end of the + ;; buffer if we could not find a next entry. + (when (re-search-forward change-log-start-entry-re nil 'move) + (goto-char (match-beginning 0)) + (forward-line -1))) + (provide 'add-log) ;; arch-tag: 81eee6fc-088f-4372-a37f-80ad9620e762 |