Fix alignment and documentation of vtable.el
* lisp/emacs-lisp/vtable.el (vtable--insert-header-line): Ensure proper alignment between the columns in header-line and in the body of the table. (Bug#73032) * doc/misc/vtable.texi (Making A Table): Document the defaults of the various keyword parameters.
This commit is contained in:
parent
4d6fadb8d2
commit
04c44405bf
2 changed files with 27 additions and 20 deletions
|
@ -337,7 +337,9 @@ width (in pixels), and @var{table} is the table.
|
||||||
@end defun
|
@end defun
|
||||||
|
|
||||||
@item align
|
@item align
|
||||||
Should be either @code{right} or @code{left}.
|
Should be either @code{right} or @code{left}. If not specified,
|
||||||
|
numerical values will be flushed to the right, and all other values will
|
||||||
|
be flushed to the left.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@item :getter
|
@item :getter
|
||||||
|
@ -426,14 +428,19 @@ current line, they can use the @code{vtable-current-object} function
|
||||||
(@pxref{Interface Functions}) to determine what that object is.
|
(@pxref{Interface Functions}) to determine what that object is.
|
||||||
|
|
||||||
@item :separator-width
|
@item :separator-width
|
||||||
The width of the blank space between columns.
|
The width of the blank space between columns. If not specified, it
|
||||||
|
defaults to 1.
|
||||||
|
|
||||||
@item :divider-width
|
@item :divider-width
|
||||||
@itemx :divider
|
@itemx :divider
|
||||||
You can have a divider inserted between the columns. This can either
|
You can have a divider inserted between the columns. This can either be
|
||||||
be specified by using @code{:divider}, which should be a string to be
|
specified by using @code{:divider}, which should be a string to be
|
||||||
displayed between the columns, or @code{:divider-width}, which
|
displayed between the columns, or @code{:divider-width}, which specifies
|
||||||
specifies the width of the space to be used as the divider.
|
the width of the space to be used as the divider, in units of characters
|
||||||
|
of the face used to display the table. If not specified,
|
||||||
|
@code{:divider} defaults to @code{nil}, but specifying
|
||||||
|
@code{:divider-width} effectively sets the divider to a whitespace
|
||||||
|
string of that width.
|
||||||
|
|
||||||
@item :sort-by
|
@item :sort-by
|
||||||
This should be a list of tuples, and specifies how the table is to be
|
This should be a list of tuples, and specifies how the table is to be
|
||||||
|
|
|
@ -722,15 +722,17 @@ This also updates the displayed table."
|
||||||
(vtable--limit-string
|
(vtable--limit-string
|
||||||
name (- (elt widths index) indicator-width))
|
name (- (elt widths index) indicator-width))
|
||||||
name))
|
name))
|
||||||
(let ((fill-width
|
(let* ((indicator-lead-width
|
||||||
(+ (- (elt widths index)
|
;; We want the indicator to not be quite flush right.
|
||||||
(string-pixel-width displayed)
|
(/ (vtable--char-width table) 2.0))
|
||||||
indicator-width
|
(indicator-pad-width (- (vtable--char-width table)
|
||||||
(vtable-separator-width table)
|
indicator-lead-width))
|
||||||
;; We want the indicator to not be quite flush
|
(fill-width
|
||||||
;; right.
|
(+ (- (elt widths index)
|
||||||
(/ (vtable--char-width table) 2.0))
|
(string-pixel-width displayed)
|
||||||
(if last 0 spacer))))
|
indicator-width
|
||||||
|
indicator-lead-width)
|
||||||
|
(if last 0 spacer))))
|
||||||
(if (or (not last)
|
(if (or (not last)
|
||||||
(zerop indicator-width)
|
(zerop indicator-width)
|
||||||
(< (seq-reduce #'+ widths 0) (window-width nil t)))
|
(< (seq-reduce #'+ widths 0) (window-width nil t)))
|
||||||
|
@ -739,7 +741,9 @@ This also updates the displayed table."
|
||||||
displayed
|
displayed
|
||||||
(propertize " " 'display
|
(propertize " " 'display
|
||||||
(list 'space :width (list fill-width)))
|
(list 'space :width (list fill-width)))
|
||||||
indicator)
|
indicator
|
||||||
|
(propertize " " 'display
|
||||||
|
(list 'space :width (list indicator-pad-width))))
|
||||||
;; This is the final column, and we have a sorting
|
;; This is the final column, and we have a sorting
|
||||||
;; indicator, and the table is too wide for the window.
|
;; indicator, and the table is too wide for the window.
|
||||||
(let* ((pre-indicator (string-pixel-width
|
(let* ((pre-indicator (string-pixel-width
|
||||||
|
@ -758,10 +762,6 @@ This also updates the displayed table."
|
||||||
(list (- fill-width pre-fill))))))))
|
(list (- fill-width pre-fill))))))))
|
||||||
(when (and divider (not last))
|
(when (and divider (not last))
|
||||||
(insert (propertize divider 'keymap dmap)))
|
(insert (propertize divider 'keymap dmap)))
|
||||||
(insert (propertize
|
|
||||||
" " 'display
|
|
||||||
(list 'space :width (list
|
|
||||||
(/ (vtable--char-width table) 2.0)))))
|
|
||||||
(put-text-property start (point) 'vtable-column index)))
|
(put-text-property start (point) 'vtable-column index)))
|
||||||
(vtable-columns table))
|
(vtable-columns table))
|
||||||
(insert "\n")
|
(insert "\n")
|
||||||
|
|
Loading…
Add table
Reference in a new issue