Hot answers tagged

24

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 ...


10

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) ...


7

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.


7

Customize the variable help-window-select: "Non-nil means select help window for viewing. Choices are: 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 ...


6

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 (from http://orgmode.org/manual/Structure-editing.html) P.S. I was googling using a wrong word: "hide" instead of "narrow" :)


6

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.


5

I've implemented this for hl-line-mode using the buffer-list-update-hook. Here's the code: (defface hl-line-inactive '((t nil)) "Inactive variant of `hl-line'." :group '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) (...


4

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: https://github.com/mina86/auto-dim-other-buffers.el


3

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 parameter.) I wrote ...


3

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 (defun switch-to-...


2

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 ...


1

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"'


1

Set magit-display-buffer-noselect to t to prevent magit-display-buffer from calling select-window.


1

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 "...


1

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.


1

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). [The ...


1

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 ...


1

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-...


1

This should work: (run-with-timer 3 nil (lambda () (select-frame-set-input-focus (new-frame))))


1

Forgot to use call-interactively on other-window. This seems to work better: (advice-add 'describe-mode :after '(lambda (&rest args) (call-interactively 'other-window)))


1

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 ...


Only top voted, non community-wiki answers of a minimum length are eligible