Maximize Emacs Windows Horizonatally or Vertically - emacs

I'm aware of C-x 1, which will maxamize the current window both horizontally and vertically.
However, my quesiton is, is it possible to expand the current window to the edge of the frame on one direction only?
So in the below I want to expand window A to the right border of the frame, taking up the space currently occupied by B and C. But I want D and E to remain untouched.... and I want to do it in a single command.
Excuse the terrible attempt at ASCII art!
_______________________
| AAAAAA |BBBBBB |CCCC |
|________|_______|______|
| DDDDD | EEEEEEEEEE |
|________|______________|
I know you can move horizontally 1 char at a time, and that you can use the repeat n times command to do this many times, but both are clunky, when what I really want to say is expand until the right hand border, I don't care how far that is.
The nearest I've come up with this to go to each frame occupying the space you want and calling C-X 0, but this is still a bit clunky.
I need this to work in terminal mode (emacs -nw) rather than graphical/X-Windows mode.
Any ideas?

You can do this with library frame-cmds.el (description).
It provides these commands:
maximize-frame-horizontally, maximize-frame-vertically, and max-frame
restore-frame-horizontally, restore-frame-vertically, and restore-frame
The "restore" commands are actually toggles that alternate between maximizing and restoring. (They are aliased to commands toggle-max-frame*.)
Commands maximize-frame and restore-frame are general, and can act like the horizontal and vertical commands by giving them a prefix arg: negative for horizontally, non-negative for vertically.

I have the same problem: I would like to maximize a window horizontally but not vertically. After searching on the internet with no avail, I decided to write my own function. And I would like to share it here in case it might help someone in the future.
(require 'cl-lib)
(defun durand-maximize-window-horizontally (&optional window)
"Make WINDOW have the same width as the frame.
WINDOW defaults to the selected window.
Other windows are retained, but moved to the top."
(let* ((window (or window (selected-window)))
;; the list of windows to the left
(left-windows-list (let ((temp-window window)
window-list)
(cl-loop while (window-in-direction
'left temp-window t)
do (let ((left-win
(window-in-direction
'left temp-window t)))
(push left-win window-list)
(setf temp-window left-win)))
window-list))
;; the list of windows to the right
(right-windows-list (let ((temp-window window)
window-list)
(cl-loop while (window-in-direction
'right temp-window t)
do (let ((right-win
(window-in-direction
'right temp-window t)))
(setf window-list
(append window-list
(list right-win)))
(setf temp-window right-win)))
window-list))
;; the list of windows to the left and to the right
;; the order is from left to the right.
(same-level-list (append left-windows-list right-windows-list))
;; save all parameters: the car is the buffer, and the cadr is a list
;; of parameters.
(window-parameters-list
(cl-loop for win in same-level-list
collect (list (window-buffer win)
;; (window-width win)
(window-parameters win)))))
(cl-loop for win in same-level-list
do (delete-window win))
;; now our window is the only window horizontally speaking.
;; now we shall create them once again, if they exist.
(when same-level-list
(let* ((split-base-window
(split-window window nil 'above))
(new-windows (list split-base-window))
newly-created-window)
(cl-loop
for ind from 1 to (1- (length same-level-list))
do
(setf newly-created-window
(split-window split-base-window
nil 'right)
;; NOTE: it is important this list also follows the order
;; of going from the left to the right
new-windows (append new-windows
(list newly-created-window))
split-base-window newly-created-window))
(cl-loop for index from 0 to (1- (length same-level-list))
do
(let ((buf (car (nth index window-parameters-list)))
(paras (cadr (nth index window-parameters-list))))
(set-window-buffer
(nth index new-windows) buf)
(cl-loop for para-pair in paras
do (set-window-parameter
(nth index new-windows)
(car para-pair)
(cdr para-pair)))))))))

Related

How to automatically add / remove scroll-bars as needed by text height

Many commercial word processors have a default behavior that automatically hides the vertical scroll bars when the lines of text in the document are less than the visible window; and, the scroll bars appear automatically when the lines of text in the document are greater than the visible window. Emacs is missing that ability and I'd like that to be the default behavior in a variety of different modes.
Does anyone have some ideas how to automatically remove or add the scroll-bars on the fly as the size (lines of text) of the document increases or decreases?
I was thinking of perhaps weaving it into the the functions for line numbers using a prior sample by #phils in a related thread:  https://stackoverflow.com/a/10593165/2112489
I'd like it work even when I'm not using linum-mode. However, I don't think the scroll-bar function should run after every single command -- it should run only when a new line is added or subtracted, taking into consideration visual-line-mode (i.e., wrapping being active) potentially being active.
The following snippet was inspired by a previous answer from #abo-abo in a related thread: https://stackoverflow.com/a/20923695/2112489
(cond
((not (> (count-lines (point-min) (point-max)) (window-height)))
(set-window-scroll-bars (get-buffer-window (buffer-name) (selected-frame)) 0 nil))
((and
(> (count-lines (point-min) (point-max)) (window-height))
(not (equal (window-scroll-bars) `(15 2 t nil))))
(set-window-scroll-bars (get-buffer-window (buffer-name) (selected-frame)) 15 'right)))
EDIT (January 17, 2014):  Working draft based upon the helpful answer to this thread by #Drew.
EDIT (January 19, 2014):  Added a function to count each word-wrapped line using vertical-motion. Setting the initial-frame-default seems to be read by Emacs after the initial frame is created, so the scroll bars are visible for a split second -- to avoid seeing this, modifying the frame parameters of the initial frame seems to fix this visual issue. Now using window-text-height instead of window-height -- The returned height does not include dividers, the mode line, any header line, nor any partial-height lines at the bottom of the text area. Copied the method used by linum-mode in terms of using -- the post-command-hook, the change-major-mode-hook, and the window-configuration-change-hook). Added window-live-p condition to avoid post-command-hook errors when starting Emacs while various buffers are loading out of sight. Added condition to deal with narrow-to-region -- still unsure why that situation causes Emacs to freeze in a loop or something -- the workaround is needed for now. The latest version of Emacs Trunk from January 19, 2014 appears to fix visual display issues experienced in prior versions -- as such, redraw-frame is no longer necessary. Added (redisplay t) to the function count-vertical-lines, which speeds up displaying the new buffer when switching buffers. Added regexp for buffers that will always have scroll bars or never have scroll bars.
EDIT (January 20, 2014):  Added just one main condition that there be a live window, and removed the same conditions from the various branches of the lawlist-scroll-bar function. Added additional condition for a narrow-to-region situation such that removing the scroll bars only need occur if scroll bars were present prior to narrowing.
EDIT (January 21, 2014):  With this revision, it is no longer necessary to count lines (which causes a slow-down in large buffers). The new method is a much simpler mathematical calculation based on four (4) points that are determined in a mere fraction of a second -- i.e., point-min, point-max, window-start and window-end. If point-min moves off the screen, scroll bars are added -- I think this behavior makes sense -- although, I did stop to ponder whether the scroll-bar should also serve as a visual representation of whether the characters within the parameters of point-min to point-max could actually fit into the window regardless of whether point-min had moved beyond the window. None of the hooks in this example are able to deal with a display-buffer situation (targeting the same window of the same frame that both already have focus) -- so, I created my own display-buffer-hook (which is beyond the scope of this example).
;;;;;;;;;;;;;;;;;;;;;;;;;; LAWLIST SCROLL BAR MODE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar regexp-always-scroll-bar '("\\.yes" "\\*Scroll-Bar\\*")
"Regexp matching buffer names that will always have scroll bars.")
(defvar regexp-never-scroll-bar '("\\.off" "\\.not")
"Regexp matching buffer names that will never have scroll bars.")
(add-to-list 'default-frame-alist '(vertical-scroll-bars . nil))
(modify-all-frames-parameters (list (cons 'vertical-scroll-bars nil)))
(defun lawlist-scroll-bar ()
(when (window-live-p (get-buffer-window (current-buffer)))
(redisplay t)
(cond
;; not regexp matches | not narrow-to-region
((and
(not (regexp-match-p regexp-always-scroll-bar (buffer-name)))
(not (regexp-match-p regexp-never-scroll-bar (buffer-name)))
(equal (- (point-max) (point-min)) (buffer-size)))
(cond
;; Lines of text are less-than or equal-to window height,
;; and scroll bars are present (which need to be removed).
((and
(<= (- (point-max) (point-min)) (- (window-end) (window-start)))
(equal (window-scroll-bars) `(15 2 right nil)))
(set-window-scroll-bars (selected-window) 0 'right nil))
;; Lines of text are greater-than window height, and
;; scroll bars are not present and need to be added.
((and
(> (- (point-max) (point-min)) (- (window-end) (window-start)))
(not (equal (window-scroll-bars) `(15 2 right nil))))
(set-window-scroll-bars (selected-window) 15 'right nil))))
;; Narrow-to-region is active, and scroll bars are present
;; (which need to be removed).
((and
(not (equal (- (point-max) (point-min)) (buffer-size)))
(equal (window-scroll-bars) `(15 2 right nil)))
(set-window-scroll-bars (selected-window) 0 'right nil))
;; not narrow-to-region | regexp always scroll-bars
((and
(equal (- (point-max) (point-min)) (buffer-size))
(regexp-match-p regexp-always-scroll-bar (buffer-name)))
(set-window-scroll-bars (selected-window) 15 'right nil))
;; not narrow-to-region | regexp never scroll-bars
((and
(equal (- (point-max) (point-min)) (buffer-size))
(regexp-match-p regexp-never-scroll-bar (buffer-name)))
(set-window-scroll-bars (selected-window) 0 'right nil)))))
(define-minor-mode lawlist-scroll-bar-mode
"This is a custom scroll bar mode."
:lighter " sc"
(if lawlist-scroll-bar-mode
(progn
(add-hook 'post-command-hook 'lawlist-scroll-bar nil t)
;; (add-hook 'change-major-mode-hook 'lawlist-scroll-bar nil t)
;; (add-hook 'window-configuration-change-hook 'lawlist-scroll-bar nil t)
)
(remove-hook 'post-command-hook 'lawlist-scroll-bar t)
(remove-hook 'change-major-mode-hook 'lawlist-scroll-bar t)
(remove-hook 'window-configuration-change-hook 'lawlist-scroll-bar t)))
(define-globalized-minor-mode global-lawlist-scroll-bar-mode
lawlist-scroll-bar-mode lawlist-scroll-bar-on)
(defun lawlist-scroll-bar-on ()
(unless (minibufferp)
(lawlist-scroll-bar-mode 1)))
(global-lawlist-scroll-bar-mode)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Supporting regexp function:
;; https://github.com/kentaro/auto-save-buffers-enhanced
;; `regexp-match-p` function modified by #sds on stackoverflow
;; https://stackoverflow.com/questions/20343048/distinguishing-files-with-extensions-from-hidden-files-and-no-extensions
(defun regexp-match-p (regexps string)
(and string
(catch 'matched
(let ((inhibit-changing-match-data t)) ; small optimization
(dolist (regexp regexps)
(when (string-match regexp string)
(throw 'matched t)))))))
If you just want to toggle scroll bars on/off interactively, or on a hook, or from your code, then scroll-bar-mode should be all you need.
You can also use menu-bar-no-scroll-bar, menu-bar-left-scroll-bar, and menu-bar-right-scroll-bar. Or just do what each of those commands does: (customize-set-variable 'scroll-bar-mode WHATEVER). Or use set-scroll-bar-mode or set-window-scroll-bars, similarly. It depends on what behavior you are looking for.
I recommend M-x apropos scroll-bar. (Or if you use Icicles, just C-h f scroll-bar S-TAB, then repeat C-M-down...)
You can add it to mode-line-position, so that update of the mode line automatically triggers turning scroll bars on/off. This pretty much works, for instance:
(setq-default
mode-line-position
'(:eval
(progn
(if (> (count-lines (point-min) (point-max)) (window-height))
(set-window-scroll-bars nil 20 t)
(set-window-scroll-bars nil 0 t))
`((-3 ,(propertize
"%p"
'local-map mode-line-column-line-number-mode-map
'mouse-face 'mode-line-highlight
'help-echo "Buffer position, mouse-1: Line/col menu"))
(line-number-mode
((column-number-mode
(10 ,(propertize
" (%l,%c)"
'face (and (> (current-column)
modelinepos-column-limit)
'modelinepos-column-warning)
'local-map mode-line-column-line-number-mode-map
'mouse-face 'mode-line-highlight
'help-echo "Line and column, mouse-1: Line/col menu"))
(6 ,(propertize
" L%l"
'local-map mode-line-column-line-number-mode-map
'mouse-face 'mode-line-highlight
'help-echo "Line number, mouse-1: Line/col menu"))))
((column-number-mode
(5 ,(propertize
" C%c"
'face (and (> (current-column)
modelinepos-column-limit)
'modelinepos-column-warning)
'local-map mode-line-column-line-number-mode-map
'mouse-face 'mode-line-highlight
'help-echo "Column number, mouse-1: Line/col menu")))))))))
You can alternatively use the following, which employs Stefan's suggestion
to make it work better with scaled text, visual-line-mode, images, etc. However, in that case, scroll bars kick in whenever some text is outside the window because of scrolling, regardless of whether that text would fit in the window. Whether that is a feature or not is for you to decide. ;-)
(setq-default
mode-line-position
'(:eval
(let ((scroll-bars (nth 2 (window-scroll-bars))))
(if (or (> (point-max) (window-end)) (< (point-min) (window-start)))
(unless scroll-bars (set-window-scroll-bars nil 20 t))
(when scroll-bars (set-window-scroll-bars nil 0 t)))
(unless (equal scroll-bars (nth 2 (window-scroll-bars))) (redraw-frame))
`((-3 ,(propertize
"%p"
'local-map mode-line-column-line-number-mode-map
'mouse-face 'mode-line-highlight
'help-echo "Buffer position, mouse-1: Line/col menu"))
(line-number-mode
((column-number-mode
(10 ,(propertize
" (%l,%c)"
'face (and (> (current-column)
modelinepos-column-limit)
'modelinepos-column-warning)
'local-map mode-line-column-line-number-mode-map
'mouse-face 'mode-line-highlight
'help-echo "Line and column, mouse-1: Line/col menu"))
(6 ,(propertize
" L%l"
'local-map mode-line-column-line-number-mode-map
'mouse-face 'mode-line-highlight
'help-echo "Line number, mouse-1: Line/col menu"))))
((column-number-mode
(5 ,(propertize
" C%c"
'face (and (> (current-column)
modelinepos-column-limit)
'modelinepos-column-warning)
'local-map mode-line-column-line-number-mode-map
'mouse-face 'mode-line-highlight
'help-echo "Column number, mouse-1: Line/col menu")))))))))
If you are used to using scroll bars only as visual indicator of where you are in the buffer (rather than looking at the modeline for that), you might like a package like yascroll. It uses the fringe for displaying the scroll bar, and it does not show it if lines of text in the document are less than the visible window, as you want.
Advantage is that there is no widgets taking up real state from your screen.
Disadvantage is that you cannot use the scroll bars with the mouse (some users never do that, anyways)

How to customize Emacs split-window-X with the new window showing the next buffer?

In Emacs 21.x I don't know if via a specific customization of split-window or due to a different default behaviour by Emacs, invoking the split-window-below besides splitting the window, it switched the buffer in the non-focused window to the next buffer.
Currently (Emacs 24.x), the split-window and siblings split-window-below and split-window-right don't seem to allow such a customization. Is this true?
If so, how to tweak Emacs to have this behaviour? Redefining split-window or split-window-below and split-window-right to have an extra step of switching to the next on the non-focused window. This could be done with advices:
(defun split-window-and-next-buffer (new-window)
(let ((old-window (selected-window)))
(select-window new-window)
(next-buffer)
(select-window old-window)
new-window))
(defadvice split-window-right (after split-window-right-and-next-buffer
activate protect compile)
(split-window-and-next-buffer ad-return-value))
(defadvice split-window-below (after split-window-bellow-and-next-buffer
activate protect compile)
(split-window-and-next-buffer ad-return-value))
With the corrections indicated by lawlist which are already available above the advices already work and I get the intended behaviour, but it isn't customizable to have the old behaviour.
In response to the question, the original poster might want try changing the spelling of the word below within the code posted.
This function adds three lines of code (at the end) to the current version of Emacs Trunk split-window-below and renames the function to lawlist-split-window-below with a defalias. One closing parentheses was moved to the end of the function to permit using two of the let bindings defined farther up in the function. If the user wants focus in the new-window (after exiting the function) instead, then just remove the last line of code (select-window old-window).
(defun lawlist-split-window-below (&optional size)
"Split the selected window into two windows, one above the other.
The selected window is above. The newly split-off window is
below, and displays the 'next-buffer'. Return the new window.
If optional argument SIZE is omitted or nil, both windows get the
same height, or close to it. If SIZE is positive, the upper
\(selected) window gets SIZE lines. If SIZE is negative, the
lower (new) window gets -SIZE lines.
If the variable `split-window-keep-point' is non-nil, both
windows get the same value of point as the selected window.
Otherwise, the window starts are chosen so as to minimize the
amount of redisplay; this is convenient on slow terminals."
(interactive "P")
(let ((old-window (selected-window))
(old-point (window-point))
(size (and size (prefix-numeric-value size)))
moved-by-window-height moved new-window bottom)
(when (and size (< size 0) (< (- size) window-min-height))
;; `split-window' would not signal an error here.
(error "Size of new window too small"))
(setq new-window (split-window nil size))
(unless split-window-keep-point
(with-current-buffer (window-buffer)
;; Use `save-excursion' around vertical movements below
;; (Bug#10971). Note: When the selected window's buffer has a
;; header line, up to two lines of the buffer may not show up
;; in the resulting configuration.
(save-excursion
(goto-char (window-start))
(setq moved (vertical-motion (window-height)))
(set-window-start new-window (point))
(when (> (point) (window-point new-window))
(set-window-point new-window (point)))
(when (= moved (window-height))
(setq moved-by-window-height t)
(vertical-motion -1))
(setq bottom (point)))
(and moved-by-window-height
(<= bottom (point))
(set-window-point old-window (1- bottom)))
(and moved-by-window-height
(<= (window-start new-window) old-point)
(set-window-point new-window old-point)
(select-window new-window)))
;; Always copy quit-restore parameter in interactive use.
(let ((quit-restore (window-parameter old-window 'quit-restore)))
(when quit-restore
(set-window-parameter new-window 'quit-restore quit-restore)))
new-window)
(select-window new-window)
(next-buffer)
(select-window old-window)))
(defalias 'split-window-below 'lawlist-split-window-below)

Wanderlust -- Open e-mail in new buffer, instead of split-window

Any ideas regarding how to configure Wanderlust to open emails in a new buffer, instead of a split window? There is just too much happening with four (4) windows -- summary message buffer; message buffer; big brother insidious database address manager; and the mini-buffer. (See the screenshot below.)
I think I've located the relevant portion of the code in wl-message.el, but I'm not sure what portion to change. (setq wl-message-window-size '(1 . 1)) in the init.el is not what I'm looking for, because I'd still have to share the screen with other buffers.
I'm spending a lot of time switching and closing windows to get a full size buffer, and I'm hoping to just eliminate multiple windows when checking my e-mail.
Thanks . . . any help would be greatly appreciated.
;;; wl-message.el -- Message buffer handling from summary buffer.
(defun wl-message-buffer-window ()
"Get message buffer window if any."
(let* ((start-win (selected-window))
(cur-win start-win))
(catch 'found
(while (progn
(setq cur-win (next-window cur-win))
(with-current-buffer (window-buffer cur-win)
(if (or (eq major-mode 'wl-message-mode)
(eq major-mode 'mime-view-mode))
(throw 'found cur-win)))
(not (eq cur-win start-win)))))))
(defun wl-message-select-buffer (buffer)
"Select BUFFER as a message buffer."
(let ((window (get-buffer-window buffer))
(sum (car wl-message-window-size))
(mes (cdr wl-message-window-size))
whi)
(when (and window
(not (eq (with-current-buffer (window-buffer window)
wl-message-buffer-cur-summary-buffer)
(current-buffer))))
(delete-window window)
(run-hooks 'wl-message-window-deleted-hook)
(setq window nil))
(if window
(select-window window)
(when wl-fixed-window-configuration
(delete-other-windows)
(and wl-stay-folder-window
(wl-summary-toggle-disp-folder)))
;; There's no buffer window. Search for message window and snatch it.
(if (setq window (wl-message-buffer-window))
(select-window window)
(setq whi (1- (window-height)))
(if mes
(progn
(let ((total (+ sum mes)))
(setq sum (max window-min-height (/ (* whi sum) total)))
(setq mes (max window-min-height (/ (* whi mes) total))))
(if (< whi (+ sum mes))
(enlarge-window (- (+ sum mes) whi)))))
(split-window (get-buffer-window (current-buffer)) sum)
(other-window 1)))
(switch-to-buffer buffer)))
(source: lawlist.com)
SOLUTION # 1:   The variable wl-message-buffer-name that is defined within wl-vars.el makes the message buffer uninteresting by virtue of the space at the beginning of the buffer name:    *WL:Message*. Inasmuch as Emacs hides uninteresting buffers by default, one solution is to modify the aforementioned variable by removing the space at the beginning of the buffer name. That way, the buffer is always visible and it is just a matter of switching to the window that displays the message and then delete-other-windows. The added advantage is that it is no longer necessary to return to the summary buffer to view an e-mail that has already been opened, since there is already an open buffer dedicated to said e-mail.
(defcustom wl-message-buffer-name "*WL:Message*" ;; " *WL:Message*"
"*Buffer name for message buffers."
:group 'wl-pref
:group 'wl-setting)
SOLUTION # 2: This second solution is no longer the preferred method and will most likely be removed entirely from this answer. The word search utility I was using could not comb the wl-vars.el file for some unknown reason, so this second solution was a workaround.
Edit the key map for wl-summary-read (inside wl-summary.el) and replace it with the function lawlist-wl-summary-read so that hitting the space bar activates said function. wl-summary-enter-handler remains defined as the enter key, which opens messages in the default manner.
(define-key wl-summary-mode-map " " 'lawlist-wl-summary-read)
(defun lawlist-wl-summary-read nil
"Clone the the buffer and make new buffer name unique."
(interactive)
(wl-summary-enter-handler)
(windmove-down)
(let ((n 0)
bufname)
(while (progn
(setq bufname (concat "email"
(if (= n 0) "" (int-to-string n))
"")) ;; could be an ending, like an asterick *
(setq n (1- n)) ;; if + instead of -, then no hyphen and no space between buffer name and the number
(get-buffer bufname)))
(clone-indirect-buffer bufname nil)
(switch-to-buffer bufname)
(delete-other-windows) ))

Looking forward a way to make cursor blinks like a heartbeat in Emacs

How can I make the cursor in Emacs blink like a heartbeat. Like the LED on the front panel of laptop when the computer is suspended.
There is variable blink-cursor-alist that control the blink of cursor, but I do not know how to use it to satisfy my requirement.
Is it possible?
This simple minor mode implements a heartbeat-style blinking cursor. You can tweak heartbeat-cursor-colors to get different hue or variations thereof.
The code is tested in Emacs 24.2.1, but would be easy to port to older Emacsen.
(require 'cl)
(require 'color)
(defvar heartbeat-fps 16)
(defvar heartbeat-period 5)
(defun heartbeat-range (from to cnt)
(let ((step (/ (- to from) (float cnt))))
(loop for i below cnt collect (+ from (* step i)))))
(defun heartbeat-cursor-colors ()
(let ((cnt (* heartbeat-period heartbeat-fps)))
(mapcar (lambda (r)
(color-rgb-to-hex r 0 0))
(nconc (heartbeat-range .2 1 (/ cnt 2))
(heartbeat-range 1 .2 (/ cnt 2))))))
(defvar heartbeat-cursor-timer nil)
(defvar heartbeat-cursor-old-color)
(define-minor-mode heartbeat-cursor-mode
"Change cursor color with the heartbeat effect."
nil "" nil
:global t
(when heartbeat-cursor-timer
(cancel-timer heartbeat-cursor-timer)
(setq heartbeat-cursor-timer nil)
(set-face-background 'cursor heartbeat-cursor-old-color))
(when heartbeat-cursor-mode
(setq heartbeat-cursor-old-color (face-background 'cursor)
heartbeat-cursor-timer
(run-with-timer
0 (/ 1 (float heartbeat-fps))
(lexical-let ((colors (heartbeat-cursor-colors)) tail)
(lambda ()
(setq tail (or (cdr tail) colors))
(set-face-background 'cursor (car tail))))))))
You guess that the option has something to do with the word "blink".
So you press C-h a (for apropos) and type "blink".
On my emacs, I get two options: blink-cursor-mode and blink-matching-open.
The first one looks right. The description says: "Toggle blinking cursor mode".
The shortcut on my emacs says: <menu-bar> <options> <blink-cursor-mode>.
So I guess that the option is somewhere in the menu, maybe under "options".
I open the Options menu, and there it is: "Blinking Cursor" with a tick box.
This also sounds like an option that can be customised.
So I type M-x customize-option and then blink-cursor-mode. This allows me to toggle the value and also save it for future sessions.
EDIT: To set the interval between ON and OFF for the cursor, there is a variable called blink-cursor-interval. You can use M-x customize-variable and then blink-cursor-interval to set the interval. The variable blink-cursor-alist matches an OFF state cursor type to the ON state cursor type, and is not related to the speed of blinking.
EDIT2: As far as I know there is no way to make the cursor gradually turn off and on, because the shape of the cursor for the ON state could be different to the shape in the OFF state (so a gradual change in shape will be required).

How to force Emacs not to display buffer in a specific window?

My windows configuration looks like this:
+----------+-----------+
| | |
| | |
| | |
| | |
| | |
| +-----------+
| | |
+----------+-----------+
And I use the lower right window for special displays (like help, completion etc.), but emacs insists on using that window when I call commands (find-file-other-window, etc.) that use display-buffer, and resize that window as well. It's annoying... Is there a way that I can force emacs NOT to use that windows? I was thinking of advising display-buffer, but it's a function in c. Any thoughts on this?
EDIT:
Based heavily on Trey's answer, this is what works for me so far:
(setq special-display-function 'my-display-buffer)
(setq special-display-regexps '(".*"))
(defun display-special-buffer (buf)
"put the special buffers in the right spot (bottom rigt)"
(let ((target-window (window-at (- (frame-width) 4) (- (frame-height) 4)))
(pop-up-windows t))
(set-window-buffer target-window buf)
target-window))
(defun my-display-buffer (buf)
"put all buffers in a window other than the one in the bottom right"
(message (buffer-name buf))
(if (member (buffer-name buf) special-display-buffer-names)
(display-special-buffer buf)
(progn
(let ((pop-up-windows t)
(windows (delete (window-at (- (frame-width) 4) (- (frame-height) 4))
(delete (minibuffer-window) (window-list)))))
(message (buffer-name (window-buffer (car windows))))
(set-window-buffer (car (cdr windows)) buf)
(car (cdr windows))))))
Well, someone already asked the same question for completion. And I wrote up an answer that seemed to work pretty well.
It looks like you could use that same solution, except instead of adding to special-display-buffer-names, you can use the variable special-display-regexps. So something along the lines of:
(add-to-list 'special-display-regexps '(".*" my-display-buffers))
(defun my-display-buffers (buf)
"put all buffers in a window other than the one in the bottom right"
(let ((windows (delete (window-at (- (frame-width) 2) (- (frame-height) 4))
(delete (minibuffer-window) (window-list))))
(if (<= 2 (length windows))
(progn
(select-window (cadr windows))
(split-window-vertically)))
(let ((pop-up-windows t))
(set-window-buffer (car windows) buf)
(car windows)))))
Obviously you'll have to modify the regexp to not match the *Help* and other buffers that you actually want in the lower right window.
Regarding advising display-buffer, that would work. You can advise functions written in c, advice works in pretty much every case you'd want except when functions are called from c, or advising macros (which doesn't work b/c the macros are generally already expanded everywhere they're used).
Perhaps something like this could work:
(defun display-buffer-avoiding-lr-corner (buffer &optional not-this-window)
(save-selected-window
(when (buffer-file-name buffer)
(select-window (window-at (- (frame-width) 1)
(- (frame-height) 2))))
(let ((display-buffer-function nil))
(display-buffer buffer not-this-window))))
(setq display-buffer-function 'display-buffer-avoiding-lr-corner)
I was thinking of advising display-buffer, but it's a function in c.
"display-buffer is an interactive Lisp function in `window.el'."
Also, you can advise C functions anyway.
Maybe it will make sense for you to make this lower right window dedicated by set-window-dedicated-p. Then this window will be ignored in operations like find-file-other-window as you want.