Merge remote-tracking branch 'origin/master' into feature/android

This commit is contained in:
Po Lu 2023-05-03 07:45:49 +08:00
commit 9283471cb4
20 changed files with 375 additions and 228 deletions

View file

@ -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}.

View file

@ -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:

View file

@ -2633,7 +2633,7 @@ symbol, @pxref{Standard Properties}.
@item (important-return-value @var{val})
If @var{val} is non-@code{nil}, the byte compiler will warn about
calls to this function that do not use the returned value. This is the
calls to this function that do not use the returned value. This is the
same as the @code{important-return-value} property of the function's
symbol, @pxref{Standard Properties}.

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -1653,7 +1653,10 @@ If HDR is non-nil, insert a header line with the directory name."
see `dired-use-ls-dired' for more details.")
nil))
dired-use-ls-dired)))
(setq switches (concat "--dired " switches)))
;; Use -N with --dired, to countermand possible non-default
;; quoting style, in particular via the environment variable
;; QUOTINTG_STYLE.
(setq switches (concat "--dired -N " switches)))
;; Expand directory wildcards and fill file-list.
(let ((dir-wildcard (insert-directory-wildcard-in-dir-p dir)))
(cond (dir-wildcard

View file

@ -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."

View file

@ -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-mode-map>\\[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-mode-map>\\[package-menu-mark-install]' after `\\[list-packages]'."
(interactive (list (not noninteractive)))
(package-refresh-contents)
(let ((upgradeable (package--upgradeable-packages)))

View file

@ -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

View file

@ -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)

View file

@ -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: ")

View file

@ -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))

View file

@ -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,14 +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
(and (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)))))
(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
@ -1217,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++"

View file

@ -9215,6 +9215,21 @@ it skips the contents of comments that end before point."
:type 'boolean
:group 'paren-blinking)
(defcustom blink-matching-paren-highlight-offscreen nil
"If non-nil, highlight matched off-screen open paren in the echo area.
This highlighting uses the `blink-matching-paren-offscreen' face."
:type 'boolean
:version "30.1"
:group 'paren-blinking)
(defface blink-matching-paren-offscreen
'((t :foreground "green"))
"Face for showing in the echo area matched open paren that is off-screen.
This face is used only when `blink-matching-paren-highlight-offscreen'
is non-nil."
:version "30.1"
:group 'paren-blinking)
(defun blink-matching-check-mismatch (start end)
"Return whether or not START...END are matching parens.
END is the current point and START is the blink position.
@ -9312,47 +9327,79 @@ The function should return non-nil if the two tokens do not match.")
(delete-overlay blink-matching--overlay)))))
((not show-paren-context-when-offscreen)
(minibuffer-message
"Matches %s"
(substring-no-properties
(blink-paren-open-paren-line-string blinkpos))))))))
#("Matches %s"
;; Make the following text (i.e., %s) prominent.
0 7 (face shadow))
(blink-paren-open-paren-line-string blinkpos)))))))
(defun blink-paren-open-paren-line-string (pos)
"Return the line string that contains the openparen at POS."
"Return the line string that contains the openparen at POS.
Remove the line string's properties but give the openparen a distinct
face if `blink-matching-paren-highlight-offscreen' is non-nil."
(save-excursion
(goto-char pos)
;; Capture the regions in terms of (beg . end) conses whose
;; buffer-substrings we want to show as a context string. Ensure
;; they are font-locked (bug#59527).
(let (regions)
;; Show what precedes the open in its line, if anything.
(let (regions
openparen-idx)
(cond
;; Show what precedes the open in its line, if anything.
((save-excursion (skip-chars-backward " \t") (not (bolp)))
(setq regions (list (cons (line-beginning-position)
(1+ pos)))))
(let ((bol (line-beginning-position)))
(setq regions (list (cons bol (1+ pos)))
openparen-idx (- pos bol))))
;; Show what follows the open in its line, if anything.
((save-excursion
(forward-char 1)
(skip-chars-forward " \t")
(not (eolp)))
(setq regions (list (cons pos (line-end-position)))))
(setq regions (list (cons pos (line-end-position)))
openparen-idx 0))
;; Otherwise show the previous nonblank line,
;; if there is one.
((save-excursion (skip-chars-backward "\n \t") (not (bobp)))
(setq regions (list (cons (progn
(skip-chars-backward "\n \t")
(line-beginning-position))
(progn (end-of-line)
(skip-chars-backward " \t")
(point)))
(setq regions (list (cons
(let (bol)
(skip-chars-backward "\n \t")
(setq bol (line-beginning-position)
openparen-idx (- bol))
bol)
(let (eol)
(end-of-line)
(skip-chars-backward " \t")
(setq eol (point)
openparen-idx (+ openparen-idx
eol
;; (length "...")
3))
eol))
(cons pos (1+ pos)))))
;; There is nothing to show except the char itself.
(t (setq regions (list (cons pos (1+ pos))))))
(t (setq regions (list (cons pos (1+ pos)))
openparen-idx 0)))
;; Ensure we've font-locked the context region.
(font-lock-ensure (caar regions) (cdar (last regions)))
(mapconcat (lambda (region)
(buffer-substring (car region) (cdr region)))
regions
"..."))))
(let ((line-string
(mapconcat
(lambda (region)
(buffer-substring (car region) (cdr region)))
regions
"..."))
(openparen-next-char-idx (1+ openparen-idx)))
(setq line-string (substring-no-properties line-string))
(concat
(substring line-string
0 openparen-idx)
(let ((matched-offscreen-openparen
(substring line-string
openparen-idx openparen-next-char-idx)))
(if blink-matching-paren-highlight-offscreen
(propertize matched-offscreen-openparen
'face 'blink-matching-paren-offscreen)
matched-offscreen-openparen))
(substring line-string
openparen-next-char-idx))))))
(defvar blink-paren-function 'blink-matching-open
"Function called, if non-nil, whenever a close parenthesis is inserted.

View file

@ -3755,6 +3755,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;

View file

@ -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",

View file

@ -20662,6 +20662,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
@ -22006,17 +22008,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);

View file

@ -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. */)