commit 01d2af9c7c9d0720022f027838d17123ca2c9cc2 (HEAD, refs/remotes/origin/master) Author: Jürgen Hötzel Date: Thu Oct 22 09:09:27 2015 +0200 Further fix for proper locale handling in tramp-gvfs.el * lisp/net/tramp-gvfs.el (tramp-gvfs-handle-file-attributes): Just suppress LC_MESSAGES locale category settings. diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index b9d2fa2..177ccfc 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el @@ -791,10 +791,7 @@ file names." (ignore-errors ;; Don't modify `last-coding-system-used' by accident. (let ((last-coding-system-used last-coding-system-used) - (process-environment - (append - '("LANG=C.utf8" "LANGUAGE=C.utf8" "LC_ALL=C.utf8") - process-environment)) + (process-environment (cons "LC_MESSAGES=C" process-environment)) dirp res-symlink-target res-numlinks res-uid res-gid res-access res-mod res-change res-size res-filemodes res-inode res-device) (with-parsed-tramp-file-name filename nil commit cd428600c2037731e74cd97a05f3cab766519b6a Author: Paul Eggert Date: Wed Oct 21 20:26:21 2015 -0700 Spelling fixes diff --git a/lib-src/ChangeLog.1 b/lib-src/ChangeLog.1 index 0bb24c3..5b41540 100644 --- a/lib-src/ChangeLog.1 +++ b/lib-src/ChangeLog.1 @@ -456,7 +456,7 @@ * update-game-score.c: Include inttypes.h, stdbool.h. (min): New macro, if not already defined. (MAX_SCORES, main): Limit the maximum number of scores only from - limits imposed by the underyling platform, instead of the + limits imposed by the underlying platform, instead of the arbitrary value 200. (struct score_entry, main, read_score, write_score): Scores are now intmax_t, not long. diff --git a/lisp/ChangeLog.5 b/lisp/ChangeLog.5 index 85f8fc1..6103eaf 100644 --- a/lisp/ChangeLog.5 +++ b/lisp/ChangeLog.5 @@ -8261,7 +8261,7 @@ * rmail.el (rmail-mode-map): Add "Get New Mail" menu item under Mail. * compile.el (compilation-next-error-locus): Don't call - compilation-forget-errors if compilation is still runing. + compilation-forget-errors if compilation is still running. 1994-07-11 Erik Naggum (erik@naggum.no) diff --git a/src/ChangeLog.3 b/src/ChangeLog.3 index d7c0a2f..5e99a27 100644 --- a/src/ChangeLog.3 +++ b/src/ChangeLog.3 @@ -1642,7 +1642,7 @@ * keymap.c (current_minor_maps): BLOCK_INPUT while calling realloc and malloc. * search.c: Since the regexp routines can malloc, BLOCK_INPUT - while runing them. #include blockinput.h. + while running them. #include blockinput.h. * sysdep.c: #include blockinput.h. Call xfree and xmalloc instead of free and malloc. BLOCK_INPUT around routines which we know will call malloc. commit f373e812d95e1822833f88db024e011a769998b4 Author: Paul Eggert Date: Wed Oct 21 20:22:34 2015 -0700 New lispref section “Security Considerations” This attempts to document some of the issues recently discussed on emacs-devel, and to indicate other such issues. The section could be a lot longer. * doc/lispref/os.texi (Security Considerations): New node. * doc/lispref/elisp.texi (Top): * doc/lispref/processes.texi (Shell Arguments): * lisp/subr.el (shell-quote-argument): * src/callproc.c (syms_of_callproc): Reference it. diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi index 5ca518e..2d3548f 100644 --- a/doc/lispref/elisp.texi +++ b/doc/lispref/elisp.texi @@ -1487,6 +1487,7 @@ Operating System Interface * Desktop Notifications:: Desktop notifications. * File Notifications:: File notifications. * Dynamic Libraries:: On-demand loading of support libraries. +* Security Considerations:: Running Emacs in an unfriendly environment. Starting Up Emacs diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index 204055d..1925bd5 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi @@ -37,6 +37,7 @@ terminal and the screen. * Desktop Notifications:: Desktop notifications. * File Notifications:: File notifications. * Dynamic Libraries:: On-demand loading of support libraries. +* Security Considerations:: Running Emacs in an unfriendly environment. @end menu @node Starting Up @@ -2760,3 +2761,106 @@ be loaded through it. This variable is ignored if the given @var{library} is statically linked into Emacs. @end defvar + +@node Security Considerations +@section Security Considerations +@cindex security +@cindex hardening + +Like any application, Emacs can be run in a secure environment, where +the operating system enforces rules about access and the like. With +some care, Emacs-based applications can also be part of a security +perimeter that checks such rules. Although the default settings for +Emacs work well for a typical software development environment, they +may require adjustment in environments containing untrusted users that +may include attackers. Here is a compendium of security issues that +may be helpful if you are developing such applications. It is by no +means complete; it is intended to give you an idea of the security +issues involved, rather than to be a security checklist. + +@table @asis +@item Access control +Although Emacs normally respects access permissions of the underlying +operating system, in some cases it handles accesses specially. For +example, file names can have handlers that treat the files specially, +with their own access checking. @xref{Magic File Names}. Also, a +buffer can be read-only even if the corresponding file is writeable, +and vice versa, which can result in messages such as @samp{File passwd +is write-protected; try to save anyway? (yes or no)}. @xref{Read Only +Buffers}. + +@item Authentication +Emacs has several functions that deal with passwords, e.g., +@code{password-read}. Although these functions do not attempt to +broadcast passwords to the world, their implementations are not proof +against determined attackers with access to Emacs internals. For +example, even if Elisp code attempts to scrub a password from +its memory after using it, remnants of the password may still reside +in the garbage-collected free list. + +@item Code injection +Emacs can send commands to many other applications, and applications +should take care that strings sent as operands of these commands are +not misinterpreted as directives. For example, when sending a shell +command to rename a file @var{a} to @var{b}, do not simply use the +string @code{mv @var{a} @var{b}}, because either file name might start +with @samp{-}, or might contain shell metacharacters like @samp{;}. +Although functions like @code{shell-quote-argument} can help avoid +this sort of problem, they are not panaceas; for example, on a POSIX +platform @code{shell-quote-argument} quotes shell metacharacters but +not leading @samp{-}. @xref{Shell Arguments}. + +@item Coding systems +Emacs attempts to infer the coding systems of the files and network +connections it accesses. If it makes a mistake, or if the other +parties to the network connection disagree with Emacs's deductions, +the resulting system could be unreliable. Also, even when it infers +correctly, Emacs often can use bytes that other programs cannot. For +example, although to Emacs the NUL (all bits zero) byte is just a +character like any other, many other applications treat it as a string +terminator and mishandle strings or files containing NUL bytes. + +@item Environment and configuration variables +POSIX specifies several environment variables that can affect how +Emacs behaves. Any environment variable whose name consists entirely +of uppercase ASCII letters, digits, and the underscore may affect the +internal behavior of Emacs. Emacs uses several such variables, e.g., +@env{EMACSLOADPATH}. @xref{Library Search}. On some platforms some +environment variables (e.g., @env{PATH}, @env{POSIXLY_CORRECT}, +@env{SHELL}, @env{TMPDIR}) need to have properly-configured values in +order to get standard behavior for any utility Emacs might invoke. +Even seemingly-benign variables like @env{TZ} may have security +implications. + +Emacs has customization and other variables with similar +considerations. For example, if the variable @code{shell-file-name} +specifies a shell with nonstandard behavior, an Emacs-based +application may misbehave. + +@item Installation +When Emacs is installed, if the installation directory hierarchy can +be modified by untrusted users, the application cannot be trusted. +This applies also to the directory hierarchies of the programs that +Emacs uses, and of the files that Emacs reads and writes. + +@item Network access +Emacs often accesses the network, and you may want to configure it to +avoid network accesses that it would normally do. For example, unless +you set @code{tramp-mode} to @code{nil}, file names using a certain +syntax are interpreted as being network files, and are retrieved +across the network. @xref{Top, The Tramp Manual,, tramp, The Tramp +Manual}. + +@item Race conditions +Emacs applications have the same sort of race-condition issues that +other applications do. For example, even when +@code{(file-readable-p "foo.txt")} returns @code{t}, it could be that +@file{foo.txt} is unreadable because some other program changed the +file's permissions between the call to @code{file-readable-p} and now. + +@item Resource limits +When Emacs exhausts memory or other operating system resources, its +behavior can be less reliable, in that computations that ordinarily +run to completion may abort back to the top level. This may cause +Emacs to neglect operations that it normally would have done. +@end table diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index 196cb7c..0ce696a 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi @@ -180,7 +180,7 @@ and then pass it to a shell for execution. Precisely what this function does depends on your operating system. The function is designed to work with the syntax of your system's standard shell; if you use an unusual shell, you will need to redefine this -function. +function. @xref{Security Considerations}. @example ;; @r{This example shows the behavior on GNU and Unix systems.} diff --git a/lisp/subr.el b/lisp/subr.el index c903ee3..ea926ae 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2714,7 +2714,8 @@ Note: :data and :device are currently not supported on Windows." "Quote ARGUMENT for passing as argument to an inferior shell. This function is designed to work with the syntax of your system's -standard shell, and might produce incorrect results with unusual shells." +standard shell, and might produce incorrect results with unusual shells. +See Info node `(elisp)Security Considerations'." (cond ((eq system-type 'ms-dos) ;; Quote using double quotes, but escape any existing quotes in diff --git a/src/callproc.c b/src/callproc.c index eafd621..bb21c35 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -1660,7 +1660,7 @@ syms_of_callproc (void) DEFVAR_LISP ("shell-file-name", Vshell_file_name, doc: /* File name to load inferior shells from. Initialized from the SHELL environment variable, or to a system-dependent -default if SHELL is not set. */); +default if SHELL is unset. See Info node `(elisp)Security Considerations'. */); DEFVAR_LISP ("exec-path", Vexec_path, doc: /* List of directories to search programs to run in subprocesses. commit 0bb27cd32e4a6a7fc4485381efc9ff0026e15689 Author: Paul Eggert Date: Wed Oct 21 20:10:40 2015 -0700 Merge from gnulib This incorporates: 2015-10-18 stdalign: work around pre-4.9 GCC x86 bug 2015-10-18 time_rz: avoid warning from bleeding-edge gcc's -Wnonnull * doc/misc/texinfo.tex, lib/stdalign.in.h, lib/time_rz.c: Copy from gnulib. diff --git a/doc/misc/texinfo.tex b/doc/misc/texinfo.tex index 46a9d15..c75ddd6 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{2015-10-09.18} +\def\texinfoversion{2015-10-17.11} % % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, @@ -1106,6 +1106,7 @@ where each line of input produces a line of output.} \newtoks\toksC \newtoks\toksD \newbox\boxA +\newbox\boxB \newcount\countA \newif\ifpdf \newif\ifpdfmakepagedest @@ -4605,6 +4606,8 @@ end } % \commondummiesnofonts: common to \commondummies and \indexnofonts. +% Define \definedumyletter, \definedummyaccent and \definedummyword before +% using. % \def\commondummiesnofonts{% % Control letters and accents. @@ -4700,11 +4703,27 @@ end { \catcode`\<=13 \catcode`\-=13 +\catcode`\`=13 \gdef\indexnonalnumdisappear{% - \backslashdisappear - \def-{}% - \def<{}% - \def\@{}% + \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax\else + % @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 + \backslashdisappear + \fi + % + \expandafter\ifx\csname SETtxiindexhyphenignore\endcsname\relax\else + \def-{}% + \fi + \expandafter\ifx\csname SETtxiindexlessthanignore\endcsname\relax\else + \def<{}% + \fi + \expandafter\ifx\csname SETtxiindexatsignignore\endcsname\relax\else + \def\@{}% + \fi } \gdef\indexnonalnumreappear{% @@ -4728,7 +4747,6 @@ end \def\definedummyletter##1{\let##1\empty}% % All control words become @asis by default; overrides below. \let\definedummyword\definedummyaccent - % \commondummiesnofonts % % Don't no-op \tt, since it isn't a user-level command @@ -4741,8 +4759,6 @@ end \def\_{\normalunderscore}% \def\-{}% @- shouldn't affect sorting % - % Unfortunately, texindex < 6.0 is not prepared to handle braces in the - % content at all, so these won't be sorted in ASCII order. \def\lbracechar{{\indexlbrace}}% \def\rbracechar{{\indexrbrace}}% \let\{=\lbracechar @@ -4805,9 +4821,6 @@ end \def\result{=>}% \def\textdegree{o}% % - \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax - \else \indexlquoteignore \fi - % % We need to get rid of all macros, leaving only the arguments (if present). % Of course this is not nearly correct, but it is the best we can do for now. % makeinfo does not expand macros in the argument to @deffn, which ends up @@ -4821,10 +4834,6 @@ end \macrolist } -% Undocumented (for FSFS 2nd ed.): @set txiindexlquoteignore makes us -% ignore left quotes in the sort term. -{\catcode`\`=\active - \gdef\indexlquoteignore{\let`=\empty}} \let\SETmarginindex=\relax % put index entries in margin (undocumented)? @@ -4917,9 +4926,9 @@ end % Get the string to sort by, by processing the index entry with all % font commands turned off. {\indexnofonts + \indexnonalnumdisappear \xdef\indexsortkey{}% \let\sortas=\indexwritesortas - \indexnonalnumdisappear \edef\temp{\the\toks0}% \setbox\dummybox = \hbox{\temp}% Make sure to execute any \sortas \ifx\indexsortkey\empty @@ -5214,30 +5223,6 @@ end % How much \indexdotfill is stretched, or how much \parfillskip is shrunk % Number of lines (\linepenalty) % - % Do not prefer a separate line ending with a hyphen to fewer lines. - \finalhyphendemerits = 0 - % - % Word spacing - no stretch - \spaceskip=\fontdimen2\font minus \fontdimen4\font - % - \linepenalty=1000 % Discourage line breaks. - \hyphenpenalty=5000 % Discourage hyphenation. - % - % Ragged right margin, but not for the last line with the leaders in it. - % When an index entry spans lines, this stretch competes with the stretch - % in \indexdotfill to determine how the line will be split. - \rightskip=\entryrightmargin - \advance\rightskip by 0pt plus .6\hsize - % - % \parfillskip is at the end of the line with the page number - \parfillskip=0pt - % Cancel the \rightskip stretch - \advance \parfillskip by 0pt plus -.6\hsize - % Determine how far we can stretch into the margin. - % This allows, e.g., "Appendix H GNU Free Documentation License" to fit - % on one line. - \advance \parfillskip by 0pt minus .6\entryrightmargin - % % Swallow the left brace of the text (first parameter): \afterassignment\doentry \let\temp = @@ -5245,20 +5230,26 @@ end \def\entrybreak{\unskip\space\ignorespaces}% \def\doentry{% % Save the text of the entry in a \vtop. - \global\setbox\entryindexbox=\vtop\bgroup + \global\setbox\boxA=\hbox\bgroup \bgroup % Instead of the swallowed brace. \noindent \aftergroup\finishentry % And now comes the text of the entry. + % Not absorbing as a macro argument reduces the chance of problems + % with catcodes occurring. } -\def\finishentry#1{% +{\catcode`\@=11 +\gdef\finishentry#1{% + \egroup % end box A + \dimen@ = \wd\boxA % Length of text of entry + \global\setbox\boxA=\hbox\bgroup\unhbox\boxA % #1 is the page number. % % The following is kludged to not output a line of dots in the index if % there are no page numbers. The next person who breaks this will be % cursed by a Unix daemon. - \setbox\boxA = \hbox{#1}% - \ifdim\wd\boxA = 0pt + \setbox\boxB = \hbox{#1}% + \ifdim\wd\boxB = 0pt \null\nobreak\hfill\ % \else % @@ -5271,23 +5262,62 @@ end \hskip\skip\thinshrinkable #1% \fi \fi - % Parameters for formatting this paragraph, reset for each paragraph. + \egroup % end \boxA + \global\setbox\entryindexbox=\vtop\bgroup\noindent + % We want the text of the entries to be aligned to the left, and the + % page numbers to be aligned to the right. % - % \hangindent is only relevant when the entry text and page number - % don't both fit on one line. In that case, bob suggests starting the - % dots pretty far over on the line. Unfortunately, a large - % indentation looks wrong when the entry text itself is broken across - % lines. So we use a small indentation and put up with long leaders. + \advance\leftskip by 0pt plus 1fil + \advance\leftskip by 0pt plus -1fill + \rightskip = 0pt plus -1fil + \advance\rightskip by 0pt plus 1fill + % Cause last line, which could consist of page numbers on their own if the + % list of page numbers is long, to be aligned to the right. + \parfillskip=0pt plus -1fill % - \hangafter = 1 - \hangindent = 1em - \par + \hangindent=1em + % + \advance\rightskip by \entryrightmargin + % Determine how far we can stretch into the margin. + % This allows, e.g., "Appendix H GNU Free Documentation License" to fit + % on one line. + \advance \parfillskip by 0pt minus .6\entryrightmargin + % + \ifdim\wd\boxA > \hsize % If the entry doesn't fit in one line + \ifdim\dimen@ > 0.9\hsize % due to long index text + \dimen@ = 0.6\dimen@ % Try to split the text roughly evenly + \dimen@ii = \hsize + \advance \dimen@ii by -1em + \ifnum\dimen@>\dimen@ii + % If the entry is too long, use the whole line + \dimen@ = \dimen@ii + \else + % Cause stretch of 1fill at the end of the first line, to avoid + % extra spacing in a short first line. + \hskip 0pt plus 1fill + \fi + \parshape = 2 0pt \dimen@ 1em \dimen@ii + % Ideally we'd add a finite glue at the end of the first line only, but + % TeX doesn't seem to provide a way to do such a thing. + \fi\fi + \unhbox\boxA + % + % Do not prefer a separate line ending with a hyphen to fewer lines. + \finalhyphendemerits = 0 + % + % Word spacing - no stretch + \spaceskip=\fontdimen2\font minus \fontdimen4\font + % + \linepenalty=1000 % Discourage line breaks. + \hyphenpenalty=10000 % Discourage hyphenation. + % + \par % format the paragraph \egroup % The \vtop \endgroup % delay text of entry until after penalty \bgroup\aftergroup\insertindexentrybox \entryorphanpenalty -} +}} \newskip\thinshrinkable \skip\thinshrinkable=.15em minus .15em @@ -5322,10 +5352,11 @@ end } % Like plain.tex's \dotfill, except uses up at least 1 em. -% Using a finite stretch encourages several words to appear on a second line -% if the entry is broken. +% The filll stretch here overpowers both the fil and fill stretch to push +% the page number to the right. \def\indexdotfill{\cleaders - \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus .4\hsize} + \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll} + \def\primary #1{\line{#1\hfil}} @@ -8945,6 +8976,7 @@ end \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup \catcode`\^^M = 5 % in case we're inside an example \normalturnoffactive % allow _ et al. in names + \def\xprocessmacroarg{\eatspaces}% in case we are being used via a macro % If the image is by itself, center it. \ifvmode \imagevmodetrue diff --git a/lib/stdalign.in.h b/lib/stdalign.in.h index c6115b6..ce1e793 100644 --- a/lib/stdalign.in.h +++ b/lib/stdalign.in.h @@ -52,7 +52,10 @@ #undef _Alignas #undef _Alignof -#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 +/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023 + . */ +#if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \ + || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9))) # ifdef __cplusplus # if 201103 <= __cplusplus # define _Alignof(type) alignof (type) diff --git a/lib/time_rz.c b/lib/time_rz.c index f94893a..a89b7e7 100644 --- a/lib/time_rz.c +++ b/lib/time_rz.c @@ -90,8 +90,7 @@ extend_abbrs (char *abbrs, char const *abbr, size_t abbr_size) } /* Return a newly allocated time zone for NAME, or NULL on failure. - As a special case, return a nonzero constant for wall clock time, a - constant that survives freeing. */ + A null NAME stands for wall clock time (which is like unset TZ). */ timezone_t tzalloc (char const *name) { @@ -288,10 +287,8 @@ localtime_rz (timezone_t tz, time_t const *t, struct tm *tm) timezone_t old_tz = set_tz (tz); if (old_tz) { - tm = localtime_r (t, tm); - if (tm && !save_abbr (tz, tm)) - tm = NULL; - if (revert_tz (old_tz)) + bool abbr_saved = localtime_r (t, tm) && save_abbr (tz, tm); + if (revert_tz (old_tz) && abbr_saved) return tm; } return NULL; commit 2ab48bafa3e8c3c686dcadfb5d2410178e9dd269 Author: Katsumi Yamaoka Date: Thu Oct 22 00:08:23 2015 +0000 Remove fboundp checks from mailcap-mime-data * lisp/gnus/mailcap.el (mailcap-mime-data): Remove fboundp checks. (mailcap-viewer-passes-test): Do it instead. Thanks to Stefan Monnier. diff --git a/lisp/gnus/mailcap.el b/lisp/gnus/mailcap.el index d888110..11a071b 100644 --- a/lisp/gnus/mailcap.el +++ b/lisp/gnus/mailcap.el @@ -96,11 +96,9 @@ This is a compatibility function for different Emacsen." (type . "application/vnd.ms-excel")) ("x-x509-ca-cert" (viewer . ssl-view-site-cert) - (test . (fboundp 'ssl-view-site-cert)) (type . "application/x-x509-ca-cert")) ("x-x509-user-cert" (viewer . ssl-view-user-cert) - (test . (fboundp 'ssl-view-user-cert)) (type . "application/x-x509-user-cert")) ("octet-stream" (viewer . mailcap-save-binary-file) @@ -129,23 +127,18 @@ This is a compatibility function for different Emacsen." (type . "application/x-tar")) ("x-latex" (viewer . tex-mode) - (test . (fboundp 'tex-mode)) (type . "application/x-latex")) ("x-tex" (viewer . tex-mode) - (test . (fboundp 'tex-mode)) (type . "application/x-tex")) ("latex" (viewer . tex-mode) - (test . (fboundp 'tex-mode)) (type . "application/latex")) ("tex" (viewer . tex-mode) - (test . (fboundp 'tex-mode)) (type . "application/tex")) ("texinfo" (viewer . texinfo-mode) - (test . (fboundp 'texinfo-mode)) (type . "application/tex")) ("zip" (viewer . mailcap-save-binary-file) @@ -155,13 +148,11 @@ This is a compatibility function for different Emacsen." ("pdf" (viewer . pdf-view-mode) (type . "application/pdf") - (test . (and (fboundp 'pdf-view-mode) - (eq window-system 'x)))) + (test . (eq window-system 'x))) ("pdf" (viewer . doc-view-mode) (type . "application/pdf") - (test . (and (fboundp 'doc-view-mode) - (eq window-system 'x)))) + (test . (eq window-system 'x))) ("pdf" (viewer . "gv -safer %s") (type . "application/pdf") @@ -202,7 +193,6 @@ This is a compatibility function for different Emacsen." ("copiousoutput")) ("sieve" (viewer . sieve-mode) - (test . (fboundp 'sieve-mode)) (type . "application/sieve")) ("pgp-keys" (viewer . "gpg --import --interactive --verbose") @@ -223,7 +213,6 @@ This is a compatibility function for different Emacsen." (type . "message/rfc822")) ("rfc-*822" (viewer . vm-mode) - (test . (fboundp 'vm-mode)) (type . "message/rfc822")) ("rfc-*822" (viewer . view-mode) @@ -260,18 +249,15 @@ This is a compatibility function for different Emacsen." ("text" ("plain" (viewer . view-mode) - (test . (fboundp 'view-mode)) (type . "text/plain")) ("plain" (viewer . fundamental-mode) (type . "text/plain")) ("enriched" (viewer . enriched-decode) - (test . (fboundp 'enriched-decode)) (type . "text/enriched")) ("dns" (viewer . dns-mode) - (test . (fboundp 'dns-mode)) (type . "text/dns"))) ("video" ("mpeg" @@ -288,8 +274,7 @@ This is a compatibility function for different Emacsen." ("archive" ("tar" (viewer . tar-mode) - (type . "archive/tar") - (test . (fboundp 'tar-mode))))) + (type . "archive/tar")))) "The mailcap structure is an assoc list of assoc lists. 1st assoc list is keyed on the major content-type 2nd assoc list is keyed on the minor content-type (which can be a regexp) @@ -310,9 +295,9 @@ attribute name (viewer, test, etc). This looks like: FLAG) Where VIEWERINFO specifies how the content-type is viewed. Can be -a string, in which case it is run through a shell, with -appropriate parameters, or a symbol, in which case the symbol is -`funcall'ed, with the buffer as an argument. +a string, in which case it is run through a shell, with appropriate +parameters, or a symbol, in which case the symbol is `funcall'ed if +and only if it exists as a function, with the buffer as an argument. TESTINFO is a test for the viewer's applicability, or nil. If nil, it means the viewer is always valid. If it is a Lisp function, it is @@ -658,10 +643,12 @@ to supply to the test." (let* ((test-info (assq 'test viewer-info)) (test (cdr test-info)) (otest test) - (viewer (cdr (assoc 'viewer viewer-info))) + (viewer (cdr (assq 'viewer viewer-info))) (default-directory (expand-file-name "~/")) status parsed-test cache result) - (cond ((setq cache (assoc test mailcap-viewer-test-cache)) + (cond ((not (or (stringp viewer) (fboundp viewer))) + nil) ; Non-existent Lisp function + ((setq cache (assoc test mailcap-viewer-test-cache)) (cadr cache)) ((not test-info) t) ; No test clause (t commit 54f59907f1e30aa9c6345295ee9a689468075802 Author: Ken Brown Date: Wed Oct 21 18:08:36 2015 -0400 Further include-file cleanup * src/sheap.c: Include stdlib.h. * src/unexcw.c: Include string.h. diff --git a/src/sheap.c b/src/sheap.c index 106b279..df33353 100644 --- a/src/sheap.c +++ b/src/sheap.c @@ -20,10 +20,9 @@ along with GNU Emacs. If not, see . */ #include #include - #include "lisp.h" - #include +#include /* for exit */ #ifdef ENABLE_CHECKING #define STATIC_HEAP_SIZE (28 * 1024 * 1024) diff --git a/src/unexcw.c b/src/unexcw.c index be88578..9583598 100644 --- a/src/unexcw.c +++ b/src/unexcw.c @@ -21,7 +21,7 @@ along with GNU Emacs. If not, see . */ #include #include "unexec.h" #include "lisp.h" - +#include #include #include #include commit 5dc48a2da9919f649952e75e54c48fda69a24ac3 Author: Eli Zaretskii Date: Wed Oct 21 19:50:10 2015 +0300 Fix logic in 'server-kill-emacs-query-function' * lisp/server.el (server-kill-emacs-query-function): Correct the logic that controls whether the user is asked for confirmation. (Bug#21723) diff --git a/lisp/server.el b/lisp/server.el index 5a67f12..59fd973 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -1491,13 +1491,12 @@ specifically for the clients and did not exist before their request for it." (defun server-kill-emacs-query-function () "Ask before exiting Emacs if it has live clients." - (or (not server-clients) - (let (live-client) - (dolist (proc server-clients) - (when (memq t (mapcar 'buffer-live-p (process-get - proc 'buffers))) - (setq live-client t))) - live-client) + (or (not (let (live-client) + (dolist (proc server-clients) + (when (memq t (mapcar 'buffer-live-p (process-get + proc 'buffers))) + (setq live-client t))) + live-client)) (yes-or-no-p "This Emacs session has clients; exit anyway? "))) (defun server-kill-buffer () commit e5ece3229d7992f4dcaca93d778c7352d1ba775f Author: Artur Malabarba Date: Wed Oct 21 17:27:23 2015 +0100 * lisp/isearch.el (isearch-search-fun-default): Simplify logic (isearch--lax-regexp-function-p): New function. diff --git a/lisp/isearch.el b/lisp/isearch.el index 61ae42e..6b99da9 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -1725,6 +1725,13 @@ the beginning or the end of the string need not match a symbol boundary." (let ((search-spaces-regexp search-whitespace-regexp)) (re-search-backward regexp bound noerror count))) +(dolist (old '(re-search-forward-lax-whitespace search-backward-lax-whitespace + search-forward-lax-whitespace re-search-backward-lax-whitespace)) + (make-obsolete old + "instead, use (let ((search-spaces-regexp search-whitespace-regexp)) + (re-search-... ...))" + "25.1")) + (defun isearch-query-replace (&optional arg regexp-flag) "Start `query-replace' with string to replace from last search string. @@ -2609,40 +2616,34 @@ search for the first occurrence of STRING or its translation.") Can be changed via `isearch-search-fun-function' for special needs." (funcall (or isearch-search-fun-function 'isearch-search-fun-default))) +(defun isearch--lax-regexp-function-p () + "Non-nil if next regexp-function call should be lax." + (not (or isearch-nonincremental + (null (car isearch-cmds)) + (eq (length isearch-string) + (length (isearch--state-string + (car isearch-cmds))))))) + (defun isearch-search-fun-default () "Return default functions to use for the search." - (cond - (isearch-regexp-function - (lambda (string &optional bound noerror count) - ;; Use lax versions to not fail at the end of the word while - ;; the user adds and removes characters in the search string - ;; (or when using nonincremental word isearch) - (let ((lax (not (or isearch-nonincremental - (null (car isearch-cmds)) - (eq (length isearch-string) - (length (isearch--state-string - (car isearch-cmds))))))) - (search-spaces-regexp (when isearch-lax-whitespace - search-whitespace-regexp))) - (funcall - (if isearch-forward #'re-search-forward #'re-search-backward) - (if (functionp isearch-regexp-function) - (funcall isearch-regexp-function string lax) - (word-search-regexp string lax)) - bound noerror count)))) - ((and isearch-regexp isearch-regexp-lax-whitespace - search-whitespace-regexp) - (if isearch-forward - 're-search-forward-lax-whitespace - 're-search-backward-lax-whitespace)) - (isearch-regexp - (if isearch-forward 're-search-forward 're-search-backward)) - ((and isearch-lax-whitespace search-whitespace-regexp) - (if isearch-forward - 'search-forward-lax-whitespace - 'search-backward-lax-whitespace)) - (t - (if isearch-forward 'search-forward 'search-backward)))) + (lambda (string &optional bound noerror count) + ;; Use lax versions to not fail at the end of the word while + ;; the user adds and removes characters in the search string + ;; (or when using nonincremental word isearch) + (let ((search-spaces-regexp (when (cond + (isearch-regexp isearch-regexp-lax-whitespace) + (t isearch-lax-whitespace)) + search-whitespace-regexp))) + (funcall + (if isearch-forward #'re-search-forward #'re-search-backward) + (cond (isearch-regexp-function + (let ((lax (isearch--lax-regexp-function-p))) + (if (functionp isearch-regexp-function) + (funcall isearch-regexp-function string lax) + (word-search-regexp string lax)))) + (isearch-regexp string) + (t (regexp-quote string))) + bound noerror count)))) (defun isearch-search-string (string bound noerror) "Search for the first occurrence of STRING or its translation. commit 19fada58e2a982024ae31272cc054af80961eb37 Author: Artur Malabarba Date: Wed Oct 21 17:16:36 2015 +0100 * lisp/isearch.el: Support lax-whitespace in regexp-function searches (isearch-search-fun-default): Let-bind `search-spaces-regexp' around `isearch-regexp-function'. diff --git a/lisp/isearch.el b/lisp/isearch.el index 26e6eb1..61ae42e 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -2621,7 +2621,9 @@ Can be changed via `isearch-search-fun-function' for special needs." (null (car isearch-cmds)) (eq (length isearch-string) (length (isearch--state-string - (car isearch-cmds)))))))) + (car isearch-cmds))))))) + (search-spaces-regexp (when isearch-lax-whitespace + search-whitespace-regexp))) (funcall (if isearch-forward #'re-search-forward #'re-search-backward) (if (functionp isearch-regexp-function) commit ab65b33f8c67d5341dae21fc03053e6202077d90 Author: Artur Malabarba Date: Wed Oct 21 17:07:08 2015 +0100 * lisp/isearch.el: Rename word search to regexp-function search `isearch-word' went well beyond its original purpose, and the name no longer makes sense. It is now called `isearch-regexp-function', and it's value should always be a function that converts a string to a regexp (though setting it to t is still supported for now). (isearch-word): Make obsolete. (isearch-regexp-function): New variable. (isearch-mode, isearch-done, isearch--state, isearch--set-state) (with-isearch-suspended, isearch-toggle-regexp) (isearch-toggle-word, isearch-toggle-symbol) (isearch-toggle-character-fold, isearch-query-replace) (isearch-occur, isearch-highlight-regexp) (isearch-search-and-update, isearch-message-prefix) (isearch-search-fun-default, isearch-search) (isearch-lazy-highlight-new-loop, isearch-lazy-highlight-search): Use it. (isearch-lazy-highlight-regexp-function): New var. (isearch-lazy-highlight-word): Make obsolete. (isearch--describe-regexp-mode): New function. (isearch--describe-word-mode): Make obsolete. * lisp/info.el (Info-isearch-search): Use the new var. * lisp/replace.el (replace-search, replace-highlight): Use the new var. * lisp/obsolete/longlines.el (longlines-search-function): Use the new var. * lisp/hexl.el (hexl-isearch-search-function): Use the new var. * lisp/cedet/semantic/senator.el (senator-isearch-search-fun): Use the new var. diff --git a/lisp/cedet/semantic/senator.el b/lisp/cedet/semantic/senator.el index 372e1d9..544abff 100644 --- a/lisp/cedet/semantic/senator.el +++ b/lisp/cedet/semantic/senator.el @@ -813,7 +813,7 @@ Use a senator search function when semantic isearch mode is enabled." (concat (if senator-isearch-semantic-mode "senator-" "") - (cond (isearch-word "word-") + (cond (isearch-regexp-function "word-") (isearch-regexp "re-") (t "")) "search-" diff --git a/lisp/hexl.el b/lisp/hexl.el index 4aa76d2..499253e 100644 --- a/lisp/hexl.el +++ b/lisp/hexl.el @@ -406,7 +406,7 @@ You can use \\[hexl-find-file] to visit a file in Hexl mode. (defun hexl-isearch-search-function () - (if (and (not isearch-regexp) (not isearch-word)) + (if (and (not isearch-regexp) (not isearch-regexp-function)) (lambda (string &optional bound noerror count) (funcall (if isearch-forward 're-search-forward 're-search-backward) diff --git a/lisp/info.el b/lisp/info.el index bd12d56..b11330b 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -2114,14 +2114,14 @@ If DIRECTION is `backward', search in the reverse direction." search-whitespace-regexp))) (Info-search (cond - (isearch-word + (isearch-regexp-function ;; Lax version of word search (let ((lax (not (or isearch-nonincremental (eq (length string) (length (isearch--state-string (car isearch-cmds)))))))) - (if (functionp isearch-word) - (funcall isearch-word string lax) + (if (functionp isearch-regexp-function) + (funcall isearch-regexp-function string lax) (word-search-regexp string lax)))) (isearch-regexp string) (t (regexp-quote string))) diff --git a/lisp/isearch.el b/lisp/isearch.el index 4fc9b38..26e6eb1 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -551,13 +551,16 @@ This is like `describe-bindings', but displays only Isearch keys." (defvar isearch-forward nil) ; Searching in the forward direction. (defvar isearch-regexp nil) ; Searching for a regexp. -(defvar isearch-word nil +(defvar isearch-regexp-function nil "Regexp-based search mode for words/symbols. -If t, do incremental search for a sequence of words, ignoring punctuation. -If the value is a function (e.g. `isearch-symbol-regexp'), it is called to -convert the search string to a regexp used by regexp search functions. -The property `isearch-message-prefix' put on this function specifies the -prefix string displayed in the search message.") +If the value is a function (e.g. `isearch-symbol-regexp'), it is +called to convert a plain search string to a regexp used by +regexp search functions. +The symbol property `isearch-message-prefix' put on this function +specifies the prefix string displayed in the search message.") +;; We still support setting this to t for backwards compatibility. +(define-obsolete-variable-alias 'isearch-word + 'isearch-regexp-function "25.1") (defvar isearch-lax-whitespace t "If non-nil, a space will match a sequence of whitespace chars. @@ -840,7 +843,7 @@ See the command `isearch-forward-symbol' for more information." (put 'character-fold-to-regexp 'isearch-message-prefix "char-fold ") (defvar character-fold-search) -(defun isearch-mode (forward &optional regexp op-fun recursive-edit word) +(defun isearch-mode (forward &optional regexp op-fun recursive-edit regexp-function) "Start Isearch minor mode. It is called by the function `isearch-forward' and other related functions. @@ -856,16 +859,16 @@ does not return to the calling function until the search is completed. To behave this way it enters a recursive-edit and exits it when done isearching. -The arg WORD, if t, does incremental search for a sequence of words, -ignoring punctuation. If the value is a function, it is called to -convert the search string to a regexp used by regexp search functions." +The arg REGEXP-FUNCTION, if non-nil, should be a function. It is +used to set the value of `isearch-regexp-function'." ;; Initialize global vars. (setq isearch-forward forward isearch-regexp regexp - isearch-word (or word (and character-fold-search - (not regexp) - 'character-fold-to-regexp)) + isearch-regexp-function (or regexp-function + (and character-fold-search + (not regexp) + 'character-fold-to-regexp)) isearch-op-fun op-fun isearch-last-case-fold-search isearch-case-fold-search isearch-case-fold-search case-fold-search @@ -1029,7 +1032,7 @@ NOPUSH is t and EDIT is t." (if isearch-resume-in-command-history (let ((command `(isearch-resume ,isearch-string ,isearch-regexp - ,isearch-word ,isearch-forward + ,isearch-regexp-function ,isearch-forward ,isearch-message ',isearch-case-fold-search))) (unless (equal (car command-history) command) @@ -1131,7 +1134,7 @@ REGEXP if non-nil says use the regexp search ring." (success isearch-success) (forward isearch-forward) (other-end isearch-other-end) - (word isearch-word) + (word isearch-regexp-function) (error isearch-error) (wrapped isearch-wrapped) (barrier isearch-barrier) @@ -1157,7 +1160,7 @@ REGEXP if non-nil says use the regexp search ring." isearch-success (isearch--state-success cmd) isearch-forward (isearch--state-forward cmd) isearch-other-end (isearch--state-other-end cmd) - isearch-word (isearch--state-word cmd) + isearch-regexp-function (isearch--state-word cmd) isearch-error (isearch--state-error cmd) isearch-wrapped (isearch--state-wrapped cmd) isearch-barrier (isearch--state-barrier cmd) @@ -1213,7 +1216,7 @@ If MSG is non-nil, use variable `isearch-message', otherwise `isearch-string'." "Exit Isearch mode, run BODY, and reinvoke the pending search. You can update the global isearch variables by setting new values to `isearch-new-string', `isearch-new-message', `isearch-new-forward', -`isearch-new-word', `isearch-new-case-fold'." +`isearch-new-regexp-function', `isearch-new-case-fold'." ;; This code is very hairy for several reasons, explained in the code. ;; Mainly, isearch-mode must be terminated while editing and then restarted. ;; If there were a way to catch any change of buffer from the minibuffer, @@ -1230,7 +1233,7 @@ You can update the global isearch variables by setting new values to (isearch-new-string isearch-string) (isearch-new-message isearch-message) (isearch-new-forward isearch-forward) - (isearch-new-word isearch-word) + (isearch-new-regexp-function isearch-regexp-function) (isearch-new-case-fold isearch-case-fold-search) (isearch-regexp isearch-regexp) @@ -1296,13 +1299,13 @@ You can update the global isearch variables by setting new values to isearch-regexp isearch-op-fun nil - isearch-word) + isearch-regexp-function) ;; Copy new local values to isearch globals (setq isearch-string isearch-new-string isearch-message isearch-new-message isearch-forward isearch-new-forward - isearch-word isearch-new-word + isearch-regexp-function isearch-new-regexp-function isearch-case-fold-search isearch-new-case-fold)) ;; Empty isearch-string means use default. @@ -1493,7 +1496,7 @@ Use `isearch-exit' to quit without signaling." ;; The status stack is left unchanged. (interactive) (setq isearch-regexp (not isearch-regexp)) - (if isearch-regexp (setq isearch-word nil)) + (if isearch-regexp (setq isearch-regexp-function nil)) (setq isearch-success t isearch-adjusted t) (isearch-update)) @@ -1501,26 +1504,30 @@ Use `isearch-exit' to quit without signaling." "Toggle word searching on or off." ;; The status stack is left unchanged. (interactive) - (setq isearch-word (if (eq isearch-word t) nil t)) - (if isearch-word (setq isearch-regexp nil)) + (setq isearch-regexp-function + (if (memq isearch-regexp-function '(t word-search-regexp)) + nil #'word-search-regexp)) + (when isearch-regexp-function (setq isearch-regexp nil)) (setq isearch-success t isearch-adjusted t) (isearch-update)) (defun isearch-toggle-symbol () "Toggle symbol searching on or off." (interactive) - (setq isearch-word (unless (eq isearch-word 'isearch-symbol-regexp) - 'isearch-symbol-regexp)) - (if isearch-word (setq isearch-regexp nil)) + (setq isearch-regexp-function + (unless (eq isearch-regexp-function #'isearch-symbol-regexp) + 'isearch-symbol-regexp)) + (when isearch-regexp-function (setq isearch-regexp nil)) (setq isearch-success t isearch-adjusted t) (isearch-update)) (defun isearch-toggle-character-fold () "Toggle character folding in searching on or off." (interactive) - (setq isearch-word (unless (eq isearch-word #'character-fold-to-regexp) - #'character-fold-to-regexp)) - (if isearch-word (setq isearch-regexp nil)) + (setq isearch-regexp-function + (unless (eq isearch-regexp-function #'character-fold-to-regexp) + #'character-fold-to-regexp)) + (when isearch-regexp-function (setq isearch-regexp nil)) (setq isearch-success t isearch-adjusted t) (isearch-update)) @@ -1767,12 +1774,12 @@ replacements from Isearch is `M-s w ... M-%'." (query-replace-read-to isearch-string (concat "Query replace" - (isearch--describe-word-mode (or delimited isearch-word) t) + (isearch--describe-regexp-mode (or delimited isearch-regexp-function) t) (if isearch-regexp " regexp" "") (if backward " backward" "") (if (and transient-mark-mode mark-active) " in region" "")) isearch-regexp) - t isearch-regexp (or delimited isearch-word) nil nil + t isearch-regexp (or delimited isearch-regexp-function) nil nil (if (and transient-mark-mode mark-active) (region-beginning)) (if (and transient-mark-mode mark-active) (region-end)) backward)) @@ -1799,9 +1806,9 @@ characters in that string." (interactive (let* ((perform-collect (consp current-prefix-arg)) (regexp (cond - ((functionp isearch-word) - (funcall isearch-word isearch-string)) - (isearch-word (word-search-regexp isearch-string)) + ((functionp isearch-regexp-function) + (funcall isearch-regexp-function isearch-string)) + (isearch-regexp-function (word-search-regexp isearch-string)) (isearch-regexp isearch-string) (t (regexp-quote isearch-string))))) (list regexp @@ -1850,9 +1857,9 @@ and reads its face argument using `hi-lock-read-face-name'." (isearch-done nil t) (isearch-clean-overlays)) (require 'hi-lock nil t) - (let ((regexp (cond ((functionp isearch-word) - (funcall isearch-word isearch-string)) - (isearch-word (word-search-regexp isearch-string)) + (let ((regexp (cond ((functionp isearch-regexp-function) + (funcall isearch-regexp-function isearch-string)) + (isearch-regexp-function (word-search-regexp isearch-string)) (isearch-regexp isearch-string) ((if (and (eq isearch-case-fold-search t) search-upper-case) @@ -2057,9 +2064,9 @@ With argument, add COUNT copies of the character." (setq case-fold-search (isearch-no-upper-case-p isearch-string isearch-regexp))) (looking-at (cond - ((functionp isearch-word) - (funcall isearch-word isearch-string t)) - (isearch-word (word-search-regexp isearch-string t)) + ((functionp isearch-regexp-function) + (funcall isearch-regexp-function isearch-string t)) + (isearch-regexp-function (word-search-regexp isearch-string t)) (isearch-regexp isearch-string) (t (regexp-quote isearch-string))))) (error nil)) @@ -2514,20 +2521,22 @@ If there is no completion possible, say so and continue searching." (isearch-message-suffix c-q-hack))) (if c-q-hack m (let ((message-log-max nil)) (message "%s" m))))) -(defun isearch--describe-word-mode (word-mode &optional space-before) - "Make a string for describing WORD-MODE. -If SPACE-BEFORE is non-nil, put a space before, instead of after, +(defun isearch--describe-regexp-mode (regexp-function &optional space-before) + "Make a string for describing REGEXP-FUNCTION. +If SPACE-BEFORE is non-nil, put a space before, instead of after, the word mode." (let ((description - (cond ((and (symbolp word-mode) - (get word-mode 'isearch-message-prefix)) - (get word-mode 'isearch-message-prefix)) - (word-mode "word ") + (cond ((and (symbolp regexp-function) + (get regexp-function 'isearch-message-prefix)) + (get regexp-function 'isearch-message-prefix)) + (regexp-function "word ") (t "")))) (if space-before ;; Move space from the end to the beginning. (replace-regexp-in-string "\\(.*\\) \\'" " \\1" description) description))) +(define-obsolete-function-alias 'isearch--describe-word-mode + 'isearch--describe-regexp-mode "25.1") (defun isearch-message-prefix (&optional ellipsis nonincremental) ;; If about to search, and previous search regexp was invalid, @@ -2556,7 +2565,7 @@ the word mode." (if np (setq prefix (concat np prefix))))) isearch-filter-predicate) prefix) - (isearch--describe-word-mode isearch-word) + (isearch--describe-regexp-mode isearch-regexp-function) (if isearch-regexp "regexp " "") (cond (multi-isearch-file-list "multi-file ") @@ -2603,7 +2612,7 @@ Can be changed via `isearch-search-fun-function' for special needs." (defun isearch-search-fun-default () "Return default functions to use for the search." (cond - (isearch-word + (isearch-regexp-function (lambda (string &optional bound noerror count) ;; Use lax versions to not fail at the end of the word while ;; the user adds and removes characters in the search string @@ -2615,8 +2624,8 @@ Can be changed via `isearch-search-fun-function' for special needs." (car isearch-cmds)))))))) (funcall (if isearch-forward #'re-search-forward #'re-search-backward) - (if (functionp isearch-word) - (funcall isearch-word string lax) + (if (functionp isearch-regexp-function) + (funcall isearch-regexp-function string lax) (word-search-regexp string lax)) bound noerror count)))) ((and isearch-regexp isearch-regexp-lax-whitespace @@ -2721,7 +2730,7 @@ update the match data, and return point." ((and (not isearch-regexp) (string-match "\\`Regular expression too big" isearch-error)) (cond - (isearch-word + (isearch-regexp-function (setq isearch-error "Too many words")) ((and isearch-lax-whitespace search-whitespace-regexp) (setq isearch-error "Too many spaces for whitespace matching")))))) @@ -2964,7 +2973,7 @@ since they have special meaning in a regexp." ;; - `isearch-string' is expected to contain the current search ;; string as entered by the user; ;; - the type of the current search is expected to be given by -;; `isearch-word' and `isearch-regexp'; +;; `isearch-regexp-function' and `isearch-regexp'; ;; - the direction of the current search is expected to be given by ;; `isearch-forward'; ;; - the variable `isearch-error' is expected to be true @@ -2985,7 +2994,9 @@ since they have special meaning in a regexp." (defvar isearch-lazy-highlight-regexp nil) (defvar isearch-lazy-highlight-lax-whitespace nil) (defvar isearch-lazy-highlight-regexp-lax-whitespace nil) -(defvar isearch-lazy-highlight-word nil) +(defvar isearch-lazy-highlight-regexp-function nil) +(define-obsolete-variable-alias 'isearch-lazy-highlight-word + 'isearch-lazy-highlight-regexp-function "25.1") (defvar isearch-lazy-highlight-forward nil) (defvar isearch-lazy-highlight-error nil) @@ -3024,8 +3035,8 @@ by other Emacs features." isearch-case-fold-search)) (not (eq isearch-lazy-highlight-regexp isearch-regexp)) - (not (eq isearch-lazy-highlight-word - isearch-word)) + (not (eq isearch-lazy-highlight-regexp-function + isearch-regexp-function)) (not (eq isearch-lazy-highlight-lax-whitespace isearch-lax-whitespace)) (not (eq isearch-lazy-highlight-regexp-lax-whitespace @@ -3065,7 +3076,7 @@ by other Emacs features." isearch-lazy-highlight-regexp isearch-regexp isearch-lazy-highlight-lax-whitespace isearch-lax-whitespace isearch-lazy-highlight-regexp-lax-whitespace isearch-regexp-lax-whitespace - isearch-lazy-highlight-word isearch-word + isearch-lazy-highlight-regexp-function isearch-regexp-function isearch-lazy-highlight-forward isearch-forward) (unless (equal isearch-string "") (setq isearch-lazy-highlight-timer @@ -3078,7 +3089,7 @@ Attempt to do the search exactly the way the pending Isearch would." (condition-case nil (let ((case-fold-search isearch-lazy-highlight-case-fold-search) (isearch-regexp isearch-lazy-highlight-regexp) - (isearch-word isearch-lazy-highlight-word) + (isearch-regexp-function isearch-lazy-highlight-regexp-function) (isearch-lax-whitespace isearch-lazy-highlight-lax-whitespace) (isearch-regexp-lax-whitespace diff --git a/lisp/obsolete/longlines.el b/lisp/obsolete/longlines.el index 7cb13ce..bfde826 100644 --- a/lisp/obsolete/longlines.el +++ b/lisp/obsolete/longlines.el @@ -464,7 +464,7 @@ This is called by `window-configuration-change-hook'." (defun longlines-search-function () (cond - ((or isearch-word isearch-regexp) (isearch-search-fun-default)) + ((or isearch-regexp-function isearch-regexp) (isearch-search-fun-default)) (isearch-forward #'longlines-search-forward) (t #'longlines-search-backward))) diff --git a/lisp/replace.el b/lisp/replace.el index 3a908ac..d6590c5 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -2013,7 +2013,7 @@ It is called with three arguments, as if it were ;; outside of this function because then another I-search ;; used after `recursive-edit' might override them. (let* ((isearch-regexp regexp-flag) - (isearch-word (or delimited-flag + (isearch-regexp-function (or delimited-flag (and replace-character-fold (not regexp-flag) #'character-fold-to-regexp))) @@ -2046,7 +2046,7 @@ It is called with three arguments, as if it were (if query-replace-lazy-highlight (let ((isearch-string search-string) (isearch-regexp regexp-flag) - (isearch-word delimited-flag) + (isearch-regexp-function delimited-flag) (isearch-lax-whitespace replace-lax-whitespace) (isearch-regexp-lax-whitespace commit f6ece2420c3dc6f3dde06c7f8722f5b0b7e1ef4a Author: Oleh Krehel Date: Wed Oct 21 16:39:36 2015 +0200 Add dired-do-compress-to command bound to "c" * lisp/dired-aux.el (dired-shell-command): Use the caller's `default-directory', return the result of `process-file'. (dired-compress-file-suffixes): Add comment on why "tar -zxf" isn't used by default. (dired-compress-files-alist): New defvar. (dired-do-compress-to): New command. * lisp/dired.el (dired-mode-map): Bind `dired-do-compress-to' to "c". (dired-do-compress-to): Add an autoload entry. * etc/NEWS: Add two entries. diff --git a/etc/NEWS b/etc/NEWS index ef90268..0cb814b 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -275,6 +275,12 @@ header. ** `tabulated-list-print' takes a second optional argument, update, which specifies an alternative printing method which is faster when few or no entries have changed. +** The command `dired-do-compress' bound to `Z' now can compress +directories and decompress zip files. +** New command `dired-do-compress-to' bound to `c' can be used to compress +many marked files into a single named archive. The compression +command is determined from the new `dired-compress-files-alist' +variable. * Editing Changes in Emacs 25.1 diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 98a974a..5cece27 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -788,19 +788,23 @@ Else returns nil for success." (defun dired-shell-command (cmd) "Run CMD, and check for output. -On error, pop up the log buffer." - (let ((out-buffer " *dired-check-process output*")) +On error, pop up the log buffer. +Return the result of `process-file' - zero for success." + (let ((out-buffer " *dired-check-process output*") + (dir default-directory)) (with-current-buffer (get-buffer-create out-buffer) (erase-buffer) - (let ((res (process-file - shell-file-name - nil - t - nil - shell-command-switch - cmd))) + (let* ((default-directory dir) + (res (process-file + shell-file-name + nil + t + nil + shell-command-switch + cmd))) (unless (zerop res) - (pop-to-buffer out-buffer)))))) + (pop-to-buffer out-buffer)) + res)))) ;; Commands that delete or redisplay part of the dired buffer. @@ -880,7 +884,11 @@ command with a prefix argument (the value does not matter)." from-file))) (defvar dired-compress-file-suffixes - '(("\\.tar\\.gz\\'" "" "gzip -dc %i | tar -xv") + '( + ;; "tar -zxf" isn't used because it's not available the on + ;; Solaris10 version of tar. Solaris10 becomes obsolete in 2021. + ;; Same thing on AIX 7.1. + ("\\.tar\\.gz\\'" "" "gzip -dc %i | tar -xv") ("\\.gz\\'" "" "gunzip") ("\\.tgz\\'" ".tar" "gunzip") ("\\.Z\\'" "" "uncompress") @@ -911,6 +919,52 @@ output file. Otherwise, the rule is a compression rule, and compression is done with gzip. ARGS are command switches passed to PROGRAM.") +(defvar dired-compress-files-alist + '(("\\.tar\\.gz\\'" . "tar -c %i | gzip -c9 > %o") + ("\\.zip\\'" . "zip %o -r --filesync %i")) + "Control the compression shell command for `dired-do-compress-to'. + +Each element is (REGEXP . CMD), where REGEXP is the name of the +archive to which you want to compress, and CMD the the +corresponding command. + +Within CMD, %i denotes the input file(s), and %o denotes the +output file. %i path(s) are relative, while %o is absolute.") + +;;;###autoload +(defun dired-do-compress-to () + "Compress selected files and directories to an archive. +You are prompted for the archive name. +The archiving command is chosen based on the archive name extension and +`dired-compress-files-alist'." + (interactive) + (let* ((in-files (dired-get-marked-files)) + (out-file (read-file-name "Compress to: ")) + (rule (cl-find-if + (lambda (x) + (string-match (car x) out-file)) + dired-compress-files-alist))) + (cond ((not rule) + (error + "No compression rule found for %s, see `dired-compress-files-alist'" + out-file)) + ((and (file-exists-p out-file) + (not (y-or-n-p + (format "%s exists, overwrite?" + (abbreviate-file-name out-file))))) + (message "Compression aborted")) + (t + (when (zerop + (dired-shell-command + (replace-regexp-in-string + "%o" out-file + (replace-regexp-in-string + "%i" (mapconcat #'file-name-nondirectory in-files " ") + (cdr rule))))) + (message "Compressed %d file(s) to %s" + (length in-files) + (file-name-nondirectory out-file))))))) + ;;;###autoload (defun dired-compress-file (file) "Compress or uncompress FILE. diff --git a/lisp/dired.el b/lisp/dired.el index e8791f8..bc0139f 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -1466,6 +1466,7 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST." (define-key map "T" 'dired-do-touch) (define-key map "X" 'dired-do-shell-command) (define-key map "Z" 'dired-do-compress) + (define-key map "c" 'dired-do-compress-to) (define-key map "!" 'dired-do-shell-command) (define-key map "&" 'dired-do-async-shell-command) ;; Comparison commands @@ -3896,7 +3897,7 @@ Ask means pop up a menu for the user to select one of copy, move or link." ;;; Start of automatically extracted autoloads. -;;;### (autoloads nil "dired-aux" "dired-aux.el" "c4ed2cda4c70d4b38ab52ad03fa9dfda") +;;;### (autoloads nil "dired-aux" "dired-aux.el" "b946c1770b736ddc39eeef00c39425e7") ;;; Generated autoloads from dired-aux.el (autoload 'dired-diff "dired-aux" "\ @@ -4088,6 +4089,14 @@ command with a prefix argument (the value does not matter). \(fn &optional ARG FMT)" t nil) +(autoload 'dired-do-compress-to "dired-aux" "\ +Compress selected files and directories to an archive. +You are prompted for the archive name. +The archiving command is chosen based on the archive name extension and +`dired-compress-files-alist'. + +\(fn)" t nil) + (autoload 'dired-compress-file "dired-aux" "\ Compress or uncompress FILE. Return the name of the compressed or uncompressed file. commit d60e5a9da157f452d891d92f7337d254a1775787 Author: Tassilo Horn Date: Wed Oct 21 14:17:18 2015 +0200 Make RefTeX work with LaTeX subfiles package * lisp/textmodes/reftex.el (reftex-TeX-master-file): Recognize subfiles document class argument as master file for referencing purposes. diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el index 6641523..84efa7a 100644 --- a/lisp/textmodes/reftex.el +++ b/lisp/textmodes/reftex.el @@ -306,12 +306,28 @@ If the symbols for the current master file do not exist, they are created." (let ((master (cond - ((fboundp 'TeX-master-file) ; AUCTeX is loaded. Use its mechanism. + ;; Test if we're in a subfile using the subfiles document + ;; class, e.g., \documentclass[main.tex]{subfiles}. It's + ;; argument is the main file, however it's not really the + ;; master file in `TeX-master-file' or `tex-main-file's + ;; sense. It should be used for references but not for + ;; compilation, thus subfiles use a setting of + ;; `TeX-master'/`tex-main-file' being themselves. + ((save-excursion + (goto-char (point-min)) + (re-search-forward + "^[[:space:]]*\\\\documentclass\\[\\([[:word:].]+\\)\\]{subfiles}" + nil t)) + (match-string-no-properties 1)) + ;; AUCTeX is loaded. Use its mechanism. + ((fboundp 'TeX-master-file) (condition-case nil (TeX-master-file t) (error (buffer-file-name)))) - ((fboundp 'tex-main-file) (tex-main-file)) ; Emacs LaTeX mode - ((boundp 'TeX-master) ; The variable is defined - let's use it. + ;; Emacs LaTeX mode + ((fboundp 'tex-main-file) (tex-main-file)) + ;; Check the `TeX-master' variable. + ((boundp 'TeX-master) (cond ((eq TeX-master t) (buffer-file-name)) @@ -322,6 +338,7 @@ If the symbols for the current master file do not exist, they are created." (t (setq TeX-master (read-file-name "Master file: " nil nil t nil))))) + ;; Check the `tex-main-file' variable. ((boundp 'tex-main-file) ;; This is the variable from the default TeX modes. (cond @@ -331,8 +348,9 @@ If the symbols for the current master file do not exist, they are created." (t ;; In this case, the buffer is its own master. (buffer-file-name)))) + ;; We know nothing about master file. Assume this is a + ;; master file. (t - ;; Know nothing about master file. Assume this is a master file. (buffer-file-name))))) (cond ((null master)