elisp - How to debug igrep in emacs -


i have highly customized igrep.el special purpose. search works fine :

grep exited abnormally code 1 @ wed feb  5 18:18:09 

at end. how go debugging code? how find out part modified causing problem? never debugged in emacs before.

my second question, there way "highlight" token igrepping in igrep window?

i trying iqbal's solution incorporating highlight inside grep comand so:

;;;###autoload (defun igrep (program regex files &optional options)   (interactive    (igrep-read-args))   (if (null program)       (setq program (or igrep-program "grep")))   (if (null options)       (setq options igrep-options))   (if (not (listp files))       ; (stringp files)       (setq files (list files)))   (if (and (member ?~ (mapcar 'string-to-char files))        (save-match-data          (string-match "\\`[rj]?sh\\(\\.exe\\)?\\'"                (file-name-nondirectory shell-file-name))))       ;; (restricted, job-control, or standard) bourne shell doesn't expand ~:       (setq files         (mapcar 'expand-file-name files)))   (let* ((use-zgrep (cond ((eq igrep-use-zgrep t))               (igrep-use-zgrep                (let ((files files)                  (compressed-p nil))                  (while (and files (not compressed-p))                    (if (save-match-data                      (string-match "\\.g?[zz]\\'" (car files)))                    (setq compressed-p t))                    (setq files (cdr files)))                  compressed-p))               (t nil)))      (command (format "%s -n %s %s %s %s %s"               (if (and use-zgrep                    (save-match-data                      (not (string-match "\\`z" program))))                   (setq program (concat "z" program))                 program)               (or options                   (and igrep-case-fold-search                    (equal regex (downcase regex))                    "-i")                     ;                 "")                   "-i") ;; r-modified - default ignore case               (or igrep-regex-option                   (progn                 (if (save-match-data                       (string-match "\\`-" regex))                     (setq regex (concat "\\" regex)))                 ""))               (shell-quote-argument regex)               (if igrep-find                   (if igrep-find-use-xargs                   ""                 (shell-quote-argument "{}"))                 (mapconcat (lambda (file)                      (let ((dir (file-name-directory file)))                        (if dir                            (expand-file-name                         (file-name-nondirectory file)                         (igrep-quote-file-name dir))                          file)))                        files " "))               igrep-null-device)))     (if igrep-find     (setq command           (igrep-format-find-command command files)))     (cond ((eq igrep-save-buffers t) (save-some-buffers t))       (igrep-save-buffers (save-some-buffers)))     (if (fboundp 'compilation-start)    ; emacs 22         (let ((compilation-process-setup-function 'grep-process-setup))           (or (fboundp 'igrep-mode)               (define-derived-mode igrep-mode grep-mode "igrep"))           (compilation-start command                ; 'igrep-mode                              'grep-mode ;;modified                              nil                              (cond ((eq compilation-highlight-regexp t))                                    (compilation-highlight-regexp                                     (if (eq program "fgrep")                                         (regexp-quote regex)                                       regex)))))       (compile-internal command (format "no more %s matches" program)                         "igrep" nil grep-regexp-alist)))    (with-current-buffer "*grep*"     ;; remove previous highlights     (dolist (pattern hi-lock-interactive-patterns)       (unhighlight-regexp (car pattern)))     ;; highlight current regex     (highlight-regexp regex))  ) 

ideally setting grep-highlight-matches non-nil should have highlighted matches in grep buffer. documentation says uses --color option getting color information matches , (in comments) grep command on os not support --color option, explains why matches not highlighted in grep buffer.

we can still highlighting in grep buffer wrapping igrep command in custom function , using drew adam's excellent highlight.el package highlight matches, following example of such function

;; download highlight.el [http://www.emacswiki.org/emacs-en/download/highlight.el] ;; , add load-path (require 'highlight)  (defface my-grep-highlight `((t :background "blue" :foreground "white")) "face highlight grep matches with")  ;; can make buffer local in *igrep* buffer, lazy (defvar my-igrep-regex nil "global var storing value of last grep pattern")  ;; wrapper around igrep, reads arguments, sets hooks ;; highlighting matches calls igrep read arguments (defun my-igrep (program regex files &optional options)   (interactive    (igrep-read-args))   ;; set current regexp   (setq my-igrep-regex regex)   ;; my-grep-highlight-setup sets compilation-filter-hook calls   ;; whenever inserts line in *igrep* buffer   ;; gives chance hightlight matches   (let ((grep-setup-hook (cons 'my-grep-highlight-setup grep-setup-hook)))     ;; call `igrep'     (igrep program regex files options)))  (defun my-grep-highlight-setup ()   ;; setup hook called every time line   ;; inserted in *igrep* buffer   (add-hook 'compilation-filter-hook 'my-highlight-regexp t t))  (defun my-highlight-regexp ()   ;; compilation-filter-start bound start of inserted line   (goto-char compilation-filter-start)   ;; highlight start of line end, assumes lines   ;; output grep of format <filename>:<line_no>:matches   ;; lot drew adams awesome function, allows   ;; highlight group of given regexp   (hlt-highlight-regexp-to-end (format ":[0-9]+:.*\\(%s\\)" my-igrep-regex)                                'my-grep-highlight nil  nil 1)) 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -