commit 552b74ba9ec0fa0486b86bea561e499ca13e92ca (HEAD, refs/remotes/origin/master) Author: Po Lu Date: Fri Dec 24 15:48:27 2021 +0800 Fix text decoration display on stretch glyphs with no box on NS * src/nsterm.m (ns_dumpglyphs_stretch): Draw decorations if there is no box. diff --git a/src/nsterm.m b/src/nsterm.m index 8428c689fd..591e28f20b 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -3793,7 +3793,7 @@ Function modeled after x_draw_glyph_string_box (). then decorations will be drawn after drawing the box in ns_draw_glyph_string, in order to prevent them from being overwritten by the box. */ - if (s->face->box != FACE_NO_BOX) + if (s->face->box == FACE_NO_BOX) ns_draw_text_decoration (s, face, fgCol, NSWidth (glyphRect), NSMinX (glyphRect)); commit c9f05cbe3fc7290cc4874afa378cdf8062e84e2f Author: Po Lu Date: Fri Dec 24 15:35:15 2021 +0800 Make precision scrolling work on margins and fringes * lisp/pixel-scroll.el (pixel-scroll-precision-mode-map): Add missing key definitions. diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el index d3b4500023..b943365a3f 100644 --- a/lisp/pixel-scroll.el +++ b/lisp/pixel-scroll.el @@ -108,6 +108,18 @@ is always with pixel resolution.") (define-key map [vertical-scroll-bar wheel-down] #'pixel-scroll-precision) (define-key map [vertical-scroll-bar wheel-up] #'pixel-scroll-precision) (define-key map [vertical-scroll-bar touch-end] #'pixel-scroll-start-momentum) + (define-key map [left-margin wheel-down] #'pixel-scroll-precision) + (define-key map [left-margin wheel-up] #'pixel-scroll-precision) + (define-key map [left-margin touch-end] #'pixel-scroll-start-momentum) + (define-key map [right-margin wheel-down] #'pixel-scroll-precision) + (define-key map [right-margin wheel-up] #'pixel-scroll-precision) + (define-key map [right-margin touch-end] #'pixel-scroll-start-momentum) + (define-key map [left-fringe wheel-down] #'pixel-scroll-precision) + (define-key map [left-fringe wheel-up] #'pixel-scroll-precision) + (define-key map [left-fringe touch-end] #'pixel-scroll-start-momentum) + (define-key map [right-fringe wheel-down] #'pixel-scroll-precision) + (define-key map [right-fringe wheel-up] #'pixel-scroll-precision) + (define-key map [right-fringe touch-end] #'pixel-scroll-start-momentum) map) "The key map used by `pixel-scroll-precision-mode'.") commit 8e0d327b8ce7cacf2de8ad38c4bd432a94750622 Author: Po Lu Date: Fri Dec 24 15:24:35 2021 +0800 Remove useless functions from PGTK port that were breaking emacsbug * src/pgtkfns.c (Fx_server_vendor, Fx_server_version): Remove useless functions that returned invalid values. (syms_of_pgtkfns): Stop defining removed subrs. diff --git a/src/pgtkfns.c b/src/pgtkfns.c index 44e3d2a37e..a756bd4284 100644 --- a/src/pgtkfns.c +++ b/src/pgtkfns.c @@ -2083,42 +2083,6 @@ DEFUN ("x-server-max-request-size", Fx_server_max_request_size, Sx_server_max_re } -DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0, - doc: /* Return the "vendor ID" string of the display server TERMINAL. -\(Labeling every distributor as a "vendor" embodies the false assumption -that operating systems cannot be developed and distributed noncommercially.) -The optional argument TERMINAL specifies which display to ask about. -TERMINAL should be a terminal object, a frame or a display name (a string). -If omitted or nil, that stands for the selected frame's display. */) - (Lisp_Object terminal) -{ - check_pgtk_display_info (terminal); - return Qnil; -} - - -DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0, - doc: /* Return the version numbers of the server of display TERMINAL. -The value is a list of three integers: the major and minor -version numbers of the X Protocol in use, and the distributor-specific release -number. See also the function `x-server-vendor'. - -The optional argument TERMINAL specifies which display to ask about. -TERMINAL should be a terminal object, a frame or a display name (a string). -If omitted or nil, that stands for the selected frame's display. */ ) - (Lisp_Object terminal) -{ - check_pgtk_display_info (terminal); - /*NOTE: it is unclear what would best correspond with "protocol"; - we return 10.3, meaning Panther, since this is roughly the - level that GNUstep's APIs correspond to. - The last number is where we distinguish between the Apple - and GNUstep implementations ("distributor-specific release - number") and give int'ized versions of major.minor. */ - return list3i (0, 0, 0); -} - - DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0, doc: /* Return the number of screens on the display server TERMINAL. The optional argument TERMINAL specifies which display to ask about. @@ -4015,8 +3979,6 @@ be used as the image of the icon representing the frame. */); defsubr (&Sxw_color_defined_p); defsubr (&Sxw_color_values); defsubr (&Sx_server_max_request_size); - defsubr (&Sx_server_vendor); - defsubr (&Sx_server_version); defsubr (&Sx_display_pixel_width); defsubr (&Sx_display_pixel_height); defsubr (&Spgtk_display_monitor_attributes_list); commit 965b8b0fad617a6a1050ca850567726cb7197694 Author: Po Lu Date: Fri Dec 24 14:22:21 2021 +0800 Grab the server when warping the client pointer * src/xfns.c (Fx_set_mouse_absolute_pixel_position): * src/xterm.c (x_make_frame_invisible): Avoid race conditions where the client pointer is destroyed between when it is obtained and when XIWarpPointer is called. diff --git a/src/xfns.c b/src/xfns.c index 168debc8f3..b02996c0d3 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -5648,6 +5648,7 @@ The coordinates X and Y are interpreted in pixels relative to a position if (FRAME_DISPLAY_INFO (f)->supports_xi2) { + XGrabServer (FRAME_X_DISPLAY (f)); if (XIGetClientPointer (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &deviceid)) { @@ -5655,6 +5656,7 @@ The coordinates X and Y are interpreted in pixels relative to a position DefaultRootWindow (FRAME_X_DISPLAY (f)), 0, 0, 0, 0, xval, yval); } + XUngrabServer (FRAME_X_DISPLAY (f)); } else #endif diff --git a/src/xterm.c b/src/xterm.c index aa88610961..42001023b3 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -13242,6 +13242,7 @@ frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y) if (FRAME_DISPLAY_INFO (f)->supports_xi2) { + XGrabServer (FRAME_X_DISPLAY (f)); if (XIGetClientPointer (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &deviceid)) { @@ -13250,6 +13251,7 @@ frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y) FRAME_X_WINDOW (f), 0, 0, 0, 0, pix_x, pix_y); } + XUngrabServer (FRAME_X_DISPLAY (f)); } else #endif commit 6a17bb48798bf88458d43e7417e64d2efd74494b Merge: fbe026cb3e 04be23f19f Author: Stefan Kangas Date: Fri Dec 24 06:30:41 2021 +0100 Merge from origin/emacs-28 04be23f19f Improve Xref documentation edb1d491d9 * lisp/net/shr.el (shr-expand-url): Also strip trailing wh... commit fbe026cb3e2f8148dd1841e0f9974915ca32c84d Author: Po Lu Date: Fri Dec 24 03:21:21 2021 +0000 Acquire draw lock when updating menubar on Haiku * src/haikumenu.c (digest_menu_items): Acquire draw lock. diff --git a/src/haikumenu.c b/src/haikumenu.c index 698da9d639..2ce0aed146 100644 --- a/src/haikumenu.c +++ b/src/haikumenu.c @@ -59,10 +59,17 @@ digest_menu_items (void *first_menu, int start, int menu_items_used, menus[0] = first_menu; void *window = NULL; + void *view = NULL; if (FRAMEP (Vmenu_updating_frame) && FRAME_LIVE_P (XFRAME (Vmenu_updating_frame)) && FRAME_HAIKU_P (XFRAME (Vmenu_updating_frame))) - window = FRAME_HAIKU_WINDOW (XFRAME (Vmenu_updating_frame)); + { + window = FRAME_HAIKU_WINDOW (XFRAME (Vmenu_updating_frame)); + view = FRAME_HAIKU_VIEW (XFRAME (Vmenu_updating_frame)); + } + + if (view) + BView_draw_lock (view); while (i < menu_items_used) { @@ -161,6 +168,9 @@ digest_menu_items (void *first_menu, int start, int menu_items_used, i += MENU_ITEMS_ITEM_LENGTH; } } + + if (view) + BView_draw_unlock (view); } static Lisp_Object commit 7078af622b05971496bf07712775d19b3980a628 Author: Po Lu Date: Fri Dec 24 11:10:09 2021 +0800 Fix menu grabs on XI2 Motif builds * src/xmenu.c (x_activate_menubar) [USE_MOTIF]: Clear XI grab. * src/xterm.c (xi_grab_or_ungrab_device) [USE_MOTIF]: Always ungrab if a popup is active. diff --git a/src/xmenu.c b/src/xmenu.c index 07255911f9..4d969fa25f 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -51,6 +51,10 @@ along with GNU Emacs. If not, see . */ #include "msdos.h" #endif +#ifdef HAVE_XINPUT2 +#include +#endif + #ifdef HAVE_X_WINDOWS /* This may include sys/types.h, and that somehow loses if this is not done before the other system files. */ @@ -444,6 +448,18 @@ x_activate_menubar (struct frame *f) XPutBackEvent (f->output_data.x->display_info->display, f->output_data.x->saved_menu_event); #else +#ifdef USE_MOTIF + struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f); + /* Clear the XI2 grab so Motif can set a core grab. Otherwise some + versions of Motif will emit a warning and hang. */ + + if (dpyinfo->num_devices) + { + for (int i = 0; i < dpyinfo->num_devices; ++i) + XIUngrabDevice (dpyinfo->display, dpyinfo->devices[i].device_id, + CurrentTime); + } +#endif XtDispatchEvent (f->output_data.x->saved_menu_event); #endif unblock_input (); diff --git a/src/xterm.c b/src/xterm.c index b8cf637f43..aa88610961 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -637,7 +637,11 @@ xi_grab_or_ungrab_device (struct xi_device_t *device, XISetMask (m, XI_Enter); XISetMask (m, XI_Leave); - if (device->grab) + if (device->grab +#ifdef USE_MOTIF + && !popup_activated () +#endif + ) { XIGrabDevice (dpyinfo->display, device->device_id, window, CurrentTime, None, GrabModeAsync, commit 8c99628a716f57eef2c181e30075ff136e76a908 Author: Po Lu Date: Fri Dec 24 09:55:15 2021 +0800 Fix some more incorrect valuator clearing * src/xterm.c (handle_one_xevent): Improve detection of stray ungrab events. diff --git a/src/xterm.c b/src/xterm.c index c5f826433f..b8cf637f43 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -10015,7 +10015,11 @@ handle_one_xevent (struct x_display_info *dpyinfo, been changed elsewhere. */ if (enter->detail != XINotifyInferior && enter->mode != XINotifyPassiveUngrab - && enter->mode != XINotifyUngrab && any) + /* See the comment under FocusIn in + `x_detect_focus_change'. The main relevant culprit + these days seems to be XFCE. */ + && enter->mode != XINotifyUngrab + && any && enter->event == FRAME_X_WINDOW (any)) xi_reset_scroll_valuators_for_device_id (dpyinfo, enter->deviceid); f = any; commit 04be23f19f6d1290906d2a392a05c58703ea76c5 (refs/remotes/origin/emacs-28) Author: Dmitry Gutov Date: Fri Dec 24 03:24:52 2021 +0200 Improve Xref documentation * lisp/progmodes/xref.el (xref-item): Add docstring for 'summary'. Fix typo in the header Commentary. diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 492be9a104..fd59a7b98c 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -44,7 +44,7 @@ ;; ;; The last three methods operate with "xref" and "location" values. ;; -;; One would usually call `make-xref' and `xref-make-file-location', +;; One would usually call `xref-make' and `xref-make-file-location', ;; `xref-make-buffer-location' or `xref-make-bogus-location' to create ;; them. More generally, a location must be an instance of a type for ;; which methods `xref-location-group' and `xref-location-marker' are @@ -199,7 +199,19 @@ is not known." (:constructor xref-make (summary location)) (:noinline t)) "An xref item describes a reference to a location somewhere." - summary location) + (summary nil :documentation "String which describes the location. + +When `xref-location-line' returns non-nil (a number), the summary +is implied to be the contents of a file or buffer line containing +the location. When multiple locations in a row report the same +line, in the same group (corresponding to the case of multiple +locations on one line), the summaries are concatenated in the +Xref output buffer. Consequently, any code that creates xref +values should take care to slice the summary values when several +locations point to the same line. + +This behavior is new in Emacs 28.") + location) (cl-defstruct (xref-match-item (:include xref-item) commit 20647467bef593c9dd3b86efdc6f21ddfd1e7f75 Author: Po Lu Date: Fri Dec 24 09:20:44 2021 +0800 Drop scrollbar motion events when valuators are found * src/xterm.c (handle_one_xevent): Drop XI_Motion if it's on top of a scroll bar and a valuator is found. diff --git a/src/xterm.c b/src/xterm.c index 070ee7d671..c5f826433f 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -10230,7 +10230,13 @@ handle_one_xevent (struct x_display_info *dpyinfo, } #endif if (found_valuator) - goto XI_OTHER; + { +#ifdef USE_GTK + if (f && xg_event_is_for_scrollbar (f, event)) + *finish = X_EVENT_DROP; +#endif + goto XI_OTHER; + } ev.x = lrint (xev->event_x); ev.y = lrint (xev->event_y); commit edb1d491d968144c4b3a0d0efe0afc22448c4684 Author: Andreas Schwab Date: Thu Dec 23 19:06:13 2021 +0100 * lisp/net/shr.el (shr-expand-url): Also strip trailing whitespace. diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 48590fd675..4a22091d59 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -941,9 +941,11 @@ size, and full-buffer size." shr-base)) (when (zerop (length url)) (setq url nil)) - ;; Strip leading whitespace + ;; Strip leading/trailing whitespace (and url (string-match "\\`\\s-+" url) (setq url (substring url (match-end 0)))) + (and url (string-match "\\s-+\\'" url) + (setq url (substring url 0 (match-beginning 0)))) (cond ((zerop (length url)) (nth 3 base)) ((or (not base) commit 2fa7feca336dd16c57ffef072e0f0da6fffe4c5f Author: Glenn Morris Date: Thu Dec 23 08:34:16 2021 -0800 * doc/misc/Makefile.in (need_emacsver): Add missing members. diff --git a/doc/misc/Makefile.in b/doc/misc/Makefile.in index 8be84e3fad..791cfa89f5 100644 --- a/doc/misc/Makefile.in +++ b/doc/misc/Makefile.in @@ -185,7 +185,8 @@ $(foreach ifile,$(filter-out info.info,$(INFO_TARGETS)),$(eval $(call info_templ ## Extra dependencies. -need_emacsver = calc cl dired-x efaq efaq-w32 erc ido reftex woman +## FIXME Updating this list manually is unreliable. +need_emacsver = calc cl dired-x efaq efaq-w32 erc forms ido newsticker reftex remember woman need_emacsver_prefix = $(addprefix ${buildinfodir}/,${need_emacsver}) $(need_emacsver_prefix:=.info) $(need_emacsver:=.dvi) $(need_emacsver:=.pdf) $(need_emacsver:=.html) : ${emacsdir}/emacsver.texi commit f9d518bc2f333e03d5e7c4e935b08fbe19f33c5b Author: Po Lu Date: Thu Dec 23 21:35:46 2021 +0800 Make precision scrolling also work on various bars * lisp/pixel-scroll.el (pixel-scroll-precision-mode-map): Define keys for various kinds of bars. diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el index 975c5133f1..d3b4500023 100644 --- a/lisp/pixel-scroll.el +++ b/lisp/pixel-scroll.el @@ -99,6 +99,15 @@ is always with pixel resolution.") (define-key map [wheel-down] #'pixel-scroll-precision) (define-key map [wheel-up] #'pixel-scroll-precision) (define-key map [touch-end] #'pixel-scroll-start-momentum) + (define-key map [mode-line wheel-down] #'pixel-scroll-precision) + (define-key map [mode-line wheel-up] #'pixel-scroll-precision) + (define-key map [mode-line touch-end] #'pixel-scroll-start-momentum) + (define-key map [header-line wheel-down] #'pixel-scroll-precision) + (define-key map [header-line wheel-up] #'pixel-scroll-precision) + (define-key map [header-line touch-end] #'pixel-scroll-start-momentum) + (define-key map [vertical-scroll-bar wheel-down] #'pixel-scroll-precision) + (define-key map [vertical-scroll-bar wheel-up] #'pixel-scroll-precision) + (define-key map [vertical-scroll-bar touch-end] #'pixel-scroll-start-momentum) map) "The key map used by `pixel-scroll-precision-mode'.") commit 03dc54ba7fbd83e93b6841acbed14ae8ce319b7c Author: Po Lu Date: Thu Dec 23 21:26:59 2021 +0800 Fix precision scrolling down for multi-line display strings * lisp/pixel-scroll.el (pixel-scroll-precision-scroll-down-page): Make sure Y delta is appropriate before deciding on next-pos. diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el index 223bc7fbc4..975c5133f1 100644 --- a/lisp/pixel-scroll.el +++ b/lisp/pixel-scroll.el @@ -461,6 +461,11 @@ the height of the current window." (when (zerop (vertical-motion (1+ scroll-margin))) (set-window-start nil desired-start) (signal 'end-of-buffer nil)) + (while (when-let ((posn (posn-at-point))) + (< (cdr (posn-x-y posn)) delta)) + (when (zerop (vertical-motion 1)) + (set-window-start nil desired-start) + (signal 'end-of-buffer nil))) (point))) (scroll-preserve-screen-position nil) (auto-window-vscroll nil)) commit 902f343c18e1894cd5a0e702151fa457651fe0b1 Author: Po Lu Date: Thu Dec 23 19:00:30 2021 +0800 Set start to desired start when pixel scrolling to end of buffer * lisp/pixel-scroll.el (pixel-scroll-precision-scroll-down-page): Set start to desired start when point cannot be moved further down. diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el index 4aae166f2e..223bc7fbc4 100644 --- a/lisp/pixel-scroll.el +++ b/lisp/pixel-scroll.el @@ -459,6 +459,7 @@ the height of the current window." (next-pos (save-excursion (goto-char desired-start) (when (zerop (vertical-motion (1+ scroll-margin))) + (set-window-start nil desired-start) (signal 'end-of-buffer nil)) (point))) (scroll-preserve-screen-position nil) commit d54d8a88e9a2f12b69e820e9bb89e304521bc8c7 Author: Po Lu Date: Thu Dec 23 09:12:02 2021 +0800 Allow window-text-pixel-size to measure pixels around a position * doc/lispref/display.texi (Size of Displayed Text): Announce new meaning of `from'. * etc/NEWS: Announce changes. * lisp/pixel-scroll.el (pixel-scroll-precision-scroll-up-page): Use new feature. * src/xdisp.c (window_text_pixel_size): Understand a special format of `from' that specifies the amount of pixels above or below a position. (Fwindow_text_pixel_size): Update doc string. diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 98a15404f9..449a58a3bb 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -2092,17 +2092,27 @@ pixels. @var{window} must be a live window and defaults to the selected one. The return value is a cons of the maximum pixel-width of any text line and the maximum pixel-height of all text lines. This function exists to allow Lisp programs to adjust the dimensions of -@var{window} to the buffer text it needs to display. +@var{window} to the buffer text it needs to display, and for other +similar situations. + +The return value can also optionally (see below) include the buffer +position of the first line whose dimensions were measured. The optional argument @var{from}, if non-@code{nil}, specifies the first text position to consider, and defaults to the minimum accessible position of the buffer. If @var{from} is @code{t}, it stands for the minimum accessible position that is not a newline -character. The optional argument @var{to}, if non-@code{nil}, -specifies the last text position to consider, and defaults to the -maximum accessible position of the buffer. If @var{to} is @code{t}, -it stands for the maximum accessible position that is not a newline -character. +character. If @var{from} is a cons, its @code{car} specifies a buffer +position, and its @code{cdr} specifies the vertical offset in pixels +from that position to the first screen line whose text is to be +measured. (The measurement will start from the visual beginning of +that screen line.) In that case, the return value will instead be a +list of the pixel-width, pixel-height, and the buffer position of the +first line that was measured. The optional argument @var{to}, if +non-@code{nil}, specifies the last text position to consider, and +defaults to the maximum accessible position of the buffer. If +@var{to} is @code{t}, it stands for the maximum accessible position +that is not a newline character. The optional argument @var{x-limit}, if non-@code{nil}, specifies the maximum X coordinate beyond which text should be ignored; it is diff --git a/etc/NEWS b/etc/NEWS index fb5ed74c9a..39fbd8f6b7 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1011,6 +1011,11 @@ This controls whether or not the last screen line of the text being measured will be counted for the purpose of calculating the text dimensions. ++++ +** 'window-text-pixel-size' understands a new meaning of 'from'. +Specifying a cons as the from argument allows to start measuring text +from a specified amount of pixels above or below a position. + ** XDG support *** New function 'xdg-state-home' returns 'XDG_STATE_HOME' environment variable. diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el index fa0185b16e..4aae166f2e 100644 --- a/lisp/pixel-scroll.el +++ b/lisp/pixel-scroll.el @@ -516,22 +516,24 @@ the height of the current window." usable-height)))) (goto-char up-point))) (let ((current-vscroll (window-vscroll nil t))) - (if (<= delta current-vscroll) - (set-window-vscroll nil (- current-vscroll delta) t) - (setq delta (- delta current-vscroll)) - (set-window-vscroll nil 0 t) - (while (> delta 0) - (let ((position (pixel-point-and-height-at-unseen-line))) - (unless (cdr position) - (signal 'beginning-of-buffer nil)) - (set-window-start nil (car position) t) - ;; If the line above is taller than the window height (i.e. there's - ;; a very tall image), keep point on it. - (when (> (cdr position) usable-height) - (goto-char (car position))) - (setq delta (- delta (cdr position))))) - (when (< delta 0) - (set-window-vscroll nil (- delta) t)))))) + (setq delta (- delta current-vscroll)) + (set-window-vscroll nil 0 t) + (when (> delta 0) + (let* ((start (window-start)) + (dims (window-text-pixel-size nil (cons start (- delta)) + start nil nil nil t)) + (height (nth 1 dims)) + (position (nth 2 dims))) + (set-window-start nil position t) + ;; If the line above is taller than the window height (i.e. there's + ;; a very tall image), keep point on it. + (when (> height usable-height) + (goto-char position)) + (when (or (not position) (eq position start)) + (signal 'beginning-of-buffer nil)) + (setq delta (- delta height)))) + (when (< delta 0) + (set-window-vscroll nil (- delta) t))))) (defun pixel-scroll-precision-interpolate (delta) "Interpolate a scroll of DELTA pixels. diff --git a/src/xdisp.c b/src/xdisp.c index 1f896c256e..a6c122aee8 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -10841,8 +10841,7 @@ window_text_pixel_size (Lisp_Object window, Lisp_Object from, Lisp_Object to, ptrdiff_t start, end, bpos; struct text_pos startp; void *itdata = NULL; - int c, max_x = 0, max_y = 0, x = 0, y = 0; - int doff = 0; + int c, max_x = 0, max_y = 0, x = 0, y = 0, vertical_offset = 0, doff = 0; if (NILP (from)) { @@ -10868,6 +10867,13 @@ window_text_pixel_size (Lisp_Object window, Lisp_Object from, Lisp_Object to, break; } } + else if (CONSP (from)) + { + start = clip_to_bounds (BEGV, fix_position (XCAR (from)), ZV); + bpos = CHAR_TO_BYTE (start); + CHECK_FIXNUM (XCDR (from)); + vertical_offset = XFIXNUM (XCDR (from)); + } else { start = clip_to_bounds (BEGV, fix_position (from), ZV); @@ -10914,7 +10920,9 @@ window_text_pixel_size (Lisp_Object window, Lisp_Object from, Lisp_Object to, itdata = bidi_shelve_cache (); start_display (&it, w, startp); + int start_y = it.current_y; + /* It makes no sense to measure dimensions of region of text that crosses the point where bidi reordering changes scan direction. By using unidirectional movement here we at least support the use @@ -10923,13 +10931,50 @@ window_text_pixel_size (Lisp_Object window, Lisp_Object from, Lisp_Object to, same directionality. */ it.bidi_p = false; - /* Start at the beginning of the line containing FROM. Otherwise - IT.current_x will be incorrectly set to zero at some arbitrary - non-zero X coordinate. */ - reseat_at_previous_visible_line_start (&it); - it.current_x = it.hpos = 0; - if (IT_CHARPOS (it) != start) - move_it_to (&it, start, -1, -1, -1, MOVE_TO_POS); + if (vertical_offset != 0) + { + int last_y; + it.current_y = 0; + + move_it_by_lines (&it, 0); + + /* `move_it_vertically_backward' is called by move_it_vertically + to move by a negative value (upwards), but it is not always + guaranteed to leave the iterator at or above the position + given by the offset, which this loop ensures. */ + if (vertical_offset < 0) + { + while (it.current_y > vertical_offset) + { + last_y = it.current_y; + move_it_vertically_backward (&it, + (abs (vertical_offset) + + it.current_y)); + + if (it.current_y == last_y) + break; + } + } + else + { + move_it_vertically (&it, vertical_offset); + } + + it.current_y = (WINDOW_TAB_LINE_HEIGHT (w) + + WINDOW_HEADER_LINE_HEIGHT (w)); + start = clip_to_bounds (BEGV, IT_CHARPOS (it), ZV); + start_y = it.current_y; + } + else + { + /* Start at the beginning of the line containing FROM. Otherwise + IT.current_x will be incorrectly set to zero at some arbitrary + non-zero X coordinate. */ + reseat_at_previous_visible_line_start (&it); + it.current_x = it.hpos = 0; + if (IT_CHARPOS (it) != start) + move_it_to (&it, start, -1, -1, -1, MOVE_TO_POS); + } /* Now move to TO. */ int start_x = it.current_x; @@ -11052,26 +11097,34 @@ window_text_pixel_size (Lisp_Object window, Lisp_Object from, Lisp_Object to, bidi_unshelve_cache (itdata, false); - return Fcons (make_fixnum (x - start_x), make_fixnum (y)); + return (!vertical_offset + ? Fcons (make_fixnum (x - start_x), make_fixnum (y)) + : list3i (x - start_x, y, start)); } DEFUN ("window-text-pixel-size", Fwindow_text_pixel_size, Swindow_text_pixel_size, 0, 7, 0, doc: /* Return the size of the text of WINDOW's buffer in pixels. WINDOW must be a live window and defaults to the selected one. The -return value is a cons of the maximum pixel-width of any text line -and the pixel-height of all the text lines in the accessible portion -of buffer text. +return value is a cons of the maximum pixel-width of any text line and +the pixel-height of all the text lines in the accessible portion of +buffer text. + +If FROM is a cons cell, the return value includes, in addition to the +dimensions, also a third element that provides the buffer position +from which measuring of the text dimensions was actually started. This function exists to allow Lisp programs to adjust the dimensions of WINDOW to the buffer text it needs to display. The optional argument FROM, if non-nil, specifies the first text position to consider, and defaults to the minimum accessible position -of the buffer. If FROM is t, it stands for the minimum accessible -position that starts a non-empty line. TO, if non-nil, specifies the -last text position and defaults to the maximum accessible position of -the buffer. If TO is t, it stands for the maximum accessible position -that ends a non-empty line. +of the buffer. If FROM is a cons, its car specifies a buffer +position, and its cdr specifies the vertical offset in pixels from +that position to the first screen line to be measured. If FROM is t, +it stands for the minimum accessible position that starts a non-empty +line. TO, if non-nil, specifies the last text position and defaults +to the maximum accessible position of the buffer. If TO is t, it +stands for the maximum accessible position that ends a non-empty line. The optional argument X-LIMIT, if non-nil, specifies the maximum X coordinate beyond which the text should be ignored. It is therefore commit 2001ae5898a1e48cae5b138828190ac2cba39b40 Author: Lars Ingebrigtsen Date: Thu Dec 23 11:43:47 2021 +0100 Revert back to using monospaced fonts in the mode line * lisp/faces.el (mode-line-active, mode-line-inactive): Revert back to using monospaced fonts on the mode line (for now). The main remaining usability problem is clicking on the very small "-" characters in "U:--". diff --git a/etc/NEWS b/etc/NEWS index 948dbba261..fb5ed74c9a 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -91,15 +91,6 @@ time. ** 'C-x 8 .' has been moved to 'C-x 8 . .'. This is to open up the 'C-x 8 .' map to bind further characters there. ---- -** The mode line now uses a proportional font by default. -To get the old monospaced mode line back, customize the -'mode-line-active' and 'mode-line-inactive' faces not to inherit from -the 'variable-pitch' face, or add this to your "~/.emacs": - - (set-face-attribute 'mode-line-active nil :inherit 'mode-line) - (set-face-attribute 'mode-line-inactive nil :inherit 'mode-line) - * Changes in Emacs 29.1 diff --git a/lisp/faces.el b/lisp/faces.el index 97579877ef..39ba0f4d1b 100644 --- a/lisp/faces.el +++ b/lisp/faces.el @@ -2630,7 +2630,7 @@ See `mode-line-display' for the face used on mode lines." :group 'basic-faces) (defface mode-line-active - '((t :inherit (mode-line variable-pitch))) + '((t :inherit mode-line)) "Face for the selected mode line. This inherits from the `mode-line' face." :version "29.1" @@ -2639,7 +2639,7 @@ This inherits from the `mode-line' face." (defface mode-line-inactive '((default - :inherit (mode-line variable-pitch)) + :inherit mode-line) (((class color) (min-colors 88) (background light)) :weight light :box (:line-width -1 :color "grey75" :style nil)