Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 619601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:40:24+00:00 2026-05-13T18:40:24+00:00

When I use grep – find it opens another window (area in the frame)

  • 0

When I use grep–find it opens another window (area in the frame) with a list of results that I can select. When I select one it opens the target file in a different window than grep–find is in.

How can I get the target file to open in the same window as the grep results (replacing the grep results window with what I am actually looking for).

How can I keep grep-find from opening a separate window (have it so it opens in the current window). My goal is I look for something, I find it, I go to it, all within the same window. I would like to add this to my .emacs file.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T18:40:24+00:00Added an answer on May 13, 2026 at 6:40 pm

    It doesn’t look like there is any way to configure the compile package to do what you’re asking. And there’s no easy way to use advice to tweak the behavior. I think you have to resort to editing the function which actually jumps to the error, which you can do with the following addition to your .emacs (tested in Emacs 23.1):

    (eval-after-load "compile"
    '(defun compilation-goto-locus (msg mk end-mk)
      "Jump to an error corresponding to MSG at MK.
    All arguments are markers.  If END-MK is non-nil, mark is set there
    and overlay is highlighted between MK and END-MK."
      ;; Show compilation buffer in other window, scrolled to this error.
      (let* ((from-compilation-buffer (eq (window-buffer (selected-window))
                      (marker-buffer msg)))
         ;; Use an existing window if it is in a visible frame.
         (pre-existing (get-buffer-window (marker-buffer msg) 0))
         (w (if (and from-compilation-buffer pre-existing)
            ;; Calling display-buffer here may end up (partly) hiding
            ;; the error location if the two buffers are in two
            ;; different frames.  So don't do it if it's not necessary.
            pre-existing
          (let ((display-buffer-reuse-frames t)
            (pop-up-windows t))
            ;; Pop up a window.
            (display-buffer (marker-buffer msg)))))
         (highlight-regexp (with-current-buffer (marker-buffer msg)
                 ;; also do this while we change buffer
                 (compilation-set-window w msg)
                 compilation-highlight-regexp)))
    ;; Ideally, the window-size should be passed to `display-buffer' (via
    ;; something like special-display-buffer) so it's only used when
    ;; creating a new window.
    (unless pre-existing (compilation-set-window-height w))
    
    (switch-to-buffer (marker-buffer mk))
    
        ;; was
    ;; (if from-compilation-buffer
    ;;     ;; If the compilation buffer window was selected,
    ;;     ;; keep the compilation buffer in this window;
    ;;     ;; display the source in another window.
    ;;     (let ((pop-up-windows t))
    ;;       (pop-to-buffer (marker-buffer mk) 'other-window))
    ;;   (if (window-dedicated-p (selected-window))
    ;;       (pop-to-buffer (marker-buffer mk))
    ;;     (switch-to-buffer (marker-buffer mk))))
    ;; If narrowing gets in the way of going to the right place, widen.
    (unless (eq (goto-char mk) (point))
      (widen)
      (goto-char mk))
    (if end-mk
        (push-mark end-mk t)
      (if mark-active (setq mark-active)))
    ;; If hideshow got in the way of
    ;; seeing the right place, open permanently.
    (dolist (ov (overlays-at (point)))
      (when (eq 'hs (overlay-get ov 'invisible))
        (delete-overlay ov)
        (goto-char mk)))
    
    (when highlight-regexp
      (if (timerp next-error-highlight-timer)
          (cancel-timer next-error-highlight-timer))
      (unless compilation-highlight-overlay
        (setq compilation-highlight-overlay
          (make-overlay (point-min) (point-min)))
        (overlay-put compilation-highlight-overlay 'face 'next-error))
      (with-current-buffer (marker-buffer mk)
        (save-excursion
          (if end-mk (goto-char end-mk) (end-of-line))
          (let ((end (point)))
        (if mk (goto-char mk) (beginning-of-line))
        (if (and (stringp highlight-regexp)
             (re-search-forward highlight-regexp end t))
            (progn
              (goto-char (match-beginning 0))
              (move-overlay compilation-highlight-overlay
                    (match-beginning 0) (match-end 0)
                    (current-buffer)))
          (move-overlay compilation-highlight-overlay
                (point) end (current-buffer)))
        (if (or (eq next-error-highlight t)
            (numberp next-error-highlight))
            ;; We want highlighting: delete overlay on next input.
            (add-hook 'pre-command-hook
                  'compilation-goto-locus-delete-o)
          ;; We don't want highlighting: delete overlay now.
          (delete-overlay compilation-highlight-overlay))
        ;; We want highlighting for a limited time:
        ;; set up a timer to delete it.
        (when (numberp next-error-highlight)
          (setq next-error-highlight-timer
            (run-at-time next-error-highlight nil
                     'compilation-goto-locus-delete-o)))))))
    (when (and (eq next-error-highlight 'fringe-arrow))
      ;; We want a fringe arrow (instead of highlighting).
      (setq next-error-overlay-arrow-position
        (copy-marker (line-beginning-position)))))))
    

    The eval-afer-load portion just ensures that you re-define it after Emacs defined it, so that your change takes hold.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 352k
  • Answers 352k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Do you just want everything after the last backslash (the… May 14, 2026 at 7:35 am
  • Editorial Team
    Editorial Team added an answer First, unsigned short isn't guaranteed to be only 16 bits,… May 14, 2026 at 7:35 am
  • Editorial Team
    Editorial Team added an answer Don't know why highlightBrushKey is not so flexible. For a… May 14, 2026 at 7:35 am

Related Questions

When I use the command: find . | xargs grep '...' I get the
I'm trying to use a somewhat old DAQ, and had to jump through a
I find from reading perldoc perlvar, about a thousand lines in is help for
Possible cause for this error may be a previous installation of Oracle Application Server
Helvetica is available in one form or another on Windows, Mac OS X, and

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.