C'est ce que la mémoire tampon ressemble lorsque je manette rgrep code>. J'aimerais juste voir mes résultats - toutes les autres informations ne me disent pas de sens.
-*- mode: grep; default-directory: "~/.emacs/" -*-
Grep started at Sat Jan 20 12:42:21
grep --exclude=.\#\* --exclude=\*.o --exclude=\*\~ --exclude=\*.bin --exclude=\*.lbin --exclude=\*.so --exclude=\*.a --exclude=\*.ln --exclude=\*.blg --exclude=\*.bbl --exclude=\*.elc --exclude=\*.lof --exclude=\*.glo --exclude=\*.idx --exclude=\*.lot --exclude=\*.fmt --exclude=\*.tfm --exclude=\*.class --exclude=\*.fas --exclude=\*.lib --exclude=\*.mem --exclude=\*.x86f --exclude=\*.sparcf --exclude=\*.dfsl --exclude=\*.pfsl --exclude=\*.d64fsl --exclude=\*.p64fsl --exclude=\*.lx64fsl --exclude=\*.lx32fsl --exclude=\*.dx64fsl --exclude=\*.dx32fsl --exclude=\*.fx64fsl --exclude=\*.fx32fsl --exclude=\*.sx64fsl --exclude=\*.sx32fsl --exclude=\*.wx64fsl --exclude=\*.wx32fsl --exclude=\*.fasl --exclude=\*.ufsl --exclude=\*.fsl --exclude=\*.dxl --exclude=\*.lo --exclude=\*.la --exclude=\*.gmo --exclude=\*.mo --exclude=\*.toc --exclude=\*.aux --exclude=\*.cp --exclude=\*.fn --exclude=\*.ky --exclude=\*.pg --exclude=\*.tp --exclude=\*.vr --exclude=\*.cps --exclude=\*.fns --exclude=\*.kys --exclude=\*.pgs --exclude=\*.tps --exclude=\*.vrs --exclude=\*.pyc --exclude=\*.pyo -i -nH -e grep *.el
init.el:236:(global-set-key (kbd "s-f") 'rgrep)
init.el:237:(global-set-key (kbd "C-f") 'lgrep)
Grep finished (matches found) at Sat Jan 20 12:42:21
3 Réponses :
L'insert d'en-tête est enterré dans un appel à Vous pouvez ensuite élargir pour révéler ces lignes avec CX KBD> N kbd> w kbd>. p> Si vous souhaitez également conseiller Compilation-Démarrage Code> au-delà de
rgrep code>. Il n'y a pas de moyen simple de conserver ces fonctions d'insertion de l'en-tête. Mais vous pouvez facilement masquer facilement les quatre premières lignes du tampon en définissant des conseils.
lgrep code>,
grep-trouver code> et
zrgrep CODE>, vous pouvez remplacer les macros code> défadvice ci-dessus avec un conseil programmatique comme celui-ci: p>
Je suis très tard à cette fête, mais merci une tonne pour cette réponse!
Une petite addition Réponse de Michael Hoffman: Nous pouvons ajouter un petit bouton au tampon Grep pour basculer le texte masqué:
(defmacro with-grep-buffer-writable (&rest body) `(save-excursion (with-current-buffer grep-last-buffer (setq buffer-read-only nil) ,@body (setq buffer-read-only t)))) (defun hide-grep-header (&rest ignored) "Hides (by narrowing) the first few lines of a grep buffer leaving only the results. Additionally, a button is created to toggle the lines." (with-grep-buffer-writable ;;HACK: If we (goto-line 5), the button is inserted *after* the results. (goto-line 4) (end-of-line) (insert "\n") (narrow-to-region (point) (point-max)) (insert-text-button "(...)" 'help-echo "Toggle display of grep invocation" 'action #'click-show-grep-button))) (defun click-hide-grep-button (button) (with-grep-buffer-writable (button-put button 'action #'click-show-grep-button) (narrow-to-region (button-start button) (point-max)))) (defun click-show-grep-button (button) (with-grep-buffer-writable (button-put button 'action #'click-hide-grep-button) (widen)) ; HACK: goto-line won't have any effect because of save-excursion (with-current-buffer grep-last-buffer (goto-line 1))) (advice-add 'grep :after #'hide-grep-header) (advice-add 'rgrep :after #'hide-grep-header)
(defun my/grep-fix () (save-excursion (let ((inhibit-read-only t)) (goto-line 4) (kill-whole-line)))) (add-hook 'grep-setup-hook 'my/grep-fix) This solution: works well with next-error (i.e., it doesn't skip the first match); preserves the header containing the root directory; works seamlessly in all the grep variants.
Alternativement,
(défunt My-Grep-Mode-Crochet () (SETQ Truncate-lignes T)) Code>
(Ajout crochet 'Mode-Mode-Hook' My-Grep-Mode-Crochet) code> qui garantit l'en-tête (et d'autres lignes) n'engage pas, ce qui le rend beaucoup moins immobilisé. Vous pouvez appeler
toggle-truncate-lignes code> si vous voulez toujours voir les lignes enveloppées, mais je n'ai rarement jamais besoin de le faire, alors j'ai trouvé cette approche assez agréable.