aboutsummaryrefslogtreecommitdiffstats
path: root/src/indent.c
diff options
context:
space:
mode:
authorEli Zaretskii2017-10-20 12:36:12 +0300
committerEli Zaretskii2017-10-20 12:36:12 +0300
commitfd3d8610b27e26107ba15070aba0d488152f8f4d (patch)
treed62498e78ac088c6f992a1f0077951ea9db6ba08 /src/indent.c
parent831eafc8ae201881e6449e2ab5d15d594573650b (diff)
downloademacs-fd3d8610b27e26107ba15070aba0d488152f8f4d.tar.gz
emacs-fd3d8610b27e26107ba15070aba0d488152f8f4d.zip
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 'src/indent.c')
-rw-r--r--src/indent.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/indent.c b/src/indent.c
index a3e9b5b0b9a..192eec72efe 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -1991,15 +1991,26 @@ line_number_display_width (struct window *w, int *width, int *pixel_width)
1991DEFUN ("line-number-display-width", Fline_number_display_width, 1991DEFUN ("line-number-display-width", Fline_number_display_width,
1992 Sline_number_display_width, 0, 1, 0, 1992 Sline_number_display_width, 0, 1, 0,
1993 doc: /* Return the width used for displaying line numbers in the selected window. 1993 doc: /* Return the width used for displaying line numbers in the selected window.
1994If optional argument PIXELWISE is non-nil, return the width in pixels, 1994If optional argument PIXELWISE is the symbol `columns', return the width
1995otherwise return the width in columns of the face used to display 1995in units of the frame's canonical character width. In this case, the
1996line numbers, `line-number'. Note that in the latter case, the value 1996value is a float.
1997doesn't include the 2 columns used for padding the numbers. */) 1997If optional argument PIXELWISE is t or any other non-nil value, return
1998the width as an integer number of pixels.
1999Otherwise return the value as an integer number of columns of the face
2000used to display line numbers, `line-number'. Note that in the latter
2001case, the value doesn't include the 2 columns used for padding the
2002numbers on display. */)
1998 (Lisp_Object pixelwise) 2003 (Lisp_Object pixelwise)
1999{ 2004{
2000 int width, pixel_width; 2005 int width, pixel_width;
2006 struct window *w = XWINDOW (selected_window);
2001 line_number_display_width (XWINDOW (selected_window), &width, &pixel_width); 2007 line_number_display_width (XWINDOW (selected_window), &width, &pixel_width);
2002 if (!NILP (pixelwise)) 2008 if (EQ (pixelwise, Qcolumns))
2009 {
2010 struct frame *f = XFRAME (w->frame);
2011 return make_float ((double) pixel_width / FRAME_COLUMN_WIDTH (f));
2012 }
2013 else if (!NILP (pixelwise))
2003 return make_number (pixel_width); 2014 return make_number (pixel_width);
2004 return make_number (width); 2015 return make_number (width);
2005} 2016}
@@ -2361,6 +2372,8 @@ syms_of_indent (void)
2361 doc: /* Indentation can insert tabs if this is non-nil. */); 2372 doc: /* Indentation can insert tabs if this is non-nil. */);
2362 indent_tabs_mode = 1; 2373 indent_tabs_mode = 1;
2363 2374
2375 DEFSYM (Qcolumns, "columns");
2376
2364 defsubr (&Scurrent_indentation); 2377 defsubr (&Scurrent_indentation);
2365 defsubr (&Sindent_to); 2378 defsubr (&Sindent_to);
2366 defsubr (&Scurrent_column); 2379 defsubr (&Scurrent_column);