From 1a677d1429d1f9fea2d6b2bc9dd5644a5564cc27 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Tue, 2 Jan 2024 15:32:03 +0200 Subject: [PATCH 1/8] treesit--pre-syntax-ppss: Fix args-out-of-range in internal--syntax-propertize * lisp/treesit.el (treesit--pre-syntax-ppss): Make sure the lower bound is still within the current restriction (bug#67977). --- lisp/treesit.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/treesit.el b/lisp/treesit.el index b656040958d..c63bf510a24 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1150,7 +1150,7 @@ START and END mark the current to-be-propertized region." (if (and new-start (< new-start start)) (progn (setq treesit--syntax-propertize-start nil) - (cons new-start end)) + (cons (max new-start (point-min)) end)) nil))) ;;; Indent From ab66b749a276c9fdc70ad2ee114314f0cde862fc Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 3 Jan 2024 15:14:41 +0200 Subject: [PATCH 2/8] ; * src/window.c (Fset_window_margins): Doc fix. --- src/window.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/window.c b/src/window.c index 894d9c4fc19..8d4bde8d6db 100644 --- a/src/window.c +++ b/src/window.c @@ -7793,7 +7793,11 @@ means no margin. Leave margins unchanged if WINDOW is not large enough to accommodate margins of the desired width. Return t if any margin was actually -changed and nil otherwise. */) +changed and nil otherwise. + +The margins specified by calling this function may be later overridden +by invoking `set-window-buffer' for the same WINDOW, with its +KEEP-MARGINS argument nil or omitted. */) (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width) { struct window *w = set_window_margins (decode_live_window (window), From a2a6619b2825c3c3d159610f0cd6fd89b791bd3f Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 4 Jan 2024 10:17:30 +0200 Subject: [PATCH 3/8] Provide decent documentation for 'help-quick' * lisp/help.el (help-quick, help-quick-toggle): Doc fix. * doc/emacs/help.texi (Help Summary, Misc Help): Document 'help-quick-toggle'. --- doc/emacs/help.texi | 15 +++++++++++++++ lisp/help.el | 13 ++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/doc/emacs/help.texi b/doc/emacs/help.texi index 68299c057d7..1330717b758 100644 --- a/doc/emacs/help.texi +++ b/doc/emacs/help.texi @@ -115,6 +115,9 @@ Display a list of commands whose names match @var{topics} Display all active key bindings; minor mode bindings first, then those of the major mode, then global bindings (@code{describe-bindings}). @xref{Misc Help}. +@item C-h C-q +Toggle display of a window showing popular commands and their key +bindings. @xref{Misc Help}. @item C-h c @var{key} Show the name of the command that the key sequence @var{key} is bound to (@code{describe-key-briefly}). Here @kbd{c} stands for @@ -700,6 +703,18 @@ displays the contents of the syntax table, with explanations of each character's syntax (@pxref{Syntax Tables,, Syntax Tables, elisp, The Emacs Lisp Reference Manual}). +@kindex C-h C-q +@findex help-quick-toggle +@findex help-quick +@cindex cheat sheet of popular Emacs commands + @kbd{C-h C-q} (@code{help-quick-toggle}) toggles on and off the +display of a buffer showing the most popular Emacs commands and their +respective key bindings (a.k.a.@: ``cheat sheet''). The contents of +that buffer are created by the command @code{help-quick}. Each key +binding shown in this buffer is a button: click on it with +@kbd{mouse-1} or @kbd{mouse-2} to show the documentation of the +command bound to that key sequence. + @findex describe-prefix-bindings You can get a list of subcommands for a particular prefix key by typing @kbd{C-h}, @kbd{?}, or @key{F1} diff --git a/lisp/help.el b/lisp/help.el index fe80dd3a72d..accd01e56f5 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -171,7 +171,10 @@ buffer.") ;; Inspired by a mg fork (https://github.com/troglobit/mg) (defun help-quick () - "Display a quick-help buffer." + "Display a quick-help buffer showing popular commands and their bindings. +The window showing quick-help can be toggled using \\[help-quick-toggle]. +You can click on a key binding shown in the quick-help buffer to display +the documentation of the command bound to that key sequence." (interactive) (with-current-buffer (get-buffer-create "*Quick Help*") (let ((inhibit-read-only t) (padding 2) blocks) @@ -244,10 +247,14 @@ buffer.") ;; ... and shrink it immediately. (fit-window-to-buffer)) (message - (substitute-command-keys "Toggle the quick help buffer using \\[help-quick-toggle].")))) + (substitute-command-keys "Toggle display of quick-help buffer using \\[help-quick-toggle].")))) (defun help-quick-toggle () - "Toggle the quick-help window." + "Toggle display of a window showing popular commands and their bindings. +This toggles on and off the display of the quick-help buffer, which shows +popular commands and their bindings as produced by `help-quick'. +You can click on a key binding shown in the quick-help buffer to display +the documentation of the command bound to that key sequence." (interactive) (if (and-let* ((window (get-buffer-window "*Quick Help*"))) (quit-window t window)) From 9308d9a74ab586e9793b2561da23116f2b4fe205 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Thu, 4 Jan 2024 11:06:41 +0100 Subject: [PATCH 4/8] * src/comp.c (Fcomp__compile_ctxt_to_file): Fix hash table Qunbound use. --- src/comp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/comp.c b/src/comp.c index 882b42cdbd5..8428cf9020e 100644 --- a/src/comp.c +++ b/src/comp.c @@ -4964,12 +4964,12 @@ DEFUN ("comp--compile-ctxt-to-file", Fcomp__compile_ctxt_to_file, struct Lisp_Hash_Table *func_h = XHASH_TABLE (CALL1I (comp-ctxt-funcs-h, Vcomp_ctxt)); for (ptrdiff_t i = 0; i < HASH_TABLE_SIZE (func_h); i++) - if (!BASE_EQ (HASH_VALUE (func_h, i), Qunbound)) + if (!BASE_EQ (HASH_KEY (func_h, i), Qunbound)) declare_function (HASH_VALUE (func_h, i)); /* Compile all functions. Can't be done before because the relocation structs has to be already defined. */ for (ptrdiff_t i = 0; i < HASH_TABLE_SIZE (func_h); i++) - if (!BASE_EQ (HASH_VALUE (func_h, i), Qunbound)) + if (!BASE_EQ (HASH_KEY (func_h, i), Qunbound)) compile_function (HASH_VALUE (func_h, i)); /* Work around bug#46495 (GCC PR99126). */ From dc9d02f8a01d86ac8ff3fb004bb2f22cf211dcef Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Fri, 5 Jan 2024 09:39:04 +0200 Subject: [PATCH 5/8] * lisp/isearch.el (isearch-search-and-update): Let-bind 'isearch-cmds'. When 'isearch-wrap-pause' is 'no' or 'no-ding', let-bind 'isearch-cmds' to avoid changing it by 'isearch-push-state' in 'isearch-repeat', so that a later DEL (isearch-delete-char) doesn't stop at the intermediate failing state (bug#68158). --- lisp/isearch.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/isearch.el b/lisp/isearch.el index ee5660309df..f753a5377ca 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -2844,7 +2844,8 @@ The command accepts Unicode names like \"smiling face\" or (isearch-search) (when (and (memq isearch-wrap-pause '(no no-ding)) (not isearch-success)) - (isearch-repeat (if isearch-forward 'forward 'backward))))) + (let ((isearch-cmds isearch-cmds)) + (isearch-repeat (if isearch-forward 'forward 'backward)))))) (isearch-push-state) (if isearch-op-fun (funcall isearch-op-fun)) (isearch-update)) From 2a861124e89d7a29b19bb9a6f22e962c37444212 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 6 Jan 2024 11:15:31 +0200 Subject: [PATCH 6/8] ; Improve documentation of 'buffer-match-p' * doc/lispref/buffers.texi (Buffer List): * doc/lispref/windows.texi (Choosing Window): Add caveats for calling 'buffer-match-p' too early, when CONDITION is 'derived-mode' or 'major-mode'. (Bug#68081) --- doc/lispref/buffers.texi | 13 +++++++++---- doc/lispref/windows.texi | 14 +++++++++----- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/doc/lispref/buffers.texi b/doc/lispref/buffers.texi index b7047a68856..f67a954edc5 100644 --- a/doc/lispref/buffers.texi +++ b/doc/lispref/buffers.texi @@ -959,7 +959,7 @@ infinite recursion. @defun buffer-match-p condition buffer-or-name &optional arg This function checks if a buffer designated by @code{buffer-or-name} -satisfies the specified @code{condition}. Optional third argument +satisfies the specified @var{condition}. Optional third argument @var{arg} is passed to the predicate function in @var{condition}. A valid @var{condition} can be one of the following: @itemize @bullet{} @@ -987,10 +987,15 @@ Satisfied if @emph{any} condition in @var{conds} satisfies Satisfied if @emph{all} the conditions in @var{conds} satisfy @code{buffer-match-p}, with the same buffer and @code{arg}. @item derived-mode -Satisfied if the buffer's major mode derives from @var{expr}. +Satisfied if the buffer's major mode derives from @var{expr}. Note +that this condition might fail to report a match if +@code{buffer-match-p} is invoked before the major mode of the buffer +has been established. @item major-mode Satisfied if the buffer's major mode is equal to @var{expr}. Prefer -using @code{derived-mode} instead, when both can work. +using @code{derived-mode} instead, when both can work. Note that this +condition might fail to report a match if @code{buffer-match-p} is +invoked before the major mode of the buffer has been established. @end table @item t Satisfied by any buffer. A convenient alternative to @code{""} (empty @@ -1000,7 +1005,7 @@ string) or @code{(and)} (empty conjunction). @defun match-buffers condition &optional buffer-list arg This function returns a list of all buffers that satisfy the -@code{condition}. If no buffers match, the function returns +@var{condition}. If no buffers match, the function returns @code{nil}. The argument @var{condition} is as defined in @code{buffer-match-p} above. By default, all the buffers are considered, but this can be restricted via the optional argument diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index 39e6d1386c6..d72da704f13 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi @@ -2629,11 +2629,15 @@ default value is an empty display action, i.e., @w{@code{(nil . nil)}}. @defopt display-buffer-alist The value of this option is an alist mapping conditions to display -actions. Each condition is passed to @code{buffer-match-p}, along -with the buffer name and the @var{action} argument passed to -@code{display-buffer}. If it returns a non-@code{nil} value, then -@code{display-buffer} uses the corresponding display action to display -the buffer. +actions. Each condition is passed to @code{buffer-match-p} +(@pxref{Buffer List}), along with the buffer name and the @var{action} +argument passed to @code{display-buffer}. If it returns a +non-@code{nil} value, then @code{display-buffer} uses the +corresponding display action to display the buffer. Caveat: if you +use @code{derived-mode} or @code{major-mode} as condition, +@code{buffer-match-p} could fail to report a match if +@code{display-buffer} is called before the major mode of the buffer is +set. @end defopt @defopt display-buffer-base-action From 466d1c98a9ef7490332469165f63a38c2b07a05d Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 6 Jan 2024 13:26:29 +0200 Subject: [PATCH 7/8] Fix icons.el when icon does not exist as a file * lisp/emacs-lisp/icons.el (icons--create): Handle the case when ICON is a file that doesn't exists or is unreadable. Suggested by David Ponce . (Bug#66846) --- lisp/emacs-lisp/icons.el | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lisp/emacs-lisp/icons.el b/lisp/emacs-lisp/icons.el index a35a00ec1f3..1fc0e39f9fe 100644 --- a/lisp/emacs-lisp/icons.el +++ b/lisp/emacs-lisp/icons.el @@ -187,11 +187,13 @@ present if the icon is represented by an image." merged) (cl-defmethod icons--create ((_type (eql 'image)) icon keywords) - (let ((file (if (file-name-absolute-p icon) - icon - (and (fboundp 'image-search-load-path) - (image-search-load-path icon))))) - (and (display-images-p) + (let* ((file (if (file-name-absolute-p icon) + icon + (and (fboundp 'image-search-load-path) + (image-search-load-path icon)))) + (file-exists (and (stringp file) (file-readable-p file)))) + (and file-exists + (display-images-p) (fboundp 'image-supported-file-p) (image-supported-file-p file) (propertize From bf7034048c16a95263e3f7c121dafbf1824ff28f Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 6 Jan 2024 13:45:33 +0200 Subject: [PATCH 8/8] ; * doc/emacs/custom.texi (Changing a Variable): Update example (bug#68279). --- doc/emacs/custom.texi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi index b45e0ef953d..4bd78f3ce83 100644 --- a/doc/emacs/custom.texi +++ b/doc/emacs/custom.texi @@ -188,14 +188,15 @@ find with @kbd{M-x customize-browse}. the customization buffer: @smallexample -[Hide] Kill Ring Max: 60 +[Hide] Kill Ring Max: Integer (positive or zero): 120 [State]: STANDARD. Maximum length of kill ring before oldest elements are thrown away. @end smallexample The first line shows that the variable is named @code{kill-ring-max}, formatted as @samp{Kill Ring Max} for easier -viewing. Its value is @samp{120}. The button labeled @samp{[Hide]}, +viewing, and also shows its expected type: a positive integer or zero. +The default value is @samp{120}. The button labeled @samp{[Hide]}, if activated, hides the variable's value and state; this is useful to avoid cluttering up the customization buffer with very long values (for this reason, variables that have very long values may start out