- (let ((nlines (if nlines
- (prefix-numeric-value nlines)
- list-matching-lines-default-context-lines))
- (first t)
- ;;flag to prevent printing separator for first match
- (occur-num-matches 0)
- (buffer (current-buffer))
- (dir default-directory)
- (linenum 1)
- (prevpos
- ;;position of most recent match
- (point-min))
- (case-fold-search (and case-fold-search
- (isearch-no-upper-case-p regexp t)))
- (final-context-start
- ;; Marker to the start of context immediately following
- ;; the matched text in *Occur*.
- (make-marker)))
+ (let* ((nlines (if nlines
+ (prefix-numeric-value nlines)
+ list-matching-lines-default-context-lines))
+ (current-tab-width tab-width)
+ (inhibit-read-only t)
+ ;; Minimum width of line number plus trailing colon.
+ (min-line-number-width 6)
+ ;; Width of line number prefix without the colon. Choose a
+ ;; width that's a multiple of `tab-width' in the original
+ ;; buffer so that lines in *Occur* appear right.
+ (line-number-width (1- (* (/ (- (+ min-line-number-width
+ tab-width)
+ 1)
+ tab-width)
+ tab-width)))
+ ;; Format string for line numbers.
+ (line-number-format (format "%%%dd" line-number-width))
+ (empty (make-string line-number-width ?\ ))
+ (first t)
+ ;;flag to prevent printing separator for first match
+ (occur-num-matches 0)
+ (buffer (current-buffer))
+ (dir default-directory)
+ (linenum 1)
+ (prevpos
+ ;;position of most recent match
+ (point-min))
+ (case-fold-search (and case-fold-search
+ (isearch-no-upper-case-p regexp t)))
+ (final-context-start
+ ;; Marker to the start of context immediately following
+ ;; the matched text in *Occur*.
+ (make-marker)))