Download
(require 'all)
(eval-when-compile (require 'cl))
(defun all-make-lineno-overlay (lineno)
(let ((o (make-overlay (point) (point))))
(overlay-put o 'before-string (format "%7d:" lineno))
(overlay-put o 'face 'default)
o))
(defun all-make-lineno-overlays-from-here (to lineno)
(all-make-lineno-overlay lineno)
(while (search-forward "\n" (1- to) t)
(setq lineno (1+ lineno))
(all-make-lineno-overlay lineno)))
(defun all-insert (start end regexp nlines)
"Redefined original `all-insert' to display line number overlay."
(let ((marker (copy-marker start))
(buffer (current-buffer)))
(with-current-buffer standard-output
(let ((from (point)) to)
(insert-buffer-substring buffer start end)
(setq to (point))
(goto-char from)
(all-make-lineno-overlays-from-here
to (with-current-buffer buffer (line-number-at-pos start)))
(overlay-put (make-overlay from to) 'all-marker marker)
(goto-char from)
(while (re-search-forward regexp to t)
(put-text-property (match-beginning 0) (match-end 0)
'face 'match))
(goto-char to)
(if (> nlines 0)
(insert "--------\n"))))))
(defun kill-All-buffer-maybe ()
(when (get-buffer "*All*")
(kill-buffer "*All*")))
(defadvice all (before delete-All-buffer activate)
"Kill *All* buffer to delete all line number overlays"
(kill-All-buffer-maybe))
(declare-function anything-run-after-quit "ext:anything")
(declare-function helm-run-after-quit "ext:helm")
(defvar anything-buffer)
(defvar anything-current-buffer)
(defvar helm-buffer)
(defvar helm-current-buffer)
(eval-after-load "anything-config"
'(define-key anything-map (kbd "C-c C-a") 'all-from-anything-occur))
(defun all-from-anything-occur ()
"Call `all' from `anything' content."
(interactive)
(anything-run-after-quit
'all-from-anything-occur-internal "anything-occur"
anything-buffer anything-current-buffer))
(eval-after-load "helm"
'(define-key helm-map (kbd "C-c C-a") 'all-from-helm-occur))
(defun all-from-helm-occur ()
"Call `all' from `helm' content."
(interactive)
(helm-run-after-quit
'all-from-anything-occur-internal "helm-occur"
helm-buffer helm-current-buffer))
(defun all-from-anything-occur-internal (from anybuf srcbuf)
(kill-All-buffer-maybe)
(let ((all-initialization-p t)
(buffer srcbuf))
(with-output-to-temp-buffer "*All*"
(with-current-buffer standard-output
(all-mode)
(setq all-buffer buffer)
(insert "From " from "\n")
(insert "--------\n"))
(if (eq buffer standard-output)
(goto-char (point-max)))
(with-current-buffer anybuf
(save-excursion
(goto-char (point-min))
(forward-line 1)
(loop with regexp = (format "^\\(%s:\\| *\\)\\([0-9]+\\)[ :]\\(.+\\)$"
(buffer-name srcbuf))
while (re-search-forward regexp nil t)
for lineno = (string-to-number (match-string 2))
for content = (match-string 3)
do
(with-current-buffer srcbuf
(save-excursion
(goto-char (point-min))
(goto-char (point-at-bol lineno))
(all-from-anything-occur-insert
(point) (progn (forward-line 1) (point)) lineno content)))))))))
(defun all-from-anything-occur-insert (start end lineno content)
(let ((marker (copy-marker start)))
(with-current-buffer standard-output
(let ((from (point)) to)
(insert content "\n")
(setq to (point))
(goto-char from)
(all-make-lineno-overlays-from-here to lineno)
(goto-char to)
(overlay-put (make-overlay from to) 'all-marker marker)))))
(defun all-next-error (&optional argp reset)
(let ((w (get-buffer-window "*All*")))
(if (not w)
(error "Cannot find *All* buffer window.")
(with-selected-window w
(when (= (point-at-bol) (point-min))
(forward-line 1))
(forward-line argp)
(all-mode-goto)))))
(defadvice all-mode (after next-error activate)
(setq next-error-function 'all-next-error))
(provide 'all-ext)