mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-30 04:10:54 -08:00
Fix some issues with `window-divider-mode'
* lisp/frame.el (window-divider-default-places): New option. (window-divider-mode): Remove option. (window-divider-mode): Make it a "regular" minor mode. (window-divider-width-valid-p): Drop frame- prefix. (window-divider-mode-apply): New argument ENABLE. Drop frame- prefix. Handle `window-divider-default-places'. (frame--window-divider-mode-set-and-apply): Remove. (window-divider-default-bottom-width) (window-divider-default-right-width): Drop :group entries. * lisp/menu-bar.el (menu-bar-bottom-and-right-window-divider) (menu-bar-right-window-divider, menu-bar-bottom-window-divider) (menu-bar-no-window-divider): Set `window-divider-default-places' and call `window-divider-mode'. * doc/emacs/frames.texi (Window Dividers): Document `window-divider-default-places'.
This commit is contained in:
parent
2b848fadd5
commit
e3c4cd0074
3 changed files with 71 additions and 78 deletions
|
|
@ -1011,13 +1011,16 @@ scroll bar height, change the @code{scroll-bar-height} frame parameter
|
|||
separate windows visually. Window dividers are bars that can be dragged
|
||||
with the mouse, thus allowing to easily resize adjacent windows.
|
||||
|
||||
@vindex window-divider-mode
|
||||
To control the display of window dividers, customize the variable
|
||||
@code{window-divider-mode}. Its value should be either
|
||||
@findex window-divider-mode
|
||||
To toggle the display of window dividers, use the command @kbd{M-x
|
||||
window-divider-mode}.
|
||||
|
||||
@vindex window-divider-default-places
|
||||
To customize where dividers should appear, use the option
|
||||
@code{window-divider-default-places}. Its value should be either
|
||||
@code{bottom-only} (to show dividers only on the bottom of windows),
|
||||
@code{right-only} (to show dividers only on the right of windows),
|
||||
@code{t} (to show them on the bottom and on the right) or @code{nil} (to
|
||||
disable window dividers).
|
||||
@code{right-only} (to show dividers only on the right of windows), or
|
||||
@code{t} (to show them on the bottom and on the right).
|
||||
|
||||
@vindex window-divider-default-bottom-width
|
||||
@vindex window-divider-default-right-width
|
||||
|
|
|
|||
107
lisp/frame.el
107
lisp/frame.el
|
|
@ -1756,48 +1756,29 @@ left untouched. FRAME nil or omitted means use the selected frame."
|
|||
:group 'frames
|
||||
:group 'windows)
|
||||
|
||||
(defvar frame--window-divider-previous-mode nil
|
||||
"Previous value of `window-divider-mode'.
|
||||
This is the value seen when `window-divider-mode' was switched
|
||||
off the last time. It's reused when `window-divider-mode' is
|
||||
switched on again.")
|
||||
(defcustom window-divider-default-places 'right-only
|
||||
"Default positions of window dividers.
|
||||
Possible values are `bottom-only' (dividers on the bottom of each
|
||||
window only), `right-only' (dividers on the right of each window
|
||||
only), and t (dividers on the bottom and on the right of each
|
||||
window). The default is `right-only'.
|
||||
|
||||
(defcustom window-divider-mode nil
|
||||
"Specify whether to display window dividers and where.
|
||||
Possible values are nil (no dividers), `bottom-only' (dividers on
|
||||
the bottom of each window only), `right-only' (dividers on the
|
||||
right of each window only), and t (dividers on the bottom and on
|
||||
the right of each window)."
|
||||
:type '(choice (const :tag "None (nil)" nil)
|
||||
(const :tag "Bottom only" bottom-only)
|
||||
The value takes effect if and only if dividers are enabled by
|
||||
`window-divider-mode'.
|
||||
|
||||
To position dividers on frames individually, use the frame
|
||||
parameters `bottom-divider-width' and `right-divider-width'."
|
||||
:type '(choice (const :tag "Bottom only" bottom-only)
|
||||
(const :tag "Right only" right-only)
|
||||
(const :tag "Bottom and right" t))
|
||||
:initialize 'custom-initialize-default
|
||||
:set (lambda (_symbol value)
|
||||
(frame--window-divider-mode-set-and-apply value))
|
||||
:group 'window-divider
|
||||
:set (lambda (symbol value)
|
||||
(set-default symbol value)
|
||||
(when window-divider-mode
|
||||
(window-divider-mode-apply t)))
|
||||
:version "25.1")
|
||||
|
||||
(define-minor-mode window-divider-mode
|
||||
"Display dividers between windows (Window Divider mode).
|
||||
With a prefix argument ARG, enable Window Divider mode if ARG is
|
||||
positive, and disable it otherwise. If called from Lisp, enable
|
||||
the mode if ARG is omitted or nil.
|
||||
|
||||
The options `window-divider-default-bottom-width' and
|
||||
`window-divider-default-right-width' allow to customize the width
|
||||
of dividers displayed by this mode."
|
||||
:group 'window-divider
|
||||
:global t
|
||||
:variable (window-divider-mode
|
||||
. (lambda (value)
|
||||
(frame--window-divider-mode-set-and-apply
|
||||
(and value
|
||||
(or frame--window-divider-previous-mode
|
||||
(default-value 'window-divider-mode)
|
||||
'right-only))))))
|
||||
|
||||
(defun frame-window-divider-width-valid-p (value)
|
||||
(defun window-divider-width-valid-p (value)
|
||||
"Return non-nil if VALUE is a positive number."
|
||||
(and (numberp value) (> value 0)))
|
||||
|
||||
|
|
@ -1809,14 +1790,13 @@ dividers are displayed by `window-divider-mode'.
|
|||
To adjust bottom dividers for frames individually, use the frame
|
||||
parameter `bottom-divider-width'."
|
||||
:type '(restricted-sexp
|
||||
:tag "Default bottom divider width"
|
||||
:tag "Default width of bottom dividers"
|
||||
:match-alternatives (frame-window-divider-width-valid-p))
|
||||
:group 'window-divider
|
||||
:initialize 'custom-initialize-default
|
||||
:set (lambda (symbol value)
|
||||
(set-default symbol value)
|
||||
(when window-divider-mode
|
||||
(frame--window-divider-mode-apply)))
|
||||
(when window-divider-mode
|
||||
(window-divider-mode-apply t)))
|
||||
:version "25.1")
|
||||
|
||||
(defcustom window-divider-default-right-width 6
|
||||
|
|
@ -1827,22 +1807,27 @@ dividers are displayed by `window-divider-mode'.
|
|||
To adjust right dividers for frames individually, use the frame
|
||||
parameter `right-divider-width'."
|
||||
:type '(restricted-sexp
|
||||
:tag "Default right divider width"
|
||||
:tag "Default width of right dividers"
|
||||
:match-alternatives (frame-window-divider-width-valid-p))
|
||||
:group 'window-divider
|
||||
:initialize 'custom-initialize-default
|
||||
:set (lambda (symbol value)
|
||||
(set-default symbol value)
|
||||
(when window-divider-mode
|
||||
(frame--window-divider-mode-apply)))
|
||||
(when window-divider-mode
|
||||
(window-divider-mode-apply t)))
|
||||
:version "25.1")
|
||||
|
||||
(defun frame--window-divider-mode-apply ()
|
||||
"Apply window divider widths."
|
||||
(let ((bottom (if (memq window-divider-mode '(bottom-only t))
|
||||
(defun window-divider-mode-apply (enable)
|
||||
"Apply window divider places and widths to all frames.
|
||||
If ENABLE is nil, apply default places and widths. Else reset
|
||||
all divider widths to zero."
|
||||
(let ((bottom (if (and enable
|
||||
(memq window-divider-default-places
|
||||
'(bottom-only t)))
|
||||
window-divider-default-bottom-width
|
||||
0))
|
||||
(right (if (memq window-divider-mode '(right-only t))
|
||||
(right (if (and enable
|
||||
(memq window-divider-default-places
|
||||
'(right-only t)))
|
||||
window-divider-default-right-width
|
||||
0)))
|
||||
(modify-all-frames-parameters
|
||||
|
|
@ -1865,18 +1850,20 @@ parameter `right-divider-width'."
|
|||
(cons 'right-divider-width right)
|
||||
default-frame-alist)))))
|
||||
|
||||
(defun frame--window-divider-mode-set-and-apply (value)
|
||||
"Set window divider mode to VALUE and apply widths."
|
||||
(unless value
|
||||
;; Remember current mode.
|
||||
(setq frame--window-divider-previous-mode window-divider-mode))
|
||||
(set-default 'window-divider-mode value)
|
||||
;; Pacify customize rigmarole.
|
||||
(put 'window-divider-mode 'customized-value
|
||||
(if (memq value '(nil t))
|
||||
(list value)
|
||||
(list (list 'quote value))))
|
||||
(frame--window-divider-mode-apply))
|
||||
(define-minor-mode window-divider-mode
|
||||
"Display dividers between windows (Window Divider mode).
|
||||
With a prefix argument ARG, enable Window Divider mode if ARG is
|
||||
positive, and disable it otherwise. If called from Lisp, enable
|
||||
the mode if ARG is omitted or nil.
|
||||
|
||||
The option `window-divider-default-places' specifies on which
|
||||
side of a window dividers are displayed. The options
|
||||
`window-divider-default-bottom-width' and
|
||||
`window-divider-default-right-width' specify their respective
|
||||
widths."
|
||||
:group 'window-divider
|
||||
:global t
|
||||
(window-divider-mode-apply window-divider-mode))
|
||||
|
||||
;; Blinking cursor
|
||||
|
||||
|
|
|
|||
|
|
@ -719,22 +719,25 @@ by \"Save Options\" in Custom buffers.")
|
|||
(defun menu-bar-bottom-and-right-window-divider ()
|
||||
"Display dividers on the bottom and right of each window."
|
||||
(interactive)
|
||||
(customize-set-variable 'window-divider-mode t))
|
||||
(customize-set-variable 'window-divider-default-places t)
|
||||
(window-divider-mode 1))
|
||||
|
||||
(defun menu-bar-right-window-divider ()
|
||||
"Display dividers only on the right of each window."
|
||||
(interactive)
|
||||
(customize-set-variable 'window-divider-mode 'right-only))
|
||||
(customize-set-variable 'window-divider-default-places 'right-only)
|
||||
(window-divider-mode 1))
|
||||
|
||||
(defun menu-bar-bottom-window-divider ()
|
||||
"Display dividers only at the bottom of each window."
|
||||
(interactive)
|
||||
(customize-set-variable 'window-divider-mode 'bottom-only))
|
||||
(customize-set-variable 'window-divider-default-places 'bottom-only)
|
||||
(window-divider-mode 1))
|
||||
|
||||
(defun menu-bar-no-window-divider ()
|
||||
"Do not display window dividers."
|
||||
(interactive)
|
||||
(customize-set-variable 'window-divider-mode nil))
|
||||
(window-divider-mode -1))
|
||||
|
||||
;; For the radio buttons below we check whether the respective dividers
|
||||
;; are displayed on the selected frame. This is not fully congruent
|
||||
|
|
@ -753,10 +756,10 @@ by \"Save Options\" in Custom buffers.")
|
|||
:help "Display window divider on the bottom and right of each window"
|
||||
:visible (memq (window-system) '(x w32))
|
||||
:button (:radio
|
||||
. (and (frame-window-divider-width-valid-p
|
||||
. (and (window-divider-width-valid-p
|
||||
(cdr (assq 'bottom-divider-width
|
||||
(frame-parameters))))
|
||||
(frame-window-divider-width-valid-p
|
||||
(window-divider-width-valid-p
|
||||
(cdr (assq 'right-divider-width
|
||||
(frame-parameters))))))))
|
||||
(bindings--define-key menu [right-only]
|
||||
|
|
@ -765,10 +768,10 @@ by \"Save Options\" in Custom buffers.")
|
|||
:help "Display window divider on the right of each window only"
|
||||
:visible (memq (window-system) '(x w32))
|
||||
:button (:radio
|
||||
. (and (not (frame-window-divider-width-valid-p
|
||||
. (and (not (window-divider-width-valid-p
|
||||
(cdr (assq 'bottom-divider-width
|
||||
(frame-parameters)))))
|
||||
(frame-window-divider-width-valid-p
|
||||
(window-divider-width-valid-p
|
||||
(cdr (assq 'right-divider-width
|
||||
(frame-parameters))))))))
|
||||
(bindings--define-key menu [bottom-only]
|
||||
|
|
@ -777,10 +780,10 @@ by \"Save Options\" in Custom buffers.")
|
|||
:help "Display window divider on the bottom of each window only"
|
||||
:visible (memq (window-system) '(x w32))
|
||||
:button (:radio
|
||||
. (and (frame-window-divider-width-valid-p
|
||||
. (and (window-divider-width-valid-p
|
||||
(cdr (assq 'bottom-divider-width
|
||||
(frame-parameters))))
|
||||
(not (frame-window-divider-width-valid-p
|
||||
(not (window-divider-width-valid-p
|
||||
(cdr (assq 'right-divider-width
|
||||
(frame-parameters)))))))))
|
||||
(bindings--define-key menu [no-divider]
|
||||
|
|
@ -789,10 +792,10 @@ by \"Save Options\" in Custom buffers.")
|
|||
:help "Do not display window dividers"
|
||||
:visible (memq (window-system) '(x w32))
|
||||
:button (:radio
|
||||
. (and (not (frame-window-divider-width-valid-p
|
||||
. (and (not (window-divider-width-valid-p
|
||||
(cdr (assq 'bottom-divider-width
|
||||
(frame-parameters)))))
|
||||
(not (frame-window-divider-width-valid-p
|
||||
(not (window-divider-width-valid-p
|
||||
(cdr (assq 'right-divider-width
|
||||
(frame-parameters)))))))))
|
||||
menu))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue