update packages
This commit is contained in:
@@ -6,11 +6,11 @@
|
||||
|
||||
;; Author: Joost Kremers <joostkremers@fastmail.fm>
|
||||
;; Maintainer: Joost Kremers <joostkremers@fastmail.fm>
|
||||
;; URL: https://github.com/joostkremers/visual-fill-column
|
||||
;; Package-Version: 20201229.2303
|
||||
;; Package-Commit: 5b08b9ae9da5b95e42e94e4c9ec01d63e8848ea2
|
||||
;; URL: https://codeberg.org/joostkremers/visual-fill-column
|
||||
;; Package-Version: 20211118.33
|
||||
;; Package-Commit: cf3e2bc632b68d54145c79beede85d3458a337de
|
||||
;; Created: 2015
|
||||
;; Version: 2.2
|
||||
;; Version: 2.4
|
||||
;; Package-Requires: ((emacs "25.1"))
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
@@ -33,8 +33,14 @@
|
||||
;; `visual-fill-column-mode' is a small Emacs minor mode that mimics the effect
|
||||
;; of `fill-column' in `visual-line-mode'. Instead of wrapping lines at the
|
||||
;; window edge, which is the standard behaviour of `visual-line-mode', it wraps
|
||||
;; lines at `fill-column'. If `fill-column' is too large for the window, the
|
||||
;; text is wrapped at the window edge.
|
||||
;; lines at `fill-column' (or `visual-fill-column-width', if set). This is
|
||||
;; accomplished by widening the margins, which narrows the text area. When the
|
||||
;; window size changes, the margins are adjusted automatically.
|
||||
;;
|
||||
;; When `visual-fill-column-center-text' is set, the text is centered in the
|
||||
;; window. This can also be used in combination with `auto-fill-mode' instead
|
||||
;; of `visual-line-mode', or in programming modes.
|
||||
|
||||
|
||||
;;; Code:
|
||||
|
||||
@@ -81,23 +87,28 @@ otherwise reduce the actual size of the text area."
|
||||
(make-variable-buffer-local 'visual-fill-column-center-text)
|
||||
(put 'visual-fill-column-center-text 'safe-local-variable 'symbolp)
|
||||
|
||||
(defcustom visual-fill-column-inhibit-sensible-window-split nil
|
||||
"Do not set `split-window-preferred-function' to allow vertical window splits.
|
||||
By default, `split-window-preferred-function' is set to
|
||||
(defcustom visual-fill-column-enable-sensible-window-split nil
|
||||
"Set `split-window-preferred-function' so as to allow vertical window splits.
|
||||
If this option is set, `visual-fill-column' sets the variable
|
||||
`split-window-preferred-function' to
|
||||
`visual-fill-column-split-window-sensibly', in order to allow
|
||||
`display-buffer' to split windows in two side-by-side windows.
|
||||
Unset this option if you wish to use your custom function for
|
||||
`split-window-sensibly'."
|
||||
`display-buffer' to split windows in two side-by-side windows."
|
||||
:group 'visual-fill-column
|
||||
:type '(choice (const :tag "Allow vertical window split" nil)
|
||||
(const :tag "Use standard window split" t)))
|
||||
|
||||
(defcustom visual-fill-column-adjust-for-text-scale t
|
||||
"Adjust the margins for text scaling.
|
||||
If set to t, the calculated margins are additionally adjusted for
|
||||
the text scale factor, so that the text is wrapped at
|
||||
`fill-column'."
|
||||
:group 'visual-fill-column
|
||||
:type '(choice (const :tag "Adjust margins for text scaling" t)
|
||||
(const :tag "Do not adjust margins for text scaling" nil)))
|
||||
|
||||
(defvar visual-fill-column--use-split-window-parameter nil "If set, the window parameter `split-window' is used.")
|
||||
|
||||
(defvar visual-fill-column--min-margins nil "Width of the margins before invoking `visual-fill-column-mode'.")
|
||||
(make-variable-buffer-local 'visual-fill-column--min-margins)
|
||||
|
||||
(defvar visual-fill-column--original-split-window-function nil "The value of `split-window-preferred-function'.")
|
||||
(defvar visual-fill-column--use-min-margins nil "If set, the window parameter `min-margins' is used.")
|
||||
|
||||
(defvar visual-fill-column-mode-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
@@ -155,33 +166,41 @@ that actually visit a file."
|
||||
|
||||
(defun visual-fill-column-mode--enable ()
|
||||
"Set up `visual-fill-column-mode' for the current buffer."
|
||||
(add-hook 'window-configuration-change-hook #'visual-fill-column--adjust-all-windows 'append 'local)
|
||||
(add-hook 'window-size-change-functions #'visual-fill-column--adjust-window 'append 'local)
|
||||
(add-hook 'window-configuration-change-hook #'visual-fill-column--adjust-window 'append 'local)
|
||||
|
||||
(when (not visual-fill-column-inhibit-sensible-window-split)
|
||||
(setq visual-fill-column--original-split-window-function split-window-preferred-function)
|
||||
(when visual-fill-column-enable-sensible-window-split
|
||||
;; Note that `split-window-preferred-function' is not reset to its original
|
||||
;; value when `visual-fill-column-mode' is disabled, because it may still be
|
||||
;; enabled in other buffers. When `visual-fill-column-mode' is disabled,
|
||||
;; `visual-fill-column-split-window-sensibly' simply invokes
|
||||
;; `split-window-sensibly', so keeping it is harmless.
|
||||
(setq-default split-window-preferred-function #'visual-fill-column-split-window-sensibly))
|
||||
|
||||
(when (version<= emacs-version "27.1")
|
||||
(cond
|
||||
((version<= emacs-version "27.1")
|
||||
(add-hook 'window-size-change-functions #'visual-fill-column--adjust-window 'append 'local)
|
||||
(setq visual-fill-column--use-split-window-parameter t))
|
||||
|
||||
(when (version< "27.1" emacs-version)
|
||||
(let ((margins (window-margins (selected-window))))
|
||||
(setq visual-fill-column--min-margins (cons (or (car margins) 0)
|
||||
(or (cdr margins) 0)))))
|
||||
((version< "27.1" emacs-version)
|
||||
(add-hook 'window-state-change-functions #'visual-fill-column--adjust-window 'append 'local)
|
||||
(setq visual-fill-column--use-min-margins t)))
|
||||
|
||||
(visual-fill-column--adjust-window (selected-window)))
|
||||
|
||||
(defun visual-fill-column-mode--disable ()
|
||||
"Disable `visual-fill-column-mode' for the current buffer."
|
||||
(if (<= emacs-major-version 26)
|
||||
(remove-hook 'window-configuration-change-hook #'visual-fill-column--adjust-window 'local))
|
||||
(remove-hook 'window-size-change-functions #'visual-fill-column--adjust-window 'local)
|
||||
(remove-hook 'window-configuration-change-hook #'visual-fill-column--adjust-window 'local)
|
||||
|
||||
(let ((window (get-buffer-window (current-buffer))))
|
||||
(set-window-margins window (car visual-fill-column--min-margins) (cdr visual-fill-column--min-margins))
|
||||
(set-window-fringes window nil)
|
||||
(set-window-parameter window 'min-margins nil)
|
||||
(kill-local-variable 'visual-fill-column--min-margins)))
|
||||
(cond
|
||||
((version<= emacs-version "27.1")
|
||||
(remove-hook 'window-size-change-functions #'visual-fill-column--adjust-window 'local))
|
||||
|
||||
((version< "27.1" emacs-version)
|
||||
(remove-hook 'window-state-change-functions #'visual-fill-column--adjust-window 'local)
|
||||
(set-window-margins window 0 0)
|
||||
(set-window-parameter window 'min-margins nil)))
|
||||
(set-window-fringes window nil)))
|
||||
|
||||
(defun visual-fill-column-split-window (&optional window size side)
|
||||
"Split WINDOW, unsetting its margins first.
|
||||
@@ -243,15 +262,10 @@ selected window has `visual-fill-column-mode' enabled."
|
||||
(set-window-fringes window nil nil visual-fill-column-fringes-outside-margins)
|
||||
(if visual-fill-column--use-split-window-parameter
|
||||
(set-window-parameter window 'split-window #'visual-fill-column-split-window))
|
||||
(if visual-fill-column--min-margins ; This is non-nil if the window parameter `min-margins' is used (Emacs 27.2).
|
||||
(set-window-parameter window 'min-margins visual-fill-column--min-margins))
|
||||
(if visual-fill-column--use-min-margins ; This is non-nil if the window parameter `min-margins' is used (Emacs 27.2).
|
||||
(set-window-parameter window 'min-margins '(0 . 0)))
|
||||
(visual-fill-column--set-margins window))))
|
||||
|
||||
(defun visual-fill-column--adjust-all-windows ()
|
||||
"Adjust margins of all windows displaying the current buffer."
|
||||
(mapc #'visual-fill-column--adjust-window
|
||||
(get-buffer-window-list (current-buffer) 'no-minibuffer 'visible)))
|
||||
|
||||
(defun visual-fill-column-adjust (&optional _inc)
|
||||
"Adjust the window margins and fringes.
|
||||
This function is for use as advice to `text-scale-adjust'. It
|
||||
@@ -270,7 +284,8 @@ and `text-scale-mode-step'."
|
||||
(or window (setq window (selected-window)))
|
||||
(let* ((margins (window-margins window))
|
||||
(buffer (window-buffer window))
|
||||
(scale (if (and (boundp 'text-scale-mode-step)
|
||||
(scale (if (and visual-fill-column-adjust-for-text-scale
|
||||
(boundp 'text-scale-mode-step)
|
||||
(boundp 'text-scale-mode-amount))
|
||||
(with-current-buffer buffer
|
||||
(expt text-scale-mode-step
|
||||
@@ -284,8 +299,8 @@ and `text-scale-mode-step'."
|
||||
(defun visual-fill-column--add-extra-width (left right add-width)
|
||||
"Calculate new margins given additional text width.
|
||||
LEFT and RIGHT are the current margins, ADD-WIDTH a cons cell of
|
||||
additional columns to be added to the text area. Return a cons
|
||||
cell of the new margins, which will never be less than zero."
|
||||
additional columns to be added to the text area. Return a cons
|
||||
cell of the new margins, which will never be less than zero."
|
||||
(cons (max 0 (- left (car add-width)))
|
||||
(max 0 (- right (cdr add-width)))))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user