diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi index 930903d5085..e621a28acda 100644 --- a/doc/lispref/control.texi +++ b/doc/lispref/control.texi @@ -1809,6 +1809,9 @@ wish the program to continue execution despite an error in a subroutine. In these cases, you would use @code{condition-case} to establish @dfn{error handlers} to recover control in case of error. + For reporting problems without terminating the execution of the +current command, consider issuing a warning instead. @xref{Warnings}. + Resist the temptation to use error handling to transfer control from one part of the program to another; use @code{catch} and @code{throw} instead. @xref{Catch and Throw}. diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 8184021d998..f1b4b001889 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -752,7 +752,8 @@ echo area (which is really a special use of the minibuffer window; @cindex warnings @dfn{Warnings} are a facility for a program to inform the user of a -possible problem, but continue running. +possible problem, but continue running (as opposed to signaling an +error, @pxref{Errors}). @menu * Warning Basics:: Warnings concepts and functions to report them. @@ -765,69 +766,74 @@ possible problem, but continue running. @subsection Warning Basics @cindex severity level - Every warning has a textual message, which explains the problem for -the user, and a @dfn{severity level} which is a symbol. Here are the -possible severity levels, in order of decreasing severity, and their -meanings: + Every warning is a textual message, which explains the problem for +the user, with the associated @dfn{severity level} which is a symbol. +Here are the supported severity levels, in order of decreasing +severity, and their meanings: @table @code @item :emergency A problem that will seriously impair Emacs operation soon -if you do not attend to it promptly. +if the user does not attend to it promptly. @item :error -A report of data or circumstances that are inherently wrong. +A report about data or circumstances that are inherently wrong. @item :warning -A report of data or circumstances that are not inherently wrong, but -raise suspicion of a possible problem. +A report about data or circumstances that are not inherently wrong, +but raise suspicion of a possible problem. @item :debug -A report of information that may be useful if you are debugging. +A report of information that may be useful if the user is currently +debugging the Lisp program which issues the warning. @end table When your program encounters invalid input data, it can either -signal a Lisp error by calling @code{error} or @code{signal} or report -a warning with severity @code{:error}. Signaling a Lisp error is the -easiest thing to do, but it means the program cannot continue -processing. If you want to take the trouble to implement a way to -continue processing despite the bad data, then reporting a warning of -severity @code{:error} is the right way to inform the user of the -problem. For instance, the Emacs Lisp byte compiler can report an -error that way and continue compiling other functions. (If the -program signals a Lisp error and then handles it with -@code{condition-case}, the user won't see the error message; it could -show the message to the user by reporting it as a warning.) +signal a Lisp error by calling @code{error} or @code{signal} +(@pxref{Signaling Errors}) or report a warning with severity +@code{:error}. Signaling a Lisp error is the easiest thing to do, but +it means the signaling program cannot continue execution. If you want +to take the trouble of implementing a way to continue processing +despite the invalid data, then reporting a warning of severity +@code{:error} is the right way of informing the user of the problem. +For instance, the Emacs Lisp byte compiler can report an error that +way and continue compiling other functions. (If the program signals a +Lisp error and then handles it with @code{condition-case}, the user +won't see the error message; reporting that as a warning instead +avoids that problem.) -@c FIXME: Why use "(bytecomp)" instead of "'bytecomp" or simply -@c "bytecomp" here? The parens are part of warning-type-format but -@c not part of the warning type. --xfq @cindex warning type - Each warning has a @dfn{warning type} to classify it. The type is a -list of symbols. The first symbol should be the custom group that you -use for the program's user options. For example, byte compiler -warnings use the warning type @code{(bytecomp)}. You can also -subcategorize the warnings, if you wish, by using more symbols in the -list. + In addition to severity level, each warning has a @dfn{warning type} +to classify it. The warning type is either a symbol or a list of +symbols. If it is a symbol, it should be the custom group that you +use for the program's user options; if it is a list, the first element +of the list should be that custom group. For example, byte compiler +warnings use the warning type @code{(bytecomp)}. If the warning type +is a list, the elements of the list after the first one, which should +be arbitrary symbols, represent subcategories of the warning: they +will be displayed to the user to better explain the nature of the +warning. @defun display-warning type message &optional level buffer-name -This function reports a warning, using @var{message} as the message -and @var{type} as the warning type. @var{level} should be the -severity level, with @code{:warning} being the default. +This function reports a warning, using the string @var{message} as the +warning text and @var{type} as the warning type. @var{level} should +be the severity level, and defaults to @code{:warning} if omitted or +@code{nil}. @var{buffer-name}, if non-@code{nil}, specifies the name of the buffer -for logging the warning. By default, it is @file{*Warnings*}. +for logging the warning message. By default, it is @file{*Warnings*}. @end defun @defun lwarn type level message &rest args -This function reports a warning using the value of @code{(format-message -@var{message} @var{args}...)} as the message in the @file{*Warnings*} -buffer. In other respects it is equivalent to @code{display-warning}. +This function reports a warning using the value returned by +@w{@code{(format-message @var{message} @var{args}@dots{})}} as the +message text in the @file{*Warnings*} buffer. In other respects it is +equivalent to @code{display-warning}. @end defun @defun warn message &rest args -This function reports a warning using the value of @code{(format-message -@var{message} @var{args}...)} as the message, @code{(emacs)} as the -type, and @code{:warning} as the severity level. It exists for -compatibility only; we recommend not using it, because you should -specify a specific warning type. +This function reports a warning using the value returned by +@w{@code{(format-message @var{message} @var{args}@dots{})}} as the +message text, @code{emacs} as the warning type, and @code{:warning} as +the severity level. It exists for compatibility only; we recommend +not using it, because you should specify a specific warning type. @end defun @node Warning Variables @@ -842,15 +848,16 @@ This list defines the meaning and severity order of the warning severity levels. Each element defines one severity level, and they are arranged in order of decreasing severity. -Each element has the form @code{(@var{level} @var{string} -@var{function})}, where @var{level} is the severity level it defines. -@var{string} specifies the textual description of this level. -@var{string} should use @samp{%s} to specify where to put the warning -type information, or it can omit the @samp{%s} so as not to include -that information. +Each element has the form @w{@code{(@var{level} @var{string} +[@var{function}])}}, where @var{level} is the severity level it +defines. @var{string} specifies the textual description of this +level. @var{string} should use @samp{%s} to specify where to put the +warning type information, or it can omit the @samp{%s} so as not to +include that information. The optional @var{function}, if non-@code{nil}, is a function to call -with no arguments, to get the user's attention. +with no arguments, to get the user's attention. A notable example is +@code{ding} (@pxref{Beeping}). Normally you should not change the value of this variable. @end defvar @@ -859,18 +866,19 @@ Normally you should not change the value of this variable. If non-@code{nil}, the value is a function to generate prefix text for warnings. Programs can bind the variable to a suitable function. @code{display-warning} calls this function with the warnings buffer -current, and the function can insert text in it. That text becomes -the beginning of the warning message. +the current buffer, and the function can insert text into it. That +text becomes the beginning of the warning message. The function is called with two arguments, the severity level and its -entry in @code{warning-levels}. It should return a list to use as the -entry (this value need not be an actual member of -@code{warning-levels}). By constructing this value, the function can -change the severity of the warning, or specify different handling for -a given severity level. +entry in @code{warning-levels}. It should return a list to use +@emph{instead} of that entry (the value need not be an actual member +of @code{warning-levels}, but it must have the same structure). By +constructing this value, the function can change the severity of the +warning, or specify different handling for a given severity level. -If the variable's value is @code{nil} then there is no function -to call. +If the variable's value is @code{nil}, there's no prefix text, before +the warning is displayed, starting with the @var{string} part of the +entry in @code{warning-levels} corresponding to the warning's level. @end defvar @defvar warning-series @@ -878,17 +886,18 @@ Programs can bind this variable to @code{t} to say that the next warning should begin a series. When several warnings form a series, that means to leave point on the first warning of the series, rather than keep moving it for each warning so that it appears on the last one. -The series ends when the local binding is unbound and +The series ends when the local binding of this variable is unbound and @code{warning-series} becomes @code{nil} again. The value can also be a symbol with a function definition. That is equivalent to @code{t}, except that the next warning will also call -the function with no arguments with the warnings buffer current. The -function can insert text which will serve as a header for the series -of warnings. +the function with no arguments with the warnings buffer the current +buffer. The function can, for example, insert text which will serve +as a header for the series of warnings. -Once a series has begun, the value is a marker which points to the -buffer position in the warnings buffer of the start of the series. +Once a series has begun, the value of this variable is a marker which +points to the buffer position in the warnings buffer of the start of +the series. The variable's normal value is @code{nil}, which means to handle each warning separately. @@ -896,7 +905,7 @@ each warning separately. @defvar warning-fill-prefix When this variable is non-@code{nil}, it specifies a fill prefix to -use for filling each warning's text. +use for filling the text of each warning. @end defvar @defvar warning-fill-column @@ -905,11 +914,11 @@ The column at which to fill warnings. @defvar warning-type-format This variable specifies the format for displaying the warning type -in the warning message. The result of formatting the type this way +in the warning text. The result of formatting the type this way gets included in the message under the control of the string in the entry in @code{warning-levels}. The default value is @code{" (%s)"}. -If you bind it to @code{""} then the warning type won't appear at -all. +If you bind it to the empty string @code{""} then the warning type +won't appear at all. @end defvar @node Warning Options @@ -921,38 +930,71 @@ when a Lisp program reports a warning. @defopt warning-minimum-level This user option specifies the minimum severity level that should be -shown immediately to the user. The default is @code{:warning}, which -means to immediately display all warnings except @code{:debug} -warnings. +shown immediately to the user, by popping the warnings buffer in some +window. The default is @code{:warning}, which means to show the +warning buffer for any warning severity except @code{:debug}. The +warnings of lower severity levels will still be written into the +warnings buffer, but the buffer will not be forced onto display. @end defopt @defopt warning-minimum-log-level This user option specifies the minimum severity level that should be -logged in the warnings buffer. The default is @code{:warning}, which -means to log all warnings except @code{:debug} warnings. +logged in the warnings buffer. Warnings of lower severity will be +completely ignored: not written to the warnings buffer and not +displayed. The default is @code{:warning}, which means to log +warnings of any severity except @code{:debug}. @end defopt @defopt warning-suppress-types This list specifies which warning types should not be displayed -immediately for the user. Each element of the list should be a list -of symbols. If its elements match the first elements in a warning -type, then that warning is not displayed immediately. +immediately when they occur. Each element of the list should be a +list of symbols. If an element of this list has the same elements as +the first elements in a warning type, then the warning of that type +will not be shown on display by popping the warnings buffer in some +window (the warning will still be logged in the warnings buffer). + +For example, if the value of this variable is a list like this: + +@lisp +((foo) (bar subtype)) +@end lisp + +@noindent +then warnings whose types are @code{foo} or @code{(foo)} or +@w{@code{(foo something)}} or @w{@code{(bar subtype other)}} will not +be shown to the user. @end defopt @defopt warning-suppress-log-types -This list specifies which warning types should not be logged in the -warnings buffer. Each element of the list should be a list of -symbols. If it matches the first few elements in a warning type, then -that warning is not logged. +This list specifies which warning types should be ignored: not logged +in the warnings buffer and not shown to the user. The structure and +the matching of warning types are the same as for +@code{warning-suppress-types} above. @end defopt +@cindex warnings, suppressing during startup +@cindex prevent warnings in init files + During startup, Emacs delays showing any warnings until after it +loads and processes the site-wide and user's init files +(@pxref{Startup Summary}). Let-binding (@pxref{Local Variables}) the +values of these options around some code in your init files which +might emit a warning will therefore not work, because it will not be +in effect by the time the warning is actually processed. Thus, if you +want to suppress some warnings during startup, change the values of +the above options in your init file early enough, or put those +let-binding forms in your @code{after-init-hook} or +@code{emacs-startup-hook} functions. @xref{Init File}. + @node Delayed Warnings @subsection Delayed Warnings @cindex delayed warnings +@cindex warnings, delayed Sometimes, you may wish to avoid showing a warning while a command is running, and only show it only after the end of the command. You can -use the function @code{delay-warning} for this. +use the function @code{delay-warning} for this. Emacs automatically +delays any warnings emitted during the early stages of startup, and +shows them only after the init files are processed. @defun delay-warning type message &optional level buffer-name This function is the delayed counterpart to @code{display-warning} @@ -973,7 +1015,7 @@ with the same form, and the same meanings, as the argument list of @code{display-warning}. Immediately after running @code{post-command-hook} (@pxref{Command Overview}), the Emacs command loop displays all the warnings specified by this variable, -then resets it to @code{nil}. +then resets the variable to @code{nil}. @end defvar Programs which need to further customize the delayed warnings @@ -982,7 +1024,9 @@ mechanism can change the variable @code{delayed-warnings-hook}: @defvar delayed-warnings-hook This is a normal hook which is run by the Emacs command loop, after @code{post-command-hook}, in order to process and display delayed -warnings. +warnings. Emacs also runs this hook during startup, after loading the +site-start and user init files (@pxref{Startup Summary}), because +warnings emitted before that are automatically delayed. Its default value is a list of two functions: diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index bca62a7a8de..91143f77551 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi @@ -182,7 +182,9 @@ is over, and, together with @code{before-init-time}, provides the measurement of how long it took. @item -It runs the normal hook @code{after-init-hook}. +It runs the normal hooks @code{after-init-hook} and +@code{delayed-warnings-hook}. The latter shows any warnings emitted +during previous stages of startup, which are automatically delayed. @item If the buffer @file{*scratch*} exists and is still in Fundamental mode diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi index 4c13185b0dd..f15b3c33e0c 100644 --- a/doc/lispref/text.texi +++ b/doc/lispref/text.texi @@ -5510,7 +5510,7 @@ contents of an SQLite database. @section Parsing HTML and XML @cindex parsing html - Emacs can be compiled with built-in libxml2 support. + Emacs can be compiled with built-in @file{libxml2} support. @defun libxml-available-p This function returns non-@code{nil} if built-in libxml2 support is @@ -5529,8 +5529,10 @@ mistakes. If @var{start} or @var{end} are @code{nil}, they default to the values from @code{point-min} and @code{point-max}, respectively. -The optional argument @var{base-url}, if non-@code{nil}, should be a -string specifying the base URL for relative URLs occurring in links. +The optional argument @var{base-url}, if non-@code{nil}, should be +used for warnings and errors reported by the @file{libxml2} library, +but Emacs currently calls the library with errors and warnings +disabled, so this argument is not used. If the optional argument @var{discard-comments} is non-@code{nil}, any top-level comment is discarded. (This argument is obsolete and diff --git a/etc/EGLOT-NEWS b/etc/EGLOT-NEWS index 27796adef4b..7a1aaffaea3 100644 --- a/etc/EGLOT-NEWS +++ b/etc/EGLOT-NEWS @@ -119,7 +119,7 @@ The position-encoding scheme (UTF-8, UTF-16 or UTF-32) can now be negotiated with the server. ** More of the user's Eldoc configuration is respected. -This change addresses the problems reported in many Elglot reports +This change addresses the problems reported in many Eglot reports dating back to early 2021 at least. (github#646, github#894, github#920, github#1031, github#1171). @@ -165,7 +165,7 @@ systems (bug#58790). These modes are usually handled by the same server that handles the "classical mode". -** New servers chsharp-ls and texlab added to 'eglot-server-programs'. +** New servers csharp-ls and texlab added to 'eglot-server-programs'. ** Assorted bugfixes. (bug#59824, bug#59338) diff --git a/etc/refcards/orgcard.tex b/etc/refcards/orgcard.tex index c5d112dba72..6ee77758e06 100644 --- a/etc/refcards/orgcard.tex +++ b/etc/refcards/orgcard.tex @@ -1,5 +1,5 @@ % Reference Card for Org Mode -\def\orgversionnumber{9.6.4} +\def\orgversionnumber{9.6.5} \def\versionyear{2023} % latest update \input emacsver.tex diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el index 1007be62dd9..a966b1e9f40 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -597,73 +597,63 @@ instead of just updating them with the new/changed autoloads." defs)))))) (progress-reporter-done progress)) - ;; If we have no autoloads data, but we have EXTRA-DATA, then - ;; generate the (almost) empty file anyway. - (if (and (not defs) extra-data) + ;; First group per output file. + (dolist (fdefs (seq-group-by (lambda (x) (expand-file-name (car x))) + defs)) + (let ((loaddefs-file (car fdefs)) + hash) (with-temp-buffer - (insert (loaddefs-generate--rubric output-file nil t)) - (search-backward "\f") - (insert extra-data) - (ensure-empty-lines 1) - (write-region (point-min) (point-max) output-file nil 'silent)) - ;; We have some data, so generate the loaddef files. First - ;; group per output file. - (dolist (fdefs (seq-group-by (lambda (x) (expand-file-name (car x))) - defs)) - (let ((loaddefs-file (car fdefs)) - hash) - (with-temp-buffer - (if (and updating (file-exists-p loaddefs-file)) - (insert-file-contents loaddefs-file) - (insert (loaddefs-generate--rubric - loaddefs-file nil t include-package-version)) - (search-backward "\f") - (when extra-data - (insert extra-data) - (ensure-empty-lines 1))) - (setq hash (buffer-hash)) - ;; Then group by source file (and sort alphabetically). - (dolist (section (sort (seq-group-by #'cadr (cdr fdefs)) - (lambda (e1 e2) - (string< - (file-name-sans-extension - (file-name-nondirectory (car e1))) - (file-name-sans-extension - (file-name-nondirectory (car e2))))))) - (pop section) - (let* ((relfile (file-relative-name - (cadar section) - (file-name-directory loaddefs-file))) - (head (concat "\n\f\n;;; Generated autoloads from " - relfile "\n\n"))) - (when (file-exists-p loaddefs-file) - ;; If we're updating an old loaddefs file, then see if - ;; there's a section here for this file already. - (goto-char (point-min)) - (if (not (search-forward head nil t)) - ;; It's a new file; put the data at the end. - (progn - (goto-char (point-max)) - (search-backward "\f\n" nil t)) - ;; Delete the old version of the section. - (delete-region (match-beginning 0) - (and (search-forward "\n\f\n;;;") - (match-beginning 0))) - (forward-line -2))) - (insert head) - (dolist (def (reverse section)) - (setq def (caddr def)) - (if (stringp def) - (princ def (current-buffer)) - (loaddefs-generate--print-form def)) - (unless (bolp) - (insert "\n"))))) - ;; Only write the file if we actually made a change. - (unless (equal (buffer-hash) hash) - (write-region (point-min) (point-max) loaddefs-file nil 'silent) - (byte-compile-info - (file-relative-name loaddefs-file (car (ensure-list dir))) - t "GEN")))))))) + (if (and updating (file-exists-p loaddefs-file)) + (insert-file-contents loaddefs-file) + (insert (loaddefs-generate--rubric + loaddefs-file nil t include-package-version)) + (search-backward "\f") + (when extra-data + (insert extra-data) + (ensure-empty-lines 1))) + (setq hash (buffer-hash)) + ;; Then group by source file (and sort alphabetically). + (dolist (section (sort (seq-group-by #'cadr (cdr fdefs)) + (lambda (e1 e2) + (string< + (file-name-sans-extension + (file-name-nondirectory (car e1))) + (file-name-sans-extension + (file-name-nondirectory (car e2))))))) + (pop section) + (let* ((relfile (file-relative-name + (cadar section) + (file-name-directory loaddefs-file))) + (head (concat "\n\f\n;;; Generated autoloads from " + relfile "\n\n"))) + (when (file-exists-p loaddefs-file) + ;; If we're updating an old loaddefs file, then see if + ;; there's a section here for this file already. + (goto-char (point-min)) + (if (not (search-forward head nil t)) + ;; It's a new file; put the data at the end. + (progn + (goto-char (point-max)) + (search-backward "\f\n" nil t)) + ;; Delete the old version of the section. + (delete-region (match-beginning 0) + (and (search-forward "\n\f\n;;;") + (match-beginning 0))) + (forward-line -2))) + (insert head) + (dolist (def (reverse section)) + (setq def (caddr def)) + (if (stringp def) + (princ def (current-buffer)) + (loaddefs-generate--print-form def)) + (unless (bolp) + (insert "\n"))))) + ;; Only write the file if we actually made a change. + (unless (equal (buffer-hash) hash) + (write-region (point-min) (point-max) loaddefs-file nil 'silent) + (byte-compile-info + (file-relative-name loaddefs-file (car (ensure-list dir))) + t "GEN"))))))) (defun loaddefs-generate--print-form (def) "Print DEF in a format that makes sense for version control." diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 6cb78801d7f..16b2218da26 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -2307,10 +2307,7 @@ interactively, QUERY is always true. Currently, packages which are part of the Emacs distribution are not upgraded by this command. To enable upgrading such a package using this command, first upgrade the package to a newer version -from ELPA by using `\\\\[package-menu-mark-install]' after `\\[list-packages]'. - - Use `i' after `M-x list-packages' to -upgrade to an ELPA version first." +from ELPA by using `\\\\[package-menu-mark-install]' after `\\[list-packages]'." (interactive (list (not noninteractive))) (package-refresh-contents) (let ((upgradeable (package--upgradeable-packages))) diff --git a/lisp/org/org-macs.el b/lisp/org/org-macs.el index b8e026553b3..1552675f8a8 100644 --- a/lisp/org/org-macs.el +++ b/lisp/org/org-macs.el @@ -37,9 +37,16 @@ ;;; Org version verification. (defvar org--inhibit-version-check nil - "When non-nil, assume that Org is a part of Emacs source. + "When non-nil, skip the detection of mixed-versions situations. For internal use only. See Emacs bug #62762. -This variable is only supposed to be changed by Emacs build scripts.") +This variable is only supposed to be changed by Emacs build scripts. +When nil, Org tries to detect when Org source files were compiled with +a different version of Org (which tends to lead to incorrect `.elc' files), +or when the current Emacs session has loaded a mix of files from different +Org versions (typically the one bundled with Emacs and another one installed +from GNU ELPA), which can happen if some parts of Org were loaded before +`load-path' was changed (e.g. before the GNU-ELPA-installed Org is activated +by `package-activate-all').") (defmacro org-assert-version () "Assert compile time and runtime version match." ;; We intentionally use a more permissive `org-release' instead of diff --git a/lisp/org/org-version.el b/lisp/org/org-version.el index b82e915ecd1..ef61dc9cbd6 100644 --- a/lisp/org/org-version.el +++ b/lisp/org/org-version.el @@ -5,13 +5,13 @@ (defun org-release () "The release version of Org. Inserted by installing Org mode or when a release is made." - (let ((org-release "9.6.4")) + (let ((org-release "9.6.5")) org-release)) ;;;###autoload (defun org-git-version () "The Git version of Org mode. Inserted by installing Org or when a release is made." - (let ((org-git-version "release_9.6.4-9-g8eb209")) + (let ((org-git-version "release_9.6.5-3-g2993f4")) org-git-version)) (provide 'org-version) diff --git a/lisp/org/org.el b/lisp/org/org.el index 61862b3d63b..f4aa28cc486 100644 --- a/lisp/org/org.el +++ b/lisp/org/org.el @@ -9,7 +9,7 @@ ;; URL: https://orgmode.org ;; Package-Requires: ((emacs "26.1")) -;; Version: 9.6.4 +;; Version: 9.6.5 ;; This file is part of GNU Emacs. ;; @@ -18602,6 +18602,10 @@ block from point." (throw 'exit n))))) nil))) +;; Defined in org-agenda.el +(defvar org-agenda-restrict) +(defvar org-agenda-restrict-begin) +(defvar org-agenda-restrict-end) (defun org-occur-in-agenda-files (regexp &optional _nlines) "Call `multi-occur' with buffers for all agenda files." (interactive "sOrg-files matching: ") diff --git a/lisp/org/ox-odt.el b/lisp/org/ox-odt.el index 03c909f78ed..dd96ed8e064 100644 --- a/lisp/org/ox-odt.el +++ b/lisp/org/ox-odt.el @@ -2926,24 +2926,25 @@ contextual information." ;; FIXME: The unnecessary spacing may still remain when a newline ;; is at a boundary between Org objects (e.g. italics markup ;; followed by newline). - (setq output - (with-temp-buffer - (save-match-data - (let ((leading (and (string-match (rx bos (1+ blank)) output) - (match-string 0 output))) - (trailing (and (string-match (rx (1+ blank) eos) output) - (match-string 0 output)))) - (insert - (substring - output - (length leading) - (pcase (length trailing) - (0 nil) - (n (- n))))) - ;; Unfill, retaining leading/trailing space. - (let ((fill-column most-positive-fixnum)) - (fill-region (point-min) (point-max))) - (concat leading (buffer-string) trailing)))))) + (when (org-string-nw-p output) ; blank string needs not to be re-filled + (setq output + (with-temp-buffer + (save-match-data + (let ((leading (and (string-match (rx bos (1+ blank)) output) + (match-string 0 output))) + (trailing (and (string-match (rx (1+ blank) eos) output) + (match-string 0 output)))) + (insert + (substring + output + (length leading) + (pcase (length trailing) + (0 nil) + (n (- n))))) + ;; Unfill, retaining leading/trailing space. + (let ((fill-column most-positive-fixnum)) + (fill-region (point-min) (point-max))) + (concat leading (buffer-string) trailing))))))) ;; Return value. output)) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 4971ed0b7c2..6fd08303b2b 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -536,6 +536,11 @@ MODE is either `c' or `cpp'." "+=" "*=" "/=" "%=" "|=" "&=" "^=" ">>=" "<<=" "--" "++") "C/C++ operators for tree-sitter font-locking.") +(defvar c-ts-mode--for-each-tail-regexp + (rx "FOR_EACH_" (or "TAIL" "TAIL_SAFE" "ALIST_VALUE" + "LIVE_BUFFER" "FRAME")) + "A regexp matching all the variants of the FOR_EACH_* macro.") + (defun c-ts-mode--font-lock-settings (mode) "Tree-sitter font-lock settings. MODE is either `c' or `cpp'." @@ -686,10 +691,14 @@ MODE is either `c' or `cpp'." :language mode :feature 'emacs-devel :override t - '(((call_expression + `(((call_expression (call_expression function: (identifier) @fn) @c-ts-mode--fontify-DEFUN) - (:match "^DEFUN$" @fn))))) + (:match "^DEFUN$" @fn)) + + ((function_definition type: (_) @for-each-tail) + @c-ts-mode--fontify-for-each-tail + (:match ,c-ts-mode--for-each-tail-regexp @for-each-tail))))) ;;; Font-lock helpers @@ -791,6 +800,20 @@ This function corrects the fontification of the colon in (treesit-node-start arg) (treesit-node-end arg) 'default override start end)))))) +(defun c-ts-mode--fontify-for-each-tail (node override start end &rest _) + "Fontify FOR_EACH_* macro variants in Emacs sources. +For NODE, OVERRIDE, START, and END, see +`treesit-font-lock-rules'. The captured NODE is a +function_definition node." + (let ((for-each-tail (treesit-node-child-by-field-name node "type")) + (args (treesit-node-child-by-field-name node "declarator"))) + (treesit-fontify-with-override + (treesit-node-start for-each-tail) (treesit-node-end for-each-tail) + 'default override start end) + (treesit-fontify-with-override + (1+ (treesit-node-start args)) (1- (treesit-node-end args)) + 'default override start end))) + (defun c-ts-mode--fontify-error (node override start end &rest _) "Fontify the error nodes. For NODE, OVERRIDE, START, and END, see @@ -984,11 +1007,12 @@ if `c-ts-mode-emacs-sources-support' is non-nil." ;; skips those FOR_EACH_*'s. Note that we only ignore FOR_EACH_*'s ;; with a unbracketed body. Those with a bracketed body parse more ;; or less fine. - -(defvar c-ts-mode--for-each-tail-regexp - (rx "FOR_EACH_" (or "TAIL" "TAIL_SAFE" "ALIST_VALUE" - "LIVE_BUFFER" "FRAME")) - "A regexp matching all the variants of the FOR_EACH_* macro.") +;; +;; In the meantime, we have a special fontification rule for +;; FOR_EACH_* macros with a bracketed body that removes any applied +;; fontification (which are wrong anyway), to keep them consistent +;; with the skipped FOR_EACH_* macros (which have no fontification). +;; The rule is in 'emacs-devel' feature. (defun c-ts-mode--for-each-tail-body-matcher (_n _p bol &rest _) "A matcher that matches the first line after a FOR_EACH_* macro. @@ -1001,13 +1025,14 @@ For BOL see `treesit-simple-indent-rules'." (looking-at c-ts-mode--for-each-tail-regexp)))) (defvar c-ts-mode--emacs-c-range-query - (treesit-query-compile - 'emacs-c `(((declaration - type: (macro_type_specifier - name: (identifier) @_name) - @for-each-tail) - (:match ,c-ts-mode--for-each-tail-regexp - @_name)))) + (when (treesit-available-p) + (treesit-query-compile + 'emacs-c `(((declaration + type: (macro_type_specifier + name: (identifier) @_name) + @for-each-tail) + (:match ,c-ts-mode--for-each-tail-regexp + @_name))))) "Query that finds a FOR_EACH_* macro with an unbracketed body.") (defvar-local c-ts-mode--for-each-tail-ranges nil @@ -1216,7 +1241,8 @@ in your configuration." (treesit-range-rules 'c-ts-mode--emacs-set-ranges)) (setq-local treesit-language-at-point-function - (lambda (_pos) 'c))))) + (lambda (_pos) 'c)) + (treesit-font-lock-recompute-features '(emacs-devel))))) ;;;###autoload (define-derived-mode c++-ts-mode c-ts-base-mode "C++" diff --git a/src/dispnew.c b/src/dispnew.c index 43306043a0c..fe661579daf 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -3748,6 +3748,14 @@ update_window (struct window *w, bool force_p) } } + /* If the window doesn't display its mode line, make sure the + corresponding row of the current glyph matrix is disabled, so + that if and when the mode line is displayed again, it will be + cleared and completely redrawn. */ + if (!window_wants_mode_line (w)) + SET_MATRIX_ROW_ENABLED_P (w->current_matrix, + w->current_matrix->nrows - 1, false); + /* Was display preempted? */ paused_p = row < end; diff --git a/src/treesit.c b/src/treesit.c index ef272fb8871..0af0e347694 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -3886,9 +3886,9 @@ syms_of_treesit (void) define_error (Qtreesit_parse_error, "Parse failed", Qtreesit_error); define_error (Qtreesit_range_invalid, - "RANGES are invalid, they have to be ordered and not overlapping", + "RANGES are invalid: they have to be ordered and should not overlap", Qtreesit_error); - define_error (Qtreesit_buffer_too_large, "Buffer too large (> 4GB)", + define_error (Qtreesit_buffer_too_large, "Buffer too large (> 4GiB)", Qtreesit_error); define_error (Qtreesit_load_language_error, "Cannot load language definition", diff --git a/src/xdisp.c b/src/xdisp.c index 18ea042e212..2817fc45993 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -20615,6 +20615,8 @@ try_window (Lisp_Object window, struct text_pos pos, int flags) int bot_scroll_margin = top_scroll_margin; if (window_wants_header_line (w)) top_scroll_margin += CURRENT_HEADER_LINE_HEIGHT (w); + if (window_wants_tab_line (w)) + top_scroll_margin += CURRENT_TAB_LINE_HEIGHT (w); start_display (&it, w, pos); if ((w->cursor.y >= 0 @@ -21959,17 +21961,23 @@ try_window_id (struct window *w) /* Don't let the cursor end in the scroll margins. */ { - int this_scroll_margin = window_scroll_margin (w, MARGIN_IN_PIXELS); + int top_scroll_margin = window_scroll_margin (w, MARGIN_IN_PIXELS); + int bot_scroll_margin = top_scroll_margin; int cursor_height = MATRIX_ROW (w->desired_matrix, w->cursor.vpos)->height; - if ((w->cursor.y < this_scroll_margin + if (window_wants_header_line (w)) + top_scroll_margin += CURRENT_HEADER_LINE_HEIGHT (w); + if (window_wants_tab_line (w)) + top_scroll_margin += CURRENT_TAB_LINE_HEIGHT (w); + + if ((w->cursor.y < top_scroll_margin && CHARPOS (start) > BEGV) /* Old redisplay didn't take scroll margin into account at the bottom, but then global-hl-line-mode doesn't scroll. KFS 2004-06-14 */ || (w->cursor.y + (cursor_row_fully_visible_p (w, false, true, true) ? 1 - : cursor_height + this_scroll_margin)) > it.last_visible_y) + : cursor_height + bot_scroll_margin)) > it.last_visible_y) { w->cursor.vpos = -1; clear_glyph_matrix (w->desired_matrix); diff --git a/src/xml.c b/src/xml.c index b55ac62cdd3..b4c849e6a65 100644 --- a/src/xml.c +++ b/src/xml.c @@ -280,7 +280,10 @@ DEFUN ("libxml-parse-html-region", Flibxml_parse_html_region, If START is nil, it defaults to `point-min'. If END is nil, it defaults to `point-max'. -If BASE-URL is non-nil, it is used to expand relative URLs. +If BASE-URL is non-nil, it is used if and when reporting errors and +warnings from the underlying libxml2 library. Currently, errors and +warnings from the library are suppressed, so this argument is largely +ignored. If you want comments to be stripped, use the `xml-remove-comments' function to strip comments before calling this function. */) @@ -298,7 +301,10 @@ DEFUN ("libxml-parse-xml-region", Flibxml_parse_xml_region, If START is nil, it defaults to `point-min'. If END is nil, it defaults to `point-max'. -If BASE-URL is non-nil, it is used to expand relative URLs. +If BASE-URL is non-nil, it is used if and when reporting errors and +warnings from the underlying libxml2 library. Currently, errors and +warnings from the library are suppressed, so this argument is largely +ignored. If you want comments to be stripped, use the `xml-remove-comments' function to strip comments before calling this function. */)