commit 466db12df04c2bbc289769094f45933819f03f6c (HEAD, refs/remotes/origin/master) Author: Eli Zaretskii Date: Wed Oct 7 11:35:59 2020 +0300 Fix last change in frame.el. * lisp/frame.el (frame-set-background-mode): Fix last change: yet another place where FRAME was not taken into account, using the selected frame instead. (Bug#43837) diff --git a/lisp/frame.el b/lisp/frame.el index 26b23f8229..29ac862ccd 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -1244,7 +1244,7 @@ face specs for the new background mode." ;; during startup with -rv on the command ;; line for the initial frame, because frames ;; are not recorded in the pdump file. - (assq face (frame-face-alist)) + (assq face (frame-face-alist frame)) (face-spec-match-p face (face-user-default-spec face) frame))) commit bc2b63876b669ede07c93bc5694030646d9fbd36 Author: Eli Zaretskii Date: Wed Oct 7 10:02:20 2020 +0300 Fix face recalculation when frame's background mode changes * lisp/frame.el (frame-set-background-mode): Use the FRAME argument instead of the selected frame, when calling 'face-spec-match-p'. (Bug#43837) diff --git a/lisp/frame.el b/lisp/frame.el index 7751ae1303..26b23f8229 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -1247,10 +1247,7 @@ face specs for the new background mode." (assq face (frame-face-alist)) (face-spec-match-p face (face-user-default-spec face) - ;; FIXME: why selected-frame and - ;; not the frame that is the - ;; argument to this function? - (selected-frame)))) + frame))) (push face locally-modified-faces))) ;; Now change to the new frame parameters (modify-frame-parameters frame params) commit 4bea5574a5f727180438ea7b87c315d77e2e58bc Author: Lars Ingebrigtsen Date: Wed Oct 7 06:42:05 2020 +0200 Remove mention of the obsolete cust-print.el from the manual * doc/lispref/edebug.texi (Printing in Edebug): Remove mention of the obsolete cust-print.el (bug#37956) and adjust the text a bit. diff --git a/doc/lispref/edebug.texi b/doc/lispref/edebug.texi index 6404e068da..6e9ec47f7b 100644 --- a/doc/lispref/edebug.texi +++ b/doc/lispref/edebug.texi @@ -863,19 +863,20 @@ to a non-@code{nil} value. @end example @noindent -Custom printing prints this as @samp{Result: #1=(#1# y)}. The -@samp{#1=} notation labels the structure that follows it with the label -@samp{1}, and the @samp{#1#} notation references the previously labeled -structure. This notation is used for any shared elements of lists or -vectors. +If @code{print-circle} is non-@code{nil}, printing functions (e.g., +@code{prin1}) will print @code{a} as @samp{#1=(#1# y)}. The +@samp{#1=} notation labels the structure that follows it with the +label @samp{1}, and the @samp{#1#} notation references the previously +labeled structure. This notation is used for any shared elements of +lists or vectors. @defopt edebug-print-circle If non-@code{nil}, Edebug binds @code{print-circle} to this value while printing results. The default value is @code{t}. @end defopt - Other programs can also use custom printing; see @file{cust-print.el} -for details. + See @xref{Output Functions} for further details about how printing +can be customized. @node Trace Buffer @subsection Trace Buffer commit 5bc2f37dfbc3751e0b265b911aff3cf723ac4072 Author: Lars Ingebrigtsen Date: Wed Oct 7 06:09:18 2020 +0200 Update documentation on this-command-keys to reflect new behavior * doc/lispref/commands.texi (Command Loop Info): `this-command-keys' does not include the C-u any more, so remove that from the description and the example (bug#22107). * src/keyboard.c (Fthis_single_command_keys): Don't say that `this-command-keys' returns the C-u prefix (bug#22111). diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi index 25f657404f..1467854904 100644 --- a/doc/lispref/commands.texi +++ b/doc/lispref/commands.texi @@ -930,9 +930,8 @@ was specified to run but remapped into another command. @defun this-command-keys This function returns a string or vector containing the key sequence -that invoked the present command, plus any previous commands that -generated the prefix argument for this command. Any events read by the -command using @code{read-event} without a timeout get tacked on to the end. +that invoked the present command. Any events read by the command +using @code{read-event} without a timeout get tacked on to the end. However, if the command has called @code{read-key-sequence}, it returns the last read key sequence. @xref{Key Sequence Input}. The @@ -943,7 +942,7 @@ fit in a string. @xref{Input Events}. @group (this-command-keys) ;; @r{Now use @kbd{C-u C-x C-e} to evaluate that.} - @result{} "^U^X^E" + @result{} "^X^E" @end group @end example @end defun diff --git a/src/keyboard.c b/src/keyboard.c index bd1cdfa15b..4d22c44810 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -10566,8 +10566,6 @@ DEFUN ("this-single-command-keys", Fthis_single_command_keys, doc: /* Return the key sequence that invoked this command. More generally, it returns the last key sequence read, either by the command loop or by `read-key-sequence'. -Unlike `this-command-keys', this function's value -does not include prefix arguments. The value is always a vector. */) (void) { commit 0ab67a65f58e767f73a55f28e37b1a80bfc36682 Author: Alex Gramiak Date: Wed Oct 7 05:41:23 2020 +0200 Default the grep commands to skip directories * lisp/progmodes/grep.el (grep-compute-defaults): Skip directories (bug#23590). diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index 279eb4d54b..6bc187028f 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -703,10 +703,15 @@ The value depends on `grep-command', `grep-template', (let ((grep-options (concat (if grep-use-null-device "-n" "-nH") (if grep-use-null-filename-separator " --null") - (if (grep-probe grep-program - `(nil nil nil "-e" "foo" ,null-device) - nil 1) - " -e")))) + (when (grep-probe grep-program + `(nil nil nil "--directories=skip" "foo" + ,null-device) + nil 1) + " --directories=skip") + (when (grep-probe grep-program + `(nil nil nil "-e" "foo" ,null-device) + nil 1) + " -e")))) (unless grep-command (setq grep-command (format "%s %s %s " grep-program commit c842bd993f343d5dce1fe51fd72cb9aa345eef99 Author: Lars Ingebrigtsen Date: Wed Oct 7 05:23:26 2020 +0200 Make artist-mode work when display-line-numbers-mode is on * lisp/textmodes/artist.el (artist--adjust-x): New function. (artist-mouse-draw-continously, artist-mouse-draw-poly) (artist-mouse-draw-1point, artist-mouse-draw-2points): Use it to take `display-line-numbers-mode' widths into account. diff --git a/lisp/textmodes/artist.el b/lisp/textmodes/artist.el index 80682883c8..7196692001 100644 --- a/lisp/textmodes/artist.el +++ b/lisp/textmodes/artist.el @@ -4943,6 +4943,12 @@ If optional argument STATE is positive, turn borders on." (cons (+ window-x window-start-x) (+ window-y window-start-y)))) +(defun artist--adjust-x (x) + "Adjust the X position wrt. `display-line-numbers-mode'." + (let ((adjust (line-number-display-width))) + (if (= adjust 0) + x + (- x adjust 2)))) (defun artist-mouse-draw-continously (ev) "Generic function for shapes that require 1 point as input. @@ -4964,7 +4970,7 @@ The event, EV, is the mouse event." (ev-start (event-start ev)) (initial-win (posn-window ev-start)) (ev-start-pos (artist-coord-win-to-buf (posn-col-row ev-start))) - (x1 (car ev-start-pos)) + (x1 (artist--adjust-x (car ev-start-pos))) (y1 (cdr ev-start-pos)) (shape) (timer)) @@ -4981,7 +4987,7 @@ The event, EV, is the mouse event." (member 'down (event-modifiers ev))) (setq ev-start-pos (artist-coord-win-to-buf (posn-col-row (event-start ev)))) - (setq x1 (car ev-start-pos)) + (setq x1 (artist--adjust-x (car ev-start-pos))) (setq y1 (cdr ev-start-pos)) ;; Cancel previous timer @@ -5061,7 +5067,7 @@ The event, EV, is the mouse event." (ev-start (event-start ev)) (initial-win (posn-window ev-start)) (ev-start-pos (artist-coord-win-to-buf (posn-col-row ev-start))) - (x1-last (car ev-start-pos)) + (x1-last (artist--adjust-x (car ev-start-pos))) (y1-last (cdr ev-start-pos)) (x2 x1-last) (y2 y1-last) @@ -5153,7 +5159,7 @@ The event, EV, is the mouse event." ;; (setq ev-start-pos (artist-coord-win-to-buf (posn-col-row (event-start ev)))) - (setq x2 (car ev-start-pos)) + (setq x2 (artist--adjust-x (car ev-start-pos))) (setq y2 (cdr ev-start-pos)) ;; Draw the new shape (if not rubber-banding, place both marks) @@ -5180,7 +5186,7 @@ The event, EV, is the mouse event." ;; set x2 and y2 (setq ev-start-pos (artist-coord-win-to-buf (posn-col-row (event-start ev)))) - (setq x2 (car ev-start-pos)) + (setq x2 (artist--adjust-x (car ev-start-pos))) (setq y2 (cdr ev-start-pos)) ;; First undraw last shape @@ -5265,7 +5271,7 @@ Operation is done once. The event, EV, is the mouse event." (arrow-set-fn (artist-go-get-arrow-set-fn-from-symbol op)) (ev-start (event-start ev)) (ev-start-pos (artist-coord-win-to-buf (posn-col-row ev-start))) - (x1 (car ev-start-pos)) + (x1 (artist--adjust-x (car ev-start-pos))) (y1 (cdr ev-start-pos))) (select-window (posn-window ev-start)) (artist-funcall init-fn x1 y1) @@ -5299,7 +5305,7 @@ The event, EV, is the mouse event." (ev-start (event-start ev)) (initial-win (posn-window ev-start)) (ev-start-pos (artist-coord-win-to-buf (posn-col-row ev-start))) - (x1 (car ev-start-pos)) + (x1 (artist--adjust-x (car ev-start-pos))) (y1 (cdr ev-start-pos)) (x2) (y2) @@ -5313,7 +5319,7 @@ The event, EV, is the mouse event." (member 'down (event-modifiers ev))) (setq ev-start-pos (artist-coord-win-to-buf (posn-col-row (event-start ev)))) - (setq x2 (car ev-start-pos)) + (setq x2 (artist--adjust-x (car ev-start-pos))) (setq y2 (cdr ev-start-pos)) (if (not (eq initial-win (posn-window (event-start ev)))) commit 95c7aa96af9f5f92d69bb856be8632e4a1ca15f2 Author: Lars Ingebrigtsen Date: Wed Oct 7 05:05:20 2020 +0200 Remove reference to outdated Gnus variable from the manual * doc/misc/gnus.texi (Startup Variables): Remove reference to gnus-use-backend-marks, which was removed in 2011 (bug#43833). diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi index ee20d28ce6..f356dfe4d0 100644 --- a/doc/misc/gnus.texi +++ b/doc/misc/gnus.texi @@ -1737,12 +1737,6 @@ of doing your job. Note that this variable is used before @vindex gnus-no-groups-message Message displayed by Gnus when no groups are available. -@item gnus-use-backend-marks -@vindex gnus-use-backend-marks -If non-@code{nil}, Gnus will store article marks both in the -@file{.newsrc.eld} file and in the backends. This will slow down -group operation some. - @end table commit cc70a7b7a823fa3c886bca1374bafdfb2662a952 Author: Lars Ingebrigtsen Date: Wed Oct 7 04:50:52 2020 +0200 alist-get doc string further clarification * lisp/subr.el (alist-get): Mention generalized variables again for easier cross-referencing (bug#43836). diff --git a/lisp/subr.el b/lisp/subr.el index a56dc35ab6..777ef103cf 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -832,10 +832,11 @@ Elements of ALIST that are not conses are ignored." If KEY is not found in ALIST, return DEFAULT. Equality with KEY is tested by TESTFN, defaulting to `eq'. -You can use `alist-get' in PLACE expressions. This will modify -an existing association (more precisely, the first one if -multiple exist), or add a new element to the beginning of ALIST, -destructively modifying the list stored in ALIST. +You can use `alist-get' in \"place expressions\"; i.e., as a +generalized variable. Doing this will modify an existing +association (more precisely, the first one if multiple exist), or +add a new element to the beginning of ALIST, destructively +modifying the list stored in ALIST. Example: commit c36cd4854663ce13ac3dbebcab4ba6c34bc17f1f Author: Hong Xu Date: Wed Oct 7 04:41:29 2020 +0200 Clarify what ``chrooted environment means'' for TRAMP * doc/misc/tramp.texi (Frequently Asked Questions): Clarify what ``chrooted environment means'' for TRAMP (bug#43839). diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi index 1b5339b8d2..0e397f4c24 100644 --- a/doc/misc/tramp.texi +++ b/doc/misc/tramp.texi @@ -4280,8 +4280,8 @@ first saving to a temporary file. @vindex tramp-local-host-regexp When connecting to a local host, @value{tramp} uses some internal -optimizations. They fail, when there is a chrooted environment. In -order to disable those optimizations, set user option +optimizations. They fail when Emacs runs in a chrooted environment. +In order to disable those optimizations, set user option @code{tramp-local-host-regexp} to @code{nil}. commit 73054376542865cd00db8876bcfb241f0aa8f6b5 Author: Mauro Aranda Date: Wed Oct 7 04:35:52 2020 +0200 Make the State button in Custom use extended menus * lisp/cus-edit.el (custom-actioned-widget): New variable. Dynamically hold the widget for which to show the menu. (custom-variable-extended-menu, custom-face-extended-menu) (custom-group-extended-menu): Keymap menus for the State menu. Use custom-actioned-widget for the :enable and :selected forms. Make related items radio buttons. (Bug#4787) (custom-variable-menu, custom-face-menu, custom-group-menu): Keep for backward compatibility, but default to nil, so we prefer the keymap menus instead. (custom-variable-action, custom-face-action, custom-group-action): Pass the keymap menu to widget-choose when the simplified menus are nil. diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index a62b623c44..9c5d89f89f 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el @@ -487,6 +487,14 @@ Return a list suitable for use in `interactive'." (if (symbolp v) v nil) (intern val))))) +(defvar custom-actioned-widget nil + "Widget for which to show the menu of available actions. + +When showing a menu for a custom-variable, custom-face or custom-group widget, +the respective custom-*-action functions bind this variable to that widget, and +the respective custom-*-menu menus use the binding in their :enable and +:selected forms.") + (defun custom-menu-filter (menu widget) "Convert MENU to the form used by `widget-choose'. MENU should be in the same format as `custom-variable-menu'. @@ -2851,53 +2859,81 @@ otherwise." (defun custom-variable-standard-value (widget) (get (widget-value widget) 'standard-value)) -(defvar custom-variable-menu - `(("Set for Current Session" custom-variable-set - (lambda (widget) - (eq (widget-get widget :custom-state) 'modified))) - ;; Note that in all the backquoted code in this file, we test - ;; init-file-user rather than user-init-file. This is in case - ;; cus-edit is loaded by something in site-start.el, because - ;; user-init-file is not set at that stage. - ;; https://lists.gnu.org/r/emacs-devel/2007-10/msg00310.html - ,@(when (or custom-file init-file-user) - '(("Save for Future Sessions" custom-variable-save - (lambda (widget) - (memq (widget-get widget :custom-state) - '(modified set changed rogue)))))) - ("Undo Edits" custom-redraw - (lambda (widget) - (and (default-boundp (widget-value widget)) - (memq (widget-get widget :custom-state) '(modified changed))))) - ("Revert This Session's Customization" custom-variable-reset-saved - (lambda (widget) - (memq (widget-get widget :custom-state) - '(modified set changed rogue)))) - ,@(when (or custom-file init-file-user) - '(("Erase Customization" custom-variable-reset-standard - (lambda (widget) - (and (get (widget-value widget) 'standard-value) - (memq (widget-get widget :custom-state) - '(modified set changed saved rogue))))))) - ("Set to Backup Value" custom-variable-reset-backup - (lambda (widget) - (get (widget-value widget) 'backup-value))) - ("---" ignore ignore) - ("Add Comment" custom-comment-show custom-comment-invisible-p) - ("---" ignore ignore) - ("Show Current Value" custom-variable-edit - (lambda (widget) - (eq (widget-get widget :custom-form) 'lisp))) - ("Show Saved Lisp Expression" custom-variable-edit-lisp - (lambda (widget) - (eq (widget-get widget :custom-form) 'edit)))) - "Alist of actions for the `custom-variable' widget. +(defvar custom-variable-menu nil + "If non-nil, an alist of actions for the `custom-variable' widget. + +This variable is kept for backward compatibility reasons, please use +`custom-variable-extended-menu' instead. + Each entry has the form (NAME ACTION FILTER) where NAME is the name of the menu entry, ACTION is the function to call on the widget when the menu is selected, and FILTER is a predicate which takes a `custom-variable' widget as an argument, and returns non-nil if ACTION is valid on that widget. If FILTER is nil, ACTION is always valid.") +(defvar custom-variable-extended-menu + ;; No need to give the keymap a prompt, `widget-choose' takes care of it. + (let ((map (make-sparse-keymap))) + (define-key-after map [custom-variable-set] + '(menu-item "Set for Current Session" custom-variable-set + :enable (eq (widget-get custom-actioned-widget :custom-state) + 'modified))) + ;; Conditionally add items that depend on having loaded the custom-file, + ;; rather than giving it a :visible form, because we used to conditionally + ;; add this item when using simplified menus. + ;; Note that we test init-file-user rather than user-init-file. This is + ;; in case cus-edit is loaded by something in site-start.el, because + ;; user-init-file is not set at that stage. + ;; https://lists.gnu.org/r/emacs-devel/2007-10/msg00310.html + (when (or custom-file init-file-user) + (define-key-after map [custom-variable-save] + '(menu-item "Save for Future Sessions" custom-variable-save + :enable (memq + (widget-get custom-actioned-widget :custom-state) + '(modified set changed rogue))))) + (define-key-after map [custom-redraw] + '(menu-item "Undo Edits" custom-redraw + :enable (memq + (widget-get custom-actioned-widget :custom-state) + '(modified changed)))) + (define-key-after map [custom-variable-reset-saved] + '(menu-item "Revert This Session's Customization" + custom-variable-reset-saved + :enable (memq + (widget-get custom-actioned-widget :custom-state) + '(modified set changed rogue)))) + (when (or custom-file init-file-user) + (define-key-after map [custom-variable-reset-standard] + '(menu-item "Erase Customization" custom-variable-reset-standard + :enable (memq + (widget-get custom-actioned-widget :custom-state) + '(modified set changed saved rogue))))) + (define-key-after map [custom-variable-reset-backup] + '(menu-item "Set to Backup Value" custom-variable-reset-backup + :enable (get + (widget-value custom-actioned-widget) + 'backup-value))) + (define-key-after map [sep0] + '(menu-item "---")) + (define-key-after map [custom-comment-show] + '(menu-item "Add Comment" custom-comment-show + :enable (custom-comment-invisible-p custom-actioned-widget))) + (define-key-after map [sep1] + '(menu-item "---")) + (define-key-after map [custom-variable-edit] + '(menu-item "Show Current Value" custom-variable-edit + :button (:radio . (eq (widget-get custom-actioned-widget + :custom-form) + 'edit)))) + (define-key-after map [custom-variable-edit-lisp] + '(menu-item "Show Saved Lisp Expression" custom-variable-edit-lisp + :button (:radio . (eq (widget-get custom-actioned-widget + :custom-form) + 'lisp)))) + map) + "A menu for `custom-variable' widgets. +Used in `custom-variable-action' to show a menu to the user.") + (defun custom-variable-action (widget &optional event) "Show the menu for `custom-variable' WIDGET. Optional EVENT is the location for the menu." @@ -2907,12 +2943,17 @@ Optional EVENT is the location for the menu." (custom-variable-state-set widget)) (custom-redraw-magic widget) (let* ((completion-ignore-case t) + (custom-actioned-widget widget) (answer (widget-choose (concat "Operation on " - (custom-unlispify-tag-name - (widget-get widget :value))) - (custom-menu-filter custom-variable-menu - widget) - event))) + (custom-unlispify-tag-name + (widget-get widget :value))) + ;; Get rid of checks like this one if we ever + ;; remove the simplified menus. + (if custom-variable-menu + (custom-menu-filter custom-variable-menu + widget) + custom-variable-extended-menu) + event))) (if answer (funcall answer widget))))) @@ -3676,39 +3717,66 @@ the present value is saved to its :shown-value property instead." (widget-put widget :children children) (custom-face-state-set widget)))))) -(defvar custom-face-menu - `(("Set for Current Session" custom-face-set) - ,@(when (or custom-file init-file-user) - '(("Save for Future Sessions" custom-face-save))) - ("Undo Edits" custom-redraw - (lambda (widget) - (memq (widget-get widget :custom-state) '(modified changed)))) - ("Revert This Session's Customization" custom-face-reset-saved - (lambda (widget) - (memq (widget-get widget :custom-state) '(modified set changed)))) - ,@(when (or custom-file init-file-user) - '(("Erase Customization" custom-face-reset-standard - (lambda (widget) - (get (widget-value widget) 'face-defface-spec))))) - ("---" ignore ignore) - ("Add Comment" custom-comment-show custom-comment-invisible-p) - ("---" ignore ignore) - ("For Current Display" custom-face-edit-selected - (lambda (widget) - (not (eq (widget-get widget :custom-form) 'selected)))) - ("For All Kinds of Displays" custom-face-edit-all - (lambda (widget) - (not (eq (widget-get widget :custom-form) 'all)))) - ("Show Lisp Expression" custom-face-edit-lisp - (lambda (widget) - (not (eq (widget-get widget :custom-form) 'lisp))))) - "Alist of actions for the `custom-face' widget. +(defvar custom-face-menu nil + "If non-nil, an alist of actions for the `custom-face' widget. + +This variable is kept for backward compatibility reasons, please use +`custom-face-extended-menu' instead. + Each entry has the form (NAME ACTION FILTER) where NAME is the name of the menu entry, ACTION is the function to call on the widget when the menu is selected, and FILTER is a predicate which takes a `custom-face' widget as an argument, and returns non-nil if ACTION is valid on that widget. If FILTER is nil, ACTION is always valid.") +(defvar custom-face-extended-menu + (let ((map (make-sparse-keymap))) + (define-key-after map [custom-face-set] + '(menu-item "Set for Current Session" custom-face-set)) + (when (or custom-file init-file-user) + (define-key-after map [custom-face-save] + '(menu-item "Save for Future Sessions" custom-face-save))) + (define-key-after map [custom-redraw] + '(menu-item "Undo Edits" custom-redraw + :enable (memq + (widget-get custom-actioned-widget :custom-state) + '(modified changed)))) + (define-key-after map [custom-face-reset-saved] + '(menu-item "Revert This Session's Customization" custom-face-reset-saved + :enable (memq + (widget-get custom-actioned-widget :custom-state) + '(modified set changed)))) + (when (or custom-file init-file-user) + (define-key-after map [custom-face-reset-standard] + '(menu-item "Erase Customization" custom-face-reset-standard + :enable (get (widget-value custom-actioned-widget) + 'face-defface-spec)))) + (define-key-after map [sep0] + '(menu-item "---")) + (define-key-after map [custom-comment-show] + '(menu-item "Add Comment" custom-comment-show + :enable (custom-comment-invisible-p custom-actioned-widget))) + (define-key-after map [sep1] + '(menu-item "---")) + (define-key-after map [custom-face-edit-selected] + '(menu-item "For Current Display" custom-face-edit-selected + :button (:radio . (eq (widget-get custom-actioned-widget + :custom-form) + 'selected)))) + (define-key-after map [custom-face-edit-all] + '(menu-item "For All Kinds of Displays" custom-face-edit-all + :button (:radio . (eq (widget-get custom-actioned-widget + :custom-form) + 'all)))) + (define-key-after map [custom-face-edit-lisp] + '(menu-item "Show Lisp Expression" custom-face-edit-lisp + :button (:radio . (eq (widget-get custom-actioned-widget + :custom-form) + 'lisp)))) + map) + "A menu for `custom-face' widgets. +Used in `custom-face-action' to show a menu to the user.") + (defun custom-face-edit-selected (widget) "Edit selected attributes of the value of WIDGET." (widget-put widget :custom-state 'unknown) @@ -3775,12 +3843,15 @@ Optional EVENT is the location for the menu." (if (eq (widget-get widget :custom-state) 'hidden) (custom-toggle-hide widget) (let* ((completion-ignore-case t) + (custom-actioned-widget widget) (symbol (widget-get widget :value)) (answer (widget-choose (concat "Operation on " (custom-unlispify-tag-name symbol)) - (custom-menu-filter custom-face-menu - widget) - event))) + (if custom-face-menu + (custom-menu-filter custom-face-menu + widget) + custom-face-extended-menu) + event))) (if answer (funcall answer widget))))) @@ -4310,43 +4381,65 @@ This works for both graphical and text displays." (insert "\n") (custom-group--draw-horizontal-line))))) -(defvar custom-group-menu - `(("Set for Current Session" custom-group-set - (lambda (widget) - (eq (widget-get widget :custom-state) 'modified))) - ,@(when (or custom-file init-file-user) - '(("Save for Future Sessions" custom-group-save - (lambda (widget) - (memq (widget-get widget :custom-state) '(modified set)))))) - ("Undo Edits" custom-group-reset-current - (lambda (widget) - (memq (widget-get widget :custom-state) '(modified)))) - ("Revert This Session's Customizations" custom-group-reset-saved - (lambda (widget) - (memq (widget-get widget :custom-state) '(modified set)))) - ,@(when (or custom-file init-file-user) - '(("Erase Customization" custom-group-reset-standard - (lambda (widget) - (memq (widget-get widget :custom-state) '(modified set saved))))))) - "Alist of actions for the `custom-group' widget. +(defvar custom-group-menu nil + "If non-nil, an alist of actions for the `custom-group' widget. + +This variable is kept for backward compatibility reasons, please use +`custom-group-extended-menu' instead. + Each entry has the form (NAME ACTION FILTER) where NAME is the name of the menu entry, ACTION is the function to call on the widget when the menu is selected, and FILTER is a predicate which takes a `custom-group' widget as an argument, and returns non-nil if ACTION is valid on that widget. If FILTER is nil, ACTION is always valid.") +(defvar custom-group-extended-menu + (let ((map (make-sparse-keymap))) + (define-key-after map [custom-group-set] + '(menu-item "Set for Current Session" custom-group-set + :enable (eq (widget-get custom-actioned-widget :custom-state) + 'modified))) + (when (or custom-file init-file-user) + (define-key-after map [custom-group-save] + '(menu-item "Save for Future Sessions" custom-group-save + :enable (memq + (widget-get custom-actioned-widget :custom-state) + '(modified set))))) + (define-key-after map [custom-group-reset-current] + '(menu-item "Undo Edits" custom-group-reset-current + :enable (eq (widget-get custom-actioned-widget :custom-state) + 'modified))) + (define-key-after map [custom-group-reset-saved] + '(menu-item "Revert This Session's Customizations" + custom-group-reset-saved + :enable (memq + (widget-get custom-actioned-widget :custom-state) + '(modified set)))) + (when (or custom-file init-file-user) + (define-key-after map [custom-group-reset-standard] + '(menu-item "Erase Customization" custom-group-reset-standard + :enable (memq + (widget-get custom-actioned-widget :custom-state) + '(modified set saved))))) + map) + "A menu for `custom-group' widgets. +Used in `custom-group-action' to show a menu to the user.") + (defun custom-group-action (widget &optional event) "Show the menu for `custom-group' WIDGET. Optional EVENT is the location for the menu." (if (eq (widget-get widget :custom-state) 'hidden) (custom-toggle-hide widget) (let* ((completion-ignore-case t) + (custom-actioned-widget widget) (answer (widget-choose (concat "Operation on " (custom-unlispify-tag-name (widget-get widget :value))) - (custom-menu-filter custom-group-menu - widget) - event))) + (if custom-group-menu + (custom-menu-filter custom-group-menu + widget) + custom-group-extended-menu) + event))) (if answer (funcall answer widget))))) commit 891248be1cf805e8539d6e042eabc27bd725d515 Author: Stefan Monnier Date: Tue Oct 6 22:08:02 2020 -0400 * test/lisp/progmodes/ruby-mode-tests.el: Fix obsolete warnings diff --git a/test/lisp/progmodes/ruby-mode-tests.el b/test/lisp/progmodes/ruby-mode-tests.el index 5988a49523..6675fb28f8 100644 --- a/test/lisp/progmodes/ruby-mode-tests.el +++ b/test/lisp/progmodes/ruby-mode-tests.el @@ -717,7 +717,7 @@ VALUES-PLIST is a list with alternating index and value elements." (ruby-with-temp-buffer ruby-sexp-test-example (goto-char (point-min)) (forward-line 1) - (ruby-forward-sexp) + (forward-sexp) (should (= 8 (line-number-at-pos))))) (ert-deftest ruby-backward-sexp-skips-method-calls-with-keyword-names () @@ -725,7 +725,7 @@ VALUES-PLIST is a list with alternating index and value elements." (goto-char (point-min)) (forward-line 7) (end-of-line) - (ruby-backward-sexp) + (backward-sexp) (should (= 2 (line-number-at-pos))))) (ert-deftest ruby-forward-sexp-jumps-do-end-block-with-no-args () @@ -734,7 +734,7 @@ VALUES-PLIST is a list with alternating index and value elements." "proc do |end") (search-backward "do\n") - (ruby-forward-sexp) + (forward-sexp) (should (eobp)))) (ert-deftest ruby-backward-sexp-jumps-do-end-block-with-no-args () @@ -743,7 +743,7 @@ VALUES-PLIST is a list with alternating index and value elements." "proc do |end") (goto-char (point-max)) - (ruby-backward-sexp) + (backward-sexp) (should (looking-at "do$")))) (ert-deftest ruby-forward-sexp-jumps-do-end-block-with-empty-args () @@ -752,7 +752,7 @@ VALUES-PLIST is a list with alternating index and value elements." "proc do || |end") (search-backward "do ") - (ruby-forward-sexp) + (forward-sexp) (should (eobp)))) (ert-deftest ruby-backward-sexp-jumps-do-end-block-with-empty-args () @@ -761,7 +761,7 @@ VALUES-PLIST is a list with alternating index and value elements." "proc do || |end") (goto-char (point-max)) - (ruby-backward-sexp) + (backward-sexp) (should (looking-at "do ")))) (ert-deftest ruby-forward-sexp-jumps-do-end-block-with-args () @@ -770,7 +770,7 @@ VALUES-PLIST is a list with alternating index and value elements." "proc do |a,b| |end") (search-backward "do ") - (ruby-forward-sexp) + (forward-sexp) (should (eobp)))) (ert-deftest ruby-backward-sexp-jumps-do-end-block-with-args () @@ -779,7 +779,7 @@ VALUES-PLIST is a list with alternating index and value elements." "proc do |a,b| |end") (goto-char (point-max)) - (ruby-backward-sexp) + (backward-sexp) (should (looking-at "do ")))) (ert-deftest ruby-forward-sexp-jumps-do-end-block-with-any-args () @@ -788,7 +788,7 @@ VALUES-PLIST is a list with alternating index and value elements." "proc do |*| |end") (search-backward "do ") - (ruby-forward-sexp) + (forward-sexp) (should (eobp)))) (ert-deftest ruby-forward-sexp-jumps-do-end-block-with-expanded-one-arg () @@ -797,7 +797,7 @@ VALUES-PLIST is a list with alternating index and value elements." "proc do |a,| |end") (search-backward "do ") - (ruby-forward-sexp) + (forward-sexp) (should (eobp)))) (ert-deftest ruby-forward-sexp-jumps-do-end-block-with-one-and-any-args () @@ -806,7 +806,7 @@ VALUES-PLIST is a list with alternating index and value elements." "proc do |a,*| |end") (search-backward "do ") - (ruby-forward-sexp) + (forward-sexp) (should (eobp)))) (ert-deftest ruby-backward-sexp-jumps-do-end-block-with-one-and-any-args () @@ -815,7 +815,7 @@ VALUES-PLIST is a list with alternating index and value elements." "proc do |a,*| |end") (goto-char (point-max)) - (ruby-backward-sexp) + (backward-sexp) (should (looking-at "do ")))) (ert-deftest ruby-toggle-string-quotes-quotes-correctly () commit 46aa145d3906d21b4eb0e088c6325967c1579f3d Author: Juri Linkov Date: Tue Oct 6 23:14:26 2020 +0300 Add match-data to isearch state and repeat faces to highlight group matches * lisp/isearch.el (isearch-match-data): New variable. (isearch-mode): Set isearch-match-data to nil. (isearch-update): Call isearch-highlight with isearch-match-data. (isearch--state): Add isearch-match-data. (isearch--set-state): Restore isearch-match-data. (with-isearch-suspended): Preserve isearch-match-data. (isearch-search): Set isearch-match-data to integers. (isearch-group-1): Rename from isearch-group-odd and adjust colors. (isearch-group-2): Rename from isearch-group-even and adjust colors. (isearch-highlight): Add optional arg 'match-data'. Rewrite search-highlight-submatches part to recycle faces. * doc/emacs/search.texi (Search Customizations): Amend the documentation for isearch-group faces. (bug#6227, bug#43702) diff --git a/doc/emacs/search.texi b/doc/emacs/search.texi index d982a9e878..d25e35635e 100644 --- a/doc/emacs/search.texi +++ b/doc/emacs/search.texi @@ -1984,11 +1984,13 @@ the @code{search-highlight-submatches} variable. If this variable's value is @code{nil}, no special highlighting is done, but if the value is non-@code{nil}, text that matches @samp{\( @dots{} \)} constructs (a.k.a.@: ``subexpressions'') in the regular expression will be -highlighted with distinct faces, named @code{isearch-group-odd} -for the odd group matches, and @code{isearch-group-even} -for the even group matches. For instance, when searching for +highlighted with distinct faces, named @code{isearch-group-1} +and @code{isearch-group-2}. For instance, when searching for @samp{foo-\([0-9]+\)}, the part matched by @samp{[0-9]+} will be -highlighted with the @code{isearch-group-odd} face. +highlighted with the @code{isearch-group-1} face. When there are +more matches than faces, then faces are recycled from beginning, +so the @code{isearch-group-1} face is used for the third match again. +You can define more faces using the same numbering scheme. @cindex lazy highlighting customizations @vindex isearch-lazy-highlight diff --git a/etc/NEWS b/etc/NEWS index 1a5634f706..9d7b6e3115 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1106,9 +1106,9 @@ keystrokes. +++ *** Interactive regular expression search now uses faces for sub-groups. -E.g., 'C-M-s foo-\([0-9]+\)' will now use the 'isearch-group-odd' face +E.g., 'C-M-s foo-\([0-9]+\)' will now use the 'isearch-group-1' face on the part of the regexp that matches the sub-expression "[0-9]+". -The even group matches are highlighted with the 'isearch-group-even' face. +By default, there are two group faces, but you can define more. This is controlled by the 'search-highlight-submatches' user option. This feature is available only on terminals that have enough colors to distinguish between sub-expression highlighting. diff --git a/lisp/isearch.el b/lisp/isearch.el index 781a8c5a93..08d4be3ca8 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -271,8 +271,11 @@ are `word-search-regexp' \(`\\[isearch-toggle-word]'), `isearch-symbol-regexp' (defcustom search-highlight-submatches t "Whether to highlight regexp subexpressions of the current regexp match. -The faces used to do the highlights are named `isearch-group-odd' and -`isearch-group-even'." +The faces used to do the highlights are named `isearch-group-1', +`isearch-group-2'. When there are more matches than faces, then faces are +recycled from beginning, so the `isearch-group-1' face is used for the +third match again. If you want to use more distinctive colors, you have to +define more of these faces using the same numbering scheme." :type 'boolean :version "28.1") @@ -887,7 +890,7 @@ variable by the command `isearch-toggle-lax-whitespace'.") "Stack of search status elements. Each element is an `isearch--state' struct where the slots are [STRING MESSAGE POINT SUCCESS FORWARD OTHER-END WORD/REGEXP-FUNCTION - ERROR WRAPPED BARRIER CASE-FOLD-SEARCH POP-FUN]") + ERROR WRAPPED BARRIER CASE-FOLD-SEARCH POP-FUN MATCH-DATA]") (defvar isearch-string "") ; The current search string. (defvar isearch-message "") ; text-char-description version of isearch-string @@ -903,6 +906,7 @@ Each element is an `isearch--state' struct where the slots are "Recorded minimum/maximal point for the current search.") (defvar isearch-just-started nil) (defvar isearch-start-hscroll 0) ; hscroll when starting the search. +(defvar isearch-match-data nil) ; match-data of regexp-based search ;; case-fold-search while searching. ;; either nil, t, or 'yes. 'yes means the same as t except that mixed @@ -1221,6 +1225,7 @@ used to set the value of `isearch-regexp-function'." isearch-small-window nil isearch-just-started t isearch-start-hscroll (window-hscroll) + isearch-match-data nil isearch-opoint (point) search-ring-yank-pointer nil @@ -1349,8 +1354,8 @@ The last thing is to trigger a new round of lazy highlighting." (set-window-hscroll (selected-window) current-scroll)))) (if isearch-other-end (if (< isearch-other-end (point)) ; isearch-forward? - (isearch-highlight isearch-other-end (point)) - (isearch-highlight (point) isearch-other-end)) + (isearch-highlight isearch-other-end (point) isearch-match-data) + (isearch-highlight (point) isearch-other-end isearch-match-data)) (isearch-dehighlight)))) (setq ;; quit-flag nil not for isearch-mode isearch-adjusted nil @@ -1508,7 +1513,8 @@ REGEXP if non-nil says use the regexp search ring." (barrier isearch-barrier) (case-fold-search isearch-case-fold-search) (pop-fun (if isearch-push-state-function - (funcall isearch-push-state-function)))))) + (funcall isearch-push-state-function))) + (match-data isearch-match-data)))) (string nil :read-only t) (message nil :read-only t) (point nil :read-only t) @@ -1520,7 +1526,8 @@ REGEXP if non-nil says use the regexp search ring." (wrapped nil :read-only t) (barrier nil :read-only t) (case-fold-search nil :read-only t) - (pop-fun nil :read-only t)) + (pop-fun nil :read-only t) + (match-data nil :read-only t)) (defun isearch--set-state (cmd) (setq isearch-string (isearch--state-string cmd) @@ -1532,7 +1539,8 @@ REGEXP if non-nil says use the regexp search ring." isearch-error (isearch--state-error cmd) isearch-wrapped (isearch--state-wrapped cmd) isearch-barrier (isearch--state-barrier cmd) - isearch-case-fold-search (isearch--state-case-fold-search cmd)) + isearch-case-fold-search (isearch--state-case-fold-search cmd) + isearch-match-data (isearch--state-match-data cmd)) (if (functionp (isearch--state-pop-fun cmd)) (funcall (isearch--state-pop-fun cmd) cmd)) (goto-char (isearch--state-point cmd))) @@ -1624,6 +1632,7 @@ You can update the global isearch variables by setting new values to (isearch-adjusted isearch-adjusted) (isearch-yank-flag isearch-yank-flag) (isearch-error isearch-error) + (isearch-match-data isearch-match-data) (multi-isearch-file-list-new multi-isearch-file-list) (multi-isearch-buffer-list-new multi-isearch-buffer-list) @@ -3432,6 +3441,7 @@ Optional third argument, if t, means if fail just return nil (no error). (match-beginning 0) (match-end 0))) (setq retry nil))) (setq isearch-just-started nil) + (setq isearch-match-data (match-data t)) (if isearch-success (setq isearch-other-end (if isearch-forward (match-beginning 0) (match-end 0))))) @@ -3663,27 +3673,27 @@ since they have special meaning in a regexp." (defvar isearch-overlay nil) (defvar isearch-submatches-overlays nil) -(defface isearch-group-odd +(defface isearch-group-1 '((((class color) (min-colors 88) (background light)) - (:background "#ff00ff" :foreground "lightskyblue1")) + (:background "#f000f0" :foreground "lightskyblue1")) (((class color) (min-colors 88) (background dark)) - (:background "palevioletred3" :foreground "brown4")) + (:background "palevioletred1" :foreground "brown4")) (t (:inherit isearch))) "Face for highlighting Isearch the odd group matches." :group 'isearch :version "28.1") -(defface isearch-group-even +(defface isearch-group-2 '((((class color) (min-colors 88) (background light)) - (:background "#800080" :foreground "lightskyblue1")) + (:background "#a000a0" :foreground "lightskyblue1")) (((class color) (min-colors 88) (background dark)) - (:background "#905070" :foreground "brown4")) + (:background "palevioletred3" :foreground "brown4")) (t (:inherit isearch))) "Face for highlighting Isearch the even group matches." :group 'isearch :version "28.1") -(defun isearch-highlight (beg end) +(defun isearch-highlight (beg end &optional match-data) (if search-highlight (if isearch-overlay ;; Overlay already exists, just move it. @@ -3693,18 +3703,24 @@ since they have special meaning in a regexp." ;; 1001 is higher than lazy's 1000 and ediff's 100+ (overlay-put isearch-overlay 'priority 1001) (overlay-put isearch-overlay 'face isearch-face))) + (when (and search-highlight-submatches isearch-regexp) (mapc 'delete-overlay isearch-submatches-overlays) (setq isearch-submatches-overlays nil) - (dotimes (i (/ (length (match-data)) 2)) - (unless (zerop i) - (let ((ov (make-overlay (match-beginning i) (match-end i)))) - (overlay-put ov 'face (if (zerop (mod i 2)) - 'isearch-group-even - 'isearch-group-odd)) - (overlay-put ov 'priority 1002) - (push ov isearch-submatches-overlays)))))) + (let ((submatch-data (cddr (butlast match-data))) + (group 0) + ov face) + (while submatch-data + (setq group (1+ group)) + (setq ov (make-overlay (pop submatch-data) (pop submatch-data)) + face (intern-soft (format "isearch-group-%d" group))) + ;; Recycle faces from beginning. + (unless (facep face) + (setq group 1 face 'isearch-group-1)) + (overlay-put ov 'face face) + (overlay-put ov 'priority 1002) + (push ov isearch-submatches-overlays))))) (defun isearch-dehighlight () (when isearch-overlay commit ec705a6c3485b508b64981bd5a7fd3a60611357d Author: Alan Third Date: Mon Oct 5 20:38:45 2020 +0100 Fix crash when creating new NS frame (bug#43812) * src/nsterm.m (ns_clear_under_internal_border): Check the frame is live. diff --git a/src/nsterm.m b/src/nsterm.m index fdcd677d14..a702a051d0 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -3032,7 +3032,7 @@ so some key presses (TAB) are swallowed by the system. */ { NSTRACE ("ns_clear_under_internal_border"); - if (FRAME_INTERNAL_BORDER_WIDTH (f) > 0) + if (FRAME_LIVE_P (f) && FRAME_INTERNAL_BORDER_WIDTH (f) > 0) { int border_width = FRAME_INTERNAL_BORDER_WIDTH (f); NSView *view = FRAME_NS_VIEW (f); commit fc6decdfbcbeb3869158bc29c2ea453587f5ad38 Author: Juri Linkov Date: Tue Oct 6 21:35:53 2020 +0300 Add check for bound and true 'ido-everywhere' in multi-occur--prompt * lisp/replace.el (multi-occur--prompt): Check if 'ido-everywhere' is bound and true (bug#41633). diff --git a/lisp/replace.el b/lisp/replace.el index 2d17ec9097..e363924501 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -1576,7 +1576,8 @@ is not modified." (concat "Next buffer to search " (cond - ((eq read-buffer-function #'ido-read-buffer) + ((or (eq read-buffer-function #'ido-read-buffer) + (bound-and-true-p ido-everywhere)) (substitute-command-keys "(\\\\[ido-select-text] to end): ")) ((bound-and-true-p fido-mode) commit c30f6da0da0469f73fad205b134b1de82a1b1b65 Author: Juri Linkov Date: Tue Oct 6 21:33:20 2020 +0300 Fix args of truncate-string-to-width in ibuffer-compile-make-substring-form * lisp/ibuffer.el (ibuffer-compile-make-substring-form): Fix args of truncate-string-to-width call (bug#41250) diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el index c9a748830c..8ff3b56c5e 100644 --- a/lisp/ibuffer.el +++ b/lisp/ibuffer.el @@ -1597,7 +1597,7 @@ If point is on a group name, this function operates on that group." (defun ibuffer-compile-make-substring-form (strvar maxvar from-end-p) (if from-end-p ;; FIXME: not sure if this case is correct (Bug#24972) - `(truncate-string-to-width str strlen (- strlen ,maxvar) nil ?\s) + `(truncate-string-to-width str strlen (- strlen ,maxvar) ?\s) `(truncate-string-to-width ,strvar ,maxvar nil ?\s))) (defun ibuffer-compile-make-format-form (strvar widthform alignment) commit 278c9d69cda1eb10ec21f619f0d97014ee6ad51a Author: Stefan Monnier Date: Tue Oct 6 11:02:00 2020 -0400 * lisp/international/mule.el (define-coding-system): Revert accidental change This was accidentally included in a9f147af716aa026ec7778202901c4cb4bd5487d "Use the full name of the null byte/character, not its abbreviation". diff --git a/lisp/international/mule.el b/lisp/international/mule.el index e7496c08bf..2af64de77b 100644 --- a/lisp/international/mule.el +++ b/lisp/international/mule.el @@ -956,8 +956,8 @@ non-ASCII files. This attribute is meaningful only when (cons :name (cons name (cons :docstring (cons (purecopy docstring) props))))) (setcdr (assq :plist common-attrs) props) - (apply 'define-coding-system-internal - name (mapcar 'cdr (append common-attrs spec-attrs))))) + (apply #'define-coding-system-internal + name (mapcar #'cdr (append common-attrs spec-attrs))))) (defun coding-system-doc-string (coding-system) "Return the documentation string for CODING-SYSTEM." commit bcd09e9869a3f371024286d25743ebaf17f0be9d Author: Stefan Monnier Date: Tue Oct 6 09:38:25 2020 -0400 * lisp/international/mule-util.el: Revert bug#41250 workaround (truncate-string-ellipsis): Use the '…' character itself since it should work now and is more readable. diff --git a/lisp/international/mule-util.el b/lisp/international/mule-util.el index c369374022..8f31633224 100644 --- a/lisp/international/mule-util.el +++ b/lisp/international/mule-util.el @@ -58,10 +58,7 @@ needs to be called on every use of `truncate-string-to-width' to decide whether the selected frame can display that Unicode character." (cond (truncate-string-ellipsis) - ;; This uses the character's codepoint instead of the character - ;; itself to avoid decoding problems when loading this file. - ;; FIXME. - ((char-displayable-p ?\u2026) "\u2026") + ((char-displayable-p ?…) "…") ("..."))) ;;;###autoload commit 9a819568ccb2f2d3c692dd35b5c710ab24942ac6 Author: Stefan Monnier Date: Tue Oct 6 09:34:20 2020 -0400 * lisp/international/ja-dic-cnv.el: Attempt to fix bug#41250 (skkdic-convert): Only bind `coding-system-for-read` where needed. diff --git a/lisp/international/ja-dic-cnv.el b/lisp/international/ja-dic-cnv.el index f5e70ce702..5f645b6e8e 100644 --- a/lisp/international/ja-dic-cnv.el +++ b/lisp/international/ja-dic-cnv.el @@ -329,12 +329,12 @@ Optional argument DIRNAME if specified is the directory name under which the generated Emacs Lisp is saved. The name of generated file is specified by the variable `ja-dic-filename'." (interactive "FSKK dictionary file: ") - (let* ((coding-system-for-read 'euc-japan) - (skkbuf (get-buffer-create " *skkdic-unannotated*")) + (let* ((skkbuf (get-buffer-create " *skkdic-unannotated*")) (buf (get-buffer-create "*skkdic-work*"))) ;; Set skkbuf to an unannotated copy of the dictionary. (with-current-buffer skkbuf - (insert-file-contents (expand-file-name filename)) + (let ((coding-system-for-read 'euc-japan)) + (insert-file-contents (expand-file-name filename))) (re-search-forward "^[^;]") (while (re-search-forward ";[^\n/]*/" nil t) (replace-match "/"))) commit 61113a325466e705e66c18164fac884fdb172593 Author: Mattias Engdegård Date: Tue Oct 6 14:22:57 2020 +0200 Suppress obsoletion warning in test of obsolete rx function * test/lisp/emacs-lisp/rx-tests.el (rx-compat): Add byte-compilation warning suppression. diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el index 3b01d89dba..59d8c600a2 100644 --- a/test/lisp/emacs-lisp/rx-tests.el +++ b/test/lisp/emacs-lisp/rx-tests.el @@ -539,6 +539,9 @@ (ert-deftest rx-compat () "Test old symbol retained for compatibility (bug#37517)." - (should (equal (rx-submatch-n '(group-n 3 (+ nonl) eol)) "\\(?3:.+$\\)"))) + (should (equal + (with-suppressed-warnings ((obsolete rx-submatch-n)) + (rx-submatch-n '(group-n 3 (+ nonl) eol))) + "\\(?3:.+$\\)"))) (provide 'rx-tests) commit ff9b04fbc4d87a8f6b52b311e1f0b441adc91135 Author: Eli Zaretskii Date: Tue Oct 6 14:51:13 2020 +0300 ; * lisp/international/mule-util.el (truncate-string-ellipsis): Fix comment. diff --git a/lisp/international/mule-util.el b/lisp/international/mule-util.el index ad56000765..c369374022 100644 --- a/lisp/international/mule-util.el +++ b/lisp/international/mule-util.el @@ -58,8 +58,9 @@ needs to be called on every use of `truncate-string-to-width' to decide whether the selected frame can display that Unicode character." (cond (truncate-string-ellipsis) - ;; This uses the character's number instead of the character itself - ;; to avoid decoding problems when loading this file. FIXME. + ;; This uses the character's codepoint instead of the character + ;; itself to avoid decoding problems when loading this file. + ;; FIXME. ((char-displayable-p ?\u2026) "\u2026") ("..."))) commit bf34cf75fc4926e917eee47c86cf2266205d02dc Author: Mattias Engdegård Date: Tue Oct 6 13:09:58 2020 +0200 Fix last change * lisp/international/mule-util.el (truncate-string-ellipsis): Use Unicode hex escapes instead of named escapes here, because \N{...} is not available during bootstrapping. (Bug#41250) diff --git a/lisp/international/mule-util.el b/lisp/international/mule-util.el index faf00a76d6..ad56000765 100644 --- a/lisp/international/mule-util.el +++ b/lisp/international/mule-util.el @@ -58,9 +58,9 @@ needs to be called on every use of `truncate-string-to-width' to decide whether the selected frame can display that Unicode character." (cond (truncate-string-ellipsis) - ;; This uses the character's name instead of the character itself + ;; This uses the character's number instead of the character itself ;; to avoid decoding problems when loading this file. FIXME. - ((char-displayable-p ?\N{HORIZONTAL ELLIPSIS}) "\N{HORIZONTAL ELLIPSIS}") + ((char-displayable-p ?\u2026) "\u2026") ("..."))) ;;;###autoload commit e704a6956d86ae394ecb029e066bf8d8c061baf3 Author: Eli Zaretskii Date: Tue Oct 6 11:24:15 2020 +0300 Fix last change * lisp/international/mule-util.el (truncate-string-ellipsis): Add a FIXME comment that explains the last change. (Bug#41250) diff --git a/lisp/international/mule-util.el b/lisp/international/mule-util.el index 05ef33ccf5..faf00a76d6 100644 --- a/lisp/international/mule-util.el +++ b/lisp/international/mule-util.el @@ -52,12 +52,14 @@ returned by the function `truncate-string-ellipsis'.") (defun truncate-string-ellipsis () "Return the string used to indicate truncation. Use the value of the variable `truncate-string-ellipsis' when it's non-nil. -Otherwise, return the Unicode character \"HORIZONTAL ELLIPSIS\" when -it's displayable on the selected frame, or `...'. This function needs -to be called on every use of `truncate-string-to-width' to decide -whether the selected frame can display that Unicode character." +Otherwise, return the Unicode character U+2026 \"HORIZONTAL ELLIPSIS\" +when it's displayable on the selected frame, or `...'. This function +needs to be called on every use of `truncate-string-to-width' to +decide whether the selected frame can display that Unicode character." (cond (truncate-string-ellipsis) + ;; This uses the character's name instead of the character itself + ;; to avoid decoding problems when loading this file. FIXME. ((char-displayable-p ?\N{HORIZONTAL ELLIPSIS}) "\N{HORIZONTAL ELLIPSIS}") ("..."))) commit 809934f0220e1d9a1780ab97d04fececf2b934eb Author: Juri Linkov Date: Tue Oct 6 10:50:46 2020 +0300 Don't use the character '…' literally in mule-util.el (bug#41250) * lisp/international/mule-util.el (truncate-string-ellipsis): Replace the character '…' with its Unicode name. diff --git a/lisp/international/mule-util.el b/lisp/international/mule-util.el index c757e86698..05ef33ccf5 100644 --- a/lisp/international/mule-util.el +++ b/lisp/international/mule-util.el @@ -52,13 +52,13 @@ returned by the function `truncate-string-ellipsis'.") (defun truncate-string-ellipsis () "Return the string used to indicate truncation. Use the value of the variable `truncate-string-ellipsis' when it's non-nil. -Otherwise, return `…' when it's displayable on the selected frame, -or `...'. This function needs to be called on every use of -`truncate-string-to-width' to decide whether the selected frame -can display the character `…'." +Otherwise, return the Unicode character \"HORIZONTAL ELLIPSIS\" when +it's displayable on the selected frame, or `...'. This function needs +to be called on every use of `truncate-string-to-width' to decide +whether the selected frame can display that Unicode character." (cond (truncate-string-ellipsis) - ((char-displayable-p ?…) "…") + ((char-displayable-p ?\N{HORIZONTAL ELLIPSIS}) "\N{HORIZONTAL ELLIPSIS}") ("..."))) ;;;###autoload commit 96f502496e973c60718f9d44975396ae0bf8bece Author: Lars Ingebrigtsen Date: Tue Oct 6 03:51:17 2020 +0200 Fix animate test that somehow changed recently diff --git a/test/lisp/play/animate-tests.el b/test/lisp/play/animate-tests.el index 8af1517ffa..7c41d3b776 100644 --- a/test/lisp/play/animate-tests.el +++ b/test/lisp/play/animate-tests.el @@ -36,8 +36,8 @@ -Happy Birthday, - Foo + Happy Birthday, + Foo You are my sunshine, commit 9410c4e6b6774642db8bac883ab7ce6d86051f4d Author: Lars Ingebrigtsen Date: Tue Oct 6 03:48:00 2020 +0200 Fix mule-util-tests after recent truncation changes * test/lisp/international/mule-util-tests.el: Fix truncation checks. diff --git a/test/lisp/international/mule-util-tests.el b/test/lisp/international/mule-util-tests.el index cc199bd497..0524dad88d 100644 --- a/test/lisp/international/mule-util-tests.el +++ b/test/lisp/international/mule-util-tests.el @@ -75,8 +75,9 @@ (eval `(ert-deftest ,testname () ,testdoc - (should (equal (apply 'truncate-string-to-width ',(car testdata)) - ,(cdr testdata))))))) + (let ((truncate-string-ellipsis "...")) + (should (equal (apply 'truncate-string-to-width ',(car testdata)) + ,(cdr testdata)))))))) (dotimes (i (length mule-util-test-truncate-data)) (mule-util-test-truncate-create i)) commit a447d5e5a9d3ef03edfd672dd55136e6b1290ffd Author: Daniel Martín Date: Tue Oct 6 03:42:44 2020 +0200 Add missing full stop in MS-DOS processes documentation * doc/emacs/msdos-xtra.texi (MS-DOS Processes): Minor copy edig (bug#43820). diff --git a/doc/emacs/msdos-xtra.texi b/doc/emacs/msdos-xtra.texi index 230e918c84..045ac6c460 100644 --- a/doc/emacs/msdos-xtra.texi +++ b/doc/emacs/msdos-xtra.texi @@ -563,7 +563,7 @@ finishes. Spell checking also works, by means of special support for synchronous invocation of the @code{ispell} program. This is slower than the -asynchronous invocation on other platforms +asynchronous invocation on other platforms. Instead of the Shell mode, which doesn't work on MS-DOS, you can use the @kbd{M-x eshell} command. This invokes the Eshell package that commit a14321ff69eac17ec0a8f3ee9cb106c1ed512281 Author: Harald Jörg Date: Tue Oct 6 03:39:55 2020 +0200 cperl-mode: Fix a test to ensure cperl-mode is active * test/lisp/progmodes/cperl-mode-tests.el (cperl-mode-test-indent-exp): Make sure that cperl-mode is active for testing 'cperl-indent-exp', also skip this test under perl-mode. * test/lisp/progmodes/cperl-mode-resources/cperl-indent-exp.pl: Eliminate dependency on unrelated customizable variables (bug#10483). diff --git a/test/lisp/progmodes/cperl-mode-resources/cperl-indent-exp.pl b/test/lisp/progmodes/cperl-mode-resources/cperl-indent-exp.pl index 4a9842ffa5..8c1883a10f 100644 --- a/test/lisp/progmodes/cperl-mode-resources/cperl-indent-exp.pl +++ b/test/lisp/progmodes/cperl-mode-resources/cperl-indent-exp.pl @@ -26,7 +26,7 @@ } continue { -last; # no endless loop, though +last; } } # -------- while loop: expected output -------- @@ -34,7 +34,7 @@ while (1) { say "boring loop"; } continue { - last; # no endless loop, though + last; } } # -------- while loop: end -------- diff --git a/test/lisp/progmodes/cperl-mode-tests.el b/test/lisp/progmodes/cperl-mode-tests.el index f0ff8e9005..20be7ed68c 100644 --- a/test/lisp/progmodes/cperl-mode-tests.el +++ b/test/lisp/progmodes/cperl-mode-tests.el @@ -148,6 +148,7 @@ under timeout control." These exercise some standard blocks and also the special treatment for Perl expressions where a closing paren isn't the end of the statement." + (skip-unless (eq cperl-test-mode #'cperl-mode)) (let ((file (expand-file-name "cperl-indent-exp.pl" cperl-mode-tests-data-directory))) (with-temp-buffer @@ -166,6 +167,7 @@ end of the statement." got) (with-temp-buffer (insert code) + (cperl-mode) (goto-char (point-min)) (cperl-indent-exp) ; here we go! (setq expected (concat "test case " name ":\n" expected)) commit a9f147af716aa026ec7778202901c4cb4bd5487d Author: Andreas Schwab Date: Mon Oct 5 19:59:00 2020 +0200 Use the full name of the null byte/character, not its abbreviation * lisp/subr.el (inhibit-nul-byte-detection): Make it an obsolete alias. * src/coding.c (setup_coding_system): Use original name. (detect_coding): Rename nul_byte_found => null_byte_found. (detect_coding_system): Use original name. Rename nul_byte_found => null_byte_found. (Fdefine_coding_system_internal): Use original name. (syms_of_coding): Rename inhibit-nul-byte-detection to inhibit-null-byte-detection. * src/w16select.c (get_clipboard_data): Rename nul_char to null_char. * src/json.c (check_string_without_embedded_nulls): Rename from check_string_without_embedded_nuls. (Fjson_parse_string): Adjust accordingly. * src/coding.h (enum define_coding_undecided_arg_index) (enum coding_attr_index): Rename ...nul_byte... to ...null_byte.... * lisp/info.el (info-insert-file-contents, Info-insert-dir): * lisp/international/mule.el (define-coding-system): * lisp/vc/vc-git.el (vc-git--call): * doc/lispref/nonascii.texi (Lisp and Coding Systems): Use original name. diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi index 92cbc2a1c9..3b8b4fb3a9 100644 --- a/doc/lispref/files.texi +++ b/doc/lispref/files.texi @@ -548,7 +548,7 @@ the functions in the list @code{after-insert-file-functions}. (@pxref{Coding Systems}) used for decoding the file's contents, including end-of-line conversion. However, if the file contains null bytes, it is by default visited without any code conversions. -@xref{Lisp and Coding Systems, inhibit-nul-byte-detection}. +@xref{Lisp and Coding Systems, inhibit-null-byte-detection}. If @var{visit} is non-@code{nil}, this function additionally marks the buffer as unmodified and sets up various fields in the buffer so that it diff --git a/doc/lispref/nonascii.texi b/doc/lispref/nonascii.texi index c6c78ec096..8e9d62429c 100644 --- a/doc/lispref/nonascii.texi +++ b/doc/lispref/nonascii.texi @@ -1379,7 +1379,7 @@ operates on the contents of @var{string} instead of bytes in the buffer. @end defun @cindex null bytes, and decoding text -@defvar inhibit-nul-byte-detection +@defvar inhibit-null-byte-detection If this variable has a non-@code{nil} value, null bytes are ignored when detecting the encoding of a region or a string. This allows the encoding of text that contains null bytes to be correctly detected, diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index 855df4b926..5fefab99d4 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi @@ -1839,7 +1839,7 @@ system comes from @code{coding-system-for-read}, if that is non-@code{nil}; or else from the defaulting mechanism (@pxref{Default Coding Systems}). If the text output by a process contains null bytes, Emacs by default uses @code{no-conversion} for it; see -@ref{Lisp and Coding Systems, inhibit-nul-byte-detection}, for how to +@ref{Lisp and Coding Systems, inhibit-null-byte-detection}, for how to control this behavior. @strong{Warning:} Coding systems such as @code{undecided}, which diff --git a/etc/NEWS b/etc/NEWS index d05b706ea3..1a5634f706 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1621,6 +1621,8 @@ convert them to a list '(R G B)' of primary color values. This user option can be one of the predefined styles or a function to personalize the uniquified buffer name. ++++ +** 'inhibit-nul-byte-detection' is renamed to 'inhibit-null-byte-detection'. * Changes in Emacs 28.1 on Non-Free Operating Systems diff --git a/lisp/info.el b/lisp/info.el index 20633fd059..6dffb3993c 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -638,14 +638,14 @@ Do the right thing if the file has been compressed or zipped." (insert-file-contents-literally fullname visit) (let ((inhibit-read-only t) (coding-system-for-write 'no-conversion) - (inhibit-nul-byte-detection t) ; Index nodes include null bytes + (inhibit-null-byte-detection t) ; Index nodes include null bytes (default-directory (or (file-name-directory fullname) default-directory))) (or (consp decoder) (setq decoder (list decoder))) (apply #'call-process-region (point-min) (point-max) (car decoder) t t nil (cdr decoder)))) - (let ((inhibit-nul-byte-detection t)) ; Index nodes include null bytes + (let ((inhibit-null-byte-detection t)) ; Index nodes include null bytes (insert-file-contents fullname visit))) ;; Clear the caches of modified Info files. @@ -1375,7 +1375,7 @@ is non-nil)." ;; Index nodes include null bytes. DIR ;; files should not have indices, but who ;; knows... - (let ((inhibit-nul-byte-detection t)) + (let ((inhibit-null-byte-detection t)) (insert-file-contents file) (setq Info-dir-file-name file) (push (current-buffer) buffers) diff --git a/lisp/international/mule.el b/lisp/international/mule.el index c4febb26d4..e7496c08bf 100644 --- a/lisp/international/mule.el +++ b/lisp/international/mule.el @@ -855,10 +855,10 @@ VALUE is a CCL program name defined by `define-ccl-program'. The CCL program reads a character sequence and writes a byte sequence as an encoding result. -`:inhibit-nul-byte-detection' +`:inhibit-null-byte-detection' VALUE non-nil means Emacs ignore null bytes on code detection. -See the variable `inhibit-nul-byte-detection'. This attribute +See the variable `inhibit-null-byte-detection'. This attribute is meaningful only when `:coding-type' is `undecided'. `:inhibit-iso-escape-detection' @@ -903,7 +903,7 @@ non-ASCII files. This attribute is meaningful only when :ccl-encoder :valids)) ((eq coding-type 'undecided) - '(:inhibit-nul-byte-detection + '(:inhibit-null-byte-detection :inhibit-iso-escape-detection :prefer-utf-8)))))) @@ -956,8 +956,8 @@ non-ASCII files. This attribute is meaningful only when (cons :name (cons name (cons :docstring (cons (purecopy docstring) props))))) (setcdr (assq :plist common-attrs) props) - (apply #'define-coding-system-internal - name (mapcar #'cdr (append common-attrs spec-attrs))))) + (apply 'define-coding-system-internal + name (mapcar 'cdr (append common-attrs spec-attrs))))) (defun coding-system-doc-string (coding-system) "Return the documentation string for CODING-SYSTEM." diff --git a/lisp/subr.el b/lisp/subr.el index 23e4dcfa7e..a56dc35ab6 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1622,8 +1622,8 @@ be a list of the form returned by `event-start' and `event-end'." (make-obsolete-variable 'x-gtk-use-window-move nil "26.1") (defvaralias 'messages-buffer-max-lines 'message-log-max) -(define-obsolete-variable-alias 'inhibit-null-byte-detection - 'inhibit-nul-byte-detection "27.1") +(define-obsolete-variable-alias 'inhibit-nul-byte-detection + 'inhibit-null-byte-detection "28.1") (make-obsolete-variable 'load-dangerous-libraries "no longer used." "27.1") diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 6ff6951dbc..b1880c0f7b 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -1795,9 +1795,9 @@ The difference to vc-do-command is that this function always invokes (defun vc-git--call (buffer command &rest args) ;; We don't need to care the arguments. If there is a file name, it ;; is always a relative one. This works also for remote - ;; directories. We enable `inhibit-nul-byte-detection', otherwise + ;; directories. We enable `inhibit-null-byte-detection', otherwise ;; Tramp's eol conversion might be confused. - (let ((inhibit-nul-byte-detection t) + (let ((inhibit-null-byte-detection t) (coding-system-for-read (or coding-system-for-read vc-git-log-output-coding-system)) (coding-system-for-write diff --git a/src/alloc.c b/src/alloc.c index b12922b585..f90d09265d 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1658,7 +1658,7 @@ sdata_size (ptrdiff_t n) #define GC_STRING_EXTRA GC_STRING_OVERRUN_COOKIE_SIZE /* Exact bound on the number of bytes in a string, not counting the - terminating NUL. A string cannot contain more bytes than + terminating null. A string cannot contain more bytes than STRING_BYTES_BOUND, nor can it be so long that the size_t arithmetic in allocate_string_data would overflow while it is calculating a value to be passed to malloc. */ diff --git a/src/bidi.c b/src/bidi.c index 1017bd2d52..225b27b18c 100644 --- a/src/bidi.c +++ b/src/bidi.c @@ -2338,7 +2338,7 @@ bidi_resolve_weak (struct bidi_it *bidi_it) and make it L right away, to avoid the potentially costly loop below. This is important when the buffer has a long series of - control characters, like binary NULs, and no + control characters, like binary nulls, and no R2L characters at all. */ && new_level == 0 && !bidi_explicit_dir_char (bidi_it->ch) @@ -2996,7 +2996,7 @@ bidi_resolve_neutral (struct bidi_it *bidi_it) } /* The next two "else if" clauses are shortcuts for the important special case when we have a long sequence of - neutral or WEAK_BN characters, such as whitespace or NULs or + neutral or WEAK_BN characters, such as whitespace or nulls or other control characters, on the base embedding level of the paragraph, and that sequence goes all the way to the end of the paragraph and follows a character whose resolved diff --git a/src/bignum.c b/src/bignum.c index 669df4d9ee..dce5908a1e 100644 --- a/src/bignum.c +++ b/src/bignum.c @@ -353,7 +353,7 @@ emacs_mpz_pow_ui (mpz_t rop, mpz_t const base, unsigned long exp) /* Yield an upper bound on the buffer size needed to contain a C string representing the NUM in base BASE. This includes any - preceding '-' and the terminating NUL. */ + preceding '-' and the terminating null. */ static ptrdiff_t mpz_bufsize (mpz_t const num, int base) { @@ -418,7 +418,7 @@ bignum_to_string (Lisp_Object num, int base) /* Create a bignum by scanning NUM, with digits in BASE. NUM must consist of an optional '-', a nonempty sequence - of base-BASE digits, and a terminating NUL byte, and + of base-BASE digits, and a terminating null byte, and the represented number must not be in fixnum range. */ Lisp_Object diff --git a/src/callint.c b/src/callint.c index f609c96a6f..f80436f3d9 100644 --- a/src/callint.c +++ b/src/callint.c @@ -712,7 +712,7 @@ invoke it (via an `interactive' spec that contains, for instance, an default: { /* How many bytes are left unprocessed in the specs string? - (Note that this excludes the trailing NUL byte.) */ + (Note that this excludes the trailing null byte.) */ ptrdiff_t bytes_left = string_len - (tem - string); unsigned letter; diff --git a/src/coding.c b/src/coding.c index 221a9cad89..2142e7fa51 100644 --- a/src/coding.c +++ b/src/coding.c @@ -5707,7 +5707,7 @@ setup_coding_system (Lisp_Object coding_system, struct coding_system *coding) coding->common_flags |= CODING_REQUIRE_DETECTION_MASK; coding->spec.undecided.inhibit_nbd = (encode_inhibit_flag - (AREF (attrs, coding_attr_undecided_inhibit_nul_byte_detection))); + (AREF (attrs, coding_attr_undecided_inhibit_null_byte_detection))); coding->spec.undecided.inhibit_ied = (encode_inhibit_flag (AREF (attrs, coding_attr_undecided_inhibit_iso_escape_detection))); @@ -6535,9 +6535,9 @@ detect_coding (struct coding_system *coding) { int c, i; struct coding_detection_info detect_info; - bool nul_byte_found = 0, eight_bit_found = 0; + bool null_byte_found = 0, eight_bit_found = 0; bool inhibit_nbd = inhibit_flag (coding->spec.undecided.inhibit_nbd, - inhibit_nul_byte_detection); + inhibit_null_byte_detection); bool inhibit_ied = inhibit_flag (coding->spec.undecided.inhibit_ied, inhibit_iso_escape_detection); bool prefer_utf_8 = coding->spec.undecided.prefer_utf_8; @@ -6550,7 +6550,7 @@ detect_coding (struct coding_system *coding) if (c & 0x80) { eight_bit_found = 1; - if (nul_byte_found) + if (null_byte_found) break; } else if (c < 0x20) @@ -6565,7 +6565,7 @@ detect_coding (struct coding_system *coding) if (! (detect_info.rejected & CATEGORY_MASK_ISO_7_ELSE)) { /* We didn't find an 8-bit code. We may - have found a NUL-byte, but it's very + have found a null-byte, but it's very rare that a binary file conforms to ISO-2022. */ src = src_end; @@ -6577,7 +6577,7 @@ detect_coding (struct coding_system *coding) } else if (! c && !inhibit_nbd) { - nul_byte_found = 1; + null_byte_found = 1; if (eight_bit_found) break; } @@ -6609,7 +6609,7 @@ detect_coding (struct coding_system *coding) coding->head_ascii++; } - if (nul_byte_found || eight_bit_found + if (null_byte_found || eight_bit_found || coding->head_ascii < coding->src_bytes || detect_info.found) { @@ -6627,7 +6627,7 @@ detect_coding (struct coding_system *coding) } else { - if (nul_byte_found) + if (null_byte_found) { detect_info.checked |= ~CATEGORY_MASK_UTF_16; detect_info.rejected |= ~CATEGORY_MASK_UTF_16; @@ -6700,7 +6700,7 @@ detect_coding (struct coding_system *coding) else found = CODING_ID_NAME (this->id); } - else if (nul_byte_found) + else if (null_byte_found) found = Qno_conversion; else if ((detect_info.rejected & CATEGORY_MASK_ANY) == CATEGORY_MASK_ANY) @@ -8476,7 +8476,7 @@ from_unicode (Lisp_Object str) Lisp_Object from_unicode_buffer (const wchar_t *wstr) { - /* We get one of the two final NUL bytes for free. */ + /* We get one of the two final null bytes for free. */ ptrdiff_t len = 1 + sizeof (wchar_t) * wcslen (wstr); AUTO_STRING_WITH_LEN (str, (char *) wstr, len); return from_unicode (str); @@ -8489,7 +8489,7 @@ to_unicode (Lisp_Object str, Lisp_Object *buf) /* We need to make another copy (in addition to the one made by code_convert_string_norecord) to ensure that the final string is _doubly_ zero terminated --- that is, that the string is - terminated by two zero bytes and one utf-16le NUL character. + terminated by two zero bytes and one utf-16le null character. Because strings are already terminated with a single zero byte, we just add one additional zero. */ str = make_uninit_string (SBYTES (*buf) + 1); @@ -8605,7 +8605,7 @@ detect_coding_system (const unsigned char *src, ptrdiff_t id; struct coding_detection_info detect_info; enum coding_category base_category; - bool nul_byte_found = 0, eight_bit_found = 0; + bool null_byte_found = 0, eight_bit_found = 0; if (NILP (coding_system)) coding_system = Qundecided; @@ -8632,7 +8632,7 @@ detect_coding_system (const unsigned char *src, struct coding_system *this UNINIT; int c, i; bool inhibit_nbd = inhibit_flag (coding.spec.undecided.inhibit_nbd, - inhibit_nul_byte_detection); + inhibit_null_byte_detection); bool inhibit_ied = inhibit_flag (coding.spec.undecided.inhibit_ied, inhibit_iso_escape_detection); bool prefer_utf_8 = coding.spec.undecided.prefer_utf_8; @@ -8644,7 +8644,7 @@ detect_coding_system (const unsigned char *src, if (c & 0x80) { eight_bit_found = 1; - if (nul_byte_found) + if (null_byte_found) break; } else if (c < 0x20) @@ -8659,7 +8659,7 @@ detect_coding_system (const unsigned char *src, if (! (detect_info.rejected & CATEGORY_MASK_ISO_7_ELSE)) { /* We didn't find an 8-bit code. We may - have found a NUL-byte, but it's very + have found a null-byte, but it's very rare that a binary file confirm to ISO-2022. */ src = src_end; @@ -8671,7 +8671,7 @@ detect_coding_system (const unsigned char *src, } else if (! c && !inhibit_nbd) { - nul_byte_found = 1; + null_byte_found = 1; if (eight_bit_found) break; } @@ -8682,7 +8682,7 @@ detect_coding_system (const unsigned char *src, coding.head_ascii++; } - if (nul_byte_found || eight_bit_found + if (null_byte_found || eight_bit_found || coding.head_ascii < coding.src_bytes || detect_info.found) { @@ -8697,7 +8697,7 @@ detect_coding_system (const unsigned char *src, } else { - if (nul_byte_found) + if (null_byte_found) { detect_info.checked |= ~CATEGORY_MASK_UTF_16; detect_info.rejected |= ~CATEGORY_MASK_UTF_16; @@ -8744,7 +8744,7 @@ detect_coding_system (const unsigned char *src, } if ((detect_info.rejected & CATEGORY_MASK_ANY) == CATEGORY_MASK_ANY - || nul_byte_found) + || null_byte_found) { detect_info.found = CATEGORY_MASK_RAW_TEXT; id = CODING_SYSTEM_ID (Qno_conversion); @@ -8846,7 +8846,7 @@ detect_coding_system (const unsigned char *src, { if (detect_info.found & ~CATEGORY_MASK_UTF_16) { - if (nul_byte_found) + if (null_byte_found) normal_eol = EOL_SEEN_LF; else normal_eol = detect_eol (coding.source, src_bytes, @@ -11320,8 +11320,8 @@ usage: (define-coding-system-internal ...) */) { if (nargs < coding_arg_undecided_max) goto short_args; - ASET (attrs, coding_attr_undecided_inhibit_nul_byte_detection, - args[coding_arg_undecided_inhibit_nul_byte_detection]); + ASET (attrs, coding_attr_undecided_inhibit_null_byte_detection, + args[coding_arg_undecided_inhibit_null_byte_detection]); ASET (attrs, coding_attr_undecided_inhibit_iso_escape_detection, args[coding_arg_undecided_inhibit_iso_escape_detection]); ASET (attrs, coding_attr_undecided_prefer_utf_8, @@ -12086,18 +12086,18 @@ to explicitly specify some coding system that doesn't use ISO-2022 escape sequence (e.g., `latin-1') on reading by \\[universal-coding-system-argument]. */); inhibit_iso_escape_detection = 0; - DEFVAR_BOOL ("inhibit-nul-byte-detection", - inhibit_nul_byte_detection, - doc: /* If non-nil, Emacs ignores NUL bytes on code detection. + DEFVAR_BOOL ("inhibit-null-byte-detection", + inhibit_null_byte_detection, + doc: /* If non-nil, Emacs ignores null bytes on code detection. By default, Emacs treats it as binary data, and does not attempt to decode it. The effect is as if you specified `no-conversion' for reading that text. -Set this to non-nil when a regular text happens to include NUL bytes. -Examples are Index nodes of Info files and NUL-byte delimited output -from GNU Find and GNU Grep. Emacs will then ignore the NUL bytes and +Set this to non-nil when a regular text happens to include null bytes. +Examples are Index nodes of Info files and null-byte delimited output +from GNU Find and GNU Grep. Emacs will then ignore the null bytes and decode text as usual. */); - inhibit_nul_byte_detection = 0; + inhibit_null_byte_detection = 0; DEFVAR_BOOL ("disable-ascii-optimization", disable_ascii_optimization, doc: /* If non-nil, Emacs does not optimize code decoder for ASCII files. @@ -12156,7 +12156,7 @@ internal character representation. */); "automatic conversion on decoding."); plist[15] = args[coding_arg_eol_type] = Qnil; args[coding_arg_plist] = CALLMANY (Flist, plist); - args[coding_arg_undecided_inhibit_nul_byte_detection] = make_fixnum (0); + args[coding_arg_undecided_inhibit_null_byte_detection] = make_fixnum (0); args[coding_arg_undecided_inhibit_iso_escape_detection] = make_fixnum (0); Fdefine_coding_system_internal (coding_arg_undecided_max, args); diff --git a/src/coding.h b/src/coding.h index c2a7b2a00f..4973cf89eb 100644 --- a/src/coding.h +++ b/src/coding.h @@ -82,7 +82,7 @@ enum define_coding_ccl_arg_index enum define_coding_undecided_arg_index { - coding_arg_undecided_inhibit_nul_byte_detection = coding_arg_max, + coding_arg_undecided_inhibit_null_byte_detection = coding_arg_max, coding_arg_undecided_inhibit_iso_escape_detection, coding_arg_undecided_prefer_utf_8, coding_arg_undecided_max @@ -139,7 +139,7 @@ enum coding_attr_index coding_attr_emacs_mule_full, - coding_attr_undecided_inhibit_nul_byte_detection, + coding_attr_undecided_inhibit_null_byte_detection, coding_attr_undecided_inhibit_iso_escape_detection, coding_attr_undecided_prefer_utf_8, @@ -353,7 +353,7 @@ struct emacs_mule_spec struct undecided_spec { - /* Inhibit NUL byte detection. 1 means always inhibit, + /* Inhibit null byte detection. 1 means always inhibit, -1 means do not inhibit, 0 means rely on user variable. */ int inhibit_nbd; diff --git a/src/dired.c b/src/dired.c index f013a4cea0..1584b6acf0 100644 --- a/src/dired.c +++ b/src/dired.c @@ -929,7 +929,7 @@ file_attributes (int fd, char const *name, struct stat s; /* An array to hold the mode string generated by filemodestring, - including its terminating space and NUL byte. */ + including its terminating space and null byte. */ char modes[sizeof "-rwxr-xr-x "]; char *uname = NULL, *gname = NULL; diff --git a/src/dispextern.h b/src/dispextern.h index 0d982f7917..848d3bcd20 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -1996,7 +1996,7 @@ struct bidi_string_data { Lisp_Object lstring; /* Lisp string to reorder, or nil */ const unsigned char *s; /* string data, or NULL if reordering buffer */ ptrdiff_t schars; /* the number of characters in the string, - excluding the terminating NUL */ + excluding the terminating null */ ptrdiff_t bufpos; /* buffer position of lstring, or 0 if N/A */ bool_bf from_disp_str : 1; /* True means the string comes from a display property */ diff --git a/src/doc.c b/src/doc.c index 285c0dbbbe..18ab346cd1 100644 --- a/src/doc.c +++ b/src/doc.c @@ -233,7 +233,7 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition) } /* Scan the text and perform quoting with ^A (char code 1). - ^A^A becomes ^A, ^A0 becomes a NUL char, and ^A_ becomes a ^_. */ + ^A^A becomes ^A, ^A0 becomes a null char, and ^A_ becomes a ^_. */ from = get_doc_string_buffer + offset; to = get_doc_string_buffer + offset; while (from != p) diff --git a/src/doprnt.c b/src/doprnt.c index b0ba12552b..ceadf3bdfa 100644 --- a/src/doprnt.c +++ b/src/doprnt.c @@ -35,7 +35,7 @@ along with GNU Emacs. If not, see . */ sequence. . It accepts a pointer to the end of the format string, so the format string - could include embedded NUL characters. + could include embedded null characters. . It signals an error if the length of the formatted string is about to overflow ptrdiff_t or size_t, to avoid producing strings longer than what @@ -123,7 +123,7 @@ along with GNU Emacs. If not, see . */ to fit and return BUFSIZE - 1; if this truncates a multibyte sequence, store '\0' into the sequence's first byte. Returns the number of bytes stored into BUFFER, excluding - the terminating NUL byte. Output is always NUL-terminated. + the terminating null byte. Output is always null-terminated. String arguments are passed as C strings. Integers are passed as C integers. */ diff --git a/src/editfns.c b/src/editfns.c index 7e1e24ef16..ca6b8981eb 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -3069,7 +3069,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) : FLT_RADIX == 16 ? 4 : -1)), - /* Maximum number of bytes (including terminating NUL) generated + /* Maximum number of bytes (including terminating null) generated by any format, if precision is no more than USEFUL_PRECISION_MAX. On all practical hosts, %Lf is the worst case. */ SPRINTF_BUFSIZE = (sizeof "-." + (LDBL_MAX_10_EXP + 1) diff --git a/src/emacs.c b/src/emacs.c index 059e1c6d8f..6ed970b9fd 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -2735,7 +2735,7 @@ decode_env_path (const char *evarname, const char *defalt, bool empty) } } else if (cnv_result != 0 && d > path_utf8) - d[-1] = '\0'; /* remove last semi-colon and NUL-terminate PATH */ + d[-1] = '\0'; /* remove last semi-colon and null-terminate PATH */ } while (q); path_copy = path_utf8; #else /* MSDOS */ diff --git a/src/fileio.c b/src/fileio.c index 6d0bafa8cf..283813ff89 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -1710,7 +1710,7 @@ See also the function `substitute-in-file-name'.") #endif /* Put into BUF the concatenation of DIR and FILE, with an intervening - directory separator if needed. Return a pointer to the NUL byte + directory separator if needed. Return a pointer to the null byte at the end of the concatenated string. */ char * splice_dir_file (char *buf, char const *dir, char const *file) diff --git a/src/filelock.c b/src/filelock.c index ee46e0e3e0..39febd366d 100644 --- a/src/filelock.c +++ b/src/filelock.c @@ -296,7 +296,7 @@ typedef struct /* Write the name of the lock file for FNAME into LOCKNAME. Length will be that of FNAME plus two more for the leading ".#", plus one - for the NUL. */ + for the null. */ #define MAKE_LOCK_NAME(lockname, fname) \ (lockname = SAFE_ALLOCA (SBYTES (fname) + 2 + 1), \ fill_in_lock_file_name (lockname, fname)) diff --git a/src/fns.c b/src/fns.c index f626fe11b2..4003fe8a81 100644 --- a/src/fns.c +++ b/src/fns.c @@ -406,7 +406,7 @@ string_version_cmp (Lisp_Object string1, Lisp_Object string2) while ((cmp = filevercmp (p1, p2)) == 0) { - /* If the strings are identical through their first NUL bytes, + /* If the strings are identical through their first null bytes, skip past identical prefixes and try again. */ ptrdiff_t size = strlen (p1) + 1; eassert (size == strlen (p2) + 1); diff --git a/src/font.c b/src/font.c index beaa7be98d..20686ce0ec 100644 --- a/src/font.c +++ b/src/font.c @@ -1011,7 +1011,7 @@ font_expand_wildcards (Lisp_Object *field, int n) } -/* Parse NAME (NUL terminated) as XLFD and store information in FONT +/* Parse NAME (null terminated) as XLFD and store information in FONT (font-spec or font-entity). Size property of FONT is set as follows: specified XLFD fields FONT property @@ -1355,7 +1355,7 @@ font_unparse_xlfd (Lisp_Object font, int pixel_size, char *name, int nbytes) return len < nbytes ? len : -1; } -/* Parse NAME (NUL terminated) and store information in FONT +/* Parse NAME (null terminated) and store information in FONT (font-spec or font-entity). NAME is supplied in either the Fontconfig or GTK font name format. If NAME is successfully parsed, return 0. Otherwise return -1. @@ -1727,7 +1727,7 @@ font_unparse_fcname (Lisp_Object font, int pixel_size, char *name, int nbytes) #endif -/* Parse NAME (NUL terminated) and store information in FONT +/* Parse NAME (null terminated) and store information in FONT (font-spec or font-entity). If NAME is successfully parsed, return 0. Otherwise return -1. */ diff --git a/src/insdel.c b/src/insdel.c index c37b071078..6e24597108 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -714,7 +714,7 @@ insert_char (int c) insert ((char *) str, len); } -/* Insert the NUL-terminated string S before point. */ +/* Insert the null-terminated string S before point. */ void insert_string (const char *s) diff --git a/src/json.c b/src/json.c index 8c9583631a..744c40a1be 100644 --- a/src/json.c +++ b/src/json.c @@ -279,10 +279,10 @@ json_release_object (void *object) } /* Signal an error if OBJECT is not a string, or if OBJECT contains - embedded NUL characters. */ + embedded null characters. */ static void -check_string_without_embedded_nuls (Lisp_Object object) +check_string_without_embedded_nulls (Lisp_Object object) { CHECK_STRING (object); CHECK_TYPE (memchr (SDATA (object), '\0', SBYTES (object)) == NULL, @@ -368,11 +368,11 @@ lisp_to_json_toplevel_1 (Lisp_Object lisp, CHECK_STRING (key); Lisp_Object ekey = json_encode (key); /* We can't specify the length, so the string must be - NUL-terminated. */ - check_string_without_embedded_nuls (ekey); + null-terminated. */ + check_string_without_embedded_nulls (ekey); const char *key_str = SSDATA (ekey); /* Reject duplicate keys. These are possible if the hash - table test is not `equal'. */ + table test is not `equal'. */ if (json_object_get (json, key_str) != NULL) wrong_type_argument (Qjson_value_p, lisp); int status @@ -419,8 +419,8 @@ lisp_to_json_toplevel_1 (Lisp_Object lisp, CHECK_SYMBOL (key_symbol); Lisp_Object key = SYMBOL_NAME (key_symbol); /* We can't specify the length, so the string must be - NUL-terminated. */ - check_string_without_embedded_nuls (key); + null-terminated. */ + check_string_without_embedded_nulls (key); key_str = SSDATA (key); /* In plists, ensure leading ":" in keys is stripped. It will be reconstructed later in `json_to_lisp'.*/ @@ -563,7 +563,7 @@ false values, t, numbers, strings, or other vectors hashtables, alists or plists. t will be converted to the JSON true value. Vectors will be converted to JSON arrays, whereas hashtables, alists and plists are converted to JSON objects. Hashtable keys must be strings without -embedded NUL characters and must be unique within each object. Alist +embedded null characters and must be unique within each object. Alist and plist keys must be symbols; if a key is duplicate, the first instance is used. @@ -976,7 +976,7 @@ usage: (json-parse-string STRING &rest ARGS) */) Lisp_Object string = args[0]; CHECK_STRING (string); Lisp_Object encoded = json_encode (string); - check_string_without_embedded_nuls (encoded); + check_string_without_embedded_nulls (encoded); struct json_configuration conf = {json_object_hashtable, json_array_array, QCnull, QCfalse}; json_parse_args (nargs - 1, args + 1, &conf, true); diff --git a/src/keyboard.c b/src/keyboard.c index 8cf3ec1813..bd1cdfa15b 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -6234,7 +6234,7 @@ parse_modifiers_uncached (Lisp_Object symbol, ptrdiff_t *modifier_end) static Lisp_Object apply_modifiers_uncached (int modifiers, char *base, int base_len, int base_len_byte) { - /* Since BASE could contain NULs, we can't use intern here; we have + /* Since BASE could contain nulls, we can't use intern here; we have to use Fintern, which expects a genuine Lisp_String, and keeps a reference to it. */ char new_mods[sizeof "A-C-H-M-S-s-up-down-drag-double-triple-"]; diff --git a/src/lisp.h b/src/lisp.h index a24898004d..45353fbef3 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -1516,11 +1516,11 @@ STRING_MULTIBYTE (Lisp_Object str) } /* An upper bound on the number of bytes in a Lisp string, not - counting the terminating NUL. This a tight enough bound to + counting the terminating null. This a tight enough bound to prevent integer overflow errors that would otherwise occur during string size calculations. A string cannot contain more bytes than a fixnum can represent, nor can it be so long that C pointer - arithmetic stops working on the string plus its terminating NUL. + arithmetic stops working on the string plus its terminating null. Although the actual size limit (see STRING_BYTES_MAX in alloc.c) may be a bit smaller than STRING_BYTES_BOUND, calculating it here would expose alloc.c internal details that we'd rather keep @@ -2988,7 +2988,7 @@ CHECK_INTEGER (Lisp_Object x) /* Define a built-in function for calling from Lisp. `lname' should be the name to give the function in Lisp, - as a NUL-terminated C string. + as a null-terminated C string. `fnname' should be the name of the function in C. By convention, it starts with F. `sname' should be the name for the C constant structure @@ -4739,7 +4739,7 @@ extern char *xlispstrdup (Lisp_Object) ATTRIBUTE_MALLOC; extern void dupstring (char **, char const *); /* Make DEST a copy of STRING's data. Return a pointer to DEST's terminating - NUL byte. This is like stpcpy, except the source is a Lisp string. */ + null byte. This is like stpcpy, except the source is a Lisp string. */ INLINE char * lispstpcpy (char *dest, Lisp_Object string) @@ -4957,7 +4957,7 @@ enum : list4 (a, b, c, d)) /* Declare NAME as an auto Lisp string if possible, a GC-based one if not. - Take its unibyte value from the NUL-terminated string STR, + Take its unibyte value from the null-terminated string STR, an expression that should not have side effects. STR's value is not necessarily copied. The resulting Lisp string should not be modified or given text properties or made visible to @@ -4967,8 +4967,8 @@ enum AUTO_STRING_WITH_LEN (name, str, strlen (str)) /* Declare NAME as an auto Lisp string if possible, a GC-based one if not. - Take its unibyte value from the NUL-terminated string STR with length LEN. - STR may have side effects and may contain NUL bytes. + Take its unibyte value from the null-terminated string STR with length LEN. + STR may have side effects and may contain null bytes. STR's value is not necessarily copied. The resulting Lisp string should not be modified or given text properties or made visible to user code. */ diff --git a/src/module-env-25.h b/src/module-env-25.h index 01ce65e914..97c7787da3 100644 --- a/src/module-env-25.h +++ b/src/module-env-25.h @@ -80,13 +80,13 @@ EMACS_ATTRIBUTE_NONNULL(1); /* Copy the content of the Lisp string VALUE to BUFFER as an utf8 - NUL-terminated string. + null-terminated string. SIZE must point to the total size of the buffer. If BUFFER is NULL or if SIZE is not big enough, write the required buffer size to SIZE and return true. - Note that SIZE must include the last NUL byte (e.g. "abc" needs + Note that SIZE must include the last null byte (e.g. "abc" needs a buffer of size 4). Return true if the string was successfully copied. */ diff --git a/src/sysdep.c b/src/sysdep.c index e161172a79..f6c0ddee01 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -267,12 +267,12 @@ get_current_dir_name_or_unreachable (void) char *pwd; - /* The maximum size of a directory name, including the terminating NUL. + /* The maximum size of a directory name, including the terminating null. Leave room so that the caller can append a trailing slash. */ ptrdiff_t dirsize_max = min (PTRDIFF_MAX, SIZE_MAX) - 1; /* The maximum size of a buffer for a file name, including the - terminating NUL. This is bounded by PATH_MAX, if available. */ + terminating null. This is bounded by PATH_MAX, if available. */ ptrdiff_t bufsize_max = dirsize_max; #ifdef PATH_MAX bufsize_max = min (bufsize_max, PATH_MAX); @@ -3331,7 +3331,7 @@ system_process_attributes (Lisp_Object pid) if (nread) { - /* We don't want trailing NUL characters. */ + /* We don't want trailing null characters. */ for (p = cmdline + nread; cmdline < p && !p[-1]; p--) continue; diff --git a/src/termcap.c b/src/termcap.c index cc6f2d11ac..1ace4c9310 100644 --- a/src/termcap.c +++ b/src/termcap.c @@ -162,7 +162,7 @@ tgetst1 (char *ptr, char **area) else ret = *area; - /* Copy the string value, stopping at NUL or colon. + /* Copy the string value, stopping at null or colon. Also process ^ and \ abbreviations. */ p = ptr; r = ret; @@ -424,7 +424,7 @@ tgetent (char *bp, const char *name) return -1; buf.size = BUFSIZE; - /* Add 1 to size to ensure room for terminating NUL. */ + /* Add 1 to size to ensure room for terminating null. */ buf.beg = xmalloc (buf.size + 1); term = indirect ? indirect : (char *)name; @@ -480,7 +480,7 @@ tgetent (char *bp, const char *name) *bp1 = '\0'; /* Does this entry refer to another terminal type's entry? - If something is found, copy it into heap and NUL-terminate it. */ + If something is found, copy it into heap and null-terminate it. */ tc_search_point = find_capability (tc_search_point, "tc"); term = tgetst1 (tc_search_point, 0); } @@ -618,7 +618,7 @@ gobble_line (int fd, register struct termcap_buffer *bufp, char *append_end) { ptrdiff_t ptr_offset = bufp->ptr - buf; ptrdiff_t append_end_offset = append_end - buf; - /* Add 1 to size to ensure room for terminating NUL. */ + /* Add 1 to size to ensure room for terminating null. */ ptrdiff_t size = bufp->size + 1; bufp->beg = buf = xpalloc (buf, &size, 1, -1, 1); bufp->size = size - 1; diff --git a/src/timefns.c b/src/timefns.c index 71d5e10872..4a28f707a3 100644 --- a/src/timefns.c +++ b/src/timefns.c @@ -1311,7 +1311,7 @@ or (if you need time as a string) `format-time-string'. */) determine how many bytes would be written, use NULL for S and ((size_t) -1) for MAXSIZE. - This function behaves like nstrftime, except it allows NUL + This function behaves like nstrftime, except it allows null bytes in FORMAT. */ static size_t emacs_nmemftime (char *s, size_t maxsize, const char *format, @@ -1320,8 +1320,8 @@ emacs_nmemftime (char *s, size_t maxsize, const char *format, int saved_errno = errno; size_t total = 0; - /* Loop through all the NUL-terminated strings in the format - argument. Normally there's just one NUL-terminated string, but + /* Loop through all the null-terminated strings in the format + argument. Normally there's just one null-terminated string, but there can be arbitrarily many, concatenated together, if the format contains '\0' bytes. nstrftime stops at the first '\0' byte so we must invoke it separately for each such string. */ diff --git a/src/unexmacosx.c b/src/unexmacosx.c index 59cbe3c18b..8cf68bb92e 100644 --- a/src/unexmacosx.c +++ b/src/unexmacosx.c @@ -447,7 +447,7 @@ unexec_regions_recorder (task_t task, void *rr, unsigned type, while (num && num_unexec_regions < MAX_UNEXEC_REGIONS) { - /* Subtract the size of trailing NUL bytes from filesize. It + /* Subtract the size of trailing null bytes from filesize. It can be smaller than vmsize in segment commands. In such a case, trailing bytes are initialized with zeros. */ for (p = ranges->address + ranges->size; p > ranges->address; p--) diff --git a/src/w16select.c b/src/w16select.c index b56ced4f2e..75933526db 100644 --- a/src/w16select.c +++ b/src/w16select.c @@ -220,7 +220,7 @@ set_clipboard_data (unsigned Format, void *Data, unsigned Size, int Raw) /* need to know final size after '\r' chars are inserted (the standard CF_OEMTEXT clipboard format uses CRLF line endings, while Emacs uses just LF internally). */ - truelen = Size + 1; /* +1 for the terminating NUL */ + truelen = Size + 1; /* +1 for the terminating null */ if (!Raw) { @@ -243,7 +243,7 @@ set_clipboard_data (unsigned Format, void *Data, unsigned Size, int Raw) { dosmemput (Data, Size, xbuf_addr); - /* Terminate with a NUL, otherwise Windows does strange things + /* Terminate with a null, otherwise Windows does strange things when the text size is an integral multiple of 32 bytes. */ _farpokeb (_dos_ds, xbuf_addr + Size, '\0'); } @@ -255,7 +255,7 @@ set_clipboard_data (unsigned Format, void *Data, unsigned Size, int Raw) while (Size--) { /* Don't allow them to put binary data into the clipboard, since - it will cause yanked data to be truncated at the first NUL. */ + it will cause yanked data to be truncated at the first null. */ if (*dp == '\0') return 2; if (*dp == '\n') @@ -263,7 +263,7 @@ set_clipboard_data (unsigned Format, void *Data, unsigned Size, int Raw) _farnspokeb (buf_offset++, *dp++); } - /* Terminate with a NUL, otherwise Windows does strange things + /* Terminate with a null, otherwise Windows does strange things when the text size is an integral multiple of 32 bytes. */ _farnspokeb (buf_offset, '\0'); } @@ -354,13 +354,13 @@ get_clipboard_data (unsigned Format, void *Data, unsigned Size, int Raw) __dpmi_int (0x2f, ®s); if (regs.x.ax != 0) { - unsigned char nul_char = '\0'; + unsigned char null_char = '\0'; unsigned long xbuf_beg = xbuf_addr; /* If last_clipboard_text is NULL, we don't want to slow down the next loop by an additional test. */ register unsigned char *lcdp = - last_clipboard_text == NULL ? &nul_char : last_clipboard_text; + last_clipboard_text == NULL ? &null_char : last_clipboard_text; /* Copy data from low memory, remove CR characters before LF if needed. */ @@ -383,7 +383,7 @@ get_clipboard_data (unsigned Format, void *Data, unsigned Size, int Raw) /* Windows reportedly rounds up the size of clipboard data (passed in SIZE) to a multiple of 32, and removes trailing spaces from each line without updating SIZE. We therefore - bail out when we see the first NUL character. */ + bail out when we see the first null character. */ else if (c == '\0') break; } @@ -392,7 +392,7 @@ get_clipboard_data (unsigned Format, void *Data, unsigned Size, int Raw) last time set_clipboard_data was called, pretend there's no data in the clipboard. This is so we don't pass our own text from the clipboard (which might be troublesome if the killed - text includes NUL characters). */ + text includes null characters). */ if (last_clipboard_text && xbuf_addr - xbuf_beg == (long)(lcdp - last_clipboard_text)) dp = (unsigned char *)Data + 1; diff --git a/src/w32.c b/src/w32.c index 7b8a116d7a..5ebae324c2 100644 --- a/src/w32.c +++ b/src/w32.c @@ -6144,7 +6144,7 @@ is_symlink (const char *filename) /* If NAME identifies a symbolic link, copy into BUF the file name of the symlink's target. Copy at most BUF_SIZE bytes, and do NOT - NUL-terminate the target name, even if it fits. Return the number + null-terminate the target name, even if it fits. Return the number of bytes copied, or -1 if NAME is not a symlink or any error was encountered while resolving it. The file name copied into BUF is encoded in the current ANSI codepage. */ @@ -6248,10 +6248,10 @@ readlink (const char *name, char *buf, size_t buf_size) size_t size_to_copy = buf_size; /* According to MSDN, PrintNameLength does not include the - terminating NUL character. */ + terminating null character. */ lwname = alloca ((lwname_len + 1) * sizeof(WCHAR)); memcpy (lwname, lwname_src, lwname_len); - lwname[lwname_len/sizeof(WCHAR)] = 0; /* NUL-terminate */ + lwname[lwname_len/sizeof(WCHAR)] = 0; /* null-terminate */ filename_from_utf16 (lwname, resolved); dostounix_filename (resolved); lname_size = strlen (resolved) + 1; @@ -9884,7 +9884,7 @@ w32_read_registry (HKEY rootkey, Lisp_Object lkey, Lisp_Object lname) /* Convert input strings to UTF-16. */ encoded_key = code_convert_string_norecord (lkey, Qutf_16le, 1); memcpy (key_w, SSDATA (encoded_key), SBYTES (encoded_key)); - /* wchar_t strings need to be terminated by 2 NUL bytes. */ + /* wchar_t strings need to be terminated by 2 null bytes. */ key_w [SBYTES (encoded_key)/2] = L'\0'; encoded_vname = code_convert_string_norecord (lname, Qutf_16le, 1); memcpy (value_w, SSDATA (encoded_vname), SBYTES (encoded_vname)); @@ -9976,7 +9976,7 @@ w32_read_registry (HKEY rootkey, Lisp_Object lkey, Lisp_Object lname) case REG_SZ: if (use_unicode) { - /* pvalue ends with 2 NUL bytes, but we need only one, + /* pvalue ends with 2 null bytes, but we need only one, and AUTO_STRING_WITH_LEN will add it. */ if (pvalue[vsize - 1] == '\0') vsize -= 2; @@ -9985,7 +9985,7 @@ w32_read_registry (HKEY rootkey, Lisp_Object lkey, Lisp_Object lname) } else { - /* Don't waste a byte on the terminating NUL character, + /* Don't waste a byte on the terminating null character, since make_unibyte_string will add one anyway. */ if (pvalue[vsize - 1] == '\0') vsize--; diff --git a/src/w32fns.c b/src/w32fns.c index 3134f678f3..ef69f40611 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -7960,7 +7960,7 @@ DEFUN ("system-move-file-to-trash", Fsystem_move_file_to_trash, { SHFILEOPSTRUCTW file_op_w; /* We need one more element beyond MAX_PATH because this is - a list of file names, with the last element double-NUL + a list of file names, with the last element double-null terminated. */ wchar_t tmp_path_w[MAX_PATH + 1]; @@ -9732,7 +9732,7 @@ get_dll_version (const char *dll_name) /* Return the number of bytes in UTF-8 encoded string STR that corresponds to at most LIM characters. If STR ends before LIM characters, return the number of bytes in STR including the - terminating NUL byte. */ + terminating null byte. */ static int utf8_mbslen_lim (const char *str, int lim) { diff --git a/src/w32proc.c b/src/w32proc.c index c50f246a45..0cf8201306 100644 --- a/src/w32proc.c +++ b/src/w32proc.c @@ -2007,9 +2007,9 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp) } /* we have to do some conjuring here to put argv and envp into the - form CreateProcess wants... argv needs to be a space separated/NUL - terminated list of parameters, and envp is a NUL - separated/double-NUL terminated list of parameters. + form CreateProcess wants... argv needs to be a space separated/null + terminated list of parameters, and envp is a null + separated/double-null terminated list of parameters. Additionally, zero-length args and args containing whitespace or quote chars need to be wrapped in double quotes - for this to work, @@ -3398,10 +3398,10 @@ If LCID (a 16-bit number) is not a valid locale, the result is nil. */) got_full = GetLocaleInfo (XFIXNUM (lcid), XFIXNUM (longform), full_name, sizeof (full_name)); - /* GetLocaleInfo's return value includes the terminating NUL + /* GetLocaleInfo's return value includes the terminating null character, when the returned information is a string, whereas make_unibyte_string needs the string length without the - terminating NUL. */ + terminating null. */ if (got_full) return make_unibyte_string (full_name, got_full - 1); } diff --git a/src/w32select.c b/src/w32select.c index 4e5bd6a00f..e754e1f1ed 100644 --- a/src/w32select.c +++ b/src/w32select.c @@ -803,7 +803,7 @@ DEFUN ("w32-get-clipboard-data", Fw32_get_clipboard_data, (void) ignored; /* Don't pass our own text from the clipboard (which might be - troublesome if the killed text includes NUL characters). */ + troublesome if the killed text includes null characters). */ if (!NILP (current_text)) return ret; diff --git a/src/xdisp.c b/src/xdisp.c index 85738f361d..9e8f4fc5ad 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -11043,7 +11043,7 @@ message_log_check_duplicate (ptrdiff_t prev_bol_byte, ptrdiff_t this_bol_byte) /* Display an echo area message M with a specified length of NBYTES - bytes. The string may include NUL characters. If M is not a + bytes. The string may include null characters. If M is not a string, clear out any existing message, and let the mini-buffer text show through. @@ -11146,7 +11146,7 @@ message3_nolog (Lisp_Object m) } -/* Display a NUL-terminated echo area message M. If M is 0, clear +/* Display a null-terminated echo area message M. If M is 0, clear out any existing message, and let the mini-buffer text show through. The buffer M must continue to exist until after the echo area gets @@ -26153,7 +26153,7 @@ are the selected window and the WINDOW's buffer). */) return unbind_to (count, str); } -/* Write a NUL-terminated, right justified decimal representation of +/* Write a null-terminated, right justified decimal representation of the positive integer D to BUF using a minimal field width WIDTH. */ static void @@ -26183,7 +26183,7 @@ pint2str (register char *buf, register int width, register ptrdiff_t d) } } -/* Write a NUL-terminated, right justified decimal and "human +/* Write a null-terminated, right justified decimal and "human readable" representation of the nonnegative integer D to BUF using a minimal field width WIDTH. D should be smaller than 999.5e24. */ @@ -26406,7 +26406,7 @@ decode_mode_spec (struct window *w, register int c, int field_width, produce strings from numerical values, so limit preposterously large values of FIELD_WIDTH to avoid overrunning the buffer's end. The size of the buffer is enough for FRAME_MESSAGE_BUF_SIZE - bytes plus the terminating NUL. */ + bytes plus the terminating null. */ int width = min (field_width, FRAME_MESSAGE_BUF_SIZE (f)); struct buffer *b = current_buffer; diff --git a/src/xfont.c b/src/xfont.c index 1563b43bf9..32f63c3f7c 100644 --- a/src/xfont.c +++ b/src/xfont.c @@ -133,7 +133,7 @@ compare_font_names (const void *name1, const void *name2) /* Decode XLFD as iso-8859-1 into OUTPUT, and return the byte length of the decoding result. LEN is the byte length of XLFD, or -1 if - XLFD is NUL terminated. The caller must assure that OUTPUT is at + XLFD is NULL terminated. The caller must assure that OUTPUT is at least twice (plus 1) as large as XLFD. */ static ptrdiff_t commit 0a5a1adab986de39a147771b8f9aa21656ecc001 Author: Michael Albinus Date: Mon Oct 5 13:58:28 2020 +0200 * src/dbusbind.c (xd_signature): Better type check for array elements. * test/lisp/net/dbus-tests.el (dbus-test01-compound-types): Extend test. diff --git a/src/dbusbind.c b/src/dbusbind.c index 1ac77313a3..7904606d39 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c @@ -446,12 +446,18 @@ xd_signature (char *signature, int dtype, int parent_type, Lisp_Object object) { Lisp_Object elt1 = XD_NEXT_VALUE (elt); if (CONSP (elt1) && STRINGP (XCAR (elt1)) && NILP (XCDR (elt1))) - subsig = SSDATA (XCAR (elt1)); + { + subsig = SSDATA (XCAR (elt1)); + elt = Qnil; + } } while (!NILP (elt)) { - if (subtype != XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt))) + char x[DBUS_MAXIMUM_SIGNATURE_LENGTH]; + subtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt)); + xd_signature (x, subtype, dtype, CAR_SAFE (XD_NEXT_VALUE (elt))); + if (strcmp (subsig, x) != 0) wrong_type_argument (intern ("D-Bus"), CAR_SAFE (elt)); elt = CDR_SAFE (XD_NEXT_VALUE (elt)); } diff --git a/test/lisp/net/dbus-tests.el b/test/lisp/net/dbus-tests.el index 94816bb492..cd2e166c10 100644 --- a/test/lisp/net/dbus-tests.el +++ b/test/lisp/net/dbus-tests.el @@ -131,7 +131,7 @@ (should-error (dbus-check-arguments :session dbus--test-service :object-path) :type 'wrong-type-argument) - ;; Raises an error on stdin. + ;; Raises an error on stderr. (should-error (dbus-check-arguments :session dbus--test-service :object-path "string") :type 'dbus-error) @@ -144,7 +144,7 @@ (should-error (dbus-check-arguments :session dbus--test-service :signature) :type 'wrong-type-argument) - ;; Raises an error on stdin. + ;; Raises an error on stderr. (should-error (dbus-check-arguments :session dbus--test-service :signature "string") :type 'dbus-error) @@ -348,8 +348,12 @@ (should (dbus-check-arguments :session dbus--test-service '(:array :string "string1" "string2"))) + (should + (dbus-check-arguments + :session dbus--test-service '(:array :signature "s" :signature "ao"))) ;; Empty array (of strings). (should (dbus-check-arguments :session dbus--test-service '(:array))) + ;; Empty array (of object paths). (should (dbus-check-arguments :session dbus--test-service '(:array :signature "o"))) ;; Different element types. @@ -358,6 +362,13 @@ :session dbus--test-service '(:array :string "string" :object-path "/object/path")) :type 'wrong-type-argument) + ;; Different variant types in array don't matter. + (should + (dbus-check-arguments + :session dbus--test-service + '(:array + (:variant :string "string1") + (:variant (:struct :string "string2" :object-path "/object/path"))))) ;; `:variant'. It contains exactly one element. (should @@ -383,7 +394,7 @@ (dbus-check-arguments :session dbus--test-service '(:array (:dict-entry :string "string" :boolean nil)))) - ;; This is an alternative syntax. FIXME: Shall this be supported? + ;; This is an alternative syntax. (should (dbus-check-arguments :session dbus--test-service @@ -414,14 +425,14 @@ (dbus-check-arguments :session dbus--test-service '(:dict-entry :string "string" :boolean t)) :type 'wrong-type-argument) - ;; Different dict entry types are not ched. FIXME: Add check. - ;; (should-error - ;; (dbus-check-arguments - ;; :session dbus--test-service - ;; '(:array - ;; (:dict-entry :string "string1" :boolean t) - ;; (:dict-entry :string "string2" :object-path "/object/path"))) - ;; :type 'wrong-type-argument) + ;; Different dict entry types in array. + (should-error + (dbus-check-arguments + :session dbus--test-service + '(:array + (:dict-entry :string "string1" :boolean t) + (:dict-entry :string "string2" :object-path "/object/path"))) + :type 'wrong-type-argument) ;; `:struct'. There is no restriction what could be an element of a struct. (should @@ -434,6 +445,14 @@ ;; Empty struct. (should-error (dbus-check-arguments :session dbus--test-service '(:struct)) + :type 'wrong-type-argument) + ;; Different struct types in array. + (should-error + (dbus-check-arguments + :session dbus--test-service + '(:array + (:struct :string "string1" :boolean t) + (:struct :object-path "/object/path"))) :type 'wrong-type-argument)) (defun dbus--test-register-service (bus) commit c47479cf171cac3d2b867fc4663398c3c3531524 Author: Jared Finder Date: Mon Oct 5 10:20:56 2020 +0200 Sort items in tmm properly, and allow clicking the final item * lisp/tmm.el (tmm-menubar-keymap): Sort the final items properly. (tmm-menubar): Allow clicking the final menu item (bug#43756). diff --git a/lisp/tmm.el b/lisp/tmm.el index e9f3f5b038..0e83f427f5 100644 --- a/lisp/tmm.el +++ b/lisp/tmm.el @@ -50,14 +50,19 @@ The ordering of the return value respects `menu-bar-final-items'." (menu-end '())) (map-keymap (lambda (key binding) - (push (cons key binding) - ;; If KEY is the name of an item that we want to put last, - ;; move it to the end. - (if (memq key menu-bar-final-items) - menu-end - menu-bar))) + (let ((pos (seq-position menu-bar-final-items key)) + (menu-item (cons key binding))) + (if pos + ;; If KEY is the name of an item that we want to put + ;; last, store it separately with explicit ordering for + ;; sorting. + (push (cons pos menu-item) menu-end) + (push menu-item menu-bar)))) (tmm-get-keybind [menu-bar])) - `(keymap ,@(nreverse menu-bar) ,@(nreverse menu-end)))) + `(keymap ,@(nreverse menu-bar) + ,@(mapcar #'cdr (sort menu-end + (lambda (a b) + (< (car a) (car b)))))))) ;;;###autoload (define-key global-map "\M-`" 'tmm-menubar) ;;;###autoload (define-key global-map [menu-bar mouse-1] 'tmm-menubar-mouse) @@ -96,7 +101,10 @@ to invoke `tmm-menubar' instead, customize the variable (or (null visible) (eval visible))))))) (setq column (+ column (length name) 1))))) - menu-bar)))) + menu-bar) + ;; Check the last menu item. + (when (> column x-position) + (setq menu-bar-item prev-key))))) (tmm-prompt menu-bar nil menu-bar-item))) ;;;###autoload diff --git a/src/keyboard.c b/src/keyboard.c index af075a42c7..8cf3ec1813 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -12106,7 +12106,8 @@ See also `pre-command-hook'. */); DEFVAR_LISP ("menu-bar-final-items", Vmenu_bar_final_items, doc: /* List of menu bar items to move to the end of the menu bar. -The elements of the list are event types that may have menu bar bindings. */); +The elements of the list are event types that may have menu bar +bindings. The order of this list controls the order of the items. */); Vmenu_bar_final_items = Qnil; DEFVAR_LISP ("tab-bar-separator-image-expression", Vtab_bar_separator_image_expression, commit 7301bf996e71fb7f3b8c50357c89853b8af78533 Author: Juri Linkov Date: Mon Oct 5 09:01:03 2020 +0200 Use … in Gnus mode lines (when shortening them) * lisp/gnus/gnus-sum.el (gnus-set-mode-line): Defer ellipsis creation to `truncate-string-to-width' (bug#41250). This uses … by default. diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index b3ed5cb664..561f199531 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el @@ -6240,8 +6240,8 @@ If WHERE is `summary', the summary mode line format will be used." ;; We might have to chop a bit of the string off... (when (> (length mode-string) max-len) (setq mode-string - (concat (truncate-string-to-width mode-string (- max-len 3)) - "..."))))) + (truncate-string-to-width + mode-string (- max-len 3) nil nil t))))) ;; Update the mode line. (setq mode-line-buffer-identification (gnus-mode-line-buffer-identification (list mode-string))) commit d494833d47968fcd97ba549654a259d6fb6c2eee Author: Nathan Moreau Date: Mon Oct 5 08:50:08 2020 +0200 Improve support for using vc commands in indirect buffers * lisp/vc/vc.el (vc-deduce-fileset-1): New defun. (vc-deduce-fileset): Adapt. (vc-maybe-buffer-sync): New defun. (vc-diff): Adapt. (vc-ediff): Adapt. (vc-root-diff): Adapt. (vc-revision-other-window): Adapt (bug#40967). diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 3852a64550..46c44fa54b 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -1038,7 +1038,9 @@ If the current buffer is in `vc-dir' or Dired mode, FILESET is the list of marked files, or the current directory if no files are marked. Otherwise, if the current buffer is visiting a version-controlled -file, FILESET is a single-file list containing that file's name. +file or is an indirect buffer whose base buffer visits a +version-controlled file, FILESET is a single-file list containing +that file's name. Otherwise, if ALLOW-UNREGISTERED is non-nil and the visited file is unregistered, FILESET is a single-file list containing the name of the visited file. @@ -1052,6 +1054,14 @@ possible values of STATE are explained in `vc-state', and MODEL in the returned list. BEWARE: this function may change the current buffer." + (with-current-buffer (or (buffer-base-buffer) (current-buffer)) + (vc-deduce-fileset-1 not-state-changing + allow-unregistered + state-model-only-files))) + +(defun vc-deduce-fileset-1 (not-state-changing + allow-unregistered + state-model-only-files) (let (backend) (cond ((derived-mode-p 'vc-dir-mode) @@ -1073,7 +1083,7 @@ BEWARE: this function may change the current buffer." (derived-mode-p 'dired-mode))))) (progn ;FIXME: Why not `with-current-buffer'? --Stef. (set-buffer vc-parent-buffer) - (vc-deduce-fileset not-state-changing allow-unregistered state-model-only-files))) + (vc-deduce-fileset-1 not-state-changing allow-unregistered state-model-only-files))) ((and (not buffer-file-name) (setq backend (vc-responsible-backend default-directory))) (list backend nil)) @@ -1883,6 +1893,10 @@ state of each file in the fileset." t (list backend (list rootdir)) rev1 rev2 (called-interactively-p 'interactive))))) +(defun vc-maybe-buffer-sync (not-urgent) + (with-current-buffer (or (buffer-base-buffer) (current-buffer)) + (when buffer-file-name (vc-buffer-sync not-urgent)))) + ;;;###autoload (defun vc-diff (&optional historic not-urgent) "Display diffs between file revisions. @@ -1895,6 +1909,7 @@ saving the buffer." (interactive (list current-prefix-arg t)) (if historic (call-interactively 'vc-version-diff) + (vc-maybe-buffer-sync not-urgent) (let ((fileset (vc-deduce-fileset t))) (vc-buffer-sync-fileset fileset not-urgent) (vc-diff-internal t fileset nil nil @@ -1981,7 +1996,7 @@ saving the buffer." (interactive (list current-prefix-arg t)) (if historic (call-interactively 'vc-version-ediff) - (when buffer-file-name (vc-buffer-sync not-urgent)) + (vc-maybe-buffer-sync not-urgent) (vc-version-ediff (cadr (vc-deduce-fileset t)) nil nil))) ;;;###autoload @@ -1998,7 +2013,7 @@ saving the buffer." (if historic ;; We want the diff for the VC root dir. (call-interactively 'vc-root-version-diff) - (when buffer-file-name (vc-buffer-sync not-urgent)) + (vc-maybe-buffer-sync not-urgent) (let ((backend (vc-deduce-backend)) (default-directory default-directory) rootdir working-revision) @@ -2038,17 +2053,18 @@ Return nil if the root directory cannot be identified." If the current file is named `F', the revision is named `F.~REV~'. If `F.~REV~' already exists, use it instead of checking it out again." (interactive - (save-current-buffer + (with-current-buffer (or (buffer-base-buffer) (current-buffer)) (vc-ensure-vc-buffer) (list (vc-read-revision "Revision to visit (default is working revision): " (list buffer-file-name))))) - (vc-ensure-vc-buffer) - (let* ((file buffer-file-name) - (revision (if (string-equal rev "") - (vc-working-revision file) - rev))) - (switch-to-buffer-other-window (vc-find-revision file revision)))) + (with-current-buffer (or (buffer-base-buffer) (current-buffer)) + (vc-ensure-vc-buffer) + (let* ((file buffer-file-name) + (revision (if (string-equal rev "") + (vc-working-revision file) + rev))) + (switch-to-buffer-other-window (vc-find-revision file revision))))) (defun vc-find-revision (file revision &optional backend) "Read REVISION of FILE into a buffer and return the buffer. commit c0577d7a39284d05da824906debd28b2be03edf1 Author: Eli Zaretskii Date: Mon Oct 5 08:37:02 2020 +0300 Fix the documentation parts of a recent commit * lisp/international/mule-util.el (truncate-string-ellipsis): Doc fix. * doc/lispref/display.texi (Size of Displayed Text): Improve wording and accuracy of the documentation of 'truncate-string-to-width'. Document the function 'truncate-string-ellipsis'. * etc/NEWS: Improve the wording of the entry for 'truncate-string-to-width'. diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index a70f61e43e..d2e6cad6c4 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -1970,37 +1970,45 @@ This function returns the width in columns of the string @var{string}, if it were displayed in the current buffer and the selected window. @end defun -@defun truncate-string-to-width string width &optional start-column padding ellipsis -This function returns the part of @var{string} that fits within -@var{width} columns, as a new string. +@defun truncate-string-to-width string width &optional start-column padding ellipsis ellipsis-text-property +This function returns a new string that is a truncation of @var{string} +which fits within @var{width} columns on display. -If @var{string} does not reach @var{width}, then the result ends where -@var{string} ends. If one multi-column character in @var{string} -extends across the column @var{width}, that character is not included in -the result. Thus, the result can fall short of @var{width} but cannot -go beyond it. +If @var{string} is narrower than @var{width}, the result is equal to +@var{string}; otherwise excess characters are omitted from the result. +If a multi-column character in @var{string} exceeds the goal +@var{width}, that character is omitted from the result. Thus, the +result can sometimes fall short of @var{width}, but cannot go beyond +it. The optional argument @var{start-column} specifies the starting column. If this is non-@code{nil}, then the first @var{start-column} columns of -the string are omitted from the value. If one multi-column character in +the string are omitted from the result. If one multi-column character in @var{string} extends across the column @var{start-column}, that -character is not included. +character is omitted. The optional argument @var{padding}, if non-@code{nil}, is a padding -character added at the beginning and end of the result string, to extend -it to exactly @var{width} columns. The padding character is used at the -end of the result if it falls short of @var{width}. It is also used at -the beginning of the result if one multi-column character in +character added at the beginning and end of the result string, to +extend it to exactly @var{width} columns. The padding character is +appended at the end of the result if it falls short of @var{width}, as +many times as needed to reach @var{width}. It is also prepended at +the beginning of the result if a multi-column character in @var{string} extends across the column @var{start-column}. -@vindex truncate-string-ellipsis If @var{ellipsis} is non-@code{nil}, it should be a string which will -replace the end of @var{string} (including any padding) if it extends -beyond @var{width}, unless the display width of @var{string} is equal -to or less than the display width of @var{ellipsis}. If -@var{ellipsis} is non-@code{nil} and not a string, it stands for -the value of the variable @code{truncate-string-ellipsis}, or -to three dots when it's nil. +replace the end of @var{string} when it is truncated. In this case, +more charcaters will be removed from @var{string} to free enough space +for @var{ellipsis} to fit within @var{width} columns. However, if +the display width of @var{string} is less than the display width of +@var{ellipsis}, @var{ellipsis} will not be appended to the result. If +@var{ellipsis} is non-@code{nil} and not a string, it stands for the +value returned by the function @code{truncate-string-ellipsis}, +described below. + +The optional argument @var{ellipsis-text-property}, if non-@code{nil}, +means hide the excess parts of @var{string} with a @code{display} text +property (@pxref{Display Property}) showing the ellipsis, instead of +actually truncating the string. @example (truncate-string-to-width "\tab\t" 12 4) @@ -2010,6 +2018,16 @@ to three dots when it's nil. @end example @end defun +@defun truncate-string-ellipsis +This function returns the string to be used as an ellipses in +@code{truncate-string-to-width} and other similar contexts. The value +is that of the variable @code{truncate-string-ellipsis}, if it's +non-@code{nil}, the string with the single character @sc{U+2026 +HORIZONTAL ELLIPSIS} if that character can be displayed on the +selected frame, and the string @samp{...} otherwise. +@end defun + + The following function returns the size in pixels of text as if it were displayed in a given window. This function is used by @code{fit-window-to-buffer} and @code{fit-frame-to-buffer} diff --git a/etc/NEWS b/etc/NEWS index cda4430c81..d05b706ea3 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1479,10 +1479,10 @@ ledit.el, lmenu.el, lucid.el and old-whitespace.el. * Lisp Changes in Emacs 28.1 +++ -** 'truncate-string-ellipsis' uses the character '…' by default. -Modes that use 'truncate-string-to-width' with non-nil non-string -argument 'ellipsis', now indicate truncation using '…' when -the selected frame can display it, and "..." otherwise. +** 'truncate-string-ellipsis' now uses '…' by default. +Modes that use 'truncate-string-to-width' with non-nil, non-string +argument 'ellipsis', will now indicate truncation using '…' when +the selected frame can display it, and using "..." otherwise. +++ *** New command 'make-directory-autoloads'. diff --git a/lisp/international/mule-util.el b/lisp/international/mule-util.el index d792b2530c..c757e86698 100644 --- a/lisp/international/mule-util.el +++ b/lisp/international/mule-util.el @@ -50,7 +50,7 @@ Serves as default value of ELLIPSIS argument to `truncate-string-to-width' returned by the function `truncate-string-ellipsis'.") (defun truncate-string-ellipsis () - "Return a string to use to indicate truncation. + "Return the string used to indicate truncation. Use the value of the variable `truncate-string-ellipsis' when it's non-nil. Otherwise, return `…' when it's displayable on the selected frame, or `...'. This function needs to be called on every use of commit 14a5db2912d9e4e802c1eeddfb3e551f9fb8f753 Author: Stefan Monnier Date: Sun Oct 4 22:50:38 2020 -0400 * src/xdisp.c (syms_of_xdisp): New var `redisplay_skip_initial_frame`. This makes it possible to run most of the redisplay code (tho not the actual drawing since there's nowhere to draw) even when there's no real frame at hand, as is the case in batch mode. This makes `xdisp-tests--minibuffer-resizing` work even in batch. (redisplay_internal): Obey it. (init_xdisp): Set `echo_area_window` even in noninteractive mode. * src/dispnew.c (update_frame): Skip the initial frame. * src/frame.c (make_frame): Use 80x25 as the default initial size. * test/src/xdisp-tests.el (xdisp-tests--minibuffer-resizing): Use the new var and fix use of `executing-kbd-macro`. diff --git a/etc/NEWS b/etc/NEWS index d67156194a..cda4430c81 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -85,6 +85,10 @@ useful on systems such as FreeBSD which ships only with "etc/termcap". * Changes in Emacs 28.1 +*** New var 'redisplay-skip-initial-frame' to enable batch redisplay tests. +Setting it to nil forces the redisplay to do its job even in the +initial frame used in batch mode. + --- ** Support for the 'strike-through' face attribute on TTY frames. If your terminal's termcap or terminfo database entry has the 'smxx' diff --git a/src/dispnew.c b/src/dispnew.c index d318e26308..3f2ae3e6ad 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -1830,7 +1830,7 @@ adjust_frame_glyphs (struct frame *f) /* Don't forget the buffer for decode_mode_spec. */ adjust_decode_mode_spec_buffer (f); - f->glyphs_initialized_p = 1; + f->glyphs_initialized_p = true; unblock_input (); } @@ -2251,7 +2251,7 @@ free_glyphs (struct frame *f) /* Block interrupt input so that we don't get surprised by an X event while we're in an inconsistent state. */ block_input (); - f->glyphs_initialized_p = 0; + f->glyphs_initialized_p = false; /* Release window sub-matrices. */ if (!NILP (f->root_window)) @@ -3236,9 +3236,16 @@ update_frame (struct frame *f, bool force_p, bool inhibit_hairy_id_p) build_frame_matrix (f); /* Update the display. */ - update_begin (f); - paused_p = update_frame_1 (f, force_p, inhibit_hairy_id_p, 1, false); - update_end (f); + if (FRAME_INITIAL_P (f)) + /* No actual display to update so the "update" is a nop and + obviously isn't interrupted by pending input. */ + paused_p = false; + else + { + update_begin (f); + paused_p = update_frame_1 (f, force_p, inhibit_hairy_id_p, 1, false); + update_end (f); + } if (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) { diff --git a/src/frame.c b/src/frame.c index 3f93450437..0b707c2af8 100644 --- a/src/frame.c +++ b/src/frame.c @@ -931,18 +931,18 @@ make_frame (bool mini_p) wset_frame (rw, frame); - /* 10 is arbitrary, + /* 80/25 is arbitrary, just so that there is "something there." Correct size will be set up later with adjust_frame_size. */ - SET_FRAME_COLS (f, 10); - SET_FRAME_LINES (f, 10); + SET_FRAME_COLS (f, 80); + SET_FRAME_LINES (f, 25); SET_FRAME_WIDTH (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f)); SET_FRAME_HEIGHT (f, FRAME_LINES (f) * FRAME_LINE_HEIGHT (f)); - rw->total_cols = 10; + rw->total_cols = FRAME_COLS (f); rw->pixel_width = rw->total_cols * FRAME_COLUMN_WIDTH (f); - rw->total_lines = mini_p ? 9 : 10; + rw->total_lines = FRAME_LINES (f) - (mini_p ? 1 : 0); rw->pixel_height = rw->total_lines * FRAME_LINE_HEIGHT (f); if (mini_p) @@ -1101,7 +1101,7 @@ make_initial_frame (void) terminal = init_initial_terminal (); - f = make_frame (1); + f = make_frame (true); XSETFRAME (frame, f); Vframe_list = Fcons (frame, Vframe_list); diff --git a/src/xdisp.c b/src/xdisp.c index d9101592b2..85738f361d 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -15464,7 +15464,8 @@ redisplay_internal (void) /* No redisplay if running in batch mode or frame is not yet fully initialized, or redisplay is explicitly turned off by setting Vinhibit_redisplay. */ - if (FRAME_INITIAL_P (SELECTED_FRAME ()) + if ((FRAME_INITIAL_P (SELECTED_FRAME ()) + && redisplay_skip_initial_frame) || !NILP (Vinhibit_redisplay)) return; @@ -35452,6 +35453,12 @@ When nil, mouse-movement events will not be generated as long as the mouse stays within the extent of a single glyph (except for images). */); mouse_fine_grained_tracking = false; + DEFVAR_BOOL ("redisplay-skip-initial-frame", redisplay_skip_initial_frame, + doc: /* Non-nil to skip redisplay in initial frame. +The initial frame is not displayed anywhere, so skipping it is +best except in special circumstances such as running redisplay tests +in batch mode. */); + redisplay_skip_initial_frame = true; } @@ -35462,6 +35469,8 @@ init_xdisp (void) { CHARPOS (this_line_start_pos) = 0; + echo_area_window = minibuf_window; + if (!noninteractive) { struct window *m = XWINDOW (minibuf_window); @@ -35471,8 +35480,6 @@ init_xdisp (void) struct window *r = XWINDOW (root); int i; - echo_area_window = minibuf_window; - r->top_line = FRAME_TOP_MARGIN (f); r->pixel_top = r->top_line * FRAME_LINE_HEIGHT (f); r->total_cols = FRAME_COLS (f); diff --git a/test/src/xdisp-tests.el b/test/src/xdisp-tests.el index 3d0d0f5830..95c39dacc3 100644 --- a/test/src/xdisp-tests.el +++ b/test/src/xdisp-tests.el @@ -33,19 +33,21 @@ (lambda () (insert "hello") (let ((ol (make-overlay (point) (point))) + (redisplay-skip-initial-frame nil) (max-mini-window-height 1) (text "askdjfhaklsjdfhlkasjdfhklasdhflkasdhflkajsdhflkashdfkljahsdlfkjahsdlfkjhasldkfhalskdjfhalskdfhlaksdhfklasdhflkasdhflkasdhflkajsdhklajsdgh")) - ;; (save-excursion (insert text)) - ;; (sit-for 2) - ;; (delete-region (point) (point-max)) - (put-text-property 0 1 'cursor t text) - (overlay-put ol 'after-string text) - (redisplay 'force) - (throw 'result - ;; Make sure we do the see "hello" text. - (prog1 (equal (window-start) (point-min)) - ;; (list (window-start) (window-end) (window-width)) - (delete-overlay ol))))) + ;; (save-excursion (insert text)) + ;; (sit-for 2) + ;; (delete-region (point) (point-max)) + (put-text-property 0 1 'cursor t text) + (overlay-put ol 'after-string text) + (let ((executing-kbd-macro nil)) ;Don't skip redisplay + (redisplay 'force)) + (throw 'result + ;; Make sure we do the see "hello" text. + (prog1 (equal (window-start) (point-min)) + ;; (list (window-start) (window-end) (window-width)) + (delete-overlay ol))))) (let ((executing-kbd-macro t)) ;Force real minibuffer in `read-string'. (read-string "toto: "))))))) commit 5ec21155c39aab8a452d190a260e6912d1d9a920 Author: Juri Linkov Date: Sun Oct 4 22:41:36 2020 +0300 Use '…' for ellipsis in truncate-string-to-width by default (bug#41250) * lisp/international/mule-util.el (truncate-string-ellipsis): Change the default value to nil. (truncate-string-ellipsis): New function. (truncate-string-to-width): Use the value returned from the function 'truncate-string-ellipsis'. * lisp/tab-bar.el (tab-bar-tab-name-truncated): * lisp/tab-line.el (tab-line-tab-name-ellipsis): Take advantage of the improvement of the ellipsis default value in truncate-string-to-width and truncate-string-ellipsis. * doc/lispref/display.texi (Size of Displayed Text): Improve description of truncate-string-ellipsis. diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 7d1c14c816..a70f61e43e 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -1999,7 +1999,8 @@ replace the end of @var{string} (including any padding) if it extends beyond @var{width}, unless the display width of @var{string} is equal to or less than the display width of @var{ellipsis}. If @var{ellipsis} is non-@code{nil} and not a string, it stands for -the value of the variable @code{truncate-string-ellipsis}. +the value of the variable @code{truncate-string-ellipsis}, or +to three dots when it's nil. @example (truncate-string-to-width "\tab\t" 12 4) diff --git a/etc/NEWS b/etc/NEWS index 88957fb01a..d67156194a 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1474,6 +1474,12 @@ ledit.el, lmenu.el, lucid.el and old-whitespace.el. * Lisp Changes in Emacs 28.1 ++++ +** 'truncate-string-ellipsis' uses the character '…' by default. +Modes that use 'truncate-string-to-width' with non-nil non-string +argument 'ellipsis', now indicate truncation using '…' when +the selected frame can display it, and "..." otherwise. + +++ *** New command 'make-directory-autoloads'. This does the same as the old command 'update-directory-autoloads', diff --git a/lisp/international/mule-util.el b/lisp/international/mule-util.el index 660ac58e02..d792b2530c 100644 --- a/lisp/international/mule-util.el +++ b/lisp/international/mule-util.el @@ -44,9 +44,22 @@ (setq i (1+ i))))) string) -(defvar truncate-string-ellipsis "..." ;"…" +(defvar truncate-string-ellipsis nil "String to use to indicate truncation. -Serves as default value of ELLIPSIS argument to `truncate-string-to-width'.") +Serves as default value of ELLIPSIS argument to `truncate-string-to-width' +returned by the function `truncate-string-ellipsis'.") + +(defun truncate-string-ellipsis () + "Return a string to use to indicate truncation. +Use the value of the variable `truncate-string-ellipsis' when it's non-nil. +Otherwise, return `…' when it's displayable on the selected frame, +or `...'. This function needs to be called on every use of +`truncate-string-to-width' to decide whether the selected frame +can display the character `…'." + (cond + (truncate-string-ellipsis) + ((char-displayable-p ?…) "…") + ("..."))) ;;;###autoload (defun truncate-string-to-width (str end-column @@ -73,7 +86,7 @@ If ELLIPSIS is non-nil, it should be a string which will replace the end of STR (including any padding) if it extends beyond END-COLUMN, unless the display width of STR is equal to or less than the display width of ELLIPSIS. If it is non-nil and not a string, then ELLIPSIS -defaults to `truncate-string-ellipsis'. +defaults to `truncate-string-ellipsis', or to three dots when it's nil. If ELLIPSIS-TEXT-PROPERTY is non-nil, a too-long string will not be truncated, but instead the elided parts will be covered by a @@ -81,7 +94,7 @@ be truncated, but instead the elided parts will be covered by a (or start-column (setq start-column 0)) (when (and ellipsis (not (stringp ellipsis))) - (setq ellipsis truncate-string-ellipsis)) + (setq ellipsis (truncate-string-ellipsis))) (let ((str-len (length str)) (str-width (string-width str)) (ellipsis-width (if ellipsis (string-width ellipsis) 0)) diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 9c6b9cbc04..2604955224 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -363,22 +363,18 @@ to `tab-bar-tab-name-truncated'." :group 'tab-bar :version "27.1") -(defvar tab-bar-tab-name-ellipsis nil) +(defvar tab-bar-tab-name-ellipsis t) (defun tab-bar-tab-name-truncated () "Generate tab name from the buffer of the selected window. Truncate it to the length specified by `tab-bar-tab-name-truncated-max'. Append ellipsis `tab-bar-tab-name-ellipsis' in this case." - (let ((tab-name (buffer-name (window-buffer (minibuffer-selected-window)))) - (ellipsis (cond - (tab-bar-tab-name-ellipsis) - ((char-displayable-p ?…) "…") - ("...")))) + (let ((tab-name (buffer-name (window-buffer (minibuffer-selected-window))))) (if (< (length tab-name) tab-bar-tab-name-truncated-max) tab-name (propertize (truncate-string-to-width tab-name tab-bar-tab-name-truncated-max nil nil - ellipsis) + tab-bar-tab-name-ellipsis) 'help-echo tab-name)))) diff --git a/lisp/tab-line.el b/lisp/tab-line.el index 8da554a326..46bf89f14e 100644 --- a/lisp/tab-line.el +++ b/lisp/tab-line.el @@ -240,8 +240,7 @@ to `tab-line-tab-name-truncated-buffer'." :group 'tab-line :version "27.1") -(defvar tab-line-tab-name-ellipsis - (if (char-displayable-p ?…) "…" "...")) +(defvar tab-line-tab-name-ellipsis t) (defun tab-line-tab-name-truncated-buffer (buffer &optional _buffers) "Generate tab name from BUFFER. commit 96a8e846061f255b1a394a5854197aa742dfff84 Author: Michael Albinus Date: Sun Oct 4 18:56:45 2020 +0200 Make dbus-unregister-object work for monitors * doc/misc/dbus.texi (Monitoring Messages): Rename from "Monitoring Events". (Register Objects, Monitoring Messages): Mention returned object. * lisp/net/dbus.el (dbus-unregister-object): Adapt docstring. (dbus-unregister-object): Delete monitor if needed. (dbus-register-monitor): Return proper object. * src/dbusbind.c (dbus-registered-objects-table): Adapt docstring. * test/lisp/net/dbus-tests.el (dbus--test-signal-handler): Adapt docstring. (dbus-test08-register-monitor): New test. diff --git a/doc/misc/dbus.texi b/doc/misc/dbus.texi index 4b2eab4eb7..5a1dd55248 100644 --- a/doc/misc/dbus.texi +++ b/doc/misc/dbus.texi @@ -63,7 +63,7 @@ another. An overview of D-Bus can be found at * Signals:: Sending and receiving signals. * Alternative Buses:: Alternative buses and environments. * Errors and Events:: Errors and events. -* Monitoring Events:: Monitoring events. +* Monitoring Messages:: Monitoring messages. * Index:: Index including concepts, functions, variables. * GNU Free Documentation License:: The license for this documentation. @@ -1622,7 +1622,9 @@ are constructed incrementally by adding single methods or properties at a time, @var{dont-register-service} can be used to prevent other clients from discovering the still incomplete interface. -@noindent Example: +@code{dbus-register-property} returns a Lisp object, which can be used +as argument in @code{dbus-unregister-object} for removing the +registration for @var{property}. Example: @lisp (dbus-register-property @@ -1687,9 +1689,9 @@ It is also possible to apply the @code{dbus-get-property}, @defun dbus-unregister-object object This function unregisters @var{object} from the D-Bus. @var{object} must be the result of a preceding @code{dbus-register-method}, -@code{dbus-register-property} or @code{dbus-register-signal} call -(@pxref{Signals}). It returns @code{t} if @var{object} has been -unregistered, @code{nil} otherwise. +@code{dbus-register-property}, @code{dbus-register-signal} +(@pxref{Signals}) or @code{dbus-register-monitor} call. It returns +@code{t} if @var{object} has been unregistered, @code{nil} otherwise. When @var{object} identifies the last method or property, which is registered for the respective service, Emacs releases its association @@ -2099,24 +2101,24 @@ D-Bus applications running. They should therefore check carefully, whether a given D-Bus error is related to them. -@node Monitoring Events -@chapter Monitoring events. +@node Monitoring Messages +@chapter Monitoring messages. @cindex monitoring @defun dbus-register-monitor bus &optional handler &key type sender destination path interface member -This function registers @var{handler} for monitor events on the D-Bus -@var{bus}. +This function registers @var{handler} for monitoring messages on the +D-Bus @var{bus}. @var{bus} is either a Lisp keyword, @code{:system} or @code{:session}, or a string denoting the bus address. @findex dbus-monitor-handler -@var{handler} is the function to be called when a monitor event -arrives. It is called with the `args' slot of the monitor event, -which are stripped off the type keywords. If @var{handler} is -@code{nil}, the default handler @code{dbus-monitor-handler} is -applied. This default handler behaves similar to the -@command{dbus-monitor} program. +@var{handler} is the function to be called when a D-Bus event to be +monitored arrives. It is called with the @var{args} slot of the D-Bus +event (@pxref{Errors and Events}), which are stripped off the type +keywords. If @var{handler} is @code{nil}, the default handler +@code{dbus-monitor-handler} is applied. This default handler behaves +similar to the @command{dbus-monitor} program. The other arguments are keyword-value pairs. @code{:type @var{type}} defines the message type to be monitored. If given, it must be equal @@ -2132,6 +2134,9 @@ names. @code{:member @var{member}} is either a method name, a signal name, or an error name. +@code{dbus-register-monitor} returns a Lisp object, which can be used +as argument in @code{dbus-unregister-object} for removing the monitor. + The following form shows all D-Bus events on the session bus in buffer @samp{*D-Bus Monitor*}: diff --git a/lisp/net/dbus.el b/lisp/net/dbus.el index 48712a9c3d..77ba5266dc 100644 --- a/lisp/net/dbus.el +++ b/lisp/net/dbus.el @@ -912,8 +912,9 @@ discovering the still incomplete interface." (defun dbus-unregister-object (object) "Unregister OBJECT from D-Bus. OBJECT must be the result of a preceding `dbus-register-method', -`dbus-register-property' or `dbus-register-signal' call. It -returns t if OBJECT has been unregistered, nil otherwise. +`dbus-register-signal', `dbus-register-property' or +`dbus-register-monitor' call. The function returns t if OBJECT +has been unregistered, nil otherwise. When OBJECT identifies the last method or property, which is registered for the respective service, Emacs releases its @@ -951,7 +952,10 @@ association to the service from D-Bus." (when (eq type :signal) (dbus-call-method bus dbus-service-dbus dbus-path-dbus dbus-interface-dbus - "RemoveMatch" (nth 4 elt))))) + "RemoveMatch" (nth 4 elt))) + ;; Delete monitor connection by reestablishing private bus. + (when (eq type :monitor) + (dbus-init-bus bus 'private)))) ;; Check, whether there is still a registered function or property ;; for the given service. If not, unregister the service from the @@ -2037,7 +2041,7 @@ either a method name, a signal name, or an error name." (when dbus-debug (message "%s" dbus-registered-objects-table)) ;; Return the object. - (list key key1))) + (list key (list nil nil handler)))) (defconst dbus-monitor-method-call (propertize "method-call" 'face 'font-lock-function-name-face) diff --git a/src/dbusbind.c b/src/dbusbind.c index cca5f13907..1ac77313a3 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c @@ -1937,11 +1937,12 @@ syms_of_dbusbind (void) doc: /* Hash table of registered functions for D-Bus. There are two different uses of the hash table: for accessing -registered interfaces properties, targeted by signals or method calls, -and for calling handlers in case of non-blocking method call returns. +registered interfaces properties, targeted by signals, method calls or +monitors, and for calling handlers in case of non-blocking method call +returns. In the first case, the key in the hash table is the list (TYPE BUS -INTERFACE MEMBER). TYPE is one of the Lisp symbols `:method', +[INTERFACE MEMBER]). TYPE is one of the Lisp symbols `:method', `:signal', `:property' or `:monitor'. BUS is either a Lisp symbol, `:system', `:session', `:system-private' or `:session-private', or a string denoting the bus address. INTERFACE is a string which denotes @@ -1951,17 +1952,18 @@ signal or a property INTERFACE is offering. All arguments can be nil. The value in the hash table is a list of quadruple lists ((UNAME SERVICE PATH OBJECT [RULE]) ...). SERVICE is the service name as registered, UNAME is the corresponding unique name. In case of -registered methods and properties, UNAME is nil. PATH is the object -path of the sending object. All of them can be nil, which means a -wildcard then. +registered methods, properties and monitors, UNAME is nil. PATH is +the object path of the sending object. All of them can be nil, which +means a wildcard then. OBJECT is either the handler to be called when a D-Bus message, which matches the key criteria, arrives (TYPE `:method', `:signal' and `:monitor'), or a list (ACCESS EMITS-SIGNAL VALUE) for TYPE `:property'. -For entries of type `:signal', there is also a fifth element RULE, -which keeps the match string the signal is registered with. +For entries of type `:signal' or `:monitor', there is also a fifth +element RULE, which keeps the match string the signal or monitor is +registered with. In the second case, the key in the hash table is the list (:serial BUS SERIAL). BUS is either a Lisp symbol, `:system' or `:session', or a diff --git a/test/lisp/net/dbus-tests.el b/test/lisp/net/dbus-tests.el index 7ebef5d260..94816bb492 100644 --- a/test/lisp/net/dbus-tests.el +++ b/test/lisp/net/dbus-tests.el @@ -697,7 +697,7 @@ is in progress." "Received signal value in `dbus--test-signal-handler'.") (defun dbus--test-signal-handler (&rest args) - "Signal handler for `dbus-test*-signal'." + "Signal handler for `dbus-test*-signal' and `dbus-test08-register-monitor'." (setq dbus--test-signal-received args)) (defun dbus--test-timeout-handler (&rest _ignore) @@ -1833,6 +1833,46 @@ The argument EXPECTED-ARGS is a list of expected arguments for the method." ;; Cleanup. (dbus-unregister-service :session dbus--test-service))) +(ert-deftest dbus-test08-register-monitor () + "Check monitor registration." + :tags '(:expensive-test) + (skip-unless dbus--test-enabled-session-bus) + + (unwind-protect + (let (registered) + (should + (equal + (setq registered + (dbus-register-monitor :session #'dbus--test-signal-handler)) + '((:monitor :session-private) + (nil nil dbus--test-signal-handler)))) + + ;; Send a signal, shall be traced. + (setq dbus--test-signal-received nil) + (dbus-send-signal + :session dbus--test-service dbus--test-path + dbus--test-interface "Foo" "foo") + (with-timeout (1 (dbus--test-timeout-handler)) + (while (null dbus--test-signal-received) + (read-event nil nil 0.1))) + + ;; Unregister monitor. + (should (dbus-unregister-object registered)) + (should-not (dbus-unregister-object registered)) + + ;; Send a signal, shall not be traced. + (setq dbus--test-signal-received nil) + (dbus-send-signal + :session dbus--test-service dbus--test-path + dbus--test-interface "Foo" "foo") + (with-timeout (1 (ignore)) + (while (null dbus--test-signal-received) + (read-event nil nil 0.1))) + (should-not dbus--test-signal-received)) + + ;; Cleanup. + (dbus-unregister-service :session dbus--test-service))) + (defun dbus-test-all (&optional interactive) "Run all tests for \\[dbus]." (interactive "p") commit d8665e6d3473403c90a0831e83439a013d0012d3 Author: Lars Ingebrigtsen Date: Sun Oct 4 16:32:16 2020 +0200 Make update-file-autoloads respect generated-autoload-file * lisp/emacs-lisp/autoload.el (update-file-autoloads): Make update-file-autoloads respect `generated-autoload-file', as documented. diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index e6e3fd9da1..07bda537b3 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -923,6 +923,7 @@ Return FILE if there was no autoload cookie in it, else nil." (interactive (list (read-file-name "Update autoloads for file: ") current-prefix-arg (read-file-name "Write autoload definitions to file: "))) + (setq outfile (or outfile generated-autoload-file)) (let* ((autoload-modified-buffers nil) ;; We need this only if the output file handles more than one input. ;; See https://debbugs.gnu.org/22213#38 and subsequent.