From 523821ed046878f70e5022f9ce27a34ee742ade4 Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Tue, 20 Sep 2022 14:12:31 +0000 Subject: [PATCH 1/6] Improve display of advices on build failures. * Makefile.in: Use three leading '*' characters, and redirect to stderr. --- Makefile.in | 54 ++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/Makefile.in b/Makefile.in index c8418047577..79a1d4204ca 100644 --- a/Makefile.in +++ b/Makefile.in @@ -380,37 +380,37 @@ bootstrap-all: actual-all: ${SUBDIR} info $(gsettings_SCHEMAS:.xml=.valid) src-depending-on-lisp # ADVICE-ON-FAILURE-BEGIN:all -# You might try to: -# - run "make bootstrap", which might fix the problem -# - run "make V=1", which displays the full commands invoked by make, -# ​ to further investigate the problem +# You might try to: +# - run "make bootstrap", which might fix the problem +# - run "make V=1", which displays the full commands invoked by make, +# to further investigate the problem # ADVICE-ON-FAILURE-END:all # ADVICE-ON-FAILURE-BEGIN:bootstrap -# You might try to: -# - run "make extraclean" and run "make" again (or, equivalently, run -# ​ "make bootstrap configure=default"), to rebuild Emacs with the -# ​ default configuration options, which might fix the problem -# - run "git clean -fdx" and run "make bootstrap" again, which might -# ​ fix the problem if "make bootstrap configure=default" did not -# ​ !BEWARE! "git clean -fdx" deletes all files that are not under -# ​ !BEWARE! version control, which means that all changes to such -# ​ !BEWARE! files will be lost and cannot be restored later -# - run "make V=1", which displays the full commands invoked by make, -# ​ to further investigate the problem -# - report the problem and ask for help by sending an email to -# ​ bug-gnu-emacs@gnu.org, mentioning at least the build error -# ​ message, the platform, and the repository revision displayed by -# ​ "git rev-parse HEAD" +# You might try to: +# - run "make extraclean" and run "make" again (or, equivalently, run +# "make bootstrap configure=default"), to rebuild Emacs with the +# default configuration options, which might fix the problem +# - run "git clean -fdx" and run "make bootstrap" again, which might +# fix the problem if "make bootstrap configure=default" did not +# !BEWARE! "git clean -fdx" deletes all files that are not under +# !BEWARE! version control, which means that all changes to such +# !BEWARE! files will be lost and cannot be restored later +# - run "make V=1", which displays the full commands invoked by make, +# to further investigate the problem +# - report the problem and ask for help by sending an email to +# bug-gnu-emacs@gnu.org, mentioning at least the build error +# message, the platform, and the repository revision displayed by +# "git rev-parse HEAD" # ADVICE-ON-FAILURE-END:bootstrap advice-on-failure: - @echo - @echo " \"make ${make-target}\" failed with exit status ${exit-status}." + @echo >&2 '***' + @echo >&2 '*** '"\"make ${make-target}\" failed with exit status ${exit-status}." @cat Makefile | \ sed -n '/^# ADVICE-ON-FAILURE-BEGIN:${make-target}/,$${p;/^# ADVICE-ON-FAILURE-END:${make-target}/q};' | \ - sed 's/^# //' | grep -v '^ADVICE-ON-FAILURE-' - @echo + sed 's/^# /*** /' | grep -v '^*** ADVICE-ON-FAILURE-' >&2 + @echo >&2 '***' @exit ${exit-status} sanity-check: @@ -418,12 +418,12 @@ sanity-check: '(progn (defun f (n) (if (= 0 n) 1 (* n (f (- n 1))))) (princ (f 10)))' \ 2> /dev/null); \ [ "X$$v" = "X3628800" ] && exit 0; \ - echo; \ - echo " \"make ${make-target}\" succeeded, but Emacs is not functional."; \ + echo >&2 '***'; \ + echo >&2 '*** '"\"make ${make-target}\" succeeded, but Emacs is not functional."; \ cat Makefile | \ sed -n '/^# ADVICE-ON-FAILURE-BEGIN:${make-target}/,$${p;/^# ADVICE-ON-FAILURE-END:${make-target}/q};' | \ - sed 's/^# //' | grep -v '^ADVICE-ON-FAILURE-'; \ - echo; \ + sed 's/^# /*** /' | grep -v '^*** ADVICE-ON-FAILURE-' >&2; \ + echo >&2 '***'; \ exit 1 .PHONY: all ${SUBDIR} blessmail epaths-force epaths-force-w32 epaths-force-ns-self-contained etc-emacsver From 127ab231be4ab3aea460ded1c8efa79fc7d39164 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Tue, 20 Sep 2022 16:47:21 +0200 Subject: [PATCH 2/6] Attempt to clarify Input Focus documentation * doc/lispref/frames.texi (Input Focus): Try to clarify the documentation (bug#51862). --- doc/lispref/frames.texi | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi index 262b86672da..e38a81d3e7e 100644 --- a/doc/lispref/frames.texi +++ b/doc/lispref/frames.texi @@ -2997,17 +2997,25 @@ explicit focus notifications.) @end defun @defvar after-focus-change-function -This function is an extension point that code can use to receive a -notification that focus has changed. +This function is called with no arguments when Emacs notices that a +frame may have gotten or lost focus. Focus events are delivered +asynchronously, and may not be delivered in the expected order, so +code that wants to do something depending on the state of focused +frames have go through all the frames and check. + +For instance, here's a simple example function that sets the +background color based on whether the frame has focus or not: + +@lisp +(add-function :after after-focus-change-function + #'my-change-background) +(defun my-change-background () + (dolist (frame (frame-list)) + (pcase (frame-focus-state frame) + (`t (set-face-background 'default "black" frame)) + (`nil (set-face-background 'default "#404040" frame))))) +@end lisp -This function is called with no arguments when Emacs notices that the -set of focused frames may have changed. Code wanting to do something -when frame focus changes should use @code{add-function} to add a -function to this one, and in this added function, re-scan the set of -focused frames, calling @code{frame-focus-state} to retrieve the last -known focus state of each frame. Focus events are delivered -asynchronously, and frame input focus according to an external system -may not correspond to the notion of the Emacs selected frame. Multiple frames may appear to have input focus simultaneously due to focus event delivery differences, the presence of multiple Emacs terminals, and other factors, and code should be robust in the face of From f372afef20eaa0ba139f378a6481b147d93c060d Mon Sep 17 00:00:00 2001 From: Drew Adams Date: Tue, 20 Sep 2022 17:11:47 +0200 Subject: [PATCH 3/6] Tweak how use-region-p works with `use-empty-active-region' * lisp/simple.el (use-region-p): Don't report non-nil if the user has just clicked mouse-1 without extending the region (bug#51874). --- lisp/simple.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lisp/simple.el b/lisp/simple.el index 1b9bf9fa6d8..aed1547b15b 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -6887,6 +6887,11 @@ The return value is t if Transient Mark mode is enabled and the mark is active; furthermore, if `use-empty-active-region' is nil, the region must not be empty. Otherwise, the return value is nil. +If `use-empty-active-region' is non-nil, there is one further +caveat: If the user has used `mouse-1' to set point, but used the +mouse to move point to a different character yet, this function +returns nil. + For some commands, it may be appropriate to ignore the value of `use-empty-active-region'; in that case, use `region-active-p'. @@ -6894,8 +6899,10 @@ Also see the convenience functions `use-region-beginning' and `use-region-end', which may be handy when writing `interactive' specs." (and (region-active-p) - (or use-empty-active-region (> (region-end) (region-beginning))) - t)) + (or (> (region-end) (region-beginning)) + (and use-empty-active-region + (not (eq (car-safe last-input-event) 'down-mouse-1)) + (not (mouse-movement-p last-input-event)))))) (defun region-active-p () "Return t if Transient Mark mode is enabled and the mark is active. From 01ceb23372e6af635f57c3ff3a8860b9035df3b0 Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Mon, 19 Sep 2022 15:29:27 +0200 Subject: [PATCH 4/6] Specify keymap in gnus-custom-mode docstring * lisp/gnus/gnus-cus.el (gnus-custom-mode): Put in the keymap to use, otherwise the bindings are looked up in the global map (where they don't exist). --- lisp/gnus/gnus-cus.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/gnus/gnus-cus.el b/lisp/gnus/gnus-cus.el index ddd939794dd..32c475239e5 100644 --- a/lisp/gnus/gnus-cus.el +++ b/lisp/gnus/gnus-cus.el @@ -36,11 +36,11 @@ (define-derived-mode gnus-custom-mode fundamental-mode "Gnus Customize" "Major mode for editing Gnus customization buffers. -The following commands are available: +The following commands are available:\\ \\[widget-forward] Move to next button or editable field. \\[widget-backward] Move to previous button or editable field. -\\[widget-button-click] Activate button under the mouse pointer. +\\[widget-button-click] Activate button under the mouse pointer. \\[widget-button-press] Activate button under point. Entry to this mode calls the value of `gnus-custom-mode-hook' From 120ade62cd26dd502f1ae3784079e4cd88607a0b Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Mon, 19 Sep 2022 15:53:52 +0200 Subject: [PATCH 5/6] Allow keymap to override advertised-binding in docstrings Previously (substitute-command-keys "\\\\[undo]") would use the global advertised-binding for `undo', even though there's a binding in `undo-repeat-map', which is highly counter-intuitive. Now the binding is looked up in the specified keymap first. * lisp/help.el (substitute-command-keys): Restrict the initial key lookup to the specified keymap (if there is one). (Bug#51384) --- lisp/help.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lisp/help.el b/lisp/help.el index 92b87cf7999..0ec5b9c85b8 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -1204,7 +1204,10 @@ Otherwise, return a new string." (delete-char 2) (let* ((fun (intern (buffer-substring (point) (1- end-point)))) (key (with-current-buffer orig-buf - (where-is-internal fun keymap t)))) + (where-is-internal fun + (and keymap + (list keymap)) + t)))) (if (not key) ;; Function is not on any key. (let ((op (point))) From cefda4a6c521a01b031f5e94a31473a91d06eaea Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Tue, 20 Sep 2022 19:11:58 +0300 Subject: [PATCH 6/6] * lisp/outline.el: Bind margin mouse event to cycle outlines (bug#57813) (outline-minor-mode): In mode keymap bind 'right/left-margin mouse-1' to outline-cycle, and 'right/left-margin S-mouse-1' to outline-cycle-buffer. (outline-hide-subtree, outline-show-subtree): Add save-excursion to keep point unmoved after mouse click. (outline-cycle): Add optional arg 'event' like in outline-hide-subtree and outline-show-subtree, and add save-excursion to keep point unmoved after mouse click. (outline--make-button-overlay, outline--make-margin-overlay): Put overlay property 'evaporate' to t. (outline--insert-open-button, outline--insert-close-button): Remove temporary attempts to bind margin-local mouse events. --- lisp/outline.el | 82 +++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/lisp/outline.el b/lisp/outline.el index 3aebc25e130..3503ba2265e 100644 --- a/lisp/outline.el +++ b/lisp/outline.el @@ -490,6 +490,10 @@ See the command `outline-mode' for more information on this mode." :keymap (define-keymap :parent outline-minor-mode-cycle-map "" outline-minor-mode-menu-bar-map + " " 'outline-cycle + " " 'outline-cycle + " S-" 'outline-cycle-buffer + " S-" 'outline-cycle-buffer (key-description outline-minor-mode-prefix) outline-mode-prefix-map) (if outline-minor-mode (progn @@ -1051,9 +1055,10 @@ Note that this does not hide the lines preceding the first heading line." "Hide everything after this heading at deeper levels. If non-nil, EVENT should be a mouse event." (interactive (list last-nonmenu-event)) - (when (mouse-event-p event) - (mouse-set-point event)) - (outline-flag-subtree t)) + (save-excursion + (when (mouse-event-p event) + (mouse-set-point event)) + (outline-flag-subtree t))) (defun outline--make-button-overlay (type) (let ((o (seq-find (lambda (o) @@ -1061,6 +1066,7 @@ If non-nil, EVENT should be a mouse event." (overlays-at (point))))) (unless o (setq o (make-overlay (point) (1+ (point)))) + (overlay-put o 'evaporate t) (overlay-put o 'follow-link 'mouse-face) (overlay-put o 'mouse-face 'highlight) (overlay-put o 'outline-button t)) @@ -1088,8 +1094,7 @@ If non-nil, EVENT should be a mouse event." (overlays-at (point))))) (unless o (setq o (make-overlay (point) (1+ (point)))) - (overlay-put o 'follow-link 'mouse-face) - (overlay-put o 'mouse-face 'highlight) + (overlay-put o 'evaporate t) (overlay-put o 'outline-margin t)) (let ((icon (icon-elements (if (eq type 'close) (if outline--use-rtl @@ -1111,11 +1116,7 @@ If non-nil, EVENT should be a mouse event." (save-excursion (beginning-of-line) (if use-margins - (let ((o (outline--make-margin-overlay 'open))) - (overlay-put o 'help-echo "Click to hide") - (overlay-put o 'keymap - (define-keymap - "" #'outline-hide-subtree))) + (outline--make-margin-overlay 'open) (when (derived-mode-p 'special-mode) (let ((inhibit-read-only t)) (insert " ") @@ -1125,19 +1126,14 @@ If non-nil, EVENT should be a mouse event." (overlay-put o 'keymap (define-keymap "RET" #'outline-hide-subtree - "" #'outline-hide-subtree - " " #'outline-hide-subtree))))))) + "" #'outline-hide-subtree))))))) (defun outline--insert-close-button (&optional use-margins) (with-silent-modifications (save-excursion (beginning-of-line) (if use-margins - (let ((o (outline--make-margin-overlay 'close))) - (overlay-put o 'help-echo "Click to show") - (overlay-put o 'keymap - (define-keymap - "" #'outline-show-subtree))) + (outline--make-margin-overlay 'close) (when (derived-mode-p 'special-mode) (let ((inhibit-read-only t)) (insert " ") @@ -1147,8 +1143,7 @@ If non-nil, EVENT should be a mouse event." (overlay-put o 'keymap (define-keymap "RET" #'outline-show-subtree - "" #'outline-show-subtree - " " #'outline-show-subtree))))))) + "" #'outline-show-subtree))))))) (defun outline--fix-up-all-buttons (&optional from to) (when (or outline--use-buttons outline--use-margins) @@ -1182,11 +1177,13 @@ If non-nil, EVENT should be a mouse event." (define-obsolete-function-alias 'hide-leaves #'outline-hide-leaves "25.1") (defun outline-show-subtree (&optional event) - "Show everything after this heading at deeper levels." + "Show everything after this heading at deeper levels. +If non-nil, EVENT should be a mouse event." (interactive (list last-nonmenu-event)) - (when (mouse-event-p event) - (mouse-set-point event)) - (outline-flag-subtree nil)) + (save-excursion + (when (mouse-event-p event) + (mouse-set-point event)) + (outline-flag-subtree nil))) (define-obsolete-function-alias 'show-subtree #'outline-show-subtree "25.1") @@ -1661,7 +1658,7 @@ Return either `hide-all', `headings-only', or `show-all'." (< (save-excursion (outline-next-heading) (point)) (save-excursion (outline-end-of-subtree) (point))))) -(defun outline-cycle () +(defun outline-cycle (&optional event) "Cycle visibility state of the current heading line's body. This cycles the visibility of the current heading line's subheadings @@ -1669,23 +1666,28 @@ and body between `hide all', `headings only' and `show all'. `Hide all' means hide all the subheadings and their bodies. `Headings only' means show the subheadings, but not their bodies. -`Show all' means show all the subheadings and their bodies." - (interactive) - (condition-case nil - (pcase (outline--cycle-state) - ('hide-all - (if (outline-has-subheading-p) - (progn (outline-show-children) - (message "Only headings")) +`Show all' means show all the subheadings and their bodies. + +If non-nil, EVENT should be a mouse event." + (interactive (list last-nonmenu-event)) + (save-excursion + (when (mouse-event-p event) + (mouse-set-point event)) + (condition-case nil + (pcase (outline--cycle-state) + ('hide-all + (if (outline-has-subheading-p) + (progn (outline-show-children) + (message "Only headings")) + (outline-show-subtree) + (message "Show all"))) + ('headings-only (outline-show-subtree) - (message "Show all"))) - ('headings-only - (outline-show-subtree) - (message "Show all")) - ('show-all - (outline-hide-subtree) - (message "Hide all"))) - (outline-before-first-heading nil))) + (message "Show all")) + ('show-all + (outline-hide-subtree) + (message "Hide all"))) + (outline-before-first-heading nil)))) (defvar-local outline--cycle-buffer-state 'show-all "Internal variable used for tracking buffer cycle state.")