diff options
| author | Juri Linkov | 2011-09-07 15:00:52 +0300 |
|---|---|---|
| committer | Juri Linkov | 2011-09-07 15:00:52 +0300 |
| commit | 0527e251e5abfd1d574d0a5bc3c9348f7ec5a8ba (patch) | |
| tree | 96fce72d1fdc35c19d976cb3d51440a40102f031 | |
| parent | 249f792c828e9ad1e04ebda32f0e68c060bbe2ec (diff) | |
| download | emacs-0527e251e5abfd1d574d0a5bc3c9348f7ec5a8ba.tar.gz emacs-0527e251e5abfd1d574d0a5bc3c9348f7ec5a8ba.zip | |
* lisp/progmodes/grep.el (grep-regexp-alist): Calculate column positions
based on text properties put by `grep-filter' instead of matching
escape sequences.
(grep-mode): Set buffer-local `compilation-error-screen-columns'
to the value of `grep-error-screen-columns'.
Fixes: debbugs:9438
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/progmodes/grep.el | 32 |
2 files changed, 28 insertions, 12 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 36944aaa1b6..e3e0c857385 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,13 @@ | |||
| 1 | 2011-09-07 Juri Linkov <juri@jurta.org> | 1 | 2011-09-07 Juri Linkov <juri@jurta.org> |
| 2 | 2 | ||
| 3 | * progmodes/grep.el (grep-regexp-alist): Calculate column positions | ||
| 4 | based on text properties put by `grep-filter' instead of matching | ||
| 5 | escape sequences. | ||
| 6 | (grep-mode): Set buffer-local `compilation-error-screen-columns' | ||
| 7 | to the value of `grep-error-screen-columns' (bug#9438). | ||
| 8 | |||
| 9 | 2011-09-07 Juri Linkov <juri@jurta.org> | ||
| 10 | |||
| 3 | * simple.el (next-error-highlight, next-error-highlight-no-select): | 11 | * simple.el (next-error-highlight, next-error-highlight-no-select): |
| 4 | Doc fix (bug#9432). | 12 | Doc fix (bug#9432). |
| 5 | 13 | ||
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index de46dc19169..b3f9758bacf 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el | |||
| @@ -344,7 +344,24 @@ Notice that using \\[next-error] or \\[compile-goto-error] modifies | |||
| 344 | ;;;###autoload | 344 | ;;;###autoload |
| 345 | (defconst grep-regexp-alist | 345 | (defconst grep-regexp-alist |
| 346 | '(("^\\(.+?\\)\\(:[ \t]*\\)\\([1-9][0-9]*\\)\\2" | 346 | '(("^\\(.+?\\)\\(:[ \t]*\\)\\([1-9][0-9]*\\)\\2" |
| 347 | 1 3) | 347 | 1 3 |
| 348 | ;; Calculate column positions (col . end-col) of first grep match on a line | ||
| 349 | ((lambda () | ||
| 350 | (when grep-highlight-matches | ||
| 351 | (let* ((beg (match-end 0)) | ||
| 352 | (end (save-excursion (goto-char beg) (line-end-position))) | ||
| 353 | (mbeg (text-property-any beg end 'font-lock-face 'match))) | ||
| 354 | (when mbeg | ||
| 355 | (- mbeg beg))))) | ||
| 356 | . | ||
| 357 | (lambda () | ||
| 358 | (when grep-highlight-matches | ||
| 359 | (let* ((beg (match-end 0)) | ||
| 360 | (end (save-excursion (goto-char beg) (line-end-position))) | ||
| 361 | (mbeg (text-property-any beg end 'font-lock-face 'match)) | ||
| 362 | (mend (and mbeg (next-single-property-change mbeg 'font-lock-face nil end)))) | ||
| 363 | (when mend | ||
| 364 | (- mend beg))))))) | ||
| 348 | ;; Rule to match column numbers is commented out since no known grep | 365 | ;; Rule to match column numbers is commented out since no known grep |
| 349 | ;; produces them | 366 | ;; produces them |
| 350 | ;; ("^\\(.+?\\)\\(:[ \t]*\\)\\([0-9]+\\)\\2\\(?:\\([0-9]+\\)\\(?:-\\([0-9]+\\)\\)?\\2\\)?" | 367 | ;; ("^\\(.+?\\)\\(:[ \t]*\\)\\([0-9]+\\)\\2\\(?:\\([0-9]+\\)\\(?:-\\([0-9]+\\)\\)?\\2\\)?" |
| @@ -353,17 +370,6 @@ Notice that using \\[next-error] or \\[compile-goto-error] modifies | |||
| 353 | ;; handle weird file names (with colons in them) as well as possible. | 370 | ;; handle weird file names (with colons in them) as well as possible. |
| 354 | ;; E.g. we use [1-9][0-9]* rather than [0-9]+ so as to accept ":034:" in | 371 | ;; E.g. we use [1-9][0-9]* rather than [0-9]+ so as to accept ":034:" in |
| 355 | ;; file names. | 372 | ;; file names. |
| 356 | ("^\\(\\(.+?\\):\\([1-9][0-9]*\\):\\).*?\ | ||
| 357 | \\(\033\\[01;31m\\(?:\033\\[K\\)?\\)\\(.*?\\)\\(\033\\[[0-9]*m\\)" | ||
| 358 | 2 3 | ||
| 359 | ;; Calculate column positions (beg . end) of first grep match on a line | ||
| 360 | ((lambda () | ||
| 361 | (setq compilation-error-screen-columns nil) | ||
| 362 | (- (match-beginning 4) (match-end 1))) | ||
| 363 | . | ||
| 364 | (lambda () (- (match-end 5) (match-end 1) | ||
| 365 | (- (match-end 4) (match-beginning 4))))) | ||
| 366 | nil 1) | ||
| 367 | ("^Binary file \\(.+\\) matches$" 1 nil nil 0 1)) | 373 | ("^Binary file \\(.+\\) matches$" 1 nil nil 0 1)) |
| 368 | "Regexp used to match grep hits. See `compilation-error-regexp-alist'.") | 374 | "Regexp used to match grep hits. See `compilation-error-regexp-alist'.") |
| 369 | 375 | ||
| @@ -709,6 +715,8 @@ This function is called from `compilation-filter-hook'." | |||
| 709 | (set (make-local-variable 'compilation-process-setup-function) | 715 | (set (make-local-variable 'compilation-process-setup-function) |
| 710 | 'grep-process-setup) | 716 | 'grep-process-setup) |
| 711 | (set (make-local-variable 'compilation-disable-input) t) | 717 | (set (make-local-variable 'compilation-disable-input) t) |
| 718 | (set (make-local-variable 'compilation-error-screen-columns) | ||
| 719 | grep-error-screen-columns) | ||
| 712 | (add-hook 'compilation-filter-hook 'grep-filter nil t)) | 720 | (add-hook 'compilation-filter-hook 'grep-filter nil t)) |
| 713 | 721 | ||
| 714 | 722 | ||