commit 3af12cb8f20d93a3fdbebe2e3b987948e8228f03 (HEAD, refs/remotes/origin/master) Merge: b5ac604b15 dbe6a3ecf7 Author: Stefan Kangas Date: Sat Mar 12 06:34:05 2022 +0100 Merge from origin/emacs-28 dbe6a3ecf7 Fix regression in 'custom-prompt-customize-unsaved-options' a9920473f6 Improve documentation of 'map-charset-chars' commit b5ac604b15532db0418f3c2393907daa317f2ca5 Author: Po Lu Date: Sat Mar 12 13:02:28 2022 +0800 Fix some issues with input methods that depend on button state * src/xterm.c (handle_one_xevent): Translate button state before filtering events. diff --git a/src/xterm.c b/src/xterm.c index cf79135497..d831182811 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -12771,6 +12771,19 @@ handle_one_xevent (struct x_display_info *dpyinfo, xkey.time = xev->time; xkey.state = ((xev->mods.effective & ~(1 << 13 | 1 << 14)) | (xev->group.effective << 13)); + + /* Some input methods react differently depending on the + buttons that are pressed. */ + if (xev->buttons.mask_len) + { + if (XIMaskIsSet (xev->buttons.mask, 1)) + xkey.state |= Button1Mask; + if (XIMaskIsSet (xev->buttons.mask, 2)) + xkey.state |= Button2Mask; + if (XIMaskIsSet (xev->buttons.mask, 3)) + xkey.state |= Button3Mask; + } + xkey.keycode = xev->detail; xkey.same_screen = True; @@ -13126,6 +13139,19 @@ handle_one_xevent (struct x_display_info *dpyinfo, xkey.time = xev->time; xkey.state = ((xev->mods.effective & ~(1 << 13 | 1 << 14)) | (xev->group.effective << 13)); + + /* Some input methods react differently depending on the + buttons that are pressed. */ + if (xev->buttons.mask_len) + { + if (XIMaskIsSet (xev->buttons.mask, 1)) + xkey.state |= Button1Mask; + if (XIMaskIsSet (xev->buttons.mask, 2)) + xkey.state |= Button2Mask; + if (XIMaskIsSet (xev->buttons.mask, 3)) + xkey.state |= Button3Mask; + } + xkey.keycode = xev->detail; xkey.same_screen = True; commit d0ff20f2e64d9247a5e0e26ddfd7e185e51d8c58 Author: Po Lu Date: Sat Mar 12 03:16:00 2022 +0000 Fix horizontal scroll bar updating on Haiku * src/haikuterm.c (haiku_set_horizontal_scroll_bar_thumb): Just take portion and position without adjustments. diff --git a/src/haikuterm.c b/src/haikuterm.c index 4ecc738898..cd0dcb0834 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -493,20 +493,19 @@ haiku_set_horizontal_scroll_bar_thumb (struct scroll_bar *bar, int portion, int position, int whole) { void *scroll_bar = bar->scroll_bar; - float shown, top; - int size, value; + double size, value, shown, top; - shown = (float) portion / whole; - top = (float) position / (whole - portion); + shown = (double) portion / whole; + top = (double) position / whole; - size = clip_to_bounds (1, shown * BE_SB_MAX, BE_SB_MAX); - value = clip_to_bounds (0, top * (BE_SB_MAX - size), BE_SB_MAX - size); + size = shown * BE_SB_MAX; + value = top * BE_SB_MAX; if (!bar->dragging) bar->page_size = size; - BView_scroll_bar_update (scroll_bar, shown, BE_SB_MAX, value, - bar->dragging); + BView_scroll_bar_update (scroll_bar, lrint (size), BE_SB_MAX, + ceil (value), bar->dragging); } static struct scroll_bar * commit 37cda51353aef6a775612eb6d167dfb9c20aabc9 Author: Po Lu Date: Sat Mar 12 03:02:03 2022 +0000 Use more reasonable default timeouts in Haiku menu loop * src/haiku_support.cc (BMenu_run): Set default timeout to 10 seconds. diff --git a/src/haiku_support.cc b/src/haiku_support.cc index c95cd6d940..6b33245f64 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -2807,7 +2807,7 @@ BMenu_run (void *menu, int x, int y, next_time = process_pending_signals_function (); if (next_time.tv_nsec < 0) - timeout = 100000; + timeout = 10000000000; else timeout = (next_time.tv_sec * 1000000 + next_time.tv_nsec / 1000); commit 3ba3fdf7aa8637afa4329bc17edfb034ee5c8162 Author: Po Lu Date: Sat Mar 12 02:47:03 2022 +0000 Make C-mouse-3 on scroll bars work on Haiku * src/haiku_support.cc (class EmacsScrollBar): New field `handle_button'. (MouseDown, MouseUp): Pass button events with ControlMask to parent view. diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 07e3ee2bb6..c95cd6d940 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -1563,6 +1563,9 @@ class EmacsScrollBar : public BScrollBar float old_value; scroll_bar_info info; + /* True if button events should be passed to the parent. */ + bool handle_button = false; + EmacsScrollBar (int x, int y, int x1, int y1, bool horizontal_p) : BScrollBar (BRect (x, y, x1, y1), NULL, NULL, 0, 0, horizontal_p ? B_HORIZONTAL : B_VERTICAL) @@ -1703,9 +1706,11 @@ class EmacsScrollBar : public BScrollBar BRegion r; BLooper *looper; BMessage *message; - int32 buttons; + int32 buttons, mods; + BView *parent; looper = Looper (); + message = NULL; if (!looper) GetMouse (&pt, (uint32 *) &buttons, false); @@ -1717,6 +1722,18 @@ class EmacsScrollBar : public BScrollBar GetMouse (&pt, (uint32 *) &buttons, false); } + if (message && (message->FindInt32 ("modifiers", &mods) + == B_OK) + && mods & B_CONTROL_KEY) + { + /* Allow C-mouse-3 to split the window on a scroll bar. */ + handle_button = true; + parent = Parent (); + parent->MouseDown (ConvertToParent (pt)); + + return; + } + if (buttons == B_PRIMARY_MOUSE_BUTTON) { r = ButtonRegionFor (HAIKU_SCROLL_BAR_UP_BUTTON); @@ -1762,6 +1779,17 @@ class EmacsScrollBar : public BScrollBar MouseUp (BPoint pt) { struct haiku_scroll_bar_drag_event rq; + BView *parent; + + if (handle_button) + { + handle_button = false; + parent = Parent (); + parent->MouseUp (ConvertToParent (pt)); + + return; + } + rq.dragging_p = 0; rq.scroll_bar = this; rq.window = Window (); commit b279e1a5ece70c2b1bb1ab32572473d0cb667b52 Author: Po Lu Date: Sat Mar 12 00:46:39 2022 +0000 Slightly improve scrollbar position accounting on Haiku * src/haiku_support.cc (MessageReceived): Use floats for calculating portion and subtract proportion directly. * src/haikuterm.c (haiku_set_scroll_bar_thumb): Take ceiling of value instead of rounding it. diff --git a/src/haiku_support.cc b/src/haiku_support.cc index dcea69bb9a..07e3ee2bb6 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -1578,20 +1578,20 @@ class EmacsScrollBar : public BScrollBar MessageReceived (BMessage *msg) { int32 portion, range; - double proportion; + float proportion; if (msg->what == SCROLL_BAR_UPDATE) { old_value = msg->GetInt32 ("emacs:units", 0); portion = msg->GetInt32 ("emacs:portion", 0); range = msg->GetInt32 ("emacs:range", 0); - proportion = (double) portion / range; + proportion = (float) portion / range; if (!msg->GetBool ("emacs:dragging", false)) { /* Unlike on Motif, PORTION isn't included in the total range of the scroll bar. */ - this->SetRange (0, std::floor ((double) range - (range * proportion))); + this->SetRange (0, range - portion); this->SetValue (old_value); this->SetProportion (proportion); } diff --git a/src/haikuterm.c b/src/haikuterm.c index 119c54b17a..4ecc738898 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -485,7 +485,7 @@ haiku_set_scroll_bar_thumb (struct scroll_bar *bar, int portion, } BView_scroll_bar_update (scroll_bar, lrint (size), - BE_SB_MAX, lrint (value), bar->dragging); + BE_SB_MAX, ceil (value), bar->dragging); } static void commit 0470a4a939772c4bd25123b15f5eadab41f8bee5 Author: Thomas Fitzsimmons Date: Fri Mar 11 18:04:53 2022 -0500 EUDC: Support querying all servers * lisp/net/eudc.el (eudc-expand-try-all): New command. (eudc-expand-inline): Add `try-all-servers' optional argument. Update `eudc-query-with-words' call. (eudc-query-with-words): Add `try-all-servers' optional argument. Move response formatting into main query loop. Query next server if `try-all-servers' is non-nil. (eudc-tail-menu): Add "Expand Inline Query Trying All Servers" menu item. * doc/misc/eudc.texi (Installation): Recommend eudc-expand-try-all. (Emacs-only Configuration): Likewise. (Inline Query Expansion, Inline Query Expansion): Likewise. Document `eudc-expand-try-all'. * etc/NEWS (EUDC): Describe new 'eudc-expand-try-all' command. diff --git a/doc/misc/eudc.texi b/doc/misc/eudc.texi index 7de0bdc180..3b24dfb919 100644 --- a/doc/misc/eudc.texi +++ b/doc/misc/eudc.texi @@ -192,9 +192,9 @@ email composition buffers (@pxref{Inline Query Expansion}) @lisp (with-eval-after-load "message" - (define-key message-mode-map [(control ?c) (tab)] 'eudc-expand-inline)) + (define-key message-mode-map [(control ?c) (tab)] 'eudc-expand-try-all)) (with-eval-after-load "sendmail" - (define-key mail-mode-map [(control ?c) (tab)] 'eudc-expand-inline)) + (define-key mail-mode-map [(control ?c) (tab)] 'eudc-expand-try-all)) @end lisp @menu @@ -281,11 +281,12 @@ LDAP: @vindex message-mode-map @findex eudc-expand-inline +@findex eudc-expand-try-all @vindex eudc-server-hotlist @vindex ldap-host-parameters-alist @lisp (with-eval-after-load "message" - (define-key message-mode-map (kbd "TAB") 'eudc-expand-inline)) + (define-key message-mode-map (kbd "TAB") 'eudc-expand-try-all)) (setopt eudc-server-hotlist '(("" . bbdb) ("ldaps://ldap.gnu.org" . ldap))) @@ -337,11 +338,12 @@ configure EUDC for LDAP: @vindex message-mode-map @findex eudc-expand-inline +@findex eudc-expand-try-all @vindex eudc-server-hotlist @vindex ldap-host-parameters-alist @lisp (with-eval-after-load "message" - (define-key message-mode-map (kbd "TAB") 'eudc-expand-inline)) + (define-key message-mode-map (kbd "TAB") 'eudc-expand-try-all)) (setopt 'eudc-server-hotlist '(("" . bbdb) ("ldaps://ldap.gnu.org" . ldap))) @@ -366,11 +368,12 @@ and the @file{.emacs} expressions become: @vindex message-mode-map @findex eudc-expand-inline +@findex eudc-expand-try-all @vindex eudc-server-hotlist @vindex ldap-host-parameters-alist @lisp (with-eval-after-load "message" - (define-key message-mode-map (kbd "TAB") 'eudc-expand-inline)) + (define-key message-mode-map (kbd "TAB") 'eudc-expand-try-all)) (setopt 'eudc-server-hotlist '(("" . bbdb) ("" . ldap))) (setopt 'ldap-host-parameters-alist @@ -709,19 +712,33 @@ be passed to the program. @node Inline Query Expansion @section Inline Query Expansion -Inline query expansion is a powerful method to get completion from your -directory server. The most common usage is for expanding names to email -addresses in mail message buffers. The expansion is performed by the -command @kbd{M-x eudc-expand-inline} which is available from the -@samp{Expand Inline Query} menu item but can also be conveniently -bound to a key shortcut (@pxref{Installation}). The operation is -controlled by the variables @code{eudc-inline-expansion-format}, -@code{eudc-inline-query-format}, +Inline query expansion is a powerful method to get completion from +your directory servers. The most common usage is for expanding names +to email addresses in mail message buffers. The expansion is +performed by the command @kbd{M-x eudc-expand-try-all} which is +available from the @samp{Expand Inline Query Trying All Servers} menu +item but can also be conveniently bound to a key shortcut +(@pxref{Installation}). The operation is controlled by the variables +@code{eudc-inline-expansion-format}, @code{eudc-inline-query-format}, @code{eudc-expanding-overwrites-query} and @code{eudc-multiple-match-handling-method}. -If the query fails for a server, other servers may be tried successively -until one of them finds a match (@pxref{Multi-server Queries}). +If the query fails for a server, other servers may be tried +successively until one of them finds a match (@pxref{Multi-server +Queries}), or all servers can be tried and all matches returned. + +@deffn Command eudc-expand-try-all try-all-servers-p +Query some or all servers and expand the query string before point. +The query string consists of the buffer substring from the point back +to the preceding comma, colon or beginning of line. +@code{eudc-inline-query-format} controls how individual words are +mapped onto directory attribute names. After querying the server or +servers for the given string, the expansion specified by +@code{eudc-inline-expansion-format} is inserted in the buffer at +point. If multiple matches are available, a selection window is +displayed. If @var{try-all-servers-p} is non-@code{nil} then all +servers are queried. +@end deffn @deffn Command eudc-expand-inline save-query-as-kill-p Query the server and expand the query string before point. The query diff --git a/etc/NEWS b/etc/NEWS index cd3db07e6e..faac1fbc91 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -638,6 +638,14 @@ Rename 'eudc-expansion-overwrites-query' to 'eudc-expansion-save-query-as-kill' to reflect the actual behaviour of the customization variable. ++++ +*** New command 'eudc-expand-try-all'. +This command can be used in place of 'eudc-expand-inline'. It takes a +prefix argument that causes 'eudc-expand-try-all' to return matches +from all servers instead of just the matches from the first server to +return any. This is useful for example, if one wants to search LDAP +for a name that happens to match a contact in one's BBDB. + ** eww/shr +++ diff --git a/lisp/net/eudc.el b/lisp/net/eudc.el index dbba69d110..98d0565c2f 100644 --- a/lisp/net/eudc.el +++ b/lisp/net/eudc.el @@ -741,9 +741,18 @@ If none try N - 1 and so forth." (setq n (1- n))) formats)) +;;;###autoload +(defun eudc-expand-try-all (&optional try-all-servers) + "Wrap `eudc-expand-inline' with a prefix argument. +If TRY-ALL-SERVERS -- the prefix argument when called +interactively -- is non-nil, collect results from all servers. +If TRY-ALL-SERVERS is nil, do not try subsequent servers after +one server returns any match." + (interactive "P") + (eudc-expand-inline (not eudc-expansion-save-query-as-kill) try-all-servers)) ;;;###autoload -(defun eudc-expand-inline (&optional save-query-as-kill) +(defun eudc-expand-inline (&optional save-query-as-kill try-all-servers) "Query the directory server, and expand the query string before point. The query string consists of the buffer substring from the point back to the preceding comma, colon or beginning of line. @@ -765,7 +774,7 @@ see `eudc-inline-expansion-servers'." (point))) (query-words (split-string (buffer-substring-no-properties beg end) "[ \t]+")) - (response-strings (eudc-query-with-words query-words))) + (response-strings (eudc-query-with-words query-words try-all-servers))) (if (null response-strings) (error "No match") @@ -788,7 +797,7 @@ see `eudc-inline-expansion-servers'." (error "There is more than one match for the query")))))) ;;;###autoload -(defun eudc-query-with-words (query-words) +(defun eudc-query-with-words (query-words &optional try-all-servers) "Query the directory server, and return the matching responses. The variable `eudc-inline-query-format' controls how to associate the individual QUERY-WORDS with directory attribute names. @@ -796,7 +805,8 @@ After querying the server for the given string, the expansion specified by `eudc-inline-expansion-format' is applied to the matches before returning them.inserted in the buffer at point. Multiple servers can be tried with the same query until one finds a match, -see `eudc-inline-expansion-servers'." +see `eudc-inline-expansion-servers'. When TRY-ALL-SERVERS is non-nil, +keep collecting results from subsequent servers after the first match." (cond ((eq eudc-inline-expansion-servers 'current-server) (or eudc-server @@ -813,6 +823,7 @@ see `eudc-inline-expansion-servers'." (error "Wrong value for `eudc-inline-expansion-servers': %S" eudc-inline-expansion-servers))) (let* (query-formats + response-strings (eudc-former-server eudc-server) (eudc-former-protocol eudc-protocol) ;; Prepare the list of servers to query @@ -824,7 +835,7 @@ see `eudc-inline-expansion-servers'." (if eudc-server (cons (cons eudc-server eudc-protocol) (delete (cons eudc-server eudc-protocol) - (copy-sequence eudc-server-hotlist))) + (copy-sequence eudc-server-hotlist))) eudc-server-hotlist)) ((eq eudc-inline-expansion-servers 'current-server) (list (cons eudc-server eudc-protocol)))))) @@ -834,46 +845,49 @@ see `eudc-inline-expansion-servers'." (setcdr (nthcdr (1- eudc-max-servers-to-query) servers) nil)) (unwind-protect - (let ((response - (catch 'found - ;; Loop on the servers - (dolist (server servers) - (eudc-set-server (car server) (cdr server) t) - - ;; Determine which formats apply in the query-format list - (setq query-formats - (or - (eudc-extract-n-word-formats eudc-inline-query-format - (length query-words)) - (if (null eudc-protocol-has-default-query-attributes) - '(name)))) - - ;; Loop on query-formats - (while query-formats - (let ((response - (eudc-query - (eudc-format-query query-words (car query-formats)) - (eudc-translate-attribute-list - (cdr eudc-inline-expansion-format))))) - (if response - (throw 'found response))) - (setq query-formats (cdr query-formats)))) - ;; No more servers to try... no match found - nil)) - (response-strings '())) - - ;; Process response through eudc-inline-expansion-format - (dolist (r response) - (let ((response-string - (apply #'format - (car eudc-inline-expansion-format) - (mapcar (lambda (field) - (or (cdr (assq field r)) - "")) - (eudc-translate-attribute-list - (cdr eudc-inline-expansion-format)))))) - (if (> (length response-string) 0) - (push response-string response-strings)))) + (cl-flet + ((run-query + (query-formats) + (let ((response + (eudc-query + (eudc-format-query query-words (car query-formats)) + (eudc-translate-attribute-list + (cdr eudc-inline-expansion-format))))) + (if response + ;; Process response through eudc-inline-expansion-format. + (dolist (r response) + (let ((response-string + (apply #'format + (car eudc-inline-expansion-format) + (mapcar + (lambda (field) + (or (cdr (assq field r)) + "")) + (eudc-translate-attribute-list + (cdr eudc-inline-expansion-format)))))) + (if (> (length response-string) 0) + (push response-string response-strings)) + (when (not try-all-servers) + (throw 'found nil)))))))) + (catch 'found + ;; Loop on the servers. + (dolist (server servers) + (eudc-set-server (car server) (cdr server) t) + + ;; Determine which formats apply in the query-format list. + (setq query-formats + (or + (eudc-extract-n-word-formats eudc-inline-query-format + (length query-words)) + (if (null eudc-protocol-has-default-query-attributes) + '(name)))) + + ;; Loop on query-formats. + (while query-formats + (run-query query-formats) + (setq query-formats (cdr query-formats)))) + ;; No more servers to try... no match found. + nil) response-strings) (or (and (equal eudc-server eudc-former-server) (equal eudc-protocol eudc-former-protocol)) @@ -1053,6 +1067,8 @@ queries the server for the existing fields and displays a corresponding form." `(["---" nil nil] ["Query with Form" eudc-query-form :help "Display a form to query the directory server"] + ["Expand Inline Query Trying All Servers" eudc-expand-try-all + :help "Query all directory servers and expand the query string before point"] ["Expand Inline Query" eudc-expand-inline :help "Query the directory server, and expand the query string before point"] ["Insert Record into BBDB" eudc-insert-record-at-point-into-bbdb commit 190e1fe94bcc1968a1c607093b7e03a2dddaac59 Author: Thomas Fitzsimmons Date: Fri Mar 11 17:40:18 2022 -0500 EUDC: Update save-query-as-kill name and docstring * lisp/net/eudc-vars.el (eudc-server): Fix quoting for checkdoc. (eudc-expansion-save-query-as-kill): Rename from `eudc-expansion-overwrites-query'. Define obsolete variable alias. Update comment and documentation. * lisp/net/eudc.el (eudc-expand-inline): Rename `replace' argument to `save-query-as-kill'. Update argument documentation. * doc/misc/eudc.texi (Inline Query Expansion): Rename `eudc-expand-inline' argument. * etc/NEWS (EUDC): Document `eudc-expansion-overwrites-query' rename to `eudc-expansion-save-query-as-kill'. diff --git a/doc/misc/eudc.texi b/doc/misc/eudc.texi index 7c37ae5505..7de0bdc180 100644 --- a/doc/misc/eudc.texi +++ b/doc/misc/eudc.texi @@ -723,17 +723,19 @@ controlled by the variables @code{eudc-inline-expansion-format}, If the query fails for a server, other servers may be tried successively until one of them finds a match (@pxref{Multi-server Queries}). -@deffn Command eudc-expand-inline replace-p +@deffn Command eudc-expand-inline save-query-as-kill-p Query the server and expand the query string before point. The query string consists of the buffer substring from the point back to the -preceding comma, colon or beginning of -line. @code{eudc-inline-query-format} controls how individual words -are mapped onto directory attribute names. After querying the server -for the given string, the expansion specified by +preceding comma, colon or beginning of line. +@code{eudc-inline-query-format} controls how individual words are +mapped onto directory attribute names. After querying the server for +the given string, the expansion specified by @code{eudc-inline-expansion-format} is inserted in the buffer at -point. If @var{replace-p} is @code{t} then this expansion replaces the -query string in the buffer. If @code{eudc-expanding-overwrites-query} -is non-@code{nil} then the meaning of @var{replace-p} is negated. +point. If multiple matches are available, a selection window is +displayed. If @var{save-query-as-kill-p} is @code{t} then the query +string is saved to the kill ring. If +@code{eudc-expansion-save-query-as-kill} is non-@code{nil} then the +meaning of @var{save-query-as-kill-p} is negated. @end deffn @defvar eudc-inline-query-format diff --git a/etc/NEWS b/etc/NEWS index 80cf0a2f72..cd3db07e6e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -630,6 +630,14 @@ header before sending a message. *** 'texinfo-mode' now has a specialised 'narrow-to-defun' definition. It narrows to the current node. +** EUDC + ++++ +*** 'eudc-expansion-overwrites-query' to 'eudc-expansion-save-query-as-kill'. +Rename 'eudc-expansion-overwrites-query' to +'eudc-expansion-save-query-as-kill' to reflect the actual behaviour of +the customization variable. + ** eww/shr +++ diff --git a/lisp/net/eudc-vars.el b/lisp/net/eudc-vars.el index 3122b26cd8..997b9e30fd 100644 --- a/lisp/net/eudc-vars.el +++ b/lisp/net/eudc-vars.el @@ -42,7 +42,7 @@ A port number may be specified by appending a colon and a number to the name of the server. Use `localhost' if the directory server resides on your computer (BBDB backend). -To specify multiple servers, customize eudc-server-hotlist +To specify multiple servers, customize `eudc-server-hotlist' instead." :type '(choice (string :tag "Server") (const :tag "None" nil))) @@ -179,10 +179,15 @@ must be set in a protocol/server-local fashion, see `eudc-server-set' and (symbol :menu-tag "Other" :tag "Attribute name")))) :version "25.1") -;; Default to nil so that the most common use of eudc-expand-inline, -;; where replace is nil, does not affect the kill ring. -(defcustom eudc-expansion-overwrites-query nil - "If non-nil, expanding a query overwrites the query string." +(define-obsolete-variable-alias + 'eudc-expansion-overwrites-query + 'eudc-expansion-save-query-as-kill + "29.1") + +;; Default to nil so that the most common use of `eudc-expand-inline', +;; where `save-query-as-kill' is nil, does not affect the kill ring. +(defcustom eudc-expansion-save-query-as-kill nil + "If non-nil, expansion saves the query string to the kill ring." :type 'boolean :version "25.1") diff --git a/lisp/net/eudc.el b/lisp/net/eudc.el index 6831c4ffe3..dbba69d110 100644 --- a/lisp/net/eudc.el +++ b/lisp/net/eudc.el @@ -743,7 +743,7 @@ If none try N - 1 and so forth." ;;;###autoload -(defun eudc-expand-inline (&optional replace) +(defun eudc-expand-inline (&optional save-query-as-kill) "Query the directory server, and expand the query string before point. The query string consists of the buffer substring from the point back to the preceding comma, colon or beginning of line. @@ -751,8 +751,9 @@ The variable `eudc-inline-query-format' controls how to associate the individual inline query words with directory attribute names. After querying the server for the given string, the expansion specified by `eudc-inline-expansion-format' is inserted in the buffer at point. -If REPLACE is non-nil, then this expansion replaces the name in the buffer. -`eudc-expansion-overwrites-query' being non-nil inverts the meaning of REPLACE. +If SAVE-QUERY-AS-KILL is non-nil, then save the pre-expansion +text to the kill ring. `eudc-expansion-save-query-as-kill' being +non-nil inverts the meaning of SAVE-QUERY-AS-KILL. Multiple servers can be tried with the same query until one finds a match, see `eudc-inline-expansion-servers'." (interactive) @@ -769,8 +770,8 @@ see `eudc-inline-expansion-servers'." (error "No match") (if (or - (and replace (not eudc-expansion-overwrites-query)) - (and (not replace) eudc-expansion-overwrites-query)) + (and save-query-as-kill (not eudc-expansion-save-query-as-kill)) + (and (not save-query-as-kill) eudc-expansion-save-query-as-kill)) (kill-ring-save beg end)) (cond ((or (= (length response-strings) 1) commit 610d85782bcf71a7821a2019055e7b411e28caec Author: Po Lu Date: Fri Mar 11 12:41:30 2022 +0000 Fix a crash inside Haiku popup menus * src/haiku_support.cc (BMenu_run): Handle B_WOULD_BLOCK from wait_for_objects loop. diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 9b85cd6e0a..dcea69bb9a 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -2787,7 +2787,8 @@ BMenu_run (void *menu, int x, int y, if ((stat = wait_for_objects_etc ((object_wait_info *) &infos, 3, B_RELATIVE_TIMEOUT, timeout)) < B_OK) { - if (stat == B_INTERRUPTED || stat == B_TIMED_OUT) + if (stat == B_INTERRUPTED || stat == B_TIMED_OUT + || stat == B_WOULD_BLOCK) continue; else gui_abort ("Failed to wait for popup"); commit 0dcc9fdc17773eb9154c43081e82c5bfb728e30e Author: Po Lu Date: Fri Mar 11 20:11:57 2022 +0800 Fix initial values of scroll bar foreground and background on GTK 3 * src/gtkutil.c (xg_create_frame_widgets): Stop creating scrollbar stylesheet providers. * src/xfns.c (Fx_create_frame): Create scroll bar stylesheet providers here instead. (x_set_scroll_bar_background): (x_set_scroll_bar_foreground): Ignore tooltip frames. diff --git a/src/gtkutil.c b/src/gtkutil.c index f488b0ff75..fd32dc15bf 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -1631,14 +1631,6 @@ xg_create_frame_widgets (struct frame *f) G_CALLBACK (delete_cb), f); #endif -#if defined HAVE_GTK3 && !defined HAVE_PGTK - /* On PGTK this is done in Fx_create_frame. */ - FRAME_OUTPUT_DATA (f)->scrollbar_background_css_provider - = gtk_css_provider_new (); - FRAME_OUTPUT_DATA (f)->scrollbar_foreground_css_provider - = gtk_css_provider_new (); -#endif - /* Convert our geometry parameters into a geometry string and specify it. GTK will itself handle calculating the real position this way. */ diff --git a/src/xfns.c b/src/xfns.c index 65f3b5097c..a1d6fd29df 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -1970,22 +1970,25 @@ x_set_scroll_bar_foreground (struct frame *f, Lisp_Object value, Lisp_Object old } #ifdef HAVE_GTK3 - if (pixel != -1) + if (!FRAME_TOOLTIP_P (f)) { - color.pixel = pixel; + if (pixel != -1) + { + color.pixel = pixel; - XQueryColor (FRAME_X_DISPLAY (f), - FRAME_X_COLORMAP (f), - &color); + XQueryColor (FRAME_X_DISPLAY (f), + FRAME_X_COLORMAP (f), + &color); - sprintf (css, "scrollbar slider { background-color: #%02x%02x%02x; }", - color.red >> 8, color.green >> 8, color.blue >> 8); - gtk_css_provider_load_from_data (FRAME_X_OUTPUT (f)->scrollbar_foreground_css_provider, - css, -1, NULL); + sprintf (css, "scrollbar slider { background-color: #%02x%02x%02x; }", + color.red >> 8, color.green >> 8, color.blue >> 8); + gtk_css_provider_load_from_data (FRAME_X_OUTPUT (f)->scrollbar_foreground_css_provider, + css, -1, NULL); + } + else + gtk_css_provider_load_from_data (FRAME_X_OUTPUT (f)->scrollbar_foreground_css_provider, + "", -1, NULL); } - else - gtk_css_provider_load_from_data (FRAME_X_OUTPUT (f)->scrollbar_foreground_css_provider, - "", -1, NULL); #endif } @@ -2040,22 +2043,25 @@ x_set_scroll_bar_background (struct frame *f, Lisp_Object value, Lisp_Object old } #ifdef HAVE_GTK3 - if (pixel != -1) - { - color.pixel = pixel; + if (!FRAME_TOOLTIP_P (f)) + { + if (pixel != -1) + { + color.pixel = pixel; - XQueryColor (FRAME_X_DISPLAY (f), - FRAME_X_COLORMAP (f), - &color); + XQueryColor (FRAME_X_DISPLAY (f), + FRAME_X_COLORMAP (f), + &color); - sprintf (css, "scrollbar trough { background-color: #%02x%02x%02x; }", - color.red >> 8, color.green >> 8, color.blue >> 8); - gtk_css_provider_load_from_data (FRAME_X_OUTPUT (f)->scrollbar_background_css_provider, - css, -1, NULL); - } - else - gtk_css_provider_load_from_data (FRAME_X_OUTPUT (f)->scrollbar_background_css_provider, - "", -1, NULL); + sprintf (css, "scrollbar trough { background-color: #%02x%02x%02x; }", + color.red >> 8, color.green >> 8, color.blue >> 8); + gtk_css_provider_load_from_data (FRAME_X_OUTPUT (f)->scrollbar_background_css_provider, + css, -1, NULL); + } + else + gtk_css_provider_load_from_data (FRAME_X_OUTPUT (f)->scrollbar_background_css_provider, + "", -1, NULL); + } #endif } @@ -4759,6 +4765,13 @@ This function is an internal primitive--use `make-frame' instead. */) gui_default_parameter (f, parms, Qno_special_glyphs, Qnil, NULL, NULL, RES_TYPE_BOOLEAN); +#ifdef HAVE_GTK3 + FRAME_OUTPUT_DATA (f)->scrollbar_background_css_provider + = gtk_css_provider_new (); + FRAME_OUTPUT_DATA (f)->scrollbar_foreground_css_provider + = gtk_css_provider_new (); +#endif + x_default_scroll_bar_color_parameter (f, parms, Qscroll_bar_foreground, "scrollBarForeground", "ScrollBarForeground", true); commit 7ad1df5e1684532efeec435be4ac7fc76affc814 Author: Po Lu Date: Fri Mar 11 20:07:52 2022 +0800 Implement customization of scroll bar colors on GTK 3 * src/gtkutil.c (xg_create_frame_widgets): Create CSS providers for scroll bars. (xg_finish_scroll_bar_creation): Attach created CSS providers. * src/xfns.c (x_set_scroll_bar_foreground): (x_set_scroll_bar_background): Put appropriate content into CSS providers. * src/xterm.c (x_free_frame_resources): Free CSS providers. * src/xterm.h (struct x_output): New fields for scroll bar stylesheet providers. diff --git a/src/gtkutil.c b/src/gtkutil.c index 1b4ecaf949..f488b0ff75 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -1612,10 +1612,7 @@ xg_create_frame_widgets (struct frame *f) with regular X drawing primitives, so from a GTK/GDK point of view, the widget is totally blank. When an expose comes, this will make the widget blank, and then Emacs redraws it. This flickers - a lot, so we turn off double buffering. - FIXME: gtk_widget_set_double_buffered is deprecated and might stop - working in the future. We need to migrate away from combining - X and GTK+ drawing to a pure GTK+ build. */ + a lot, so we turn off double buffering. */ #ifndef HAVE_PGTK gtk_widget_set_double_buffered (wfixed, FALSE); @@ -1634,6 +1631,14 @@ xg_create_frame_widgets (struct frame *f) G_CALLBACK (delete_cb), f); #endif +#if defined HAVE_GTK3 && !defined HAVE_PGTK + /* On PGTK this is done in Fx_create_frame. */ + FRAME_OUTPUT_DATA (f)->scrollbar_background_css_provider + = gtk_css_provider_new (); + FRAME_OUTPUT_DATA (f)->scrollbar_foreground_css_provider + = gtk_css_provider_new (); +#endif + /* Convert our geometry parameters into a geometry string and specify it. GTK will itself handle calculating the real position this way. */ @@ -4448,6 +4453,10 @@ xg_finish_scroll_bar_creation (struct frame *f, const char *scroll_bar_name) { GtkWidget *webox = gtk_event_box_new (); +#ifdef HAVE_GTK3 + GtkCssProvider *foreground_provider; + GtkCssProvider *background_provider; +#endif gtk_widget_set_name (wscroll, scroll_bar_name); #ifndef HAVE_GTK3 @@ -4496,15 +4505,14 @@ xg_finish_scroll_bar_creation (struct frame *f, /* Set the cursor to an arrow. */ xg_set_cursor (webox, FRAME_DISPLAY_INFO (f)->xg_cursor); -#ifdef HAVE_PGTK +#ifdef HAVE_GTK3 GtkStyleContext *ctxt = gtk_widget_get_style_context (wscroll); - gtk_style_context_add_provider (ctxt, - GTK_STYLE_PROVIDER (FRAME_OUTPUT_DATA (f)-> - scrollbar_foreground_css_provider), + foreground_provider = FRAME_OUTPUT_DATA (f)->scrollbar_foreground_css_provider; + background_provider = FRAME_OUTPUT_DATA (f)->scrollbar_background_css_provider; + + gtk_style_context_add_provider (ctxt, GTK_STYLE_PROVIDER (foreground_provider), GTK_STYLE_PROVIDER_PRIORITY_USER); - gtk_style_context_add_provider (ctxt, - GTK_STYLE_PROVIDER (FRAME_OUTPUT_DATA (f)-> - scrollbar_background_css_provider), + gtk_style_context_add_provider (ctxt, GTK_STYLE_PROVIDER (background_provider), GTK_STYLE_PROVIDER_PRIORITY_USER); #endif diff --git a/src/xfns.c b/src/xfns.c index a3236efbcc..65f3b5097c 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -1943,6 +1943,10 @@ static void x_set_scroll_bar_foreground (struct frame *f, Lisp_Object value, Lisp_Object oldval) { unsigned long pixel; +#ifdef HAVE_GTK3 + XColor color; + char css[64]; +#endif if (STRINGP (value)) pixel = x_decode_color (f, value, BLACK_PIX_DEFAULT (f)); @@ -1964,6 +1968,25 @@ x_set_scroll_bar_foreground (struct frame *f, Lisp_Object value, Lisp_Object old update_face_from_frame_parameter (f, Qscroll_bar_foreground, value); redraw_frame (f); } + +#ifdef HAVE_GTK3 + if (pixel != -1) + { + color.pixel = pixel; + + XQueryColor (FRAME_X_DISPLAY (f), + FRAME_X_COLORMAP (f), + &color); + + sprintf (css, "scrollbar slider { background-color: #%02x%02x%02x; }", + color.red >> 8, color.green >> 8, color.blue >> 8); + gtk_css_provider_load_from_data (FRAME_X_OUTPUT (f)->scrollbar_foreground_css_provider, + css, -1, NULL); + } + else + gtk_css_provider_load_from_data (FRAME_X_OUTPUT (f)->scrollbar_foreground_css_provider, + "", -1, NULL); +#endif } @@ -1976,6 +1999,10 @@ static void x_set_scroll_bar_background (struct frame *f, Lisp_Object value, Lisp_Object oldval) { unsigned long pixel; +#ifdef HAVE_GTK3 + XColor color; + char css[64]; +#endif if (STRINGP (value)) pixel = x_decode_color (f, value, WHITE_PIX_DEFAULT (f)); @@ -2011,6 +2038,25 @@ x_set_scroll_bar_background (struct frame *f, Lisp_Object value, Lisp_Object old update_face_from_frame_parameter (f, Qscroll_bar_background, value); redraw_frame (f); } + +#ifdef HAVE_GTK3 + if (pixel != -1) + { + color.pixel = pixel; + + XQueryColor (FRAME_X_DISPLAY (f), + FRAME_X_COLORMAP (f), + &color); + + sprintf (css, "scrollbar trough { background-color: #%02x%02x%02x; }", + color.red >> 8, color.green >> 8, color.blue >> 8); + gtk_css_provider_load_from_data (FRAME_X_OUTPUT (f)->scrollbar_background_css_provider, + css, -1, NULL); + } + else + gtk_css_provider_load_from_data (FRAME_X_OUTPUT (f)->scrollbar_background_css_provider, + "", -1, NULL); +#endif } diff --git a/src/xterm.c b/src/xterm.c index 2adf70b829..cf79135497 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -16579,6 +16579,14 @@ x_free_frame_resources (struct frame *f) XFlush (FRAME_X_DISPLAY (f)); } +#ifdef HAVE_GTK3 + if (FRAME_OUTPUT_DATA (f)->scrollbar_background_css_provider) + g_object_unref (FRAME_OUTPUT_DATA (f)->scrollbar_background_css_provider); + + if (FRAME_OUTPUT_DATA (f)->scrollbar_foreground_css_provider) + g_object_unref (FRAME_OUTPUT_DATA (f)->scrollbar_foreground_css_provider); +#endif + xfree (f->output_data.x->saved_menu_event); xfree (f->output_data.x); f->output_data.x = NULL; diff --git a/src/xterm.h b/src/xterm.h index 4875eabafe..5b199cab6b 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -758,6 +758,13 @@ struct x_output GtkWindow *ttip_window; GtkIMContext *im_context; + +#ifdef HAVE_GTK3 + /* The CSS providers used for scroll bar foreground and background + colors. */ + GtkCssProvider *scrollbar_foreground_css_provider; + GtkCssProvider *scrollbar_background_css_provider; +#endif #endif /* USE_GTK */ /* If >=0, a bitmap index. The indicated bitmap is used for the commit 92ebfe7da4af5c60d33538d3526ef06d2a0142c4 Author: Po Lu Date: Fri Mar 11 19:38:45 2022 +0800 * src/frame.c (scroll_bar_adjust_thumb_portion_p): Adjust doc string. diff --git a/src/frame.c b/src/frame.c index b3990ae2aa..0ec7057db2 100644 --- a/src/frame.c +++ b/src/frame.c @@ -6270,7 +6270,7 @@ Setting this variable does not affect existing frames, only new ones. */); DEFVAR_BOOL ("scroll-bar-adjust-thumb-portion", scroll_bar_adjust_thumb_portion_p, - doc: /* Adjust thumb for overscrolling for Gtk+ and MOTIF. + doc: /* Adjust scroll bars for overscrolling for Gtk+, Motif and Haiku. Non-nil means adjust the thumb in the scroll bar so it can be dragged downwards even if the end of the buffer is shown (i.e. overscrolling). Set to nil if you want the thumb to be at the bottom when the end of the buffer commit fc987de94b1aaaf25391a3cc2b7fffdf5e35dccf Author: Po Lu Date: Fri Mar 11 10:44:33 2022 +0000 Improve scroll bar treatment on Haiku * src/haiku_support.cc (MessageReceived): Subtract portion from range of scroll bar. * src/haikuterm.c (BE_SB_MAX): Adjust values for better rounding. (haiku_set_scroll_bar_thumb): Round values instead of truncating them. diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 6f5196dc1c..9b85cd6e0a 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -1578,18 +1578,22 @@ class EmacsScrollBar : public BScrollBar MessageReceived (BMessage *msg) { int32 portion, range; + double proportion; if (msg->what == SCROLL_BAR_UPDATE) { old_value = msg->GetInt32 ("emacs:units", 0); portion = msg->GetInt32 ("emacs:portion", 0); range = msg->GetInt32 ("emacs:range", 0); + proportion = (double) portion / range; if (!msg->GetBool ("emacs:dragging", false)) { - this->SetRange (0, range); + /* Unlike on Motif, PORTION isn't included in the total + range of the scroll bar. */ + this->SetRange (0, std::floor ((double) range - (range * proportion))); this->SetValue (old_value); - this->SetProportion ((float) portion / range); + this->SetProportion (proportion); } } diff --git a/src/haikuterm.c b/src/haikuterm.c index a7b971f2c1..119c54b17a 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -41,7 +41,7 @@ along with GNU Emacs. If not, see . */ #endif /* Minimum and maximum values used for Haiku scroll bars. */ -#define BE_SB_MAX 10000000 +#define BE_SB_MAX 12000000 struct haiku_display_info *x_display_list = NULL; extern frame_parm_handler haiku_frame_parm_handlers[]; @@ -440,8 +440,7 @@ haiku_set_scroll_bar_thumb (struct scroll_bar *bar, int portion, int position, int whole) { void *scroll_bar = bar->scroll_bar; - float top, shown; - int size, value; + double top, shown, size, value; if (scroll_bar_adjust_thumb_portion_p) { @@ -461,8 +460,8 @@ haiku_set_scroll_bar_thumb (struct scroll_bar *bar, int portion, top = 0, shown = 1; else { - top = (float) position / whole; - shown = (float) portion / whole; + top = (double) position / whole; + shown = (double) portion / whole; } /* Slider size. Must be in the range [1 .. MAX - MIN] where MAX @@ -481,12 +480,12 @@ haiku_set_scroll_bar_thumb (struct scroll_bar *bar, int portion, { bar->page_size = 0; - size = (((float) portion / whole) * BE_SB_MAX); - value = (((float) position / whole) * BE_SB_MAX); + size = (((double) portion / whole) * BE_SB_MAX); + value = (((double) position / whole) * BE_SB_MAX); } - BView_scroll_bar_update (scroll_bar, size, BE_SB_MAX, value, - bar->dragging); + BView_scroll_bar_update (scroll_bar, lrint (size), + BE_SB_MAX, lrint (value), bar->dragging); } static void commit 88d474308e2a0b4a6cac2714135f6bbcae689ed4 Author: Po Lu Date: Fri Mar 11 08:56:54 2022 +0000 Fix inconsistent thumb position on Haiku scroll bars * src/haikuterm.c (haiku_set_scroll_bar_thumb): If scroll_bar_adjust_thumb_portion is nil, directly calculate thumb portions without setting page_size. diff --git a/src/haikuterm.c b/src/haikuterm.c index b100952f11..a7b971f2c1 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -456,27 +456,34 @@ haiku_set_scroll_bar_thumb (struct scroll_bar *bar, int portion, /* When the thumb is at the bottom, position == whole. So we need to increase `whole' to make space for the thumb. */ whole += portion; - } - if (whole <= 0) - top = 0, shown = 1; - else - { - top = (float) position / whole; - shown = (float) portion / whole; - } + if (whole <= 0) + top = 0, shown = 1; + else + { + top = (float) position / whole; + shown = (float) portion / whole; + } - /* Slider size. Must be in the range [1 .. MAX - MIN] where MAX - is the scroll bar's maximum and MIN is the scroll bar's minimum - value. */ - size = clip_to_bounds (1, shown * BE_SB_MAX, BE_SB_MAX); + /* Slider size. Must be in the range [1 .. MAX - MIN] where MAX + is the scroll bar's maximum and MIN is the scroll bar's minimum + value. */ + size = clip_to_bounds (1, shown * BE_SB_MAX, BE_SB_MAX); - /* Position. Must be in the range [MIN .. MAX - SLIDER_SIZE]. */ - value = top * BE_SB_MAX; - value = min (value, BE_SB_MAX - size); + /* Position. Must be in the range [MIN .. MAX - SLIDER_SIZE]. */ + value = top * BE_SB_MAX; + value = min (value, BE_SB_MAX - size); - if (!bar->dragging) - bar->page_size = size; + if (!bar->dragging) + bar->page_size = size; + } + else + { + bar->page_size = 0; + + size = (((float) portion / whole) * BE_SB_MAX); + value = (((float) position / whole) * BE_SB_MAX); + } BView_scroll_bar_update (scroll_bar, size, BE_SB_MAX, value, bar->dragging); commit 61a038bec0fe34a81531b38ebf0a2cb5ece9b789 Author: Po Lu Date: Fri Mar 11 16:36:11 2022 +0800 Handle Wayland displays correctly in browse-url * lisp/net/browse-url.el (browse-url-process-environment): Use WAYLAND_DISPLAY as the display environment variable on PGTK. (bug#54333) diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index 6d28e318ff..776f774172 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -970,7 +970,13 @@ non-nil, or the same display as Emacs if different from the current environment, otherwise just use the current environment." (let ((display (or browse-url-browser-display (browse-url-emacs-display)))) (if display - (cons (concat "DISPLAY=" display) process-environment) + (cons (concat (if (and (eq window-system 'pgtk) + (equal (pgtk-backend-display-class) + "GdkWaylandDisplay")) + "WAYLAND_DISPLAY=" + "DISPLAY=") + display) + process-environment) process-environment))) (defun browse-url-emacs-display () commit dbe6a3ecf74536cbfb7ca59630b48020ae4e732a (refs/remotes/origin/emacs-28) Author: Eli Zaretskii Date: Thu Mar 10 20:26:13 2022 +0200 Fix regression in 'custom-prompt-customize-unsaved-options' * lisp/cus-edit.el (custom-prompt-customize-unsaved-options): Don't depend on the value returned by 'customize-unsaved'. Fix the doc string. Patch by Sebastian Miele . (Bug#54329) diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index c2ddaeb7b1..fd42c542b4 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el @@ -1531,12 +1531,12 @@ If TYPE is `groups', include only groups." ;;;###autoload (defun custom-prompt-customize-unsaved-options () "Prompt user to customize any unsaved customization options. -Return non-nil if user chooses to customize, for use in +Return nil if user chooses to customize, for use in `kill-emacs-query-functions'." (not (and (custom-unsaved-options) - (yes-or-no-p "Some customized options have not been saved; Examine? ") - (customize-unsaved) - t))) + (yes-or-no-p + "Some customized options have not been saved; Examine? ") + (progn (customize-unsaved) t)))) ;;; Buffer. commit a9920473f68ce20fe95f67a4941ff3c1fb274f2a Author: Eli Zaretskii Date: Thu Mar 10 09:29:29 2022 +0200 Improve documentation of 'map-charset-chars' * doc/lispref/nonascii.texi (Character Sets): * src/charset.c (Fmap_charset_chars): Clarify the codepoint issue in using 'map-charset-chars'. diff --git a/doc/lispref/nonascii.texi b/doc/lispref/nonascii.texi index f495910fcd..d7d25dc36a 100644 --- a/doc/lispref/nonascii.texi +++ b/doc/lispref/nonascii.texi @@ -855,15 +855,24 @@ function to all or part of the characters in a charset: Call @var{function} for characters in @var{charset}. @var{function} is called with two arguments. The first one is a cons cell @code{(@var{from} . @var{to})}, where @var{from} and @var{to} -indicate a range of characters contained in charset. The second -argument passed to @var{function} is @var{arg}. +indicate a range of characters contained in @var{charset}. The second +argument passed to @var{function} is @var{arg}, or @code{nil} if +@var{arg} is omitted. By default, the range of codepoints passed to @var{function} includes all the characters in @var{charset}, but optional arguments @var{from-code} and @var{to-code} limit that to the range of characters between these two codepoints of @var{charset}. If either of them is @code{nil}, it defaults to the first or last codepoint of -@var{charset}, respectively. +@var{charset}, respectively. Note that @var{from-code} and +@var{to-code} are @var{charset}'s codepoints, not the Emacs codes of +characters; by contrast, the values @var{from} and @var{to} in the +cons cell passed to @var{function} @emph{are} Emacs character codes. +Those Emacs character codes are either Unicode code points, or Emacs +internal code points that extend Unicode and are beyond the Unicode +range of characters @code{0..#x10FFFF} (@pxref{Text Representations}). +The latter happens rarely, with legacy CJK charsets for codepoints of +@var{charset} which specify characters not yet unified with Unicode. @end defun @node Scanning Charsets diff --git a/src/charset.c b/src/charset.c index dec9d56df2..b9e1584083 100644 --- a/src/charset.c +++ b/src/charset.c @@ -793,16 +793,21 @@ map_charset_chars (void (*c_function)(Lisp_Object, Lisp_Object), Lisp_Object fun DEFUN ("map-charset-chars", Fmap_charset_chars, Smap_charset_chars, 2, 5, 0, doc: /* Call FUNCTION for all characters in CHARSET. -FUNCTION is called with an argument RANGE and the optional 3rd -argument ARG. - -RANGE is a cons (FROM . TO), where FROM and TO indicate a range of -characters contained in CHARSET. - -The optional 4th and 5th arguments FROM-CODE and TO-CODE specify the -range of code points (in CHARSET) of target characters. Note that -these are not character codes, but code points in CHARSET; for the -difference see `decode-char' and `list-charset-chars'. */) +Optional 3rd argument ARG is an additional argument to be passed +to FUNCTION, see below. +Optional 4th and 5th arguments FROM-CODE and TO-CODE specify the +range of code points (in CHARSET) of target characters on which to +map the FUNCTION. Note that these are not character codes, but code +points of CHARSET; for the difference see `decode-char' and +`list-charset-chars'. If FROM-CODE is nil or imitted, it stands for +the first code point of CHARSET; if TO-CODE is nil or omitted, it +stands for the last code point of CHARSET. + +FUNCTION will be called with two arguments: RANGE and ARG. +RANGE is a cons (FROM . TO), where FROM and TO specify a range of +characters that belong to CHARSET on which FUNCTION should do its +job. FROM and TO are Emacs character codes, unlike FROM-CODE and +TO-CODE, which are CHARSET code points. */) (Lisp_Object function, Lisp_Object charset, Lisp_Object arg, Lisp_Object from_code, Lisp_Object to_code) { struct charset *cs;