window-buffer returns the buffer currently displayed by a given window.
get-buffer-window, on the contrary, returns a window currently displaying the given buffer (or nil if there is no such window; play with the optional 2nd argument to tell it how to behave in cases where you have multiple frames).
With these two ingredients, you should be able to ...
You can use selected-frame and selected-window to get the current frame and window. Also see the focus-in-hook an focus-out-hook hooks (new in Emacs 24.4) if you want to take some action when a frame gains or loses focus.
Customize the variable help-window-select:
"Non-nil means select help window for viewing.
never (nil) Select help window only if there is no other window
on its frame.
other Select help window unless the selected window is the
only other window on the help window's frame.
always (t) Always select the help ...
You can replace the command list-buffers which is run with C-x C-b to a function that does what you want. In this case buffer-menu-other-window opens the buffers list in another window with focus. Adding the following snippet to your init file should remap C-x C-b to the new function.
(define-key global-map [remap list-buffers] 'buffer-menu-other-window)
An alternative is to switch to ibuffer, which does not share this problem.
ibuffer is part of GNU Emacs, so on recent versions of Emacs you should just need to add
(global-set-key (kbd "C-x C-b") 'ibuffer)
to your init file.
What I need is:
C-x n s (org-narrow-to-subtree)
Narrow buffer to current subtree.
To widen the buffer again, use C-x n w
P.S. I was googling using a wrong word: "hide" instead of "narrow" :)
I've implemented this for hl-line-mode using the buffer-list-update-hook.
Here's the code:
"Inactive variant of `hl-line'."
(defun hl-line-update-face (window)
"Update the `hl-line' face in WINDOW to indicate whether the window is selected."
(with-current-buffer (window-buffer window)
See if auto-dim-other-buffers-mode works for you.
Out of the box it dims frames when they lose focus as well as buffers when they lose current-buffer status.
It's available on MELPA. Source here:
Assuming that are you using the GUI frame, basically you just need pass -e '(x-focus-frame nil)' as argument of emacsclient.
In that case: emacsclient -n -e '(x-focus-frame nil)' filepath
EDIT by OP:
(You may need to use: emacsclient -n -e "(progn (x-focus-frame nil) (find-file \"filepath\"))" —— See documentation for emacsclient's -e ...
Sure. See function doremi-increment-color in library doremi-frm.el.
In this case, you want to use a negative INCREMENT argument and specify s (for saturation) as the COMPONENT argument to increment (decrement, in this case).
You would call doremi-increment-color on any color of any UI feature you like (or on all of them), to calculate a less saturated ...
Here is how to solve the problem. The problem you describe has two parts, really. One part is to change focus (like you describe), so the "q" is sent to the Help window. The second part is to get back to your original window.
I solved the issue by forcing the Help window to pop up over top of my current window, so that I can just type "q" to dispatch the ...
Displaying the source line in the middle of the window is the default behaviour, so something in your own config has caused your problem.
The variable C-hv next-error-recenter usually determines where the line is positioned. A value of -1 will place it at the bottom of the window (which may be the cause of your problem); a value of 0 at the top; nil means "...
I prefer to select a window in a particular direction -- that way, I don't have to "cycle" through too many windows. That being said, here is a repost from Emacs wiki -- "The following command returns the focus to the minibuffer, no matter which window is currently selected.": https://www.emacswiki.org/emacs/MiniBuffer#minibuffer
Gnu Emacs has the function other-window which is bound to C-x o.
The relevant section from the doc string of other-window:
(other-window COUNT &optional ALL-FRAMES)
Select another window in cyclic ordering of windows.
COUNT specifies the number of windows to skip, starting with the
selected window, before making the selection. If COUNT ...
You can use Crosshairs Highlighting (crosshairs.el) to highlight point using crosshairs.
Command crosshairs does this (there are other, related commands).
But if you want to have crosshairs show up automatically when you switch window-manager focus from another application to an Emacs frame then you might have to jump through some hoops.
To have ...
You can automatically have the *Help* window be selected when it is displayed, by customizing option help-window-select.
help-window-select is a variable defined in help.el.
Its value is t
Original value was nil
Non-nil means select help window for viewing.
never (nil) -- Select help window only if ...
In both Linux and Windows a separate program must be invoked after emacsclient (if it succeeds) to find and elevate the frame window. This is pretty simple in Linux because most of the work can be done by wmctrl, a general-purpose X window control program. This is not included in the Ubuntu distro but is listed in the repository, making installation easy (...
So the sequencing is a bit tricky as mentioned in the comment below, but reselecting the previous window seems like the easiest way:
(defun my-debug-hook ()
;; Selecting the window in `debug-mode-hook' is too early, it will
;; confuse the debugger's code, causing it to replace the current
;; buffer contents with the backtrace, and reset `buffer-undo-...
I use xdotool to shift focus back to Emacs after Tex-command-run-all. Works on an X system (Linux/Unix) with xdotool installed. I use Okular as pdf-viewer and the following settings:
(setq TeX-view-program-selection '((output-pdf "Okular")))
'(("Okular" "emacswinno=`xdotool getwindowfocus` \; okular --unique %o\#src:%n`pwd`/./%...
I have found that somehow running the following applescript in my script works (I have to give assistive access to IntelliJ, which is no problem):
osascript -e 'tell application "System Events" to click UI element "Emacs" of list 1 of application process "Dock"'
I recently faced the same problem. Searching around, I found centered-cursor-mode. It does not solve the problem directly, but by enabling it when looking at search results, I solved the problem well enough for my needs. Perhaps it will work for you as well.
Start from emacs -q, switch to the *scratch* buffer, copy and paste the example below to the *scratch* buffer, place the cursor immediately following the last closing parenthesis, and press: C-x C-e (aka eval-last-sexp). Then type M-x my-example
STEP BY STEP:
Step #1: Create or retrieve the process buffer (in this example we use run-python).
What @abo-abo says is almost enough to do what you want (since you explicitly ask not only that the frame be shown on top but also that it be focused).
What it leaves out is that raising a frame does not necessarily focus it (select it for input focus). The behavior can depend on your window manager.
On MS Windows, you can set or bind variable w32-grab-...
Different answer based on your edit.
If you just want to change the mode line, check out what the Emacs manual has to say about mode-line-inactive face.
Like mode-line, but used for mode lines of the windows other than the selected one (if mode-line-in-non-selected-windows is non-nil). This face inherits from mode-line, so changes in that face affect ...