commit a457aa62577284333c7d25d48a49704788b25a04 (HEAD, refs/remotes/origin/master) Author: Jim Porter Date: Sat Aug 20 10:48:32 2022 -0700 Kill the buffer for the temp file after using '$' in Eshell * lisp/eshell/esh-var.el (eshell-parse-variable-ref): Kill the temp file's buffer when we're done. Ref: https://lists.gnu.org/archive/html/bug-gnu-emacs/2022-08/msg01444.html diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el index 2f6614b5d7..a9df172e88 100644 --- a/lisp/eshell/esh-var.el +++ b/lisp/eshell/esh-var.el @@ -490,8 +490,11 @@ Possible variable references are: ;; by `eshell-do-eval', which requires very ;; particular forms in order to work ;; properly. See bug#54190. - (list (function (lambda () - (delete-file ,temp)))))) + (list (function + (lambda () + (delete-file ,temp) + (when-let ((buffer (get-file-buffer ,temp))) + (kill-buffer buffer))))))) (eshell-apply-indices ,temp indices ,eshell-current-quoted))) (goto-char (1+ end))))))) ((eq (char-after) ?\() commit 23c01a23a3a23ad195ebbbaad9a0b6de846b41b0 Merge: 4ac59b3313 e3b8577525 Author: Stefan Kangas Date: Fri Aug 26 06:30:30 2022 +0200 Merge from origin/emacs-28 e3b8577525 ; * etc/DEBUG: Fix wording of "X protocol errors" section. commit 4ac59b331372fb3cf894e1bbf9083a34c27bff33 Merge: 6d3d9dba60 ba64d09156 Author: Stefan Kangas Date: Fri Aug 26 06:30:30 2022 +0200 ; Merge from origin/emacs-28 The following commit was skipped: ba64d09156 Treat smtp-auth method from auth-info as a symbol commit 6d3d9dba60f1ba5e259a73f21c3af8b4ae5d85fa Merge: 743e966cb8 9e03e29c4e Author: Stefan Kangas Date: Fri Aug 26 06:30:29 2022 +0200 Merge from origin/emacs-28 9e03e29c4e * lisp/wdired.el: Improve "Commentary" section. 92e90297f9 * lisp/wdired.el: Doc fix; don't mention obsolete variable. 2ccefef4c7 * lisp/progmodes/etags.el (next-file): Minor doc fix. commit 743e966cb8fd67af16b581f9411265b141072342 Merge: 8cad97e3db 82bcd44378 Author: Stefan Kangas Date: Fri Aug 26 06:30:29 2022 +0200 ; Merge from origin/emacs-28 The following commit was skipped: 82bcd44378 * configure.ac: Move AC_LANG_PUSH/POP out of AC_CACHE_CHEC... commit 8cad97e3db879e21663aea5da6138618f4901154 Author: Po Lu Date: Fri Aug 26 09:42:35 2022 +0800 Restore old code in x_sync_trigger_fence * src/xterm.c (x_sync_trigger_fence): Restore old code, since that makes it easier to adapt to more than 2 sync fences (which might be necessary in the future, if we ever decide to do frame handling asynchronously), and is much more recognizable for people coming from other programs. diff --git a/src/xterm.c b/src/xterm.c index 5a36aa0302..b91d3a9517 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -6905,16 +6905,22 @@ x_sync_update_begin (struct frame *f) static void x_sync_trigger_fence (struct frame *f, XSyncValue value) { + uint_fast64_t n, low, high, idx; + /* Sync fences aren't supported by the X server. */ if (FRAME_DISPLAY_INFO (f)->xsync_major < 3 || (FRAME_DISPLAY_INFO (f)->xsync_major == 3 && FRAME_DISPLAY_INFO (f)->xsync_minor < 1)) return; - bool idx = !! (XSyncValueLow32 (value) & 4); + low = XSyncValueLow32 (value); + high = XSyncValueHigh32 (value); + + n = low | (high << 32); + idx = (n / 4) % 2; #ifdef FRAME_DEBUG - fprintf (stderr, "Triggering synchronization fence: %d\n", idx); + fprintf (stderr, "Triggering synchronization fence: %lu\n", idx); #endif XSyncTriggerFence (FRAME_X_DISPLAY (f), commit 7ffac97f4908f0eaf38364336c1844665dd17335 Author: Po Lu Date: Fri Aug 26 09:37:47 2022 +0800 ; * src/xterm.h (struct x_display_info): Update comment. diff --git a/src/xterm.h b/src/xterm.h index 3654c3d5db..a0ae3a330a 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -834,7 +834,8 @@ struct x_display_info bool server_time_monotonic_p; /* The time difference between the X server clock and the monotonic - clock, or 0 if unknown (FIXME: what if the difference is zero?). */ + clock, or 0 if unknown (if the difference is legitimately 0, + server_time_monotonic_p will be true). */ int_fast64_t server_time_offset; #endif }; commit 7b05ffda80151d0c1a73ec1a4d0cd359849968d5 Author: Paul Eggert Date: Thu Aug 25 18:16:56 2022 -0500 Update from Gnulib by running admin/merge-gnulib diff --git a/doc/misc/texinfo.tex b/doc/misc/texinfo.tex index 8872e5e055..f86af0db3e 100644 --- a/doc/misc/texinfo.tex +++ b/doc/misc/texinfo.tex @@ -3,7 +3,7 @@ % Load plain if necessary, i.e., if running under initex. \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi % -\def\texinfoversion{2022-04-09.08} +\def\texinfoversion{2022-08-20.19} % % Copyright 1985, 1986, 1988, 1990-2022 Free Software Foundation, Inc. % @@ -725,32 +725,22 @@ \dimen2 = \ht\strutbox \advance\dimen2 by \dp\strutbox \ifdim\dimen0 > \dimen2 + % This is similar to the 'needspace' module in LaTeX. + % The first penalty allows a break if the end of the page is + % not too far away. Following penalties and skips are discarded. + % Otherwise, require at least \dimen0 of vertical space. % - % Do a \strut just to make the height of this box be normal, so the - % normal leading is inserted relative to the preceding line. - % And a page break here is fine. - \vtop to #1\mil{\strut\vfil}% - % - % TeX does not even consider page breaks if a penalty added to the - % main vertical list is 10000 or more. But in order to see if the - % empty box we just added fits on the page, we must make it consider - % page breaks. On the other hand, we don't want to actually break the - % page after the empty box. So we use a penalty of 9999. - % - % There is an extremely small chance that TeX will actually break the - % page at this \penalty, if there are no other feasible breakpoints in - % sight. (If the user is using lots of big @group commands, which - % almost-but-not-quite fill up a page, TeX will have a hard time doing - % good page breaking, for example.) However, I could not construct an - % example where a page broke at this \penalty; if it happens in a real - % document, then we can reconsider our strategy. + % (We used to use a \vtop to reserve space, but this had spacing issues + % when followed by a section heading, as it was not a "discardable item". + % This also has the benefit of providing glue before the page break if + % there isn't enough space.) + \vskip0pt plus \dimen0 + \penalty-100 + \vskip0pt plus -\dimen0 + \vskip \dimen0 \penalty9999 - % - % Back up by the size of the box, whether we did a page break or not. - \kern -#1\mil - % - % Do not allow a page break right after this kern. - \nobreak + \vskip -\dimen0 + \penalty0\relax % this hides the above glue from \safewhatsit and \dobreak \fi } @@ -2558,7 +2548,7 @@ \def\it{\fam=\itfam \setfontstyle{it}} \def\sl{\fam=\slfam \setfontstyle{sl}} \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf} -\def\tt{\fam=\ttfam \setfontstyle{tt}}\def\ttstylename{tt} +\def\tt{\fam=\ttfam \setfontstyle{tt}} % Texinfo sort of supports the sans serif font style, which plain TeX does not. % So we set up a \sf. @@ -2691,6 +2681,14 @@ % \def\ifmonospace{\ifdim\fontdimen3\font=0pt } +% Check if internal flag is clear, i.e. has not been @set. +\def\ifflagclear#1#2#3{% + \expandafter\ifx\csname SET#1\endcsname\relax + #2\else#3\fi +} + + + { \catcode`\'=\active \catcode`\`=\active @@ -2707,14 +2705,14 @@ % \def\codequoteright{% \ifmonospace - \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax - \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax + \ifflagclear{txicodequoteundirected}{% + \ifflagclear{codequoteundirected}{% '% - \else \char'15 \fi - \else \char'15 \fi - \else - '% - \fi + }{\char'15 }% + }{\char'15 }% + \else + '% + \fi } % % and a similar option for the left quote char vs. a grave accent. @@ -2723,16 +2721,16 @@ % \def\codequoteleft{% \ifmonospace - \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax - \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax + \ifflagclear{txicodequotebacktick}{% + \ifflagclear{codequotebacktick}{% % [Knuth] pp. 380,381,391 % \relax disables Spanish ligatures ?` and !` of \tt font. \relax`% - \else \char'22 \fi - \else \char'22 \fi - \else - \relax`% - \fi + }{\char'22 }% + }{\char'22 }% + \else + \relax`% + \fi } % Commands to set the quote options. @@ -2779,15 +2777,16 @@ \def\dosmartslant#1#2{% \ifusingtt {{\ttsl #2}\let\next=\relax}% - {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}% + {\def\next{{#1#2}\smartitaliccorrection}}% \next } \def\smartslanted{\dosmartslant\sl} \def\smartitalic{\dosmartslant\it} -% Output an italic correction unless \next (presumed to be the following -% character) is such as not to need one. -\def\smartitaliccorrection{% +% Output an italic correction unless the following character is such as +% not to need one. +\def\smartitaliccorrection{\futurelet\next\smartitaliccorrectionx} +\def\smartitaliccorrectionx{% \ifx\next,% \else\ifx\next-% \else\ifx\next.% @@ -2798,18 +2797,18 @@ \aftersmartic } -% Unconditional use \ttsl, and no ic. @var is set to this for defuns. -\def\ttslanted#1{{\ttsl #1}} - -% @cite is like \smartslanted except unconditionally use \sl. We never want -% ttsl for book titles, do we? -\def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection} +% @cite unconditionally uses \sl with \smartitaliccorrection. +\def\cite#1{{\sl #1}\smartitaliccorrection} +% @var unconditionally uses \sl. This gives consistency for +% parameter names whether they are in @def, @table @code or a +% regular paragraph. +% The \null is to reset \spacefactor. \def\aftersmartic{} \def\var#1{% \let\saveaftersmartic = \aftersmartic \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}% - \smartslanted{#1}% + {\sl #1}\smartitaliccorrection } \let\i=\smartitalic @@ -2817,8 +2816,14 @@ \let\dfn=\smartslanted \let\emph=\smartitalic -% Explicit font changes: @r, @sc, undocumented @ii. -\def\r#1{{\rm #1}} % roman font +% @r for roman font, used for code comment +\def\r#1{{% + \usenormaldash % get --, --- ligatures even if in @code + \defcharsdefault % in case on def line + \rm #1}} +{\catcode`-=\active \gdef\usenormaldash{\let-\normaldash}} + +% @sc, undocumented @ii. \def\sc#1{{\smallcaps#1}} % smallcaps font \def\ii#1{{\it #1}} % italic font @@ -2856,7 +2861,7 @@ % @t, explicit typewriter. \def\t#1{% - {\tt \plainfrenchspacing #1}% + {\tt \defcharsdefault \plainfrenchspacing #1}% \null } @@ -4432,7 +4437,7 @@ \message{conditionals,} -% @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext, +% @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotlatex, @ifnotplaintext, % @ifnotxml always succeed. They currently do nothing; we don't % attempt to check whether the conditionals are properly nested. But we % have to remember that they are conditionals, so that @end doesn't @@ -4446,6 +4451,7 @@ \makecond{ifnotdocbook} \makecond{ifnothtml} \makecond{ifnotinfo} +\makecond{ifnotlatex} \makecond{ifnotplaintext} \makecond{ifnotxml} @@ -4458,10 +4464,12 @@ \def\ifdocbook{\doignore{ifdocbook}} \def\ifhtml{\doignore{ifhtml}} \def\ifinfo{\doignore{ifinfo}} +\def\iflatex{\doignore{iflatex}} \def\ifnottex{\doignore{ifnottex}} \def\ifplaintext{\doignore{ifplaintext}} \def\ifxml{\doignore{ifxml}} \def\ignore{\doignore{ignore}} +\def\latex{\doignore{latex}} \def\menu{\doignore{menu}} \def\xml{\doignore{xml}} @@ -4985,25 +4993,24 @@ \catcode`\-=13 \catcode`\`=13 \gdef\indexnonalnumdisappear{% - \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax\else + \ifflagclear{txiindexlquoteignore}{}{% % @set txiindexlquoteignore makes us ignore left quotes in the sort term. % (Introduced for FSFS 2nd ed.) \let`=\empty - \fi + }% % - \expandafter\ifx\csname SETtxiindexbackslashignore\endcsname\relax\else + \ifflagclear{txiindexbackslashignore}{}{% \backslashdisappear - \fi - % - \expandafter\ifx\csname SETtxiindexhyphenignore\endcsname\relax\else + }% + \ifflagclear{txiindexhyphenignore}{}{% \def-{}% - \fi - \expandafter\ifx\csname SETtxiindexlessthanignore\endcsname\relax\else + }% + \ifflagclear{txiindexlessthanignore}{}{% \def<{}% - \fi - \expandafter\ifx\csname SETtxiindexatsignignore\endcsname\relax\else + }% + \ifflagclear{txiindexatsignignore}{}{% \def\@{}% - \fi + }% } \gdef\indexnonalnumreappear{% @@ -5295,9 +5302,7 @@ % \atdummies % - \expandafter\ifx\csname SETtxiindexescapeisbackslash\endcsname\relax\else - \escapeisbackslash - \fi + \ifflagclear{txiindexescapeisbackslash}{}{\escapeisbackslash}% % % For texindex which always views { and } as separators. \def\{{\lbracechar{}}% @@ -5481,9 +5486,9 @@ % old index files using \ as the escape character. Reading this would % at best lead to typesetting garbage, at worst a TeX syntax error. \def\printindexzz#1#2\finish{% - \expandafter\ifx\csname SETtxiindexescapeisbackslash\endcsname\relax + \ifflagclear{txiindexescapeisbackslash}{% \uccode`\~=`\\ \uppercase{\if\noexpand~}\noexpand#1 - \expandafter\ifx\csname SETtxiskipindexfileswithbackslash\endcsname\relax + \ifflagclear{txiskipindexfileswithbackslash}{% \errmessage{% ERROR: A sorted index file in an obsolete format was skipped. To fix this problem, please upgrade your version of 'texi2dvi' @@ -5499,15 +5504,15 @@ If you continue to have problems, deleting the index files and starting again might help (with 'rm \jobname.?? \jobname.??s')% }% - \else + }{% (Skipped sorted index file in obsolete format) - \fi + }% \else \begindoublecolumns \input \jobname.\indexname s \enddoublecolumns \fi - \else + }{% \begindoublecolumns \catcode`\\=0\relax % @@ -5517,7 +5522,7 @@ \catcode`\@=0\relax \input \jobname.\indexname s \enddoublecolumns - \fi + }% } % These macros are used by the sorted index file itself. @@ -7277,22 +7282,6 @@ } \let\Eraggedright\par -\envdef\raggedleft{% - \parindent=0pt \leftskip0pt plus2em - \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt - \hbadness=10000 % Last line will usually be underfull, so turn off - % badness reporting. -} -\let\Eraggedleft\par - -\envdef\raggedcenter{% - \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em - \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt - \hbadness=10000 % Last line will usually be underfull, so turn off - % badness reporting. -} -\let\Eraggedcenter\par - % @quotation does normal linebreaking (hence we can't use \nonfillstart) % and narrows the margins. We keep \parskip nonzero in general, since @@ -7515,9 +7504,11 @@ % file; b) letting users define the frontmatter in as flexible order as % possible is desirable. % -\def\copying{\checkenv{}\begingroup\scanargctxt\docopying} -\def\docopying#1@end copying{\endgroup\def\copyingtext{#1}} -% +\def\copying{\checkenv{}\begingroup\macrobodyctxt\docopying} +{\catcode`\ =\other +\gdef\docopying#1@end copying{\endgroup\def\copyingtext{#1}} +} + \def\insertcopying{% \begingroup \parindent = 0pt % paragraph indentation looks wrong on title page @@ -7599,21 +7590,15 @@ \def\Edefun{\endgraf\medbreak} -% \makedefun{deffn} creates \deffn, \deffnx and \Edeffn; -% the only thing remaining is to define \deffnheader. +% \makedefun{deffoo}{ (definition of \deffooheader) } % +% Define \deffoo, \deffoox \Edeffoo and \deffooheader. \def\makedefun#1{% \expandafter\let\csname E#1\endcsname = \Edefun \edef\temp{\noexpand\domakedefun \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}% \temp } - -% \domakedefun \deffn \deffnx \deffnheader { (defn. of \deffnheader) } -% -% Define \deffn and \deffnx, without parameters. -% \deffnheader has to be defined explicitly. -% \def\domakedefun#1#2#3{% \envdef#1{% \startdefun @@ -7646,74 +7631,51 @@ \fi\fi } -% \dosubind {index}{topic}{subtopic} -% -% If SUBTOPIC is present, precede it with a space, and call \doind. -% (At some time during the 20th century, this made a two-level entry in an -% index such as the operation index. Nobody seemed to notice the change in -% behaviour though.) -\def\dosubind#1#2#3{% - \def\thirdarg{#3}% - \ifx\thirdarg\empty - \doind{#1}{#2}% - \else - \doind{#1}{#2\space#3}% - \fi -} - % Untyped functions: % @deffn category name args -\makedefun{deffn}{\deffngeneral{}} - -% @deffn category class name args -\makedefun{defop}#1 {\defopon{#1\ \putwordon}} - -% \defopon {category on}class name args -\def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } +\makedefun{deffn}#1 #2 #3\endheader{% + \doind{fn}{\code{#2}}% + \defname{#1}{}{#2}\magicamp\defunargs{#3\unskip}% +} -% \deffngeneral {subind}category name args -% -\def\deffngeneral#1#2 #3 #4\endheader{% - \dosubind{fn}{\code{#3}}{#1}% - \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}% +% @defop category class name args +\makedefun{defop}#1 {\defopheaderx{#1\ \putwordon}} +\def\defopheaderx#1#2 #3 #4\endheader{% + \doind{fn}{\code{#3}\space\putwordon\ \code{#2}}% + \defname{#1\ \code{#2}}{}{#3}\magicamp\defunargs{#4\unskip}% } % Typed functions: % @deftypefn category type name args -\makedefun{deftypefn}{\deftypefngeneral{}} +\makedefun{deftypefn}#1 #2 #3 #4\endheader{% + \doind{fn}{\code{#3}}% + \doingtypefntrue + \defname{#1}{#2}{#3}\defunargs{#4\unskip}% +} % @deftypeop category class type name args -\makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}} - -% \deftypeopon {category on}class type name args -\def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } - -% \deftypefngeneral {subind}category type name args -% -\def\deftypefngeneral#1#2 #3 #4 #5\endheader{% - \dosubind{fn}{\code{#4}}{#1}% +\makedefun{deftypeop}#1 {\deftypeopheaderx{#1\ \putwordon}} +\def\deftypeopheaderx#1#2 #3 #4 #5\endheader{% + \doind{fn}{\code{#4}\space\putwordon\ \code{#1\ \code{#2}}}% \doingtypefntrue - \defname{#2}{#3}{#4}\defunargs{#5\unskip}% + \defname{#1\ \code{#2}}{#3}{#4}\defunargs{#5\unskip}% } % Typed variables: % @deftypevr category type var args -\makedefun{deftypevr}{\deftypecvgeneral{}} +\makedefun{deftypevr}#1 #2 #3 #4\endheader{% + \doind{vr}{\code{#3}}% + \defname{#1}{#2}{#3}\defunargs{#4\unskip}% +} % @deftypecv category class type var args -\makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}} - -% \deftypecvof {category of}class type var args -\def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} } - -% \deftypecvgeneral {subind}category type var args -% -\def\deftypecvgeneral#1#2 #3 #4 #5\endheader{% - \dosubind{vr}{\code{#4}}{#1}% - \defname{#2}{#3}{#4}\defunargs{#5\unskip}% +\makedefun{deftypecv}#1 {\deftypecvheaderx{#1\ \putwordof}} +\def\deftypecvheaderx#1#2 #3 #4 #5\endheader{% + \doind{vr}{\code{#4}\space\putwordof\ \code{#2}}% + \defname{#1\ \code{#2}}{#3}{#4}\defunargs{#5\unskip}% } % Untyped variables: @@ -7722,10 +7684,8 @@ \makedefun{defvr}#1 {\deftypevrheader{#1} {} } % @defcv category class var args -\makedefun{defcv}#1 {\defcvof{#1\ \putwordof}} - -% \defcvof {category of}class var args -\def\defcvof#1#2 {\deftypecvof{#1}#2 {} } +\makedefun{defcv}#1 {\defcvheaderx{#1\ \putwordof}} +\def\defcvheaderx#1#2 {\deftypecvheaderx{#1}#2 {} } % Types: @@ -7743,10 +7703,10 @@ \makedefun{defvar}{\defvrheader{\putwordDefvar} } \makedefun{defopt}{\defvrheader{\putwordDefopt} } \makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} } -\makedefun{defmethod}{\defopon\putwordMethodon} -\makedefun{deftypemethod}{\deftypeopon\putwordMethodon} -\makedefun{defivar}{\defcvof\putwordInstanceVariableof} -\makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof} +\makedefun{defmethod}{\defopheaderx\putwordMethodon} +\makedefun{deftypemethod}{\deftypeopheaderx\putwordMethodon} +\makedefun{defivar}{\defcvheaderx\putwordInstanceVariableof} +\makedefun{deftypeivar}{\deftypecvheaderx\putwordInstanceVariableof} % \defname, which formats the name of the @def (not the args). % #1 is the category, such as "Function". @@ -7765,9 +7725,7 @@ \rettypeownlinefalse \ifdoingtypefn % doing a typed function specifically? % then check user option for putting return type on its own line: - \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else - \rettypeownlinetrue - \fi + \ifflagclear{txideftypefnnl}{}{\rettypeownlinetrue}% \fi % % How we'll format the category name. Putting it in brackets helps @@ -7832,30 +7790,18 @@ \fi % no return type #3% output function name }% - {\rm\enskip}% hskip 0.5 em of \rmfont + \ifflagclear{txidefnamenospace}{% + {\rm\enskip}% hskip 0.5 em of \rmfont + }{}% % \boldbrax % arguments will be output next, if any. } -% Print arguments in slanted roman (not ttsl), inconsistently with using -% tt for the name. This is because literal text is sometimes needed in -% the argument list (groff manual), and ttsl and tt are not very -% distinguishable. Prevent hyphenation at `-' chars. -% +% Print arguments. Use slanted for @def*, typewriter for @deftype*. \def\defunargs#1{% - % use sl by default (not ttsl), - % tt for the names. - \df \sl \hyphenchar\font=0 - % - % On the other hand, if an argument has two dashes (for instance), we - % want a way to get ttsl. We used to recommend @var for that, so - % leave the code in, but it's strange for @var to lead to typewriter. - % Nowadays we recommend @code, since the difference between a ttsl hyphen - % and a tt hyphen is pretty tiny. @code also disables ?` !`. - \def\var##1{{\setregularquotes\ttslanted{##1}}}% + \df \ifdoingtypefn \tt \else \sl \fi #1% - \sl\hyphenchar\font=45 } % We want ()&[] to print specially on the defun line. @@ -7874,9 +7820,12 @@ % so TeX would otherwise complain about undefined control sequence. { \activeparens - \global\let(=\lparen \global\let)=\rparen - \global\let[=\lbrack \global\let]=\rbrack - \global\let& = \& + \gdef\defcharsdefault{% + \let(=\lparen \let)=\rparen + \let[=\lbrack \let]=\rbrack + \let& = \&% + } + \globaldefs=1 \defcharsdefault \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} \gdef\magicamp{\let&=\amprm} @@ -8060,24 +8009,17 @@ \catcode`\_=\other \catcode`\|=\other \catcode`\~=\other - \passthroughcharstrue -} - -\def\scanargctxt{% used for copying and captions, not macros. - \scanctxt \catcode`\@=\other - \catcode`\\=\other \catcode`\^^M=\other + \catcode`\\=\active + \passthroughcharstrue } -\def\macrobodyctxt{% used for @macro definitions +\def\macrobodyctxt{% used for @macro definitions and @copying \scanctxt \catcode`\ =\other - \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other - \catcode`\^^M=\other - \usembodybackslash } % Used when scanning braced macro arguments. Note, however, that catcode @@ -8086,14 +8028,10 @@ \def\macroargctxt{% \scanctxt \catcode`\ =\active - \catcode`\@=\other - \catcode`\^^M=\other - \catcode`\\=\active } \def\macrolineargctxt{% used for whole-line arguments without braces \scanctxt - \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other } @@ -8137,7 +8075,7 @@ \global\expandafter\let\csname ismacro.\the\macname\endcsname=1% \addtomacrolist{\the\macname}% \fi - \begingroup \macrobodyctxt + \begingroup \macrobodyctxt \usembodybackslash \ifrecursive \expandafter\parsermacbody \else \expandafter\parsemacbody \fi} @@ -8941,7 +8879,7 @@ % output the `[mynode]' via the macro below so it can be overridden. \xrefprintnodename\printedrefname % - \expandafter\ifx\csname SETtxiomitxrefpg\endcsname\relax + \ifflagclear{txiomitxrefpg}{% % But we always want a comma and a space: ,\space % @@ -8956,7 +8894,7 @@ \tokenafterxref ,% @NL \else\ifx\tie\tokenafterxref ,% @tie \fi\fi\fi\fi\fi\fi - \fi + }{}% \fi\fi \fi \endlink @@ -9604,7 +9542,7 @@ % \def\caption{\docaption\thiscaption} \def\shortcaption{\docaption\thisshortcaption} -\def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption} +\def\docaption{\checkenv\float \bgroup\scanctxt\defcaption} \def\defcaption#1#2{\egroup \def#1{#2}} % The parameter is the control sequence identifying the counter we are @@ -10324,9 +10262,9 @@ % Given the value in \countUTFz as a Unicode code point, set \UTFviiiTmp % to the corresponding UTF-8 sequence. \gdef\parseXMLCharref{% - \ifnum\countUTFz < "A0\relax + \ifnum\countUTFz < "20\relax \errhelp = \EMsimple - \errmessage{Cannot define Unicode char value < 00A0}% + \errmessage{Cannot define Unicode char value < 0020}% \else\ifnum\countUTFz < "800\relax \parseUTFviiiA,% \parseUTFviiiB C\UTFviiiTwoOctetsName.,% @@ -10396,6 +10334,103 @@ % least make most of the characters not bomb out. % \def\unicodechardefs{% + \DeclareUnicodeCharacter{0020}{ } % space + \DeclareUnicodeCharacter{0021}{\char"21 }% % space to terminate number + \DeclareUnicodeCharacter{0022}{\char"22 }% + \DeclareUnicodeCharacter{0023}{\char"23 }% + \DeclareUnicodeCharacter{0024}{\char"24 }% + \DeclareUnicodeCharacter{0025}{\char"25 }% + \DeclareUnicodeCharacter{0026}{\char"26 }% + \DeclareUnicodeCharacter{0027}{\char"27 }% + \DeclareUnicodeCharacter{0028}{\char"28 }% + \DeclareUnicodeCharacter{0029}{\char"29 }% + \DeclareUnicodeCharacter{002A}{\char"2A }% + \DeclareUnicodeCharacter{002B}{\char"2B }% + \DeclareUnicodeCharacter{002C}{\char"2C }% + \DeclareUnicodeCharacter{002D}{\char"2D }% + \DeclareUnicodeCharacter{002E}{\char"2E }% + \DeclareUnicodeCharacter{002F}{\char"2F }% + \DeclareUnicodeCharacter{0030}{0}% + \DeclareUnicodeCharacter{0031}{1}% + \DeclareUnicodeCharacter{0032}{2}% + \DeclareUnicodeCharacter{0033}{3}% + \DeclareUnicodeCharacter{0034}{4}% + \DeclareUnicodeCharacter{0035}{5}% + \DeclareUnicodeCharacter{0036}{6}% + \DeclareUnicodeCharacter{0037}{7}% + \DeclareUnicodeCharacter{0038}{8}% + \DeclareUnicodeCharacter{0039}{9}% + \DeclareUnicodeCharacter{003A}{\char"3A }% + \DeclareUnicodeCharacter{003B}{\char"3B }% + \DeclareUnicodeCharacter{003C}{\char"3C }% + \DeclareUnicodeCharacter{003D}{\char"3D }% + \DeclareUnicodeCharacter{003E}{\char"3E }% + \DeclareUnicodeCharacter{003F}{\char"3F }% + \DeclareUnicodeCharacter{0040}{\char"40 }% + \DeclareUnicodeCharacter{0041}{A}% + \DeclareUnicodeCharacter{0042}{B}% + \DeclareUnicodeCharacter{0043}{C}% + \DeclareUnicodeCharacter{0044}{D}% + \DeclareUnicodeCharacter{0045}{E}% + \DeclareUnicodeCharacter{0046}{F}% + \DeclareUnicodeCharacter{0047}{G}% + \DeclareUnicodeCharacter{0048}{H}% + \DeclareUnicodeCharacter{0049}{I}% + \DeclareUnicodeCharacter{004A}{J}% + \DeclareUnicodeCharacter{004B}{K}% + \DeclareUnicodeCharacter{004C}{L}% + \DeclareUnicodeCharacter{004D}{M}% + \DeclareUnicodeCharacter{004E}{N}% + \DeclareUnicodeCharacter{004F}{O}% + \DeclareUnicodeCharacter{0050}{P}% + \DeclareUnicodeCharacter{0051}{Q}% + \DeclareUnicodeCharacter{0052}{R}% + \DeclareUnicodeCharacter{0053}{S}% + \DeclareUnicodeCharacter{0054}{T}% + \DeclareUnicodeCharacter{0055}{U}% + \DeclareUnicodeCharacter{0056}{V}% + \DeclareUnicodeCharacter{0057}{W}% + \DeclareUnicodeCharacter{0058}{X}% + \DeclareUnicodeCharacter{0059}{Y}% + \DeclareUnicodeCharacter{005A}{Z}% + \DeclareUnicodeCharacter{005B}{\char"5B }% + \DeclareUnicodeCharacter{005C}{\char"5C }% + \DeclareUnicodeCharacter{005D}{\char"5D }% + \DeclareUnicodeCharacter{005E}{\char"5E }% + \DeclareUnicodeCharacter{005F}{\char"5F }% + \DeclareUnicodeCharacter{0060}{\char"60 }% + \DeclareUnicodeCharacter{0061}{a}% + \DeclareUnicodeCharacter{0062}{b}% + \DeclareUnicodeCharacter{0063}{c}% + \DeclareUnicodeCharacter{0064}{d}% + \DeclareUnicodeCharacter{0065}{e}% + \DeclareUnicodeCharacter{0066}{f}% + \DeclareUnicodeCharacter{0067}{g}% + \DeclareUnicodeCharacter{0068}{h}% + \DeclareUnicodeCharacter{0069}{i}% + \DeclareUnicodeCharacter{006A}{j}% + \DeclareUnicodeCharacter{006B}{k}% + \DeclareUnicodeCharacter{006C}{l}% + \DeclareUnicodeCharacter{006D}{m}% + \DeclareUnicodeCharacter{006E}{n}% + \DeclareUnicodeCharacter{006F}{o}% + \DeclareUnicodeCharacter{0070}{p}% + \DeclareUnicodeCharacter{0071}{q}% + \DeclareUnicodeCharacter{0072}{r}% + \DeclareUnicodeCharacter{0073}{s}% + \DeclareUnicodeCharacter{0074}{t}% + \DeclareUnicodeCharacter{0075}{u}% + \DeclareUnicodeCharacter{0076}{v}% + \DeclareUnicodeCharacter{0077}{w}% + \DeclareUnicodeCharacter{0078}{x}% + \DeclareUnicodeCharacter{0079}{y}% + \DeclareUnicodeCharacter{007A}{z}% + \DeclareUnicodeCharacter{007B}{\char"7B }% + \DeclareUnicodeCharacter{007C}{\char"7C }% + \DeclareUnicodeCharacter{007D}{\char"7D }% + \DeclareUnicodeCharacter{007E}{\char"7E }% + % \DeclareUnicodeCharacter{007F}{} % DEL + % \DeclareUnicodeCharacter{00A0}{\tie}% \DeclareUnicodeCharacter{00A1}{\exclamdown}% \DeclareUnicodeCharacter{00A2}{{\tcfont \char162}}% 0242=cent @@ -11080,24 +11115,26 @@ % provide a definition macro to replace/pass-through a Unicode character % \def\DeclareUnicodeCharacterNative#1#2{% - \catcode"#1=\active - \def\dodeclareunicodecharacternative##1##2##3{% + \ifnum"#1>"7F % only make non-ASCII chars active + \catcode"#1=\active + \def\dodeclareunicodecharacternative##1##2##3{% + \begingroup + \uccode`\~="##2\relax + \uppercase{\gdef~}{% + \ifpassthroughchars + ##1% + \else + ##3% + \fi + } + \endgroup + } \begingroup - \uccode`\~="##2\relax - \uppercase{\gdef~}{% - \ifpassthroughchars - ##1% - \else - ##3% - \fi - } + \uccode`\.="#1\relax + \uppercase{\def\UTFNativeTmp{.}}% + \expandafter\dodeclareunicodecharacternative\UTFNativeTmp{#1}{#2}% \endgroup - } - \begingroup - \uccode`\.="#1\relax - \uppercase{\def\UTFNativeTmp{.}}% - \expandafter\dodeclareunicodecharacternative\UTFNativeTmp{#1}{#2}% - \endgroup + \fi } % Native Unicode handling (XeTeX and LuaTeX) character replacing definition. @@ -11276,7 +11313,7 @@ \textleading = 12.5pt % \internalpagesizes{160mm}{120mm}% - {\voffset}{\hoffset}% + {\voffset}{-11.4mm}% {\bindingoffset}{8pt}% {210mm}{148mm}% % @@ -11358,6 +11395,7 @@ \message{and turning on texinfo input format.} \def^^L{\par} % remove \outer, so ^L can appear in an @comment +\catcode`\^^K = 10 % treat vertical tab as whitespace % DEL is a comment character, in case @c does not suffice. \catcode`\^^? = 14 diff --git a/lib/tempname.c b/lib/tempname.c index 5adfe629a8..11b4796b34 100644 --- a/lib/tempname.c +++ b/lib/tempname.c @@ -20,16 +20,10 @@ # include "tempname.h" #endif -#include -#include #include - #include #include -#ifndef P_tmpdir -# define P_tmpdir "/tmp" -#endif #ifndef TMP_MAX # define TMP_MAX 238328 #endif @@ -43,27 +37,23 @@ # error report this to bug-gnulib@gnu.org #endif -#include #include #include #include -#include #include #include #include #include #if _LIBC -# define struct_stat64 struct stat64 -# define __secure_getenv __libc_secure_getenv +# define struct_stat64 struct __stat64_t64 #else # define struct_stat64 struct stat # define __gen_tempname gen_tempname # define __mkdir mkdir # define __open open -# define __lstat64(file, buf) lstat (file, buf) -# define __stat64(file, buf) stat (file, buf) +# define __lstat64_time64(file, buf) lstat (file, buf) # define __getrandom getrandom # define __clock_gettime64 clock_gettime # define __timespec64 timespec @@ -77,100 +67,56 @@ typedef uint_fast64_t random_value; #define BASE_62_DIGITS 10 /* 62**10 < UINT_FAST64_MAX */ #define BASE_62_POWER (62LL * 62 * 62 * 62 * 62 * 62 * 62 * 62 * 62 * 62) -#if _LIBC || (defined CLOCK_MONOTONIC && HAVE_CLOCK_GETTIME) -# define HAS_CLOCK_ENTROPY true -#else -# define HAS_CLOCK_ENTROPY false -#endif +/* Return the result of mixing the entropy from R and S. + Assume that R and S are not particularly random, + and that the result should look randomish to an untrained eye. */ static random_value -random_bits (random_value var, bool use_getrandom) +mix_random_values (random_value r, random_value s) { - random_value r; - /* Without GRND_NONBLOCK it can be blocked for minutes on some systems. */ - if (use_getrandom && __getrandom (&r, sizeof r, GRND_NONBLOCK) == sizeof r) - return r; -#if HAS_CLOCK_ENTROPY - /* Add entropy if getrandom did not work. */ - struct __timespec64 tv; - __clock_gettime64 (CLOCK_MONOTONIC, &tv); - var ^= tv.tv_nsec; -#endif - return 2862933555777941757 * var + 3037000493; + /* As this code is used only when high-quality randomness is neither + available nor necessary, there is no need for fancier polynomials + such as those in the Linux kernel's 'random' driver. */ + return (2862933555777941757 * r + 3037000493) ^ s; } -#if _LIBC -/* Return nonzero if DIR is an existent directory. */ -static int -direxists (const char *dir) -{ - struct_stat64 buf; - return __stat64 (dir, &buf) == 0 && S_ISDIR (buf.st_mode); -} +/* Set *R to a random value. + Return true if *R is set to high-quality value taken from getrandom. + Otherwise return false, falling back to a low-quality *R that might + depend on S. -/* Path search algorithm, for tmpnam, tmpfile, etc. If DIR is - non-null and exists, uses it; otherwise uses the first of $TMPDIR, - P_tmpdir, /tmp that exists. Copies into TMPL a template suitable - for use with mk[s]temp. Will fail (-1) if DIR is non-null and - doesn't exist, none of the searched dirs exists, or there's not - enough space in TMPL. */ -int -__path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx, - int try_tmpdir) + This function returns false only when getrandom fails. + On GNU systems this should happen only early in the boot process, + when the fallback should be good enough for programs using tempname + because any attacker likely has root privileges already. */ + +static bool +random_bits (random_value *r, random_value s) { - const char *d; - size_t dlen, plen; + /* Without GRND_NONBLOCK it can be blocked for minutes on some systems. */ + if (__getrandom (r, sizeof *r, GRND_NONBLOCK) == sizeof *r) + return true; - if (!pfx || !pfx[0]) - { - pfx = "file"; - plen = 4; - } - else - { - plen = strlen (pfx); - if (plen > 5) - plen = 5; - } + /* If getrandom did not work, use ersatz entropy based on low-order + clock bits. On GNU systems getrandom should fail only + early in booting, when ersatz should be good enough. + Do not use ASLR-based entropy, as that would leak ASLR info into + the resulting file name which is typically public. - if (try_tmpdir) - { - d = __secure_getenv ("TMPDIR"); - if (d != NULL && direxists (d)) - dir = d; - else if (dir != NULL && direxists (dir)) - /* nothing */ ; - else - dir = NULL; - } - if (dir == NULL) - { - if (direxists (P_tmpdir)) - dir = P_tmpdir; - else if (strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp")) - dir = "/tmp"; - else - { - __set_errno (ENOENT); - return -1; - } - } + Of course we are in a state of sin here. */ - dlen = strlen (dir); - while (dlen > 1 && dir[dlen - 1] == '/') - dlen--; /* remove trailing slashes */ + random_value v = s; - /* check we have room for "${dir}/${pfx}XXXXXX\0" */ - if (tmpl_len < dlen + 1 + plen + 6 + 1) - { - __set_errno (EINVAL); - return -1; - } +#if _LIBC || (defined CLOCK_REALTIME && HAVE_CLOCK_GETTIME) + struct __timespec64 tv; + __clock_gettime64 (CLOCK_REALTIME, &tv); + v = mix_random_values (v, tv.tv_sec); + v = mix_random_values (v, tv.tv_nsec); +#endif - sprintf (tmpl, "%.*s/%.*sXXXXXX", (int) dlen, dir, (int) plen, pfx); - return 0; + *r = mix_random_values (v, clock ()); + return false; } -#endif /* _LIBC */ #if _LIBC static int try_tempname_len (char *, int, void *, int (*) (char *, void *), @@ -197,7 +143,7 @@ try_nocreate (char *tmpl, _GL_UNUSED void *flags) { struct_stat64 st; - if (__lstat64 (tmpl, &st) == 0 || errno == EOVERFLOW) + if (__lstat64_time64 (tmpl, &st) == 0 || errno == EOVERFLOW) __set_errno (EEXIST); return errno == ENOENT ? 0 : -1; } @@ -267,32 +213,17 @@ try_tempname_len (char *tmpl, int suffixlen, void *args, unsigned int attempts = ATTEMPTS_MIN; #endif - /* A random variable. The initial value is used only the for fallback path - on 'random_bits' on 'getrandom' failure. Its initial value tries to use - some entropy from the ASLR and ignore possible bits from the stack - alignment. */ - random_value v = ((uintptr_t) &v) / alignof (max_align_t); - -#if !HAS_CLOCK_ENTROPY - /* Arrange gen_tempname to return less predictable file names on - systems lacking clock entropy . */ - static random_value prev_v; - v ^= prev_v; -#endif + /* A random variable. */ + random_value v = 0; - /* How many random base-62 digits can currently be extracted from V. */ + /* A value derived from the random variable, and how many random + base-62 digits can currently be extracted from VDIGBUF. */ + random_value vdigbuf; int vdigits = 0; - /* Whether to consume entropy when acquiring random bits. On the - first try it's worth the entropy cost with __GT_NOCREATE, which - is inherently insecure and can use the entropy to make it a bit - more secure. On the (rare) second and later attempts it might - help against DoS attacks. */ - bool use_getrandom = tryfunc == try_nocreate; - - /* Least unfair value for V. If V is less than this, V can generate - BASE_62_DIGITS digits fairly. Otherwise it might be biased. */ - random_value const unfair_min + /* Least biased value for V. If V is less than this, V can generate + BASE_62_DIGITS unbiased digits. Otherwise the digits are biased. */ + random_value const biased_min = RANDOM_VALUE_MAX - RANDOM_VALUE_MAX % BASE_62_POWER; len = strlen (tmpl); @@ -312,18 +243,16 @@ try_tempname_len (char *tmpl, int suffixlen, void *args, { if (vdigits == 0) { - do - { - v = random_bits (v, use_getrandom); - use_getrandom = true; - } - while (unfair_min <= v); + /* Worry about bias only if the bits are high quality. */ + while (random_bits (&v, v) && biased_min <= v) + continue; + vdigbuf = v; vdigits = BASE_62_DIGITS; } - XXXXXX[i] = letters[v % 62]; - v /= 62; + XXXXXX[i] = letters[vdigbuf % 62]; + vdigbuf /= 62; vdigits--; } @@ -331,9 +260,6 @@ try_tempname_len (char *tmpl, int suffixlen, void *args, if (fd >= 0) { __set_errno (save_errno); -#if !HAS_CLOCK_ENTROPY - prev_v = v; -#endif return fd; } else if (errno != EEXIST) diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index 30911d1581..8a5daa230e 100644 --- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -313,7 +313,8 @@ AC_DEFUN([gl_COMMON_BODY], [ #else # define _GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_UNUSED #endif -/* Alternative spelling of this macro, for convenience. */ +/* Alternative spelling of this macro, for convenience and for + compatibility with glibc/include/libc-symbols.h. */ #define _GL_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED /* Earlier spellings of this macro. */ #define _UNUSED_PARAMETER_ _GL_ATTRIBUTE_MAYBE_UNUSED commit 9bd91a3751cfb01c9499a5ee7080349b9c8f0f65 Author: Paul Eggert Date: Tue Aug 23 18:18:13 2022 -0700 Fix overflows in HAVE_XSYNC timestamp handling Also, port to platforms lacking CLOCK_MONOTONIC and int64_t, and use 0 more consistently to represent missing timestamps. * src/xterm.h (struct x_display_info): Omit server_time_monotonic_p and server_time_offset if !HAVE_CLOCK_GETTIME since they are unused in that case. * src/xterm.h (struct x_display_info, struct x_output): * src/xterm.c (x_sync_get_monotonic_time) (x_sync_current_monotonic_time, x_sync_note_frame_times): Use int_fast64_t instead of int64_t as POSIX doesn't guarantee the latter. Similarly for uint_fast64_t. (x_sync_get_monotonic_time, x_sync_current_monotonic_time) (x_sync_note_frame_times, x_display_set_last_user_time): Check for integer overflow in time arithmetic. (CLOCK_MONOTONIC): Define to CLOCK_REALTIME if absent. (x_sync_current_monotonic_time): Check for clock_gettime failure and fall back on CLOCK_REALTIME if CLOCK_MONOTONIC does not work, which POSIX allows. (x_sync_current_monotonic_time, x_sync_note_frame_times) (x_display_set_last_user_time): Use 0 more consistently to represent missing timestamps. diff --git a/src/xterm.c b/src/xterm.c index fb4c0c74db..5a36aa0302 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -6714,9 +6714,9 @@ x_if_event (Display *dpy, XEvent *event_return, server timestamp TIMESTAMP. Return 0 if the necessary information is not available. */ -static uint64_t +static uint_fast64_t x_sync_get_monotonic_time (struct x_display_info *dpyinfo, - uint64_t timestamp) + uint_fast64_t timestamp) { if (dpyinfo->server_time_monotonic_p) return timestamp; @@ -6725,19 +6725,29 @@ x_sync_get_monotonic_time (struct x_display_info *dpyinfo, if (!dpyinfo->server_time_offset) return 0; - return timestamp - dpyinfo->server_time_offset; + uint_fast64_t t; + return (INT_SUBTRACT_WRAPV (timestamp, dpyinfo->server_time_offset, &t) + ? 0 : t); } +# ifndef CLOCK_MONOTONIC +# define CLOCK_MONOTONIC CLOCK_REALTIME +# endif + /* Return the current monotonic time in the same format as a - high-resolution server timestamp. */ + high-resolution server timestamp, or 0 if not available. */ -static uint64_t +static uint_fast64_t x_sync_current_monotonic_time (void) { struct timespec time; - - clock_gettime (CLOCK_MONOTONIC, &time); - return time.tv_sec * 1000000 + time.tv_nsec / 1000; + uint_fast64_t t; + return (((clock_gettime (CLOCK_MONOTONIC, &time) != 0 + && (CLOCK_MONOTONIC == CLOCK_REALTIME + || clock_gettime (CLOCK_REALTIME, &time) != 0)) + || INT_MULTIPLY_WRAPV (time.tv_sec, 1000000, &t) + || INT_ADD_WRAPV (t, time.tv_nsec / 1000, &t)) + ? 0 : t); } /* Decode a _NET_WM_FRAME_DRAWN message and calculate the time it took @@ -6747,7 +6757,7 @@ static void x_sync_note_frame_times (struct x_display_info *dpyinfo, struct frame *f, XEvent *event) { - uint64_t low, high, time; + uint_fast64_t low, high, time; struct x_output *output; low = event->xclient.data.l[2]; @@ -6756,12 +6766,16 @@ x_sync_note_frame_times (struct x_display_info *dpyinfo, time = x_sync_get_monotonic_time (dpyinfo, low | (high << 32)); - if (time) - output->last_frame_time = time - output->temp_frame_time; + if (!time || !output->temp_frame_time + || INT_SUBTRACT_WRAPV (time, output->temp_frame_time, + &output->last_frame_time)) + output->last_frame_time = 0; #ifdef FRAME_DEBUG - fprintf (stderr, "Drawing the last frame took: %lu ms (%lu)\n", - output->last_frame_time / 1000, time); + uint_fast64_t last_frame_ms = output->last_frame_time / 1000; + fprintf (stderr, + "Drawing the last frame took: %"PRIuFAST64" ms (%"PRIuFAST64")\n", + last_frame_ms, time); #endif } @@ -6891,22 +6905,16 @@ x_sync_update_begin (struct frame *f) static void x_sync_trigger_fence (struct frame *f, XSyncValue value) { - uint64_t n, low, high, idx; - /* Sync fences aren't supported by the X server. */ if (FRAME_DISPLAY_INFO (f)->xsync_major < 3 || (FRAME_DISPLAY_INFO (f)->xsync_major == 3 && FRAME_DISPLAY_INFO (f)->xsync_minor < 1)) return; - low = XSyncValueLow32 (value); - high = XSyncValueHigh32 (value); - - n = low | (high << 32); - idx = (n / 4) % 2; + bool idx = !! (XSyncValueLow32 (value) & 4); #ifdef FRAME_DEBUG - fprintf (stderr, "Triggering synchronization fence: %lu\n", idx); + fprintf (stderr, "Triggering synchronization fence: %d\n", idx); #endif XSyncTriggerFence (FRAME_X_DISPLAY (f), @@ -7600,9 +7608,6 @@ x_display_set_last_user_time (struct x_display_info *dpyinfo, Time time, #ifndef USE_GTK struct frame *focus_frame; Time old_time; -#if defined HAVE_XSYNC && defined HAVE_CLOCK_GETTIME - uint64_t monotonic_time; -#endif focus_frame = dpyinfo->x_focus_frame; old_time = dpyinfo->last_user_time; @@ -7620,19 +7625,26 @@ x_display_set_last_user_time (struct x_display_info *dpyinfo, Time time, { /* See if the current CLOCK_MONOTONIC time is reasonably close to the X server time. */ - monotonic_time = x_sync_current_monotonic_time (); + uint_fast64_t monotonic_time = x_sync_current_monotonic_time (); + uint_fast64_t monotonic_ms = monotonic_time / 1000; + int_fast64_t diff_ms; - if (time * 1000 > monotonic_time - 500 * 1000 - && time * 1000 < monotonic_time + 500 * 1000) - dpyinfo->server_time_monotonic_p = true; - else + dpyinfo->server_time_monotonic_p + = (monotonic_time != 0 + && !INT_SUBTRACT_WRAPV (time, monotonic_ms, &diff_ms) + && -500 < diff_ms && diff_ms < 500); + + if (!dpyinfo->server_time_monotonic_p) { /* Compute an offset that can be subtracted from the server time to estimate the monotonic time on the X server. */ - dpyinfo->server_time_monotonic_p = false; - dpyinfo->server_time_offset - = ((int64_t) time * 1000) - monotonic_time; + if (!monotonic_time + || INT_MULTIPLY_WRAPV (time, 1000, &dpyinfo->server_time_offset) + || INT_SUBTRACT_WRAPV (dpyinfo->server_time_offset, + monotonic_time, + &dpyinfo->server_time_offset)) + dpyinfo->server_time_offset = 0; } } #endif diff --git a/src/xterm.h b/src/xterm.h index 9d9675428f..3654c3d5db 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -828,14 +828,14 @@ struct x_display_info drag-and-drop emulation. */ Time pending_dnd_time; -#if defined HAVE_XSYNC && !defined USE_GTK +#if defined HAVE_XSYNC && !defined USE_GTK && defined HAVE_CLOCK_GETTIME /* Whether or not the server time is probably the same as "clock_gettime (CLOCK_MONOTONIC, ...)". */ bool server_time_monotonic_p; /* The time difference between the X server clock and the monotonic - clock. */ - int64_t server_time_offset; + clock, or 0 if unknown (FIXME: what if the difference is zero?). */ + int_fast64_t server_time_offset; #endif }; @@ -1131,10 +1131,10 @@ struct x_output bool_bf use_vsync_p : 1; /* The time (in microseconds) it took to draw the last frame. */ - uint64_t last_frame_time; + uint_fast64_t last_frame_time; /* A temporary time used to calculate that value. */ - uint64_t temp_frame_time; + uint_fast64_t temp_frame_time; #ifdef HAVE_XSYNCTRIGGERFENCE /* An array of two sync fences that are triggered in order after a commit 97067349a8d75ab720ff2e98653a6b21f60b221e Author: Paul Eggert Date: Tue Aug 23 16:25:40 2022 -0700 Fix unlikely core dump with Xaw * lwlib/lwlib-Xaw.c (make_dialog): Don’t dump core if calloc fails. Caught with --enable-gcc-warnings. diff --git a/lwlib/lwlib-Xaw.c b/lwlib/lwlib-Xaw.c index d17acae728..b09795ec38 100644 --- a/lwlib/lwlib-Xaw.c +++ b/lwlib/lwlib-Xaw.c @@ -594,6 +594,8 @@ make_dialog (char* name, int nr_xft_data = left_buttons + right_buttons + 1; instance->xft_data = calloc (nr_xft_data + 1, sizeof(*instance->xft_data)); + if (!instance->xft_data) + memory_full ((nr_xft_data + 1) * sizeof *instance->xft_data); fill_xft_data (&instance->xft_data[0], w, xft_font); XtAddCallback (dialog, XtNdestroyCallback, destroy_xft_data, commit 5b5896132f292986e89913b650d21c0b16896298 Author: Stefan Monnier Date: Thu Aug 25 16:59:30 2022 -0400 * lisp/progmodes/cc-langs.el (c-make-no-parens-syntax-table): Fix bug#57065 (c-lang-const c-make-mode-syntax-table) already returns a function, so quote it to avoid double evaluation since it could fail if the function is not self-evaluating, such as when it's a symbol or a value of the form (closure ...). diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index 75f1660f22..120949a5bc 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el @@ -403,7 +403,7 @@ The syntax tables aren't stored directly since they're quite large." t (if (c-lang-const c-recognize-<>-arglists) `(lambda () ;(if (c-lang-const c-recognize-<>-arglists) - (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table)))) + (let ((table (funcall ',(c-lang-const c-make-mode-syntax-table)))) (modify-syntax-entry ?\( "." table) (modify-syntax-entry ?\) "." table) (modify-syntax-entry ?\[ "." table) commit e3b85775252adbe3135580df321cbd69eb2f2bf1 (refs/remotes/origin/emacs-28) Author: Eli Zaretskii Date: Thu Aug 25 22:07:04 2022 +0300 ; * etc/DEBUG: Fix wording of "X protocol errors" section. diff --git a/etc/DEBUG b/etc/DEBUG index dd33b42f19..5d99c313f9 100644 --- a/etc/DEBUG +++ b/etc/DEBUG @@ -661,10 +661,10 @@ Setting a breakpoint in the function 'x_error_quitter' and looking at the backtrace when Emacs stops inside that function will show what code causes the X protocol errors. -Note that the -xrm option may have no effect when you make an Emacs -process invoked with the -nw option a server and want to trace X -protocol errors from subsequent invocations of emacsclient in a GUI -frame. In that case calling the initial Emacs via +Note that the -xrm option may have no effect when you start a server +in an Emacs session invoked with the -nw command-line option, and want +to trace X protocol errors from GUI frames created by subsequent +invocations of emacsclient. In that case starting Emacs via emacs -nw --eval '(setq x-command-line-resources "emacs.synchronous: true")' commit 9ba6a7c508cbaed5eeedd56e7df633b722bf86b7 Author: Eli Zaretskii Date: Thu Aug 25 21:56:50 2022 +0300 ; * etc/NEWS: Fix wording of a recently-added entry. diff --git a/etc/NEWS b/etc/NEWS index 2297d8137d..9eeab7bb9a 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -163,7 +163,7 @@ of 'user-emacs-directory'. * Incompatible changes in Emacs 29.1 +++ -*** Explicitly-set readedness state is preserved when reverting a buffer. +*** Explicitly-set read-only state is preserved when reverting a buffer. If you use the 'C-x C-q' command to change the read-only state of the buffer and then revert it, Emacs would previously use the file permission bits to determine whether the buffer should be read-only commit 2265fc964bb9879d40b1f3cf748ed8837058a0e6 Author: Eli Zaretskii Date: Thu Aug 25 21:51:23 2022 +0300 ; * lisp/progmodes/grep.el (grep-command-position): Doc fix. diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index d64beaefcf..2446e86abb 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -134,9 +134,11 @@ Also see `grep-command-position'." :set #'grep-apply-setting) (defcustom grep-command-position nil - "Where point will be put when prompting for a grep command. -If nil, put point at the end. If not nil, this should be the -column number where point should be set in `grep-command'." + "Where to put point when prompting for a grep command. +This controls the placement of point in the minibuffer when Emacs +prompts for the grep command. If nil, put point at the end of +the suggested command. If non-nil, this should be the one-based +position in the minibuffer where to place point." :type '(choice (const :tag "At the end" nil) natnum)) commit 7c463120cc60d197973560a5e034d32777fdeb9e Author: Stefan Kangas Date: Thu Aug 25 20:01:00 2022 +0200 ; Delete some commented out code from linum.el * lisp/linum.el (linum-mode): Delete code commented out since 2009. diff --git a/lisp/linum.el b/lisp/linum.el index d491da5206..1b897a2bd2 100644 --- a/lisp/linum.el +++ b/lisp/linum.el @@ -89,9 +89,6 @@ Linum mode is a buffer-local minor mode." 'linum-update-current) nil t) (add-hook 'after-change-functions 'linum-after-change nil t)) (add-hook 'window-scroll-functions 'linum-after-scroll nil t) - ;; Using both window-size-change-functions and - ;; window-configuration-change-hook seems redundant. --Stef - ;; (add-hook 'window-size-change-functions 'linum-after-size nil t) (add-hook 'change-major-mode-hook 'linum-delete-overlays nil t) (add-hook 'window-configuration-change-hook ;; FIXME: If the buffer is shown in N windows, this @@ -101,7 +98,6 @@ Linum mode is a buffer-local minor mode." (linum-update-current)) (remove-hook 'post-command-hook 'linum-update-current t) (remove-hook 'post-command-hook 'linum-schedule t) - ;; (remove-hook 'window-size-change-functions 'linum-after-size t) (remove-hook 'window-scroll-functions 'linum-after-scroll t) (remove-hook 'after-change-functions 'linum-after-change t) (remove-hook 'window-configuration-change-hook 'linum-update-current t) @@ -231,16 +227,10 @@ Linum mode is a buffer-local minor mode." (defun linum-after-scroll (win _start) (linum-update (window-buffer win))) -;; (defun linum-after-size (frame) -;; (linum-after-config)) - (defun linum-schedule () ;; schedule an update; the delay gives Emacs a chance for display changes (run-with-idle-timer 0 nil #'linum-update-current)) -;; (defun linum-after-config () -;; (walk-windows (lambda (w) (linum-update (window-buffer w))) nil 'visible)) - (defun linum-unload-function () "Unload the Linum library." (global-linum-mode -1) commit 55f681359ea055ca889620ac61c50e35a36c058d Author: Stefan Kangas Date: Thu Aug 25 18:46:48 2022 +0200 Improve explanation of init file in FAQ * doc/misc/efaq.texi (Setting up a customization file): Improve and update section to reflect current behavior. Add cross-references back to this section. * doc/emacs/custom.texi (Init File): Add comment to remind about also updating the FAQ. Ref: https://lists.gnu.org/r/emacs-devel/2022-08/msg01056.html diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi index efaf0dfd38..ff7ab83190 100644 --- a/doc/emacs/custom.texi +++ b/doc/emacs/custom.texi @@ -2303,6 +2303,8 @@ as a function from Lisp programs. @cindex startup (init file) @cindex XDG_CONFIG_HOME +@c When updating this, also update ``Setting up a customization file'' +@c in efaq.texi. When Emacs is started, it normally tries to load a Lisp program from an @dfn{initialization file}, or @dfn{init file} for short. This file, if it exists, specifies how to initialize Emacs for you. diff --git a/doc/misc/efaq.texi b/doc/misc/efaq.texi index 4431d73ed9..a3459abd04 100644 --- a/doc/misc/efaq.texi +++ b/doc/misc/efaq.texi @@ -693,9 +693,10 @@ of the file in parentheses, like this: @item You can create your own Info directory. You can tell Emacs where that Info directory is by adding its pathname to the value of the variable -@code{Info-default-directory-list}. For example, to use a private Info -directory which is a subdirectory of your home directory named @file{Info}, -you could put this in your init file: +@code{Info-default-directory-list}. For example, to use a private +Info directory which is a subdirectory of your home directory named +@file{Info}, you could put this in your init file (@pxref{Setting up a +customization file}): @lisp (add-to-list 'Info-default-directory-list "~/Info/") @@ -1611,15 +1612,14 @@ is better to write ``Emacs and XEmacs.'' @cindex Init file, locating @cindex Customization file, setting up +When Emacs is started, it normally tries to load a Lisp program from +an @dfn{initialization file}, or @dfn{init file} for short. This +file, if it exists, specifies how to initialize Emacs for you. +Traditionally, file @file{~/.emacs} is used as the init file, although +Emacs also looks at @file{~/.emacs.el}, @file{~/.emacs.d/init.el}, +@file{~/.config/emacs/init.el}, or other locations. @xref{Init File,,, emacs, The GNU Emacs Manual}. -In general, new Emacs users should not be provided with init -files, because this can cause confusing non-standard behavior. Then -they send questions to -@url{https://lists.gnu.org/mailman/listinfo/help-gnu-emacs, -the help-gnu-emacs mailing list} asking why Emacs -isn't behaving as documented. - Emacs includes the Customize facility (@pxref{Using Customize}). This allows users who are unfamiliar with Emacs Lisp to modify their init files in a relatively straightforward way, using menus @@ -1631,9 +1631,12 @@ init file directly. Simple configuration options are described rather completely in @ref{Init File,,, emacs, The GNU Emacs Manual}, for users interested in performing frequently requested, basic tasks. -Sometimes users are unsure as to where their init file is found. -Visiting the file as @file{~/.emacs.el}, @file{~/.emacs}, or -@file{~/.emacs.d/init.el} from Emacs will find the correct file. +In general, new Emacs users should not be provided with init +files, because this can cause confusing non-standard behavior. Then +they send questions to +@url{https://lists.gnu.org/mailman/listinfo/help-gnu-emacs, +the help-gnu-emacs mailing list} asking why Emacs +isn't behaving as documented. @node Using Customize @section How do I start using Customize? @@ -1786,7 +1789,8 @@ You can similarly display the current column with @end lisp @noindent -in your init file. This feature is off by default. +in your init file (@pxref{Setting up a customization file}). This +feature is off by default. The @code{"%c"} format specifier in the variable @code{mode-line-format} will insert the current column's value into the mode line. See the @@ -1832,7 +1836,7 @@ machine at which Emacs was invoked. This is done by setting To modify the behavior such that frame titlebars contain the buffer's name regardless of the number of existing frames, include the following -in your init file: +in your init file (@pxref{Setting up a customization file}): @lisp (setq frame-title-format "%b") @@ -1842,9 +1846,10 @@ in your init file: @section How do I turn on abbrevs by default just in mode @var{mymode}? @cindex Abbrevs, turning on by default -Abbrev mode expands abbreviations as you type them. To turn it on in a -specific buffer, use @kbd{M-x abbrev-mode}. To turn it on in every -buffer by default, put this in your init file: +Abbrev mode expands abbreviations as you type them. To turn it on in +a specific buffer, use @kbd{M-x abbrev-mode}. To turn it on in every +buffer by default, put this in your init file (@pxref{Setting up a +customization file}): @lisp (setq-default abbrev-mode t) @@ -1894,7 +1899,8 @@ the script. Use @kbd{C-h v} (or @kbd{M-x describe-variable}) on @cindex Highlighting and replacing text Use @code{delete-selection-mode}, which you can start automatically by -placing the following Lisp form in your init file: +placing the following Lisp form in your init file (@pxref{Setting up a +customization file}): @lisp (delete-selection-mode 1) @@ -2032,9 +2038,10 @@ The default maximum line width is 70, determined by the variable To turn on @code{auto-fill-mode} just once for one buffer, use @kbd{M-x auto-fill-mode}. -To turn it on for every buffer in a certain mode, you must use the hook -for that mode. For example, to turn on @code{auto-fill} mode for all -text buffers, including the following in your init file: +To turn it on for every buffer in a certain mode, you must use the +hook for that mode. For example, to turn on @code{auto-fill} mode for +all text buffers, including the following in your init file +(@pxref{Setting up a customization file}): @lisp (add-hook 'text-mode-hook 'turn-on-auto-fill) @@ -2089,7 +2096,8 @@ option: emacs -f server-start @end example -or by invoking @code{server-start} from init file: +or by invoking @code{server-start} from init file (@pxref{Setting up a +customization file}): @lisp (if (@var{some conditions are met}) (server-start)) @@ -2160,7 +2168,8 @@ f() @} @end example -@noindent To achieve this, add the following line to your init file: +@noindent To achieve this, add the following line to your init file +(@pxref{Setting up a customization file}): @lisp (c-set-offset 'case-label '+) @@ -2211,7 +2220,8 @@ the line or the block according to what you just specified. @item If you don't like the result, go back to step 1. Otherwise, add the -following line to your init file: +following line to your init file (@pxref{Setting up a customization +file}): @lisp (c-set-offset '@var{syntactic-symbol} @var{offset}) @@ -2241,8 +2251,8 @@ customizations inside a C mode hook, like this: @noindent Using @code{c-mode-hook} avoids the need to put a @w{@code{(require -'cc-mode)}} into your init file, because @code{c-set-offset} -might be unavailable when @code{cc-mode} is not loaded. +'cc-mode)}} into your init file, because @code{c-set-offset} might be +unavailable when @code{cc-mode} is not loaded. Note that @code{c-mode-hook} runs for C source files only; use @code{c++-mode-hook} for C@t{++} sources, @code{java-mode-hook} for @@ -2353,7 +2363,8 @@ new paragraph. There are many packages available to deal with this @cindex Pairs of parentheses, highlighting @cindex Matching parentheses -Call @code{show-paren-mode} in your init file: +Call @code{show-paren-mode} in your init file (@pxref{Setting up a +customization file}): @lisp (show-paren-mode 1) @@ -2460,7 +2471,7 @@ Emacs Lisp @dfn{form}: If you want it evaluated every time you run Emacs, put it in a file named @file{.emacs.d/init.el} in your home directory. This is known as ``your init file,'' and contains all of your personal -customizations. +customizations (@pxref{Setting up a customization file}). @item You can type the form in the @file{*scratch*} buffer, and then type @@ -2498,7 +2509,7 @@ about them. Set the default value of the variable @code{tab-width}. For example, to set @key{TAB} stops every 10 characters, insert the following in your -init file: +init file (@pxref{Setting up a customization file}): @lisp (setq-default tab-width 10) @@ -2640,8 +2651,9 @@ Quick command-line switch descriptions are also available. For example, You probably don't want to do this, since backups are useful, especially when something goes wrong. -To avoid seeing backup files (and other ``uninteresting'' files) in Dired, -load @code{dired-x} by adding the following to your init file: +To avoid seeing backup files (and other ``uninteresting'' files) in +Dired, load @code{dired-x} by adding the following to your init file +(@pxref{Setting up a customization file}): @lisp (with-eval-after-load 'dired @@ -2904,10 +2916,11 @@ Different levels of decoration are available, from slight to gaudy. More decoration means you need to wait more time for a buffer to be fontified (or a faster machine). To control how decorated your buffers should become, set the value of -@code{font-lock-maximum-decoration} in your init file, with a -@code{nil} value indicating default (usually minimum) decoration, and a -@code{t} value indicating the maximum decoration. For the gaudiest -possible look, then, include the line +@code{font-lock-maximum-decoration} in your init file (@pxref{Setting +up a customization file}), with a @code{nil} value indicating default +(usually minimum) decoration, and a @code{t} value indicating the +maximum decoration. For the gaudiest possible look, then, include the +line @lisp (setq font-lock-maximum-decoration t) @@ -2941,7 +2954,8 @@ customize-variable @key{RET} scroll-conservatively @key{RET}} and set it to a large value like, say, 10000. For an explanation of what this means, @pxref{Auto Scrolling,,, emacs, The GNU Emacs Manual}. -Alternatively, use the following Lisp form in your init file: +Alternatively, use the following Lisp form in your init file +(@pxref{Setting up a customization file}): @lisp (setq scroll-conservatively most-positive-fixnum) @@ -2970,7 +2984,8 @@ default, a backslash (@samp{\}) will appear in the mode line. @cindex Single space following periods @cindex Periods, one space following -Add the following line to your init file: +Add the following line to your init file (@pxref{Setting up a +customization file}): @lisp (setq sentence-end-double-space nil) @@ -2992,7 +3007,8 @@ escape sequences. It is enabled by default. @cindex Fullscreen mode Beginning with Emacs 24.4 either run Emacs with the @samp{--maximized} -command-line option or put the following form in your init file: +command-line option or put the following form in your init file +(@pxref{Setting up a customization file}): @lisp (add-hook 'emacs-startup-hook 'toggle-frame-maximized) @@ -3123,7 +3139,8 @@ with the following Lisp form, The above solutions try to prevent the shell from producing the @samp{^M} characters in the first place. If this is not possible (e.g., if you use a Windows shell), you can get Emacs to remove these -characters from the buffer by adding this to your init file: +characters from the buffer by adding this to your init file +(@pxref{Setting up a customization file}): @smalllisp (add-hook 'comint-output-filter-functions #'comint-strip-ctrl-m) @@ -3145,8 +3162,8 @@ stty -icrnl -onlcr -echo susp ^Z @cindex @code{explicit-shell-file-name} This might happen because Emacs tries to look for the shell in a wrong place. If you know where your shell executable is, set the variable -@code{explicit-shell-file-name} in your init file to point to -its full file name. +@code{explicit-shell-file-name} in your init file (@pxref{Setting up a +customization file}) to point to its full file name. @cindex Antivirus programs, and Shell Mode Some people have trouble with Shell Mode on MS-Windows because of @@ -3712,9 +3729,10 @@ information is available from @cindex Keys, binding to commands @cindex Commands, binding keys to -Keys can be bound to commands either interactively or in your -init file. To interactively bind keys for all modes, type -@kbd{M-x global-set-key @key{RET} @var{key} @var{cmd} @key{RET}}. +Keys can be bound to commands either interactively or in your init +file (@pxref{Setting up a customization file}). To interactively bind +keys for all modes, type @kbd{M-x global-set-key @key{RET} @var{key} +@var{cmd} @key{RET}}. To bind a key just in the current major mode, type @kbd{M-x local-set-key @key{RET} @var{key} @var{cmd} @key{RET}}. @@ -3733,9 +3751,9 @@ command are required. For example, @end lisp @noindent -can be placed directly into the init file. If the key binding is -local, the command is used in conjunction with the @samp{add-hook} function. -For example, in TeX mode, a local binding might be +can be placed directly into your init file. If the key binding is +local, the command is used in conjunction with the @samp{add-hook} +function. For example, in TeX mode, a local binding might be @lisp (add-hook 'tex-mode-hook @@ -3796,11 +3814,12 @@ of these forms before attempting to bind the key sequence: @section Why doesn't this [terminal or window-system setup] code work in my init file, but it works just fine after Emacs starts up? @cindex Terminal setup code in init file -During startup, Emacs initializes itself according to a given code/file -order. If some of the code executed in your init file needs to -be postponed until the initial terminal or window-system setup code has -been executed but is not, then you will experience this problem (this -code/file execution order is not enforced after startup). +During startup, Emacs initializes itself according to a given +code/file order. If some of the code executed in your init file +(@pxref{Setting up a customization file}) needs to be postponed until +the initial terminal or window-system setup code has been executed but +is not, then you will experience this problem (this code/file +execution order is not enforced after startup). To postpone the execution of Emacs Lisp code until after terminal or window-system setup, treat the code as a @dfn{lambda list} and add it to @@ -4249,7 +4268,8 @@ arrange for these two commands to run whenever you log in, e.g., by adding them to your window-system startup file, such as @file{~/.xsessionrc} or @file{~/.gnomerc}. -Now, add the following line to your init file: +Now, add the following line to your init file (@pxref{Setting up a +customization file}): @lisp (add-to-list 'bdf-directory-list "/usr/share/emacs/fonts/bdf") @@ -4329,8 +4349,9 @@ yourself by putting @end lisp @noindent -in your init file. You can automatically include an @samp{FCC} field -by putting something like the following in your init file: +in your init file (@pxref{Setting up a customization file}). You can +automatically include an @samp{FCC} field by putting something like +the following in your init file: @lisp (setq mail-archive-file-name (expand-file-name "~/outgoing")) commit df8e705eb2077b62e3c3a13d0d596362c05542c7 Author: Stefan Kangas Date: Thu Aug 25 18:06:30 2022 +0200 Don't refer to Emacs 24.3 or older in FAQ * doc/misc/efaq.texi: Don't say that the FAQ has been edited. (Displaying the current line or column, Automatic indentation) (Problems with very large files, Emacs for other operating systems) (Right-to-left alphabets, Expanding aliases when sending mail): Remove references to Emacs 24.3 or older. (Learning how to do something): Don't include the reference card price; it is currently incorrect and is likely to be incorrect again in the future. diff --git a/doc/misc/efaq.texi b/doc/misc/efaq.texi index 1361551602..4431d73ed9 100644 --- a/doc/misc/efaq.texi +++ b/doc/misc/efaq.texi @@ -27,9 +27,6 @@ latest version of the FAQ is archived. The FAQ may be copied and redistributed under these conditions, except that the FAQ may not be embedded in a larger literary work unless that work itself allows free copying and redistribution. - -[This version has been heavily edited since it was included in the Emacs -distribution in 1999.] @end quotation @end copying @@ -545,11 +542,11 @@ printed manual}. @cindex Reference cards, in other languages @item You can get a printed reference card listing commands and keys to -invoke them. You can order one from the FSF for $2 (or 10 for $18), -or you can print your own from the @file{etc/refcards/refcard.tex} or -@file{etc/refcards/refcard.pdf} files in the Emacs distribution. -The Emacs distribution comes with translations of the reference card -into several languages; look for files named +invoke them. You can order one from the FSF, or you can print your +own from the @file{etc/refcards/refcard.tex} or +@file{etc/refcards/refcard.pdf} files in the Emacs distribution. The +Emacs distribution comes with translations of the reference card into +several languages; look for files named @file{etc/refcards/@var{lang}-refcard.*}, where @var{lang} is a two-letter code of the language. For example, the German version of the reference card is in the files @file{etc/refcards/de-refcard.tex} @@ -1808,9 +1805,8 @@ optional display. Alternatively, you can use the customize @code{display-line-numbers-type} with the same value as you would use with @code{display-line-numbers}. -There is also the @samp{linum} package (distributed with Emacs since -version 23.1) which will henceforth become obsolete. Users and -developers are encouraged to use @samp{display-line-numbers} instead. +There is also the @samp{linum} package which will henceforth become +obsolete. We recommend using @samp{display-line-numbers} instead. @node Displaying the current file name in the titlebar @section How can I modify the titlebar to contain the current file name? @@ -2318,8 +2314,8 @@ usage: xset [-display host:dpy] option ... @cindex Previous line, indenting according to @cindex Text indentation -Such behavior is automatic (in Text mode) in Emacs 20 and later. From the -@file{etc/NEWS} file for Emacs 20.2: +Such behavior is automatic (in Text mode). From the @file{etc/NEWS} +file for Emacs 20.2: @example ** In Text mode, now only blank lines separate paragraphs. This makes @@ -3061,10 +3057,9 @@ Emacs has an inherent fixed limitation on the size of buffers. This limit is stricter than the maximum size of objects supported by other programs on the same architecture. -The maximum buffer size on 32-bit machines is 512 MBytes beginning -with version 23.2. If Emacs was built using the -@code{--with-wide-int} flag, the maximum buffer size on 32-bit -machines is 2 GB. +The maximum buffer size on 32-bit machines is 512 MBytes. If Emacs +was built using the @code{--with-wide-int} flag, the maximum buffer +size on 32-bit machines is 2 GB. Emacs compiled on a 64-bit machine can handle much larger buffers; up to @code{most-positive-fixnum} (2.3 exabytes). @@ -3490,8 +3485,8 @@ and any Emacs Info files that might be in @file{/usr/local/share/info/}. @cindex Apple computers, Emacs for @cindex Macintosh, Emacs for @cindex macOS, Emacs for -Beginning with version 22.1, Emacs supports macOS natively. -See the file @file{nextstep/INSTALL} in the distribution. +Emacs supports macOS natively. See the file @file{nextstep/INSTALL} +in the distribution. @cindex FAQ for Emacs on MS-Windows @cindex Emacs for MS-Windows @@ -3500,8 +3495,8 @@ There is a separate FAQ for Emacs on MS-Windows, @pxref{Top,,,efaq-w32,FAQ for Emacs on MS Windows}. @cindex GNUstep, Emacs for -Beginning with version 23.1, Emacs supports GNUstep natively. -See the file @file{nextstep/INSTALL} in the distribution. +Emacs supports GNUstep natively. See the file @file{nextstep/INSTALL} +in the distribution. @cindex MS-DOS, Emacs for @cindex DOS, Emacs for @@ -4226,8 +4221,7 @@ Emacs Manual}. For more sophisticated methods, @cindex bidirectional scripts Emacs supports display and editing of bidirectional scripts, such as -Arabic, Farsi, and Hebrew, since version 24.1. -@xref{New in Emacs 24, bidirectional display}. +Arabic, Farsi, and Hebrew. @node How to add fonts @@ -4368,8 +4362,7 @@ To expand them before this, use @kbd{M-x expand-mail-aliases}. Emacs normally only reads the @file{.mailrc} file once per session, when you start to compose your first mail message. If you edit the file after this, you can use @kbd{M-x build-mail-aliases} to make Emacs -reread it. Prior to Emacs 24.1, this is not an interactive command, so -you must instead type @kbd{M-: (build-mail-aliases) @key{RET}}. +reread it. @item If you like, you can expand mail aliases as abbrevs, as soon as you commit ba64d091568f67bb648ad2d8cde61c7cf6fabf8e Author: Robert Pluim Date: Thu Aug 25 18:13:16 2022 +0200 Treat smtp-auth method from auth-info as a symbol The lookup of the SMTP auth method is done based on symbols, but sometimes the requested value comes from `auth-info', in which case it is a string, so call `intern-soft' to convert it to a symbol (which does nothing if it's already a symbol). * lisp/mail/smtpmail.el (smtpmail-try-auth-methods): Call `intern-soft' on the smtp-auth key's value. (Bug#57373) Do not merge to master diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el index 33458178a5..10e926a2a5 100644 --- a/lisp/mail/smtpmail.el +++ b/lisp/mail/smtpmail.el @@ -578,7 +578,7 @@ for `smtpmail-try-auth-method'.") (setq password (funcall password))) (let ((result (catch 'done (if (and mech user password) - (smtpmail-try-auth-method process mech user password) + (smtpmail-try-auth-method process (intern-soft mech) user password) ;; No mechanism, or no credentials. mech)))) (if (stringp result) commit 9e03e29c4ea275e03598163e48b56ab96b9063bf Author: Stefan Kangas Date: Thu Aug 25 17:15:39 2022 +0200 * lisp/wdired.el: Improve "Commentary" section. diff --git a/lisp/wdired.el b/lisp/wdired.el index 223ee3c9c9..175668a51b 100644 --- a/lisp/wdired.el +++ b/lisp/wdired.el @@ -27,16 +27,16 @@ ;; wdired.el (the "w" is for writable) provides an alternative way of ;; renaming files. ;; -;; Have you ever wanted to use C-x r t (string-rectangle), M-% -;; (query-replace), M-c (capitalize-word), etc... to change the name of -;; the files in a "dired" buffer? Now you can do this. All the power -;; of Emacs commands are available when renaming files! +;; Have you ever wanted to use `C-x r t' (`string-rectangle'), `M-%' +;; (`query-replace'), `M-c' (`capitalize-word'), etc... to change the +;; name of the files in a Dired buffer? Now you can do this. All the +;; power of Emacs commands are available when renaming files! ;; ;; This package provides a function that makes the filenames of a -;; dired buffer editable, by changing the buffer mode (which inhibits -;; all of the commands of dired mode). Here you can edit the names of -;; one or more files and directories, and when you press C-c C-c, the -;; renaming takes effect and you are back to dired mode. +;; Dired buffer editable, by changing the buffer mode (which inhibits +;; all of the commands of Dired mode). Here you can edit the names of +;; one or more files and directories, and when you press `C-c C-c', +;; the renaming takes effect and you are back to dired mode. ;; ;; Other things you can do with WDired: ;; @@ -48,7 +48,7 @@ ;; - Change the permission bits of the filenames (in systems with a ;; working unix-alike "chmod"). See and customize the variable ;; `wdired-allow-to-change-permissions'. To change a single char -;; (toggling between its two more usual values) you can press the +;; (toggling between its two more usual values), you can press the ;; space bar over it or left-click the mouse. To set any char to a ;; specific value (this includes the SUID, SGID and STI bits) you ;; can use the key labeled as the letter you want. Please note that @@ -58,18 +58,14 @@ ;; ;; - Mark files for deletion, by deleting their whole filename. -;;; Usage: +;; * Usage: -;; You can edit the names of the files by typing C-x C-q or by -;; executing M-x wdired-change-to-wdired-mode. Use C-c C-c when -;; finished or C-c C-k to abort. While editing filenames, a new -;; submenu "WDired" is available at top level. You can customize the -;; behavior of this package from this menu. - -;;; Change Log: - -;; Previous versions with complete changelogs were posted to -;; gnu.emacs.sources. +;; You can edit the names of the files by typing `C-x C-q' or +;; `M-x wdired-change-to-wdired-mode'. Use `C-c C-c' when +;; finished or `C-c C-k' to abort. +;; +;; You can customize the behavior of this package from the "WDired" +;; menu or with `M-x customize-group RET wdired RET'. ;;; Code: commit 92e90297f9ca487073acf5565e708892b1d9e124 Author: Stefan Kangas Date: Thu Aug 25 17:11:05 2022 +0200 * lisp/wdired.el: Doc fix; don't mention obsolete variable. diff --git a/lisp/wdired.el b/lisp/wdired.el index f6d2b37904..223ee3c9c9 100644 --- a/lisp/wdired.el +++ b/lisp/wdired.el @@ -46,11 +46,11 @@ ;; - Change the target of symbolic links. ;; ;; - Change the permission bits of the filenames (in systems with a -;; working unix-alike `dired-chmod-program'). See and customize the -;; variable `wdired-allow-to-change-permissions'. To change a single -;; char (toggling between its two more usual values) you can press -;; the space bar over it or left-click the mouse. To set any char to -;; an specific value (this includes the SUID, SGID and STI bits) you +;; working unix-alike "chmod"). See and customize the variable +;; `wdired-allow-to-change-permissions'. To change a single char +;; (toggling between its two more usual values) you can press the +;; space bar over it or left-click the mouse. To set any char to a +;; specific value (this includes the SUID, SGID and STI bits) you ;; can use the key labeled as the letter you want. Please note that ;; permissions of the links cannot be changed in that way, because ;; the change would affect to their targets, and this would not be @@ -127,8 +127,8 @@ If `advanced', the bits are freely editable. You can use newlines), but if you want your changes to be useful, you better put a intelligible value. -Anyway, the real change of the permissions is done by the external -program `dired-chmod-program', which must exist." +The real change of the permissions is done by the external +program \"chmod\", which must exist." :type '(choice (const :tag "Not allowed" nil) (const :tag "Toggle/set bits" t) (other :tag "Bits freely editable" advanced))) commit 2ccefef4c732d199e0d67815aabe47d38db38653 Author: Stefan Kangas Date: Tue Aug 23 16:18:57 2022 +0200 * lisp/progmodes/etags.el (next-file): Minor doc fix. diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el index 124817ffda..a95918a167 100644 --- a/lisp/progmodes/etags.el +++ b/lisp/progmodes/etags.el @@ -1702,7 +1702,7 @@ Point should be just after a string that matches TAG." ;;;###autoload (defalias 'next-file 'tags-next-file) (make-obsolete 'next-file - "use tags-next-file or fileloop-initialize and fileloop-next-file instead" "27.1") + "use `tags-next-file' or `fileloop-initialize' and `fileloop-next-file' instead" "27.1") ;;;###autoload (defun tags-next-file (&optional initialize novisit) "Select next file among files in current tags table. commit 681f2e23ae3a07decf1a459c982ee7940986cff4 Author: Lars Ingebrigtsen Date: Thu Aug 25 17:02:34 2022 +0200 Add a new user option grep-command-position * lisp/progmodes/grep.el (grep-command): Mention it. (grep-command-position): New user option. (grep): Use it (bug#50502). diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index 4c1f801980..d64beaefcf 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -126,11 +126,20 @@ include it when specifying `grep-command'. In interactive usage, the actual value of this variable is set up by `grep-compute-defaults'; to change the default value, use -\\[customize] or call the function `grep-apply-setting'." +\\[customize] or call the function `grep-apply-setting'. + +Also see `grep-command-position'." :type '(choice string (const :tag "Not Set" nil)) :set #'grep-apply-setting) +(defcustom grep-command-position nil + "Where point will be put when prompting for a grep command. +If nil, put point at the end. If not nil, this should be the +column number where point should be set in `grep-command'." + :type '(choice (const :tag "At the end" nil) + natnum)) + (defcustom grep-template nil "The default command to run for \\[lgrep]. The following place holders should be present in the string: @@ -931,10 +940,15 @@ list is empty)." (progn (grep-compute-defaults) (let ((default (grep-default-command))) - (list (read-shell-command "Run grep (like this): " - (if current-prefix-arg default grep-command) - 'grep-history - (if current-prefix-arg nil default)))))) + (list (read-shell-command + "Run grep (like this): " + (if current-prefix-arg + default + (if grep-command-position + (cons grep-command grep-command-position) + grep-command)) + 'grep-history + (if current-prefix-arg nil default)))))) ;; If called non-interactively, also compute the defaults if we ;; haven't already. (when (eq grep-highlight-matches 'auto-detect) commit ec4f976e8e1c072d6d6e05d77009e79da9efe885 Author: Lars Ingebrigtsen Date: Thu Aug 25 16:38:14 2022 +0200 Document how :map and :scale interacts in image maps * doc/lispref/display.texi (Image Descriptors): Mention problems with scaling (bug#50487). diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index d336cda674..fde7274d59 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -5886,6 +5886,14 @@ When you click the mouse when the mouse pointer is over a hot-spot, an event is composed by combining the @var{id} of the hot-spot with the mouse event; for instance, @code{[area4 mouse-1]} if the hot-spot's @var{id} is @code{area4}. + +Note that the map's coordinates should reflect the displayed image +after all transforms have been done (rotation, scaling and so on), and +also note that Emacs (by default) performs auto-scaling of images, so +to make things match up, you should either specify @code{:scale 1.0} +when creating the image, or use the result of +@code{image-compute-scaling-factor} to compute the elements of the +map. @end table @defun image-mask-p spec &optional frame commit 514372722a5d611b37c818f66646497268605ac2 Author: Stefan Kangas Date: Thu Aug 25 16:23:50 2022 +0200 Fix generalized variable documentation for recent change * doc/lispref/variables.texi (Setting Generalized Variables): Delete obsolete generalized variable 'frame-width'. diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi index 9d45c6c52e..80d6a01412 100644 --- a/doc/lispref/variables.texi +++ b/doc/lispref/variables.texi @@ -2679,21 +2679,21 @@ cdar nthcdr A call to any of the following Emacs-specific functions: @smallexample -alist-get overlay-end -default-value overlay-start -face-background overlay-get -face-font process-buffer -face-foreground process-filter -face-stipple process-get -face-underline-p process-sentinel -file-modes terminal-parameter -frame-parameter window-buffer -frame-parameters window-dedicated-p -frame-width window-display-table +alist-get overlay-start +default-value overlay-get +face-background process-buffer +face-font process-filter +face-foreground process-get +face-stipple process-sentinel +face-underline-p terminal-parameter +file-modes window-buffer +frame-parameter window-dedicated-p +frame-parameters window-display-table get-register window-hscroll getenv window-parameter keymap-parent window-point match-data window-start +overlay-end @end smallexample @item commit 7464640d2ac6a0342c4134aad15ba8e96ba1a40c Author: Lars Ingebrigtsen Date: Thu Aug 25 16:20:07 2022 +0200 Make a prefix go to the previous error * lisp/textmodes/flyspell.el (flyspell-goto-next-error): Make a prefix find the previous error (bug#50443). diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index 1094ef3e93..a893bc7b9c 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el @@ -1714,25 +1714,32 @@ of a misspelled word removed when you've corrected it." ;;*---------------------------------------------------------------------*/ ;;* flyspell-goto-next-error ... */ ;;*---------------------------------------------------------------------*/ -(defun flyspell-goto-next-error () - "Go to the next previously detected error. +(defun flyspell-goto-next-error (&optional previous) + "Go to the next error. +If PREVIOUS (interactively, the prefix), go to the previous error +instead. + In general FLYSPELL-GOTO-NEXT-ERROR must be used after FLYSPELL-BUFFER." - (interactive) + (interactive "P") (let ((pos (point)) - (max (point-max))) - (if (and (eq (current-buffer) flyspell-old-buffer-error) - (eq pos flyspell-old-pos-error)) - (progn - (if (= flyspell-old-pos-error max) - ;; goto beginning of buffer + (max (if previous (point-min) (point-max)))) + (when (and (eq (current-buffer) flyspell-old-buffer-error) + (eq pos flyspell-old-pos-error)) + (if previous + (if (= flyspell-old-pos-error max) (progn - (message "Restarting from beginning of buffer") - (goto-char (point-min))) - (forward-word 1)) - (setq pos (point)))) - ;; seek the next error - (while (and (< pos max) + (message "Restarting from end of the buffer") + (goto-char (point-max))) + (forward-word -1)) + (if (= flyspell-old-pos-error max) + (progn + (message "Restarting from beginning of buffer") + (goto-char (point-min))) + (forward-word 1))) + (setq pos (point))) + ;; Seek the next error. + (while (and (/= pos max) (let ((ovs (overlays-at pos)) (r '())) (while (and (not r) (consp ovs)) @@ -1740,13 +1747,15 @@ FLYSPELL-BUFFER." (setq r t) (setq ovs (cdr ovs)))) (not r))) - (setq pos (1+ pos))) - ;; save the current location for next invocation - (setq flyspell-old-pos-error pos) - (setq flyspell-old-buffer-error (current-buffer)) + (setq pos (if previous (1- pos) (1+ pos)))) (goto-char pos) - (if (= pos max) - (message "No more miss-spelled word!")))) + (when previous + (forward-word -1)) + ;; Save the current location for next invocation. + (setq flyspell-old-pos-error (point)) + (setq flyspell-old-buffer-error (current-buffer)) + (when (= (point) max) + (message "No more miss-spelled words")))) ;;*---------------------------------------------------------------------*/ ;;* flyspell-overlay-p ... */ commit 52f9ce5528e3a82c4170be2f3d117966793e8efc Author: Lars Ingebrigtsen Date: Thu Aug 25 16:00:27 2022 +0200 Mention C-x C-q + revert change in NEWS diff --git a/etc/NEWS b/etc/NEWS index 7f460e8b88..2297d8137d 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -162,6 +162,14 @@ of 'user-emacs-directory'. * Incompatible changes in Emacs 29.1 ++++ +*** Explicitly-set readedness state is preserved when reverting a buffer. +If you use the 'C-x C-q' command to change the read-only state of the +buffer and then revert it, Emacs would previously use the file +permission bits to determine whether the buffer should be read-only +after reverting the buffer. Emacs now remembers the decision made in +'C-x C-q'. + --- *** The Gtk selection face is no longer used for the region. The combination of a Gtk-controlled background and a foreground color commit 2385bf3397f8a92e226a29a5050c69dd8d2a1c31 Author: Robert Pluim Date: Thu Aug 25 11:47:57 2022 +0200 Treat smtp-auth method from auth-info as a symbol The lookup of the SMTP auth method is done based on symbols, but sometimes the requested value comes from `auth-info', in which case it is a string, so call `intern-soft' to convert it to a symbol (which does nothing if it's already a symbol). * lisp/mail/smtpmail.el (smtpmail-try-auth-methods): Call `intern-soft' on the smtp-auth key's value. (Bug#57373) diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el index c2f8f27377..8573532eac 100644 --- a/lisp/mail/smtpmail.el +++ b/lisp/mail/smtpmail.el @@ -577,7 +577,7 @@ for `smtpmail-try-auth-method'.") (stringp result)) (setq result (catch 'done (smtpmail-try-auth-method - process (pop mechs) user password)))) + process (intern-soft (pop mechs)) user password)))) ;; A string result is an error. (if (stringp result) (progn commit 34e0a232cd0e7b38a33bc9134134c47665aeb185 Author: Kien Nguyen Date: Wed Aug 24 23:19:35 2022 +0900 Allow symlink creation on MS-Windows without Administrator privileges * src/w32.c (symlink): Use the SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE flag when available. (Bug#57386) diff --git a/src/w32.c b/src/w32.c index cbcfcdd4f6..44c279602c 100644 --- a/src/w32.c +++ b/src/w32.c @@ -5992,12 +5992,22 @@ sys_umask (int mode) #ifndef SYMBOLIC_LINK_FLAG_DIRECTORY #define SYMBOLIC_LINK_FLAG_DIRECTORY 0x1 #endif +#ifndef SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE +#define SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE 0x2 +#endif int symlink (char const *filename, char const *linkname) { char linkfn[MAX_UTF8_PATH], *tgtfn; - DWORD flags = 0; + /* The SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE flag is + supported from Windows 10 build 14972. It is only supported if + Developer Mode is enabled, and is ignored if it isn't. */ + DWORD flags = + (os_subtype == OS_SUBTYPE_NT + && (w32_major_version > 10 + || (w32_major_version == 10 && w32_build_number >= 14972))) + ? SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE : 0; int dir_access, filename_ends_in_slash; /* Diagnostics follows Posix as much as possible. */ @@ -6055,7 +6065,7 @@ symlink (char const *filename, char const *linkname) directory. */ filename_ends_in_slash = IS_DIRECTORY_SEP (filename[strlen (filename) - 1]); if (dir_access == 0 || filename_ends_in_slash) - flags = SYMBOLIC_LINK_FLAG_DIRECTORY; + flags |= SYMBOLIC_LINK_FLAG_DIRECTORY; tgtfn = (char *)map_w32_filename (filename, NULL); if (filename_ends_in_slash) commit b28b2cefaea0d7846ab9a45dc92f68ad00e92085 Author: Lars Ingebrigtsen Date: Thu Aug 25 14:54:49 2022 +0200 Fix warning about obsoleted generalized variables * lisp/emacs-lisp/bytecomp.el (byte-compile-warn-obsolete): Autoload so that the call here from gv.el (about obsolete generalized variables) doesn't bug out (bug#57394). diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index c25250533a..a16486dc31 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -1356,6 +1356,7 @@ FORMAT and ARGS are as in `byte-compile-warn'." (let ((byte-compile-form-stack (cons arg byte-compile-form-stack))) (apply #'byte-compile-warn format args))) +;;;###autoload (defun byte-compile-warn-obsolete (symbol type) "Warn that SYMBOL (a variable, function or generalized variable) is obsolete. TYPE is a string that say which one of these three types it is." commit a8a3608c074c00e32a551c6fa27131b0094c8b2c Author: Lars Ingebrigtsen Date: Thu Aug 25 14:42:59 2022 +0200 Make frame-width obsolete as a generalized variable * lisp/emacs-lisp/gv.el (frame-width): Make obsolete as generalized variable. diff --git a/etc/NEWS b/etc/NEWS index 44ee9b8fc7..7f460e8b88 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2599,13 +2599,13 @@ The following generalized variables have been made obsolete: 'current-column', 'current-global-map', 'current-input-mode', 'current-local-map', 'current-window-configuration', 'default-file-modes', 'documentation-property', 'frame-height', -'frame-visible-p', 'global-key-binding', 'local-key-binding', 'mark', -'mark-marker', 'marker-position', 'mouse-position', 'point', -'point-marker', 'point-max', 'point-min', 'read-mouse-position', -'screen-height', 'screen-width', 'selected-frame', 'selected-screen', -'selected-window', 'standard-case-table', 'syntax-table', -'visited-file-modtime', 'window-height', 'window-width', and -'x-get-secondary-selection'. +'frame-width', 'frame-visible-p', 'global-key-binding', +'local-key-binding', 'mark', 'mark-marker', 'marker-position', +'mouse-position', 'point', 'point-marker', 'point-max', 'point-min', +'read-mouse-position', 'screen-height', 'screen-width', +'selected-frame', 'selected-screen', 'selected-window', +'standard-case-table', 'syntax-table', 'visited-file-modtime', +'window-height', 'window-width', and 'x-get-secondary-selection'. * Lisp Changes in Emacs 29.1 diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el index 770cdb3d4f..eaab6439ad 100644 --- a/lisp/emacs-lisp/gv.el +++ b/lisp/emacs-lisp/gv.el @@ -706,6 +706,8 @@ REF must have been previously obtained with `gv-ref'." (gv-define-setter frame-width (x &optional frame) `(set-frame-width (or ,frame (selected-frame)) ,x)) +(make-obsolete-generalized-variable 'frame-width 'set-frame-width "29.1") + (gv-define-simple-setter getenv setenv t) (gv-define-simple-setter get-register set-register) commit dbec115948657d4f0b5c8ad86410b8e1c9e825d2 Author: Daniel Martín Date: Thu Aug 25 14:37:36 2022 +0200 Fix instrumented eval-defun not printing "Edebug:" to the echo area * lisp/progmodes/elisp-mode.el (elisp--eval-defun): Determine if we're instrumenting a function and call eval-region with PRINTFLAG set to nil if so (Bug#50245). * test/lisp/progmodes/elisp-mode-tests.el (eval-defun-prints-edebug-when-instrumented): Add a new test. diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index 9dc67010aa..4ada27a1ac 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -1646,6 +1646,7 @@ Return the result of evaluation." ;; printing, not while evaluating. (defvar elisp--eval-defun-result) (let ((debug-on-error eval-expression-debug-on-error) + (edebugging edebug-all-defs) elisp--eval-defun-result) (save-excursion ;; Arrange for eval-region to "read" the (possibly) altered form. @@ -1670,8 +1671,9 @@ Return the result of evaluation." (elisp--eval-defun-1 (macroexpand form))))) (print-length eval-expression-print-length) - (print-level eval-expression-print-level)) - (eval-region beg end standard-output + (print-level eval-expression-print-level) + (should-print (if (not edebugging) standard-output))) + (eval-region beg end should-print (lambda (_ignore) ;; Skipping to the end of the specified region ;; will make eval-region return. diff --git a/test/lisp/progmodes/elisp-mode-tests.el b/test/lisp/progmodes/elisp-mode-tests.el index 8074d8d706..e73be0db50 100644 --- a/test/lisp/progmodes/elisp-mode-tests.el +++ b/test/lisp/progmodes/elisp-mode-tests.el @@ -183,6 +183,16 @@ (call-interactively #'eval-last-sexp) (should (equal (current-message) "66 (#o102, #x42, ?B)")))))) +;;; eval-defun + +(ert-deftest eval-defun-prints-edebug-when-instrumented () + (skip-unless (not noninteractive)) + (with-temp-buffer + (let ((current-prefix-arg '(4))) + (erase-buffer) (insert "(defun foo ())") (message nil) + (call-interactively #'eval-defun) + (should (equal (current-message) "Edebug: foo"))))) + ;;; eldoc (defun elisp-mode-tests--face-propertized-string (string) commit b947f80a623c9a8c6abd2bcd4e2e245af6b0e03a Author: Lars Ingebrigtsen Date: Thu Aug 25 14:29:43 2022 +0200 Add hideshow-test.el file (bug#56635) diff --git a/test/lisp/progmodes/hideshow-tests.el b/test/lisp/progmodes/hideshow-tests.el new file mode 100644 index 0000000000..ee2a0c7c4c --- /dev/null +++ b/test/lisp/progmodes/hideshow-tests.el @@ -0,0 +1,268 @@ +;;; hideshow-tests.el --- Test suite for hideshow.el -*- lexical-binding:t -*- + +;; Copyright (C) 2022 Free Software Foundation, Inc. + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Commentary: + +;;; Code: + +(require 'ert) +(require 'ert-x) +(require 'hideshow) + +;; Dependencies for testing: +(require 'cc-mode) + + +(defmacro hideshow-tests-with-temp-buffer (mode contents &rest body) + "Create a `hs-minor-mode' enabled MODE temp buffer with CONTENTS. +BODY is code to be executed within the temp buffer. Point is +always located at the beginning of buffer." + (declare (indent 1) (debug t)) + `(with-temp-buffer + (,mode) + (hs-minor-mode 1) + (insert ,contents) + (goto-char (point-min)) + ,@body)) + +(defun hideshow-tests-look-at (string &optional num restore-point) + "Move point at beginning of STRING in the current buffer. +Optional argument NUM defaults to 1 and is an integer indicating +how many occurrences must be found, when positive the search is +done forwards, otherwise backwards. When RESTORE-POINT is +non-nil the point is not moved but the position found is still +returned. When searching forward and point is already looking at +STRING, it is skipped so the next STRING occurrence is selected." + (let* ((num (or num 1)) + (starting-point (point)) + (string (regexp-quote string)) + (search-fn (if (> num 0) #'re-search-forward #'re-search-backward)) + (deinc-fn (if (> num 0) #'1- #'1+)) + (found-point)) + (prog2 + (catch 'exit + (while (not (= num 0)) + (when (and (> num 0) + (looking-at string)) + ;; Moving forward and already looking at STRING, skip it. + (forward-char (length (match-string-no-properties 0)))) + (and (not (funcall search-fn string nil t)) + (throw 'exit t)) + (when (> num 0) + ;; `re-search-forward' leaves point at the end of the + ;; occurrence, move back so point is at the beginning + ;; instead. + (forward-char (- (length (match-string-no-properties 0))))) + (setq + num (funcall deinc-fn num) + found-point (point)))) + found-point + (and restore-point (goto-char starting-point))))) + +(defun hideshow-tests-visible-string (&optional min max) + "Return the buffer string excluding invisible overlays. +Argument MIN and MAX delimit the region to be returned and +default to `point-min' and `point-max' respectively." + (let* ((min (or min (point-min))) + (max (or max (point-max))) + (buffer-contents (buffer-substring-no-properties min max)) + (overlays + (sort (overlays-in min max) + (lambda (a b) + (let ((overlay-end-a (overlay-end a)) + (overlay-end-b (overlay-end b))) + (> overlay-end-a overlay-end-b)))))) + (with-temp-buffer + (insert buffer-contents) + (dolist (overlay overlays) + (if (overlay-get overlay 'invisible) + (delete-region (overlay-start overlay) + (overlay-end overlay)))) + (buffer-substring-no-properties (point-min) (point-max))))) + +(ert-deftest hideshow-hide-block-1 () + "Should hide current block." + (let ((contents " +int +main() +{ + printf(\"Hello\\n\"); +} +")) + (hideshow-tests-with-temp-buffer + c-mode + contents + (hideshow-tests-look-at "printf") + (hs-hide-block) + (should (string= + (hideshow-tests-visible-string) + " +int +main() +{} +")) + (hs-show-block) + (should (string= (hideshow-tests-visible-string) contents))))) + +(ert-deftest hideshow-hide-all-1 () + "Should hide all blocks and comments." + (let ((contents " +/* + Comments +*/ + +int +main() +{ + sub(); +} + +void +sub() +{ + printf(\"Hello\\n\"); +} +")) + (hideshow-tests-with-temp-buffer + c-mode + contents + (hs-hide-all) + (should (string= + (hideshow-tests-visible-string) + " +/* + +int +main() +{} + +void +sub() +{} +")) + (hs-show-all) + (should (string= (hideshow-tests-visible-string) contents))))) + +(ert-deftest hideshow-hide-all-2 () + "Should not hide comments when `hs-hide-comments-when-hiding-all' is nil." + (let ((contents " +/* + Comments +*/ + +int +main() +{ + sub(); +} + +void +sub() +{ + printf(\"Hello\\n\"); +} +")) + (hideshow-tests-with-temp-buffer + c-mode + contents + (let ((hs-hide-comments-when-hiding-all nil)) + (hs-hide-all)) + (should (string= + (hideshow-tests-visible-string) + " +/* + Comments +*/ + +int +main() +{} + +void +sub() +{} +")) + (hs-show-all) + (should (string= (hideshow-tests-visible-string) contents))))) + +(ert-deftest hideshow-hide-level-1 () + "Should hide 1st level blocks." + (hideshow-tests-with-temp-buffer + c-mode + " +/* + Comments +*/ + +int +main(int argc, char **argv) +{ + if (argc > 1) { + printf(\"Hello\\n\"); + } +} +" + (hs-hide-level 1) + (should (string= + (hideshow-tests-visible-string) + " +/* + Comments +*/ + +int +main(int argc, char **argv) +{} +")))) + +(ert-deftest hideshow-hide-level-2 () + "Should hide 2nd level blocks." + (hideshow-tests-with-temp-buffer + c-mode + " +/* + Comments +*/ + +int +main(int argc, char **argv) +{ + if (argc > 1) { + printf(\"Hello\\n\"); + } +} +" + (hs-hide-level 2) + (should (string= + (hideshow-tests-visible-string) + " +/* + Comments +*/ + +int +main(int argc, char **argv) +{ + if (argc > 1) {} +} +")))) + +(provide 'hideshow-tests) + +;;; hideshow-tests.el ends here commit 7c7fc8fa5be69ccbfd2d134a899cdedf29d25aab Author: kobarity Date: Thu Aug 25 14:29:10 2022 +0200 Add Python blocks support for hideshow * lisp/progmodes/python.el (python-nav-beginning-of-block-regexp): New variable. (python-hideshow-forward-sexp-function): Change to call `python-nav-end-of-block'. (python-hideshow-find-next-block): New function to be used as FIND-NEXT-BLOCK-FUNC in `hs-special-modes-alist'. (python-info-looking-at-beginning-of-block): New function to be used as LOOKING-AT-BLOCK-START-P-FUNC in `hs-special-modes-alist'. (python-mode): Change settings of `hs-special-modes-alist'. * test/lisp/progmodes/python-tests.el (python-hideshow-hide-levels-1): Fix to keep empty lines. (python-info-looking-at-beginning-of-block-1) (python-hideshow-hide-levels-3, python-hideshow-hide-levels-4) (python-hideshow-hide-all-1, python-hideshow-hide-all-2) (python-hideshow-hide-all-3, python-hideshow-hide-block-1): New tests (bug#56635). diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index e1347754c4..d3ffc2db2c 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -1524,6 +1524,10 @@ marks the next defun after the ones already marked." The name of the defun should be grouped so it can be retrieved via `match-string'.") +(defvar python-nav-beginning-of-block-regexp + (python-rx line-start (* space) block-start) + "Regexp matching block start.") + (defun python-nav--beginning-of-defun (&optional arg) "Internal implementation of `python-nav-beginning-of-defun'. With positive ARG search backwards, else search forwards." @@ -4916,9 +4920,37 @@ Interactively, prompt for symbol." (defun python-hideshow-forward-sexp-function (_arg) "Python specific `forward-sexp' function for `hs-minor-mode'. Argument ARG is ignored." - (python-nav-end-of-defun) - (unless (python-info-current-line-empty-p) - (backward-char))) + (python-nav-end-of-block)) + +(defun python-hideshow-find-next-block (regexp maxp comments) + "Python specific `hs-find-next-block' function for `hs-minor-mode'. +Call `python-nav-forward-block' to find next block and check if +block-start ends within MAXP. If COMMENTS is not nil, comments +are also searched. REGEXP is passed to `looking-at' to set +`match-data'." + (let* ((next-block (save-excursion + (or (and + (python-info-looking-at-beginning-of-block) + (re-search-forward + (python-rx block-start) maxp t)) + (and (python-nav-forward-block) + (< (point) maxp) + (re-search-forward + (python-rx block-start) maxp t)) + (1+ maxp)))) + (next-comment + (or (when comments + (save-excursion + (cl-loop while (re-search-forward "#" maxp t) + if (python-syntax-context 'comment) + return (point)))) + (1+ maxp))) + (next-block-or-comment (min next-block next-comment))) + (when (<= next-block-or-comment maxp) + (goto-char next-block-or-comment) + (save-excursion + (beginning-of-line) + (looking-at regexp))))) ;;; Imenu @@ -5415,6 +5447,16 @@ instead of the current physical line." (beginning-of-line 1) (looking-at python-nav-beginning-of-defun-regexp)))) +(defun python-info-looking-at-beginning-of-block () + "Check if point is at the beginning of block." + (let ((pos (point))) + (save-excursion + (python-nav-beginning-of-statement) + (beginning-of-line) + (and + (<= (point) pos (+ (point) (current-indentation))) + (looking-at python-nav-beginning-of-block-regexp))))) + (defun python-info-current-line-comment-p () "Return non-nil if current line is a comment line." (char-equal @@ -5870,14 +5912,17 @@ REPORT-FN is Flymake's callback function." (add-to-list 'hs-special-modes-alist - '(python-mode - "\\s-*\\_<\\(?:def\\|class\\)\\_>" + `(python-mode + ,python-nav-beginning-of-block-regexp ;; Use the empty string as end regexp so it doesn't default to ;; "\\s)". This way parens at end of defun are properly hidden. "" "#" python-hideshow-forward-sexp-function - nil)) + nil + python-nav-beginning-of-block + python-hideshow-find-next-block + python-info-looking-at-beginning-of-block)) (setq-local outline-regexp (python-rx (* space) block-start)) (setq-local outline-level diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index 12ac871fdf..906f7eca7d 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -5730,6 +5730,39 @@ def \\ (should (not (python-info-looking-at-beginning-of-defun))) (should (not (python-info-looking-at-beginning-of-defun nil t))))) +(ert-deftest python-info-looking-at-beginning-of-block-1 () + (python-tests-with-temp-buffer + " +def f(): + if True: + pass + l = [x * 2 + for x in range(5) + if x < 3] +# if False: +\"\"\" +if 0: +\"\"\" +" + (python-tests-look-at "def f():") + (should (python-info-looking-at-beginning-of-block)) + (forward-char) + (should (not (python-info-looking-at-beginning-of-block))) + (python-tests-look-at "if True:") + (should (python-info-looking-at-beginning-of-block)) + (forward-char) + (should (not (python-info-looking-at-beginning-of-block))) + (beginning-of-line) + (should (python-info-looking-at-beginning-of-block)) + (python-tests-look-at "for x") + (should (not (python-info-looking-at-beginning-of-block))) + (python-tests-look-at "if x < 3") + (should (not (python-info-looking-at-beginning-of-block))) + (python-tests-look-at "if False:") + (should (not (python-info-looking-at-beginning-of-block))) + (python-tests-look-at "if 0:") + (should (not (python-info-looking-at-beginning-of-block))))) + (ert-deftest python-info-current-line-comment-p-1 () (python-tests-with-temp-buffer " @@ -6183,8 +6216,11 @@ class SomeClass: class SomeClass: def __init__(self, arg, kwarg=1): + def filter(self, nums): - def __str__(self):")))) + + def __str__(self): +")))) (or enabled (hs-minor-mode -1))))) (ert-deftest python-hideshow-hide-levels-2 () @@ -6230,6 +6266,165 @@ class SomeClass: ")))) (or enabled (hs-minor-mode -1))))) +(ert-deftest python-hideshow-hide-levels-3 () + "Should hide all blocks." + (python-tests-with-temp-buffer + " +def f(): + if 0: + l = [i for i in range(5) + if i < 3] + abc = o.match(1, 2, 3) + +def g(): + pass +" + (hs-minor-mode 1) + (hs-hide-level 1) + (should + (string= + (python-tests-visible-string) + " +def f(): + +def g(): +")))) + +(ert-deftest python-hideshow-hide-levels-4 () + "Should hide 2nd level block." + (python-tests-with-temp-buffer + " +def f(): + if 0: + l = [i for i in range(5) + if i < 3] + abc = o.match(1, 2, 3) + +def g(): + pass +" + (hs-minor-mode 1) + (hs-hide-level 2) + (should + (string= + (python-tests-visible-string) + " +def f(): + if 0: + +def g(): + pass +")))) + +(ert-deftest python-hideshow-hide-all-1 () + "Should hide all blocks." + (python-tests-with-temp-buffer + "if 0: + + aaa + l = [i for i in range(5) + if i < 3] + ccc + abc = o.match(1, 2, 3) + ddd + +def f(): + pass +" + (hs-minor-mode 1) + (hs-hide-all) + (should + (string= + (python-tests-visible-string) + "if 0: + +def f(): +")))) + +(ert-deftest python-hideshow-hide-all-2 () + "Should hide comments." + (python-tests-with-temp-buffer + " +# Multi line +# comment + +\"\"\" +# Multi line +# string +\"\"\" +" + (hs-minor-mode 1) + (hs-hide-all) + (should + (string= + (python-tests-visible-string) + " +# Multi line + +\"\"\" +# Multi line +# string +\"\"\" +")))) + +(ert-deftest python-hideshow-hide-all-3 () + "Should not hide comments when `hs-hide-comments-when-hiding-all' is nil." + (python-tests-with-temp-buffer + " +# Multi line +# comment + +\"\"\" +# Multi line +# string +\"\"\" +" + (hs-minor-mode 1) + (let ((hs-hide-comments-when-hiding-all nil)) + (hs-hide-all)) + (should + (string= + (python-tests-visible-string) + " +# Multi line +# comment + +\"\"\" +# Multi line +# string +\"\"\" +")))) + +(ert-deftest python-hideshow-hide-block-1 () + "Should hide current block." + (python-tests-with-temp-buffer + " +if 0: + + aaa + l = [i for i in range(5) + if i < 3] + ccc + abc = o.match(1, 2, 3) + ddd + +def f(): + pass +" + (hs-minor-mode 1) + (python-tests-look-at "ddd") + (forward-line) + (hs-hide-block) + (should + (string= + (python-tests-visible-string) + " +if 0: + +def f(): + pass +")))) + (ert-deftest python-tests--python-nav-end-of-statement--infloop () "Checks that `python-nav-end-of-statement' doesn't infloop in a commit 74d0304ad446dbad6fed887784ffbc3d0fdb59fd Author: kobarity Date: Thu Aug 25 14:28:22 2022 +0200 Extend `hs-special-modes-alist' for languages such as Python * lisp/progmodes/hideshow.el (hs-special-modes-alist): Add elements FIND-BLOCK-BEGINNING-FUNC, FIND-NEXT-BLOCK-FUNC, and LOOKING-AT-BLOCK-START-P-FUNC. (hs-find-block-beginning-func): New variable to hold FIND-BLOCK-BEGINNING-FUNC. (hs-find-next-block-func): New variable to hold FIND-NEXT-BLOCK-FUNC. (hs-looking-at-block-start-p-func): New variable to hold LOOKING-AT-BLOCK-START-P-FUNC. (hs-grok-mode-type): Set new variables from `hs-special-modes-alist'. (hs-find-next-block): New function. (Misc.): Update callers of the above functions. * test/lisp/progmodes/hideshow-tests.el: New test file (bug#56635). diff --git a/lisp/progmodes/hideshow.el b/lisp/progmodes/hideshow.el index f574ec84fb..c0796fc2ee 100644 --- a/lisp/progmodes/hideshow.el +++ b/lisp/progmodes/hideshow.el @@ -267,7 +267,9 @@ This has effect only if `search-invisible' is set to `open'." )) "Alist for initializing the hideshow variables for different modes. Each element has the form - (MODE START END COMMENT-START FORWARD-SEXP-FUNC ADJUST-BEG-FUNC). + (MODE START END COMMENT-START FORWARD-SEXP-FUNC ADJUST-BEG-FUNC + FIND-BLOCK-BEGINNING-FUNC FIND-NEXT-BLOCK-FUNC + LOOKING-AT-BLOCK-START-P-FUNC). If non-nil, hideshow will use these values as regexps to define blocks and comments, respectively for major mode MODE. @@ -288,6 +290,15 @@ cases, FORWARD-SEXP-FUNC specifies another function to use instead. See the documentation for `hs-adjust-block-beginning' to see what is the use of ADJUST-BEG-FUNC. +See the documentation for `hs-find-block-beginning-func' to see +what is the use of FIND-BLOCK-BEGINNING-FUNC. + +See the documentation for `hs-find-next-block-func' to see what +is the use of FIND-NEXT-BLOCK-FUNC. + +See the documentation for `hs-looking-at-block-start-p-func' to +see what is the use of LOOKING-AT-BLOCK-START-P-FUNC. + If any of the elements is left nil or omitted, hideshow tries to guess appropriate values. The regexps should not contain leading or trailing whitespace. Case does not matter.") @@ -433,6 +444,39 @@ It should not move the point. See `hs-c-like-adjust-block-beginning' for an example of using this.") +(defvar-local hs-find-block-beginning-func #'hs-find-block-beginning + "Function used to do `hs-find-block-beginning'. +It should reposition point at the beginning of the current block +and return point, or nil if original point was not in a block. + +Specifying this function is necessary for languages such as +Python, where regexp search and `syntax-ppss' check is not enough +to find the beginning of the current block.") + +(defvar-local hs-find-next-block-func #'hs-find-next-block + "Function used to do `hs-find-next-block'. +It should reposition point at next block start. + +It is called with three arguments REGEXP, MAXP, and COMMENTS. +REGEXP is a regexp representing block start. When block start is +found, `match-data' should be set using REGEXP. MAXP is a buffer +position that bounds the search. When COMMENTS is nil, comments +should be skipped. When COMMENTS is not nil, REGEXP matches not +only beginning of a block but also beginning of a comment. In +this case, the function should find nearest block or comment. + +Specifying this function is necessary for languages such as +Python, where regexp search is not enough to find the beginning +of the next block.") + +(defvar-local hs-looking-at-block-start-p-func #'hs-looking-at-block-start-p + "Function used to do `hs-looking-at-block-start-p'. +It should return non-nil if the point is at the block start. + +Specifying this function is necessary for languages such as +Python, where `looking-at' and `syntax-ppss' check is not enough +to check if the point is at the block start.") + (defvar hs-headline nil "Text of the line where a hidden block begins, set during isearch. You can display this in the mode line by adding the symbol `hs-headline' @@ -565,7 +609,7 @@ The block beginning is adjusted by `hs-adjust-block-beginning' and then further adjusted to be at the end of the line." (if comment-reg (hs-hide-comment-region (car comment-reg) (cadr comment-reg) end) - (when (hs-looking-at-block-start-p) + (when (funcall hs-looking-at-block-start-p-func) (let ((mdata (match-data t)) (header-end (match-end 0)) p q ov) @@ -672,7 +716,14 @@ function; and adjust-block-beginning function." 0 (1- (match-end 0))) c-start-regexp))) hs-forward-sexp-func (or (nth 4 lookup) #'forward-sexp) - hs-adjust-block-beginning (or (nth 5 lookup) #'identity))) + hs-adjust-block-beginning (or (nth 5 lookup) #'identity) + hs-find-block-beginning-func (or (nth 6 lookup) + #'hs-find-block-beginning) + hs-find-next-block-func (or (nth 7 lookup) + #'hs-find-next-block) + hs-looking-at-block-start-p-func + (or (nth 8 lookup) + #'hs-looking-at-block-start-p))) (setq hs-minor-mode nil) (error "%s Mode doesn't support Hideshow Minor Mode" (format-mode-line mode-name)))) @@ -683,7 +734,7 @@ Return point, or nil if original point was not in a block." (let ((done nil) (here (point))) ;; look if current line is block start - (if (hs-looking-at-block-start-p) + (if (funcall hs-looking-at-block-start-p-func) (point) ;; look backward for the start of a block that contains the cursor (while (and (re-search-backward hs-block-start-regexp nil t) @@ -698,19 +749,25 @@ Return point, or nil if original point was not in a block." (goto-char here) nil)))) +(defun hs-find-next-block (regexp maxp comments) + "Reposition point at next block-start. +Skip comments if COMMENTS is nil, and search for REGEXP in +region (point MAXP)." + (when (not comments) + (forward-comment (point-max))) + (and (< (point) maxp) + (re-search-forward regexp maxp t))) + (defun hs-hide-level-recursive (arg minp maxp) "Recursively hide blocks ARG levels below point in region (MINP MAXP)." - (when (hs-find-block-beginning) + (when (funcall hs-find-block-beginning-func) (setq minp (1+ (point))) (funcall hs-forward-sexp-func 1) (setq maxp (1- (point)))) (unless hs-allow-nesting (hs-discard-overlays minp maxp)) (goto-char minp) - (while (progn - (forward-comment (buffer-size)) - (and (< (point) maxp) - (re-search-forward hs-block-start-regexp maxp t))) + (while (funcall hs-find-next-block-func hs-block-start-regexp maxp nil) (when (save-match-data (not (nth 8 (syntax-ppss)))) ; not inside comments or strings (if (> arg 1) @@ -747,8 +804,8 @@ and `case-fold-search' are both t." (goto-char (nth 0 c-reg)) (end-of-line) (when (and (not c-reg) - (hs-find-block-beginning) - (hs-looking-at-block-start-p)) + (funcall hs-find-block-beginning-func) + (funcall hs-looking-at-block-start-p-func)) ;; point is inside a block (goto-char (match-end 0))))) (end-of-line) @@ -790,10 +847,8 @@ If `hs-hide-comments-when-hiding-all' is non-nil, also hide the comments." hs-c-start-regexp "\\)") "")))) - (while (progn - (unless hs-hide-comments-when-hiding-all - (forward-comment (point-max))) - (re-search-forward re (point-max) t)) + (while (funcall hs-find-next-block-func re (point-max) + hs-hide-comments-when-hiding-all) (if (match-beginning 1) ;; We have found a block beginning. (progn @@ -838,8 +893,8 @@ Upon completion, point is repositioned and the normal hook (<= (count-lines (car c-reg) (nth 1 c-reg)) 1))) (message "(not enough comment lines to hide)")) ((or c-reg - (hs-looking-at-block-start-p) - (hs-find-block-beginning)) + (funcall hs-looking-at-block-start-p-func) + (funcall hs-find-block-beginning-func)) (hs-hide-block-at-point end c-reg) (run-hooks 'hs-hide-hook)))))) @@ -868,9 +923,9 @@ See documentation for functions `hs-hide-block' and `run-hooks'." (when (car c-reg) (setq p (car c-reg) q (cadr c-reg)))) - ((and (hs-find-block-beginning) + ((and (funcall hs-find-block-beginning-func) ;; ugh, fresh match-data - (hs-looking-at-block-start-p)) + (funcall hs-looking-at-block-start-p-func)) (setq p (point) q (progn (hs-forward-sexp (match-data t) 1) (point))))) (when (and p q) commit 0ce30e92958538bb16bbefa1460580853fe82371 Author: Lars Ingebrigtsen Date: Thu Aug 25 14:18:45 2022 +0200 Allow not deleting the config.cache file with "make FAST=true bootstrap" * Makefile.in: Add some commentary about make bootstrap, ./configure -C and FASTo (top_bootclean): Don't delete config.cache here. (top_distclean): Delete it here instead. (bootstrap-clean): Allow not deleting the cache file. * admin/emake (cores): Adjust. diff --git a/Makefile.in b/Makefile.in index 7541e8d6b6..d288bacb9d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -51,7 +51,15 @@ # # make bootstrap # Removes all the compiled files to force a new bootstrap from a -# clean slate, and then build in the normal way. +# clean slate, and then build in the normal way. If the FAST Make +# variable is set, then the config.cache file isn't removed. This +# allows you to say +# +# ./configure -C +# make FAST=true bootstrap +# +# and use the cached results from the configure run, which is much +# faster. # # make docs # Make Emacs documentation files from their sources; requires makeinfo. @@ -936,7 +944,7 @@ clean: $(clean_dirs:=_clean) clean-gsettings-schemas ### 'bootclean' ### Delete all files that need to be remade for a clean bootstrap. top_bootclean=\ - rm -f config.cache config.log ${srcdir}/doc/man/emacs.1 + rm -f config.log ${srcdir}/doc/man/emacs.1 ### 'distclean' ### Delete all files from the current directory that are created by @@ -946,7 +954,7 @@ top_bootclean=\ ### distribution. top_distclean=\ ${top_bootclean}; \ - rm -f config.status config.log~ \ + rm -f config.cache config.status config.log~ \ Makefile makefile lib/gnulib.mk ${SUBDIR_MAKEFILES} distclean_dirs = $(clean_dirs) leim lisp admin/grammars @@ -966,6 +974,9 @@ bootstrap-clean: $(distclean_dirs:=_bootstrap-clean) rm -rf ${srcdir}/info rm -f ${srcdir}/etc/refcards/emacsver.tex rm -rf native-lisp/ lisp/leim/ja-dic/ +ifndef FAST + rm -f config.cache +endif ${top_bootclean} ### 'maintainer-clean' diff --git a/admin/emake b/admin/emake index dfe3664e12..8b2114b3f8 100755 --- a/admin/emake +++ b/admin/emake @@ -20,7 +20,7 @@ if [ -f /proc/cpuinfo ]; then sed 's/^[0-9]*/+/'))) fi -make -j$cores "$@" 2>&1 | \ +make FAST=true -j$cores "$@" 2>&1 | \ sed -u 's# \.\./\.\./# # s# \.\./# # s#^Configuring local git # Configuring local git # commit 82bcd443782738fd163b282497de5501d03f175a Author: Andreas Schwab Date: Thu Aug 25 09:51:40 2022 +0200 * configure.ac: Move AC_LANG_PUSH/POP out of AC_CACHE_CHECK. (Bug#57380) (cherry picked from commit ce82300221f270241fdda1f5dfb567bdb1208543) diff --git a/configure.ac b/configure.ac index bc7485b81c..7c98522448 100644 --- a/configure.ac +++ b/configure.ac @@ -2047,17 +2047,16 @@ AC_SUBST(NS_OBJ) AC_SUBST(NS_OBJC_OBJ) if test "${HAVE_NS}" = yes; then + AC_LANG_PUSH([Objective C]) AC_CACHE_CHECK( [if the Objective C compiler supports instancetype], [emacs_cv_objc_instancetype], - [AC_LANG_PUSH([Objective C]) - AC_COMPILE_IFELSE( + [AC_COMPILE_IFELSE( [AC_LANG_SOURCE([[@interface Test + (instancetype)test; @end]])], - emacs_cv_objc_instancetype=yes, - emacs_cv_objc_instancetype=no) - AC_LANG_POP([Objective C])]) + [emacs_cv_objc_instancetype=yes], + [emacs_cv_objc_instancetype=no])]) if test x$emacs_cv_objc_instancetype = xyes ; then AC_DEFINE(NATIVE_OBJC_INSTANCETYPE, 1, @@ -2067,16 +2066,15 @@ if test "${HAVE_NS}" = yes; then AC_CACHE_CHECK( [if the Objective C compiler defaults to C99], [emacs_cv_objc_c99], - [AC_LANG_PUSH([Objective C]) - AC_COMPILE_IFELSE( + [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([], [[for (int i = 0;;);]])], - emacs_cv_objc_c99=yes, - emacs_cv_objc_c99=no) - AC_LANG_POP([Objective C])]) + [emacs_cv_objc_c99=yes], + [emacs_cv_objc_c99=no])]) - if test x$emacs_cv_objc_c99 = xno ; then - GNU_OBJC_CFLAGS="$GNU_OBJC_CFLAGS -std=c99" - fi + if test x$emacs_cv_objc_c99 = xno ; then + GNU_OBJC_CFLAGS="$GNU_OBJC_CFLAGS -std=c99" + fi + AC_LANG_POP([Objective C]) fi HAVE_W32=no commit c5c3f57bd437235d247c1b6ee2e3059413d134b4 Author: Michael Albinus Date: Thu Aug 25 11:08:48 2022 +0200 Minor fixes in tramp-tests.el * test/lisp/net/tramp-tests.el (tramp--test-deftest-with-stat) (tramp--test-deftest-with-perl) (tramp--test-deftest-with-ls): Skip if underlying test didn't run or lasted too long. (tramp--test-shell-file-name): Do not depend on `tramp--test-adb-p'. diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 4dcf671f51..3e318a729d 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -3593,12 +3593,16 @@ This tests also `access-file', `file-readable-p', (skip-unless (tramp--test-enabled)) (skip-unless (tramp--test-sh-p)) (skip-unless (tramp-get-remote-stat tramp-test-vec)) - (let ((default-directory ert-remote-temporary-file-directory) - (ert-test (ert-get-test ',test)) - (tramp-connection-properties - (cons '(nil "perl" nil) - tramp-connection-properties))) - (funcall (ert-test-body ert-test))))) + (if-let ((default-directory ert-remote-temporary-file-directory) + (ert-test (ert-get-test ',test)) + (result (ert-test-most-recent-result ert-test)) + (tramp-connection-properties + (cons '(nil "perl" nil) + tramp-connection-properties))) + (progn + (skip-unless (< (ert-test-result-duration result) 300)) + (funcall (ert-test-body ert-test))) + (ert-skip (format "Test `%s' must run before" ',test))))) (defmacro tramp--test-deftest-with-perl (test) "Define ert `TEST-with-perl'." @@ -3612,15 +3616,19 @@ This tests also `access-file', `file-readable-p', (skip-unless (tramp--test-enabled)) (skip-unless (tramp--test-sh-p)) (skip-unless (tramp-get-remote-perl tramp-test-vec)) - (let ((default-directory ert-remote-temporary-file-directory) - (ert-test (ert-get-test ',test)) - (tramp-connection-properties - (append - '((nil "stat" nil) - ;; See `tramp-sh-handle-file-truename'. - (nil "readlink" nil)) - tramp-connection-properties))) - (funcall (ert-test-body ert-test))))) + (if-let ((default-directory ert-remote-temporary-file-directory) + (ert-test (ert-get-test ',test)) + (result (ert-test-most-recent-result ert-test)) + (tramp-connection-properties + (append + '((nil "stat" nil) + ;; See `tramp-sh-handle-file-truename'. + (nil "readlink" nil)) + tramp-connection-properties))) + (progn + (skip-unless (< (ert-test-result-duration result) 300)) + (funcall (ert-test-body ert-test))) + (ert-skip (format "Test `%s' must run before" ',test))))) (defmacro tramp--test-deftest-with-ls (test) "Define ert `TEST-with-ls'." @@ -3633,16 +3641,20 @@ This tests also `access-file', `file-readable-p', :tags '(:expensive-test) (skip-unless (tramp--test-enabled)) (skip-unless (tramp--test-sh-p)) - (let ((default-directory ert-remote-temporary-file-directory) - (ert-test (ert-get-test ',test)) - (tramp-connection-properties - (append - '((nil "perl" nil) - (nil "stat" nil) - ;; See `tramp-sh-handle-file-truename'. - (nil "readlink" nil)) - tramp-connection-properties))) - (funcall (ert-test-body ert-test))))) + (if-let ((default-directory ert-remote-temporary-file-directory) + (ert-test (ert-get-test ',test)) + (result (ert-test-most-recent-result ert-test)) + (tramp-connection-properties + (append + '((nil "perl" nil) + (nil "stat" nil) + ;; See `tramp-sh-handle-file-truename'. + (nil "readlink" nil)) + tramp-connection-properties))) + (progn + (skip-unless (< (ert-test-result-duration result) 300)) + (funcall (ert-test-body ert-test))) + (ert-skip (format "Test `%s' must run before" ',test))))) (tramp--test-deftest-with-stat tramp-test18-file-attributes) @@ -4598,7 +4610,10 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." (defun tramp--test-shell-file-name () "Return default remote shell." - (if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh")) + (if (file-exists-p + (concat + (file-remote-p ert-remote-temporary-file-directory) "/system/bin/sh")) + "/system/bin/sh" "/bin/sh")) (ert-deftest tramp-test28-process-file () "Check `process-file'." commit ce82300221f270241fdda1f5dfb567bdb1208543 Author: Andreas Schwab Date: Thu Aug 25 09:51:40 2022 +0200 * configure.ac: Move AC_LANG_PUSH/POP out of AC_CACHE_CHECK. (Bug#57380) diff --git a/configure.ac b/configure.ac index 7616e450d0..6ca3052ea3 100644 --- a/configure.ac +++ b/configure.ac @@ -2155,17 +2155,16 @@ AC_SUBST([NS_OBJ]) AC_SUBST([NS_OBJC_OBJ]) if test "${HAVE_NS}" = yes; then + AC_LANG_PUSH([Objective C]) AC_CACHE_CHECK( [if the Objective C compiler supports instancetype], [emacs_cv_objc_instancetype], - [AC_LANG_PUSH([Objective C]) - AC_COMPILE_IFELSE( + [AC_COMPILE_IFELSE( [AC_LANG_SOURCE([[@interface Test + (instancetype)test; @end]])], [emacs_cv_objc_instancetype=yes], - [emacs_cv_objc_instancetype=no]) - AC_LANG_POP([Objective C])]) + [emacs_cv_objc_instancetype=no])]) if test x$emacs_cv_objc_instancetype = xyes ; then AC_DEFINE([NATIVE_OBJC_INSTANCETYPE], [1], @@ -2175,16 +2174,15 @@ if test "${HAVE_NS}" = yes; then AC_CACHE_CHECK( [if the Objective C compiler defaults to C99], [emacs_cv_objc_c99], - [AC_LANG_PUSH([Objective C]) - AC_COMPILE_IFELSE( + [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([], [[for (int i = 0;;);]])], [emacs_cv_objc_c99=yes], - [emacs_cv_objc_c99=no]) - AC_LANG_POP([Objective C])]) + [emacs_cv_objc_c99=no])]) - if test x$emacs_cv_objc_c99 = xno ; then - GNU_OBJC_CFLAGS="$GNU_OBJC_CFLAGS -std=c99" - fi + if test x$emacs_cv_objc_c99 = xno ; then + GNU_OBJC_CFLAGS="$GNU_OBJC_CFLAGS -std=c99" + fi + AC_LANG_POP([Objective C]) fi HAVE_BE_APP=no