diff options
author | Eli Zaretskii <eliz@gnu.org> | 2017-10-20 12:36:12 +0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2017-10-20 12:36:12 +0300 |
commit | fd3d8610b27e26107ba15070aba0d488152f8f4d (patch) | |
tree | d62498e78ac088c6f992a1f0077951ea9db6ba08 /lisp/ruler-mode.el | |
parent | 831eafc8ae201881e6449e2ab5d15d594573650b (diff) | |
download | emacs-fd3d8610b27e26107ba15070aba0d488152f8f4d.tar.gz |
Make :align-to account for display-line-numbers
These changes also update the various bundled packages to use
new feature, and better support customizations of the line-number
face.
* src/xdisp.c (calc_pixel_width_or_height): Improve commentary.
Make :align-to count from the end of the line-number display when
the offset or the width form reference that of the text area.
(Bug#28855)
* src/indent.c (Fline_number_display_width): Implement support for
the PIXELWISE argument being 'columns'. Update the doc string.
(syms_of_indent): New symbol 'columns'.
* lisp/ruler-mode.el (ruler-mode-window-col, ruler-mode-ruler):
Call line-number-display-width with last argument 'columns'.
* lisp/proced.el (proced-header-line): Call
line-number-display-width with 2nd arg 'columns', which also fixes
a problem when display-line-numbers is nil.
* lisp/emacs-lisp/tabulated-list.el
(tabulated-list-line-number-width): Call line-number-display-width
with 2nd arg 'columns.
(tabulated-list-entry-lnum-width): Remove unneeded defvar.
(tabulated-list-print, tabulated-list-print-entry): No need to
account for the value of tabulated-list-entry-lnum-width.
(tabulated-list--current-lnum-width): New defvar.
(tabulated-list-watch-line-number-width): New function.
(tabulated-list-mode): Bind tabulated-list--current-lnum-width
locally, and set up tabulated-list-watch-line-number-width as
pre-redisplay-functions hook.
* doc/lispref/display.texi (Size of Displayed Text): Document the
'columns' value of the PIXELWISE argument.
(Pixel Specification): Update and improve the documentation of the
supported forms.
Diffstat (limited to 'lisp/ruler-mode.el')
-rw-r--r-- | lisp/ruler-mode.el | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lisp/ruler-mode.el b/lisp/ruler-mode.el index 7a23f4d03c0..3d27858d0fe 100644 --- a/lisp/ruler-mode.el +++ b/lisp/ruler-mode.el @@ -307,7 +307,12 @@ or remove a tab stop. \\[ruler-mode-toggle-show-tab-stops] or N is a column number relative to selected frame. If required, account for screen estate taken by `display-line-numbers'." (if display-line-numbers - (setq n (- n (line-number-display-width) 2))) + ;; FIXME: ruler-mode relies on N being an integer, so if the + ;; 'line-number' face is customized to use a font that is larger + ;; or smaller than that of the default face, the alignment might + ;; be off by up to half a column, unless the font width is an + ;; integral multiple or divisor of the default face's font. + (setq n (- n (round (line-number-display-width 'columns))))) (- n (or (car (window-margins)) 0) (fringe-columns 'left) @@ -668,7 +673,12 @@ Optional argument PROPS specifies other text properties to apply." (let* ((w (ruler-mode-text-scaled-window-width)) (m (window-margins)) (f (window-fringes)) - (i (if display-line-numbers (+ (line-number-display-width) 2) 0)) + (i (if display-line-numbers + ;; FIXME: ruler-mode relies on I being an integer, so + ;; the column numbers might be slightly off if the + ;; line-number face is customized. + (round (line-number-display-width 'columns)) + 0)) (j (ruler-mode-text-scaled-window-hscroll)) ;; Setup the scrollbar, fringes, and margins areas. (lf (ruler-mode-space @@ -708,7 +718,7 @@ Optional argument PROPS specifies other text properties to apply." ;; line-number display be blank, not filled with ;; ruler-mode-basic-graduation-char. (if display-line-numbers - (let* ((lndw (+ (line-number-display-width) 2)) + (let* ((lndw (round (line-number-display-width 'columns))) (s (make-string lndw ?\s))) (concat s (make-string (- w lndw) ruler-mode-basic-graduation-char))) |