commit 1393a4d22c4f69fa4cc2f02b70431c28e3c45046 (HEAD, refs/remotes/origin/master) Author: Paul Eggert Date: Tue Aug 30 20:54:05 2016 -0700 ; Spelling and quotation fixes diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index e043578..e54cf30 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi @@ -528,7 +528,7 @@ standard input to an inferior shell running @var{command}. This function is similar than @code{call-process-region}, with process being a shell. The arguments @code{delete}, @code{destination} and the return value are like in @code{call-process-region}. -Note that this funtion doesn't accept additional arguments. +Note that this function doesn't accept additional arguments. @end defun @defun shell-command-to-string command diff --git a/etc/NEWS b/etc/NEWS index ee2bc3a..18975cb 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -56,7 +56,7 @@ affected by this, as SGI stopped supporting IRIX in December 2013. * Changes in Emacs 25.2 +++ -** The new funtion 'call-shell-region' executes a command in an +** The new function 'call-shell-region' executes a command in an inferior shell with the buffer region as input. +++ @@ -240,13 +240,13 @@ all buffers without asking confirmation; bound to 'U'; 'ibuffer-do-replace-regexp' bound to 'r'. --- -*** A new command `ibuffer-mark-by-content-regexp' to mark buffers +*** A new command 'ibuffer-mark-by-content-regexp' to mark buffers whose content matches a regexp; bound to '% g'. --- -*** Two new options `ibuffer-never-search-content-name' and -`ibuffer-never-search-content-mode' used by -`ibuffer-mark-by-content-regexp'. +*** Two new options 'ibuffer-never-search-content-name' and +'ibuffer-never-search-content-mode' used by +'ibuffer-mark-by-content-regexp'. ** Compilation mode @@ -373,7 +373,7 @@ different group ID. Drive onsite repositories. +++ -Setting the "ENV" environment variable in `tramp-remote-process-environment' +Setting the "ENV" environment variable in 'tramp-remote-process-environment' enables reading of shell initialization files. --- @@ -441,7 +441,7 @@ file. * New Modes and Packages in Emacs 25.2 -** New Elisp data-structure library `radix-tree'. +** New Elisp data-structure library 'radix-tree'. * Incompatible Lisp Changes in Emacs 25.2 @@ -478,9 +478,9 @@ function 'check-declare-errmsg' has been removed. ** New function undo-amalgamate-change-group to get rid of undo-boundaries between two states. -** New var `definition-prefixes' is a hashtable mapping prefixes to the +** New var 'definition-prefixes' is a hashtable mapping prefixes to the files where corresponding definitions can be found. This can be used -to fetch definitions that are not yet loaded, for example for `C-h f'. +to fetch definitions that are not yet loaded, for example for 'C-h f'. ** New var syntax-ppss-table to control the syntax-table used in syntax-ppss. @@ -580,11 +580,11 @@ ABBR is a time zone abbreviation. The affected functions are *** New basic face 'fixed-pitch-serif', for a fixed-width font with serifs. The Info-quoted and tex-verbatim faces now default to inheriting from it. -** New built-in function `mapcan' which avoids unnecessary consing (and garbage +** New built-in function 'mapcan' which avoids unnecessary consing (and garbage collection). +++ -** The new functions `make-nearby-temp-file' and `temporary-file-directory' +** The new functions 'make-nearby-temp-file' and 'temporary-file-directory' can be used for creation of temporary files of remote or mounted directories. diff --git a/lisp/ChangeLog.17 b/lisp/ChangeLog.17 index bbf25b6..1361e7a 100644 --- a/lisp/ChangeLog.17 +++ b/lisp/ChangeLog.17 @@ -8033,7 +8033,7 @@ 2014-08-24 Alan Mackenzie Handle C++11's "auto" and "decltype" constructions. - * progmodes/cc-engine.el (c-forward-type): Enhance to recognise + * progmodes/cc-engine.el (c-forward-type): Enhance to recognize and return 'decltype. (c-forward-decl-or-cast-1): New let variables backup-kwd-sym, prev-kwd-sym, new-style-auto. Enhance to handle the new "auto" @@ -13542,7 +13542,7 @@ c-parse-state. Don't "append-lower-brace-pair" in certain circumstances. Also fix an obscure bug where "\\s!" shouldn't be - recognised as a comment. + recognized as a comment. * progmodes/cc-engine.el (c-state-pp-to-literal): Check for "\\s!" as well as normal comment starter. @@ -17480,7 +17480,7 @@ after a function declaration with only types (no identifiers) in the parentheses. Also, accept a function declaration with just a type inside the parentheses, if this type can be positively - recognised as such, or if a prefix keyword like "explicit" nails + recognized as such, or if a prefix keyword like "explicit" nails down the construct as a declaration. 2013-10-19 Eli Zaretskii diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 83ed308..2cad2d0 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -8136,7 +8136,7 @@ comment at the start of cc-engine.el for more info." (and (not context) ;; Deal with C++11's "copy-initialization" ;; where we have (), by - ;; contraasting with a typeless + ;; contrasting with a typeless ;; (, ...). (save-excursion (goto-char after-paren-pos) @@ -9839,7 +9839,7 @@ comment at the start of cc-engine.el for more info." ;; return t. If point is definitely neither at nor in a brace list, return ;; nil. ;; - ;; CONTAINING-SEXP is the position of the brace/paren/braacket enclosing + ;; CONTAINING-SEXP is the position of the brace/paren/bracket enclosing ;; POINT, or nil if there is no such position, or we do not know it. LIM is ;; a backward search limit. ;; @@ -9856,7 +9856,7 @@ comment at the start of cc-engine.el for more info." (setq res (c-backward-token-2 1 t lim)) ;; Checks to do only on the first sexp before the brace. - ;; Have we a C++ initialisation, without an "="? + ;; Have we a C++ initialization, without an "="? (if (and (c-major-mode-is 'c++-mode) (cond ((and (not (eq res 0)) diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el index a23dddf..735108f 100644 --- a/lisp/progmodes/cc-fonts.el +++ b/lisp/progmodes/cc-fonts.el @@ -1205,7 +1205,7 @@ casts and declarations are fontified. Used on level 2 and higher." (setq start-pos (point)) (when ;; The result of the form below is true when we don't recognize a - ;; declaration or cast, and we don't recognise a "non-decl", + ;; declaration or cast, and we don't recognize a "non-decl", ;; typically a brace list. (if (or (and (eq (get-text-property (point) 'face) 'font-lock-keyword-face) diff --git a/test/manual/etags/html-src/software.html b/test/manual/etags/html-src/software.html index dbf8228..f1abba7 100644 --- a/test/manual/etags/html-src/software.html +++ b/test/manual/etags/html-src/software.html @@ -168,7 +168,7 @@
Shows the location of the first read error detected. Can extract a disk Id from the image or the CD itself and build a local database of Ids for future checking of archived CDs. The Id contains the image length, the MD5 - signature and the Volume ID of the disk, so it can automatically recognise + signature and the Volume ID of the disk, so it can automatically recognize the CD to check. Contains a small internal database of Debian CD images. commit f24011b4d17da2b39b180fb091d2e6b83aee0d57 Author: Paul Eggert Date: Tue Aug 30 19:54:35 2016 -0700 * src/editfns.c (Fformat_message): Fix doc to match current behavior. diff --git a/src/editfns.c b/src/editfns.c index a46e33b..20cb3a8 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -3906,10 +3906,9 @@ DEFUN ("format-message", Fformat_message, Sformat_message, 1, MANY, 0, The first argument is a format control string. The other arguments are substituted into it to make the result, a string. -This acts like `format', except it also replaces each left single -quotation mark (‘) and grave accent (\\=`) by a left quote, and each -right single quotation mark (’) and apostrophe (\\=') by a right quote. -The left and right quote replacement characters are specified by +This acts like `format', except it also replaces each grave accent (\\=`) +by a left quote, and each apostrophe (\\=') by a right quote. The left +and right quote replacement characters are specified by `text-quoting-style'. usage: (format-message STRING &rest OBJECTS) */) commit 6f40b8b23a7c4dcc1ad07e0ad9d32609d21c9f79 Author: Paul Eggert Date: Tue Aug 30 19:44:41 2016 -0700 Minor doc quoting fixes * doc/misc/htmlfontify.texi (Interactive): * lisp/htmlfontify.el (htmlfontify-buffer): Spell out character names, for clarity. The old doc string generated the *Help* text ‘^L ([FF]) or ¤ (244)’, where ‘[FF]’ stands for a form feed character; this was confusing. * lisp/electric.el (electric-quote-mode): * src/doc.c (syms_of_doc): * src/editfns.c (Fformat_message): Remove no-longer-necessary ‘\=’s in doc strings. diff --git a/doc/misc/htmlfontify.texi b/doc/misc/htmlfontify.texi index 20cde71..9cb1d6f 100644 --- a/doc/misc/htmlfontify.texi +++ b/doc/misc/htmlfontify.texi @@ -126,7 +126,8 @@ entities, so you should even be able to do html-within-html fontified display. You should, however, note that random control or non-ASCII characters -such as ^L (\x0c) or ¤ (\xa4) won't get mapped yet. +such as ^L (U+000C FORM FEED (FF)) or ¤ (U+00A4 CURRENCY SIGN) won't +get mapped yet. If the @var{srcdir} and @var{file} arguments are set, lookup etags derived entries in the @ref{hfy-tags-cache} and add html anchors diff --git a/lisp/electric.el b/lisp/electric.el index e289601..0ec0a1e 100644 --- a/lisp/electric.el +++ b/lisp/electric.el @@ -491,7 +491,7 @@ With a prefix argument ARG, enable Electric Quote mode if ARG is positive, and disable it otherwise. If called from Lisp, enable the mode if ARG is omitted or nil. -When enabled, as you type this replaces \\=` with \\=‘, \\=' with \\=’, +When enabled, as you type this replaces \\=` with ‘, \\=' with ’, \\=`\\=` with “, and \\='\\=' with ”. This occurs only in comments, strings, and text paragraphs, and these are selectively controlled with `electric-quote-comment', `electric-quote-string', and diff --git a/lisp/htmlfontify.el b/lisp/htmlfontify.el index 431300c..8cbe3c1 100644 --- a/lisp/htmlfontify.el +++ b/lisp/htmlfontify.el @@ -1849,8 +1849,9 @@ Dangerous characters in the existing buffer are turned into HTML entities, so you should even be able to do HTML-within-HTML fontified display. -You should, however, note that random control or eight-bit -characters such as ^L (\x0c) or ¤ (\xa4) won't get mapped yet. +You should, however, note that random control or non-ASCII +characters such as ^L (U+000C FORM FEED (FF)) or ¤ (U+00A4 +CURRENCY SIGN) won't get mapped yet. If the SRCDIR and FILE arguments are set, lookup etags derived entries in the `hfy-tags-cache' and add HTML anchors and diff --git a/src/doc.c b/src/doc.c index 6376398..ce4f89b 100644 --- a/src/doc.c +++ b/src/doc.c @@ -1014,7 +1014,7 @@ quotes for grave accent and apostrophe. This is done in help output and in functions like `message' and `format-message'. It is not done in `format'. -`curve' means quote with curved single quotes \\=‘like this\\=’. +`curve' means quote with curved single quotes ‘like this’. `straight' means quote with straight apostrophes \\='like this\\='. `grave' means quote with grave accent and apostrophe \\=`like this\\='; i.e., do not alter quote marks. The default value nil acts like diff --git a/src/editfns.c b/src/editfns.c index 26a86c7..a46e33b 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -3907,8 +3907,8 @@ The first argument is a format control string. The other arguments are substituted into it to make the result, a string. This acts like `format', except it also replaces each left single -quotation mark (\\=‘) and grave accent (\\=`) by a left quote, and each -right single quotation mark (\\=’) and apostrophe (\\=') by a right quote. +quotation mark (‘) and grave accent (\\=`) by a left quote, and each +right single quotation mark (’) and apostrophe (\\=') by a right quote. The left and right quote replacement characters are specified by `text-quoting-style'. commit 6cf3ee3d5474a61d6615a6a21d9e7723f7ba9151 Author: Paul Eggert Date: Tue Aug 30 13:15:04 2016 -0700 Update from gnulib This incorporates: 2016-08-30 intprops: tune INT_NEGATE_OVERFLOW for GCC 5 and 6 2016-08-29 xalloc-oversized.h: port change to GCC 6.2.0 2016-08-29 intprops.h: port recent changes to GCC 6.2.0 2016-08-29 intprops.h: use __typeof__ with GCC 7 2016-08-29 intprops.h, xalloc-oversized.h: work with gcc 7 2016-08-24 intprops: fix paren typo on old platforms 2016-08-24 intprops: port to OpenVMS * lib/intprops.h, lib/xalloc-oversized.h: Copy from gnulib. diff --git a/lib/intprops.h b/lib/intprops.h index e1fce5c..7e832bc 100644 --- a/lib/intprops.h +++ b/lib/intprops.h @@ -23,6 +23,10 @@ #include #include +#ifndef __has_builtin +# define __has_builtin(x) 0 +#endif + /* Return a value with the common real type of E and V and the value of V. */ #define _GL_INT_CONVERT(e, v) (0 * (e) + (v)) @@ -67,6 +71,12 @@ #define _GL_SIGNED_INT_MAXIMUM(e) \ (((_GL_INT_CONVERT (e, 1) << (sizeof ((e) + 0) * CHAR_BIT - 2)) - 1) * 2 + 1) +/* Work around OpenVMS incompatibility with C99. */ +#if !defined LLONG_MAX && defined __INT64_MAX +# define LLONG_MAX __INT64_MAX +# define LLONG_MIN __INT64_MIN +#endif + /* This include file assumes that signed types are two's complement without padding bits; the above macros have undefined behavior otherwise. If this is a problem for you, please let us know how to fix it for your host. @@ -222,20 +232,25 @@ verify (TYPE_MAXIMUM (long long int) == LLONG_MAX); ? (a) < (min) >> (b) \ : (max) >> (b) < (a)) -/* True if __builtin_add_overflow (A, B, P) works when P is null. */ -#define _GL_HAS_BUILTIN_OVERFLOW_WITH_NULL (7 <= __GNUC__) +/* True if __builtin_add_overflow (A, B, P) works when P is non-null. */ +#define _GL_HAS_BUILTIN_OVERFLOW \ + (5 <= __GNUC__ || __has_builtin (__builtin_add_overflow)) + +/* True if __builtin_add_overflow_p (A, B, C) works. */ +#define _GL_HAS_BUILTIN_OVERFLOW_P \ + (7 <= __GNUC__ || __has_builtin (__builtin_add_overflow_p)) /* The _GL*_OVERFLOW macros have the same restrictions as the *_RANGE_OVERFLOW macros, except that they do not assume that operands (e.g., A and B) have the same type as MIN and MAX. Instead, they assume that the result (e.g., A + B) has that type. */ -#if _GL_HAS_BUILTIN_OVERFLOW_WITH_NULL -# define _GL_ADD_OVERFLOW(a, b, min, max) - __builtin_add_overflow (a, b, (__typeof__ ((a) + (b)) *) 0) -# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) - __builtin_sub_overflow (a, b, (__typeof__ ((a) - (b)) *) 0) -# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) - __builtin_mul_overflow (a, b, (__typeof__ ((a) * (b)) *) 0) +#if _GL_HAS_BUILTIN_OVERFLOW_P +# define _GL_ADD_OVERFLOW(a, b, min, max) \ + __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0) +# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \ + __builtin_sub_overflow_p (a, b, (__typeof__ ((a) - (b))) 0) +# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \ + __builtin_mul_overflow_p (a, b, (__typeof__ ((a) * (b))) 0) #else # define _GL_ADD_OVERFLOW(a, b, min, max) \ ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \ @@ -315,7 +330,7 @@ verify (TYPE_MAXIMUM (long long int) == LLONG_MAX); _GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW) #define INT_SUBTRACT_OVERFLOW(a, b) \ _GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW) -#if _GL_HAS_BUILTIN_OVERFLOW_WITH_NULL +#if _GL_HAS_BUILTIN_OVERFLOW_P # define INT_NEGATE_OVERFLOW(a) INT_SUBTRACT_OVERFLOW (0, a) #else # define INT_NEGATE_OVERFLOW(a) \ @@ -349,10 +364,6 @@ verify (TYPE_MAXIMUM (long long int) == LLONG_MAX); #define INT_MULTIPLY_WRAPV(a, b, r) \ _GL_INT_OP_WRAPV (a, b, r, *, __builtin_mul_overflow, INT_MULTIPLY_OVERFLOW) -#ifndef __has_builtin -# define __has_builtin(x) 0 -#endif - /* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193 https://llvm.org/bugs/show_bug.cgi?id=25390 @@ -369,7 +380,7 @@ verify (TYPE_MAXIMUM (long long int) == LLONG_MAX); the operation. BUILTIN is the builtin operation, and OVERFLOW the overflow predicate. Return 1 if the result overflows. See above for restrictions. */ -#if 5 <= __GNUC__ || __has_builtin (__builtin_add_overflow) +#if _GL_HAS_BUILTIN_OVERFLOW # define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) builtin (a, b, r) #elif 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS # define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \ @@ -412,7 +423,7 @@ verify (TYPE_MAXIMUM (long long int) == LLONG_MAX); # else # define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ - long int, LONG_MIN, LONG_MAX)) + long int, LONG_MIN, LONG_MAX) # endif #endif diff --git a/lib/xalloc-oversized.h b/lib/xalloc-oversized.h index 44f1644..53e6556 100644 --- a/lib/xalloc-oversized.h +++ b/lib/xalloc-oversized.h @@ -43,16 +43,8 @@ nonnegative. This is a macro, not a function, so that it works correctly even when SIZE_MAX < N. */ -/* GCC 7 __builtin_mul_overflow should easily compute this. See: - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68120 */ -#if 7 <= __GNUC__ -# define xalloc_oversized(n, s) __builtin_mul_overflow (n, s, (size_t *) NULL) - -/* GCC 5 and Clang __builtin_mul_overflow needs a temporary, and - should be used only for non-constant operands, so that - xalloc_oversized is a constant expression if both arguments are. - Do not use this if pedantic, since pedantic GCC issues a diagnostic - for ({ ... }). */ +#if 7 <= __GNUC__ || __has_builtin (__builtin_add_overflow_p) +# define xalloc_oversized(n, s) __builtin_mul_overflow_p (n, s, (size_t) 1) #elif ((5 <= __GNUC__ \ || (__has_builtin (__builtin_mul_overflow) \ && __has_builtin (__builtin_constant_p))) \ commit 1145322a114bb7359fcfdbdce6ccb7d9d44c82ba Author: Tassilo Horn Date: Tue Aug 30 20:30:46 2016 +0200 Fix rules for \phi and \varphi which were reversed * lisp/leim/quail/latin-ltx.el: Special-case phi/varphi because those are reversed in ucs-names. Also remove FIXME stating sigma/varsigma were reversed which is not true (anymore?). diff --git a/lisp/leim/quail/latin-ltx.el b/lisp/leim/quail/latin-ltx.el index c265add..fb3d2ba 100644 --- a/lisp/leim/quail/latin-ltx.el +++ b/lisp/leim/quail/latin-ltx.el @@ -239,10 +239,15 @@ system, including many technical ones. Examples: "\\`\\([^- ]+\\) SIGN\\'") ((lambda (name char) - (concat "\\" (funcall (if (match-end 1) #' capitalize #'downcase) - (match-string 2 name)))) + ;; "GREEK SMALL LETTER PHI" (which is \phi) and "GREEK PHI SYMBOL" + ;; (which is \varphi) are reversed in `ucs-names', so we define + ;; them manually. + (unless (string-match-p "\\" name) + (concat "\\" (funcall (if (match-end 1) #' capitalize #'downcase) + (match-string 2 name))))) "\\`GREEK \\(?:SMALL\\|CAPITA\\(L\\)\\) LETTER \\([^- ]+\\)\\'") + ("\\phi" ?ϕ) ("\\Box" ?□) ("\\Bumpeq" ?≎) ("\\Cap" ?⋒) @@ -628,12 +633,17 @@ system, including many technical ones. Examples: ("\\vDash" ?⊨) ((lambda (name char) - (concat "\\var" (downcase (match-string 1 name)))) + ;; "GREEK SMALL LETTER PHI" (which is \phi) and "GREEK PHI SYMBOL" + ;; (which is \varphi) are reversed in `ucs-names', so we define + ;; them manually. + (unless (string-match-p "\\" name) + (concat "\\var" (downcase (match-string 1 name))))) "\\`GREEK \\([^- ]+\\) SYMBOL\\'") + ("\\varphi" ?φ) ("\\varprime" ?′) ("\\varpropto" ?∝) - ("\\varsigma" ?ς) ;FIXME: Looks reversed with the non\var. + ("\\varsigma" ?ς) ("\\vartriangleleft" ?⊲) ("\\vartriangleright" ?⊳) ("\\vdash" ?⊢) commit 6730432053f3ad2ce144db2fcd685ee1ad76f881 Author: Tassilo Horn Date: Tue Aug 30 19:51:33 2016 +0200 Fix prettification of \phi, \varphi, and \varsigma * lisp/textmodes/tex-mode.el (tex--prettify-symbols-alist): Fix prettification of \phi, \varphi, and \varsigma. Concretely, \phi's symbol was actually varphi, \varphi was missing, and \varsigma was commented out with a FIXME that it was reversed with \sigma which it was not. diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index 4430fd6..4562828 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -2991,7 +2991,7 @@ There might be text before point." ("\\sigma" . ?σ) ("\\tau" . ?τ) ("\\upsilon" . ?υ) - ("\\phi" . ?φ) + ("\\phi" . ?ϕ) ("\\chi" . ?χ) ("\\psi" . ?ψ) ("\\omega" . ?ω) @@ -3380,10 +3380,11 @@ There might be text before point." ("\\u{i}" . ?ĭ) ("\\vDash" . ?⊨) ("\\varepsilon" . ?ε) + ("\\varphi" . ?φ) ("\\varprime" . ?′) ("\\varpropto" . ?∝) ("\\varrho" . ?ϱ) - ;; ("\\varsigma" ?ς) ;FIXME: Looks reversed with the non\var. + ("\\varsigma" ?ς) ("\\vartriangleleft" . ?⊲) ("\\vartriangleright" . ?⊳) ("\\vdash" . ?⊢) commit 2b404e8391b7ac26b734710d8290a6ef6a2e32b1 Author: Karl Fogel Date: Tue Aug 30 11:14:37 2016 -0500 Use normal double quotes in TeX / LaTeX comments * lisp/textmodes/tex-mode.el (tex-insert-quote): When in a comment, default to inserting a normal double quote (") instead of TeX-style open (``) or close ('') quote marks. * etc/NEWS (TeX mode): Note the change. * test/lisp/electric-tests.el (autowrapping-7): Adjust accordingly. See this thread for discussion: https://lists.gnu.org/archive/html/emacs-devel/2016-08/msg00611.html From: Karl Fogel To: Emacs Development Subject: [PATCH] Have LaTeX mode use normal double quotes in comments. Date: Mon, 29 Aug 2016 14:44:12 -0500 Message-ID: <87twe3icmr.fsf@red-bean.com> diff --git a/etc/NEWS b/etc/NEWS index 1290fa4..ee2bc3a 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1477,6 +1477,9 @@ looking for macro definitions. By default, no symbols are ignored. ** TeX mode +*** When in a TeX (LaTeX, etc) comment, insert a normal double quote (") +instead of defaulting to TeX-style open (``) or close ('') quote marks. + *** New custom variable 'tex-print-file-extension' to help users who use PDF instead of DVI. diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index 710899f..4430fd6 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -1311,6 +1311,7 @@ inserts \" characters." ;; (if (or arg (memq (char-syntax (preceding-char)) '(?/ ?\\)) (eq (get-text-property (point) 'face) 'tex-verbatim) + (nth 4 (syntax-ppss)) ; non-nil if point is in a TeX comment ;; Discover if a preceding occurrence of `tex-open-quote' ;; should be morphed to a normal double quote. ;; diff --git a/test/lisp/electric-tests.el b/test/lisp/electric-tests.el index afd7076..17b4e02 100644 --- a/test/lisp/electric-tests.el +++ b/test/lisp/electric-tests.el @@ -578,6 +578,7 @@ baz\"\"" (define-electric-pair-test autowrapping-7 "foo" "\"" :expected-string "``foo''" :expected-point 8 :modes '(tex-mode) + :test-in-comments nil :fixture-fn #'(lambda () (electric-pair-mode 1) (goto-char (point-max)) commit a9118afcd7d601190c5474820b58289b5ab5cd7e Author: Alan Mackenzie Date: Tue Aug 30 15:36:15 2016 +0000 Correctly analyze C++ list initialization in member init areas. * lisp/progmodes/cc-engine.el (c-back-over-list-of-member-inits): Remove a superfluous call to c-backward-syntactic-ws. (c-looking-at-or-maybe-in-bracelist): Change calling convention, so that it reports encountering the Java "new" keyword. Add, as an alternative, a check that we can move back over member initializations, and handle this as finding a brace block. (c-looking-at-special-brace-list, c-guess-continued-construct): Adapt to the new calling convention of c-looking-at-or-maybe-in-bracelist. (c-guess-basic-syntax, CASE 5A.3): Replace lots of inline ad-hoc code with calls to c-backward-over-enum-header and c-looking-at-or-maybe-in-bracelist, using the extra info from the value of that function to generate a topmost-into-cont element where needed (in Java). * lisp/progmodes/cc-fonts.el (c-font-lock-declarations): Adapt to the new calling convention of c-looking-at-or-maybe-in-bracelist. * lisp/progmodes/cc-mode.el (c-fl-decl-start): Adapt to the new calling convention of c-looking-at-or-maybe-in-bracelist. diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 28d6618..83ed308 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -7434,7 +7434,6 @@ comment at the start of cc-engine.el for more info." (when (not (c-backward-<>-arglist nil)) (throw 'done nil)) (c-backward-syntactic-ws)) - (c-backward-syntactic-ws) (when (not (c-back-over-compound-identifier)) (throw 'level nil)) (c-backward-syntactic-ws))) @@ -9831,15 +9830,18 @@ comment at the start of cc-engine.el for more info." (or (looking-at c-brace-list-key) (progn (goto-char here) nil)))) -(defun c-looking-at-or-maybe-in-bracelist (containing-sexp &optional lim) - ;; Point is at an open brace. If this starts a brace list, return the - ;; buffer position of the start of the construct which introduces the list. - ;; Otherwise, if point might be inside an enclosing brace list, return t. - ;; If point is definitely neither at nor in a brace list, return nil. +(defun c-looking-at-or-maybe-in-bracelist (&optional containing-sexp lim) + ;; Point is at an open brace. If this starts a brace list, return a list + ;; whose car is the buffer position of the start of the construct which + ;; introduces the list, and whose cdr is t if we have parsed a keyword + ;; matching `c-opt-inexpr-brace-list-key' (e.g. Java's "new"), nil + ;; otherwise. Otherwise, if point might be inside an enclosing brace list, + ;; return t. If point is definitely neither at nor in a brace list, return + ;; nil. ;; ;; CONTAINING-SEXP is the position of the brace/paren/braacket enclosing - ;; POINT, or nil if there is no such position. LIM is a backward search - ;; limit. + ;; POINT, or nil if there is no such position, or we do not know it. LIM is + ;; a backward search limit. ;; ;; Here, "brace list" does not include the body of an enum. (save-excursion @@ -9850,7 +9852,7 @@ comment at the start of cc-engine.el for more info." (and (c-major-mode-is 'pike-mode) c-decl-block-key)) (braceassignp 'dontknow) - bufpos macro-start res after-type-id-pos) + inexpr-brace-list bufpos macro-start res pos after-type-id-pos) (setq res (c-backward-token-2 1 t lim)) ;; Checks to do only on the first sexp before the brace. @@ -9886,7 +9888,9 @@ comment at the start of cc-engine.el for more info." (while (eq braceassignp 'dontknow) (setq braceassignp (cond ((/= (c-backward-token-2 1 t lim) 0) nil) - ((looking-at c-opt-inexpr-brace-list-key) t) + ((looking-at c-opt-inexpr-brace-list-key) + (setq inexpr-brace-list t) + t) ((looking-at "\\sw\\|\\s_\\|[.[]") ;; Carry on looking if this is an ;; identifier (may contain "." in Java) @@ -9894,104 +9898,116 @@ comment at the start of cc-engine.el for more info." 'dontknow) (t nil))))) - ;; Checks to do on all sexps before the brace, up to the - ;; beginning of the statement. - (while (eq braceassignp 'dontknow) - (cond ((eq (char-after) ?\;) - (setq braceassignp nil)) - ((and class-key - (looking-at class-key)) - (setq braceassignp nil)) - ((eq (char-after) ?=) - ;; We've seen a =, but must check earlier tokens so - ;; that it isn't something that should be ignored. - (setq braceassignp 'maybe) - (while (and (eq braceassignp 'maybe) - (zerop (c-backward-token-2 1 t lim))) - (setq braceassignp - (cond - ;; Check for operator = - ((and c-opt-op-identifier-prefix - (looking-at c-opt-op-identifier-prefix)) - nil) - ;; Check for `= in Pike. - ((and (c-major-mode-is 'pike-mode) - (or (eq (char-after) ?`) - ;; Special case for Pikes - ;; `[]=, since '[' is not in - ;; the punctuation class. - (and (eq (char-after) ?\[) - (eq (char-before) ?`)))) - nil) - ((looking-at "\\s.") 'maybe) - ;; make sure we're not in a C++ template - ;; argument assignment - ((and - (c-major-mode-is 'c++-mode) - (save-excursion - (let ((here (point)) - (pos< (progn - (skip-chars-backward "^<>") - (point)))) - (and (eq (char-before) ?<) - (not (c-crosses-statement-barrier-p - pos< here)) - (not (c-in-literal)) - )))) - nil) - (t t)))))) - (if (and (eq braceassignp 'dontknow) - (/= (c-backward-token-2 1 t lim) 0)) - (setq braceassignp nil))) + (setq pos (point)) + (if (and after-type-id-pos + (goto-char after-type-id-pos) + (setq res (c-back-over-member-initializers)) + (goto-char res) + (eq (car (c-beginning-of-decl-1 lim)) 'same)) + (cons (point) nil) ; Return value. + + (goto-char pos) + ;; Checks to do on all sexps before the brace, up to the + ;; beginning of the statement. + (while (eq braceassignp 'dontknow) + (cond ((eq (char-after) ?\;) + (setq braceassignp nil)) + ((and class-key + (looking-at class-key)) + (setq braceassignp nil)) + ((eq (char-after) ?=) + ;; We've seen a =, but must check earlier tokens so + ;; that it isn't something that should be ignored. + (setq braceassignp 'maybe) + (while (and (eq braceassignp 'maybe) + (zerop (c-backward-token-2 1 t lim))) + (setq braceassignp + (cond + ;; Check for operator = + ((and c-opt-op-identifier-prefix + (looking-at c-opt-op-identifier-prefix)) + nil) + ;; Check for `= in Pike. + ((and (c-major-mode-is 'pike-mode) + (or (eq (char-after) ?`) + ;; Special case for Pikes + ;; `[]=, since '[' is not in + ;; the punctuation class. + (and (eq (char-after) ?\[) + (eq (char-before) ?`)))) + nil) + ((looking-at "\\s.") 'maybe) + ;; make sure we're not in a C++ template + ;; argument assignment + ((and + (c-major-mode-is 'c++-mode) + (save-excursion + (let ((here (point)) + (pos< (progn + (skip-chars-backward "^<>") + (point)))) + (and (eq (char-before) ?<) + (not (c-crosses-statement-barrier-p + pos< here)) + (not (c-in-literal)) + )))) + nil) + (t t)))))) + (if (and (eq braceassignp 'dontknow) + (/= (c-backward-token-2 1 t lim) 0)) + (setq braceassignp nil))) - (cond - (braceassignp - ;; We've hit the beginning of the aggregate list. - (c-beginning-of-statement-1 containing-sexp) - (point)) - ((and after-type-id-pos - (save-excursion - (when (eq (char-after) ?\;) - (c-forward-token-2 1 t)) - (setq bufpos (point)) - (when (looking-at c-opt-<>-sexp-key) - (c-forward-token-2) - (when (and (eq (char-after) ?<) - (c-get-char-property (point) 'syntax-table)) - (c-go-list-forward nil after-type-id-pos) - (c-forward-syntactic-ws))) - (and - (or (not (looking-at c-class-key)) - (save-excursion - (goto-char (match-end 1)) - (c-forward-syntactic-ws) - (not (eq (point) after-type-id-pos)))) - (progn - (setq res - (c-forward-decl-or-cast-1 - (save-excursion (c-backward-syntactic-ws) (point)) - nil nil)) - (and (consp res) - (eq (car res) after-type-id-pos)))))) - bufpos) - ((eq (char-after) ?\;) - ;; Brace lists can't contain a semicolon, so we're done. - ;; (setq containing-sexp nil) - nil) - ((and (setq macro-start (point)) - (c-forward-to-cpp-define-body) - (eq (point) start)) - ;; We've a macro whose expansion starts with the '{'. - ;; Heuristically, if we have a ';' in it we've not got a - ;; brace list, otherwise we have. - (let ((macro-end (progn (c-end-of-macro) (point)))) - (goto-char start) - (forward-char) - (if (and (c-syntactic-re-search-forward "[;,]" macro-end t t) - (eq (char-before) ?\;)) - nil - macro-start))) - (t t)) ;; The caller can go up one level. + (cond + (braceassignp + ;; We've hit the beginning of the aggregate list. + (c-beginning-of-statement-1 containing-sexp) + (cons (point) inexpr-brace-list)) + ((and after-type-id-pos + (save-excursion + (when (eq (char-after) ?\;) + (c-forward-token-2 1 t)) + (setq bufpos (point)) + (when (looking-at c-opt-<>-sexp-key) + (c-forward-token-2) + (when (and (eq (char-after) ?<) + (c-get-char-property (point) 'syntax-table)) + (c-go-list-forward nil after-type-id-pos) + (c-forward-syntactic-ws))) + (and + (or (not (looking-at c-class-key)) + (save-excursion + (goto-char (match-end 1)) + (c-forward-syntactic-ws) + (not (eq (point) after-type-id-pos)))) + (progn + (setq res + (c-forward-decl-or-cast-1 + (save-excursion (c-backward-syntactic-ws) (point)) + nil nil)) + (and (consp res) + (eq (car res) after-type-id-pos)))))) + (cons bufpos inexpr-brace-list)) + ((eq (char-after) ?\;) + ;; Brace lists can't contain a semicolon, so we're done. + ;; (setq containing-sexp nil) + nil) + ((and (setq macro-start (point)) + (c-forward-to-cpp-define-body) + (eq (point) start)) + ;; We've a macro whose expansion starts with the '{'. + ;; Heuristically, if we have a ';' in it we've not got a + ;; brace list, otherwise we have. + (let ((macro-end (progn (c-end-of-macro) (point)))) + (goto-char start) + (forward-char) + (if (and (c-syntactic-re-search-forward "[;,]" macro-end t t) + (eq (char-before) ?\;)) + nil + (cons macro-start nil)))) ; (2016-08-30): Lazy! We have no + ; languages where + ; `c-opt-inexpr-brace-list-key' is + ; non-nil and we have macros. + (t t))) ;; The caller can go up one level. ))) (defun c-inside-bracelist-p (containing-sexp paren-state) @@ -10040,7 +10056,7 @@ comment at the start of cc-engine.el for more info." (setq containing-sexp next-containing lim nil next-containing nil)))) - (and (numberp bufpos) bufpos))))) + (and (consp bufpos) (car bufpos)))))) (defun c-looking-at-special-brace-list (&optional lim) ;; If we're looking at the start of a pike-style list, i.e., `({ })', @@ -10688,7 +10704,7 @@ comment at the start of cc-engine.el for more info." ;; CASE B.2: brace-list-open ((or (consp special-brace-list) - (numberp + (consp (c-looking-at-or-maybe-in-bracelist containing-sexp beg-of-same-or-containing-stmt)) ) @@ -11231,42 +11247,18 @@ comment at the start of cc-engine.el for more info." ;; CASE 5A.3: brace list open ((save-excursion - (c-beginning-of-decl-1 lim) - (while (cond - ((looking-at c-specifier-key) - (c-forward-keyword-clause 1)) - ((and c-opt-cpp-prefix - (looking-at c-noise-macro-with-parens-name-re)) - (c-forward-noise-clause)))) - (setq placeholder (c-point 'boi)) - (or (consp special-brace-list) - (and (or (save-excursion - (goto-char indent-point) - (setq tmpsymbol nil) - (while (and (> (point) placeholder) - (zerop (c-backward-token-2 1 t)) - (not (looking-at "=\\([^=]\\|$\\)"))) - (and c-opt-inexpr-brace-list-key - (not tmpsymbol) - (looking-at c-opt-inexpr-brace-list-key) - (setq tmpsymbol 'topmost-intro-cont))) - (looking-at "=\\([^=]\\|$\\)")) - (looking-at c-brace-list-key) - (looking-at c-return-key) - (save-excursion - (and (c-forward-type) - (looking-at c-identifier-start) - (not (looking-at c-keywords-regexp)) - (c-forward-token-2) - (eq (point) (c-point 'boi indent-point))))) - (save-excursion - (while (and (< (point) indent-point) - (zerop (c-forward-token-2 1 t)) - (not (memq (char-after) '(?\; ?\())))) - (not (memq (char-after) '(?\; ?\())) - )))) + (goto-char indent-point) + (skip-chars-forward " \t") + (cond + ((c-backward-over-enum-header) + (setq placeholder (c-point 'boi))) + ((consp (setq placeholder + (c-looking-at-or-maybe-in-bracelist + containing-sexp lim))) + (setq tmpsymbol (and (cdr placeholder) 'topmost-intro-cont)) + (setq placeholder (c-point 'boi (car placeholder)))))) (if (and (not c-auto-newline-analysis) - (c-major-mode-is 'java-mode) + ;(c-major-mode-is 'java-mode) ; Not needed anymore (2016-08-30). (eq tmpsymbol 'topmost-intro-cont)) ;; We're in Java and have found that the open brace ;; belongs to a "new Foo[]" initialization list, diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el index bf8b857..a23dddf 100644 --- a/lisp/progmodes/cc-fonts.el +++ b/lisp/progmodes/cc-fonts.el @@ -1261,12 +1261,12 @@ casts and declarations are fontified. Used on level 2 and higher." c-restricted-<>-arglists nil) (c-put-char-property (1- match-pos) 'c-type 'c-decl-arg-start)) - ;; We're inside an brace list. + ;; We're inside a brace list. ((and (eq (char-before match-pos) ?{) (save-excursion (goto-char (1- match-pos)) - (numberp - (c-looking-at-or-maybe-in-bracelist nil)))) + (consp + (c-looking-at-or-maybe-in-bracelist)))) (setq context 'not-decl c-restricted-<>-arglists nil) (c-put-char-property (1- match-pos) 'c-type diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index 5b324d6..f2c6256 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el @@ -1406,7 +1406,7 @@ Note that the style variables are always made local to the buffer." (and (eq (char-before) ?{) (save-excursion (backward-char) - (numberp (c-looking-at-or-maybe-in-bracelist nil)))) + (consp (c-looking-at-or-maybe-in-bracelist)))) ))) (not (bobp))) (backward-char)) ; back over (, [, <. commit 62b6c5d2805a07515cbc4368a32376e4d82cf2c3 Author: Michael Albinus Date: Tue Aug 30 15:36:14 2016 +0200 Use `file-attribute-*' in Tramp * lisp/net/tramp-compat.el (tramp-compat-file-attribute-type) (tramp-compat-file-attribute-link-number) (tramp-compat-file-attribute-user-id) (tramp-compat-file-attribute-group-id) (tramp-compat-file-attribute-modification-time) (tramp-compat-file-attribute-size) (tramp-compat-file-attribute-modes): New defaliases. * lisp/net/tramp.el (tramp-handle-file-modes) (tramp-handle-file-newer-than-file-p) (tramp-handle-file-regular-p, tramp-handle-file-symlink-p) (tramp-handle-set-visited-file-modtime) (tramp-handle-verify-visited-file-modtime) (tramp-get-local-gid, tramp-check-cached-permissions): * lisp/net/tramp-adb.el (tramp-adb-handle-file-directory-p) (tramp-adb-handle-file-truename, tramp-adb-handle-copy-file): * lisp/net/tramp-gvfs.el (tramp-gvfs-handle-delete-directory) (tramp-gvfs-handle-file-directory-p) (tramp-gvfs-handle-write-region, tramp-gvfs-get-remote-uid) (tramp-gvfs-get-remote-gid): * lisp/net/tramp-sh.el (tramp-sh-handle-file-truename) (tramp-sh-handle-set-visited-file-modtime) (tramp-sh-handle-verify-visited-file-modtime) (tramp-sh-handle-file-newer-than-file-p) (tramp-sh-handle-file-ownership-preserved-p) (tramp-do-copy-or-rename-file) (tramp-do-copy-or-rename-file-via-buffer) (tramp-do-copy-or-rename-file-directly) (tramp-do-copy-or-rename-file-out-of-band) (tramp-sh-handle-file-local-copy) (tramp-sh-handle-write-region): * lisp/net/tramp-smb.el (tramp-smb-handle-copy-directory) (tramp-smb-handle-copy-file) (tramp-smb-handle-file-directory-p) (tramp-smb-handle-file-writable-p) (tramp-smb-handle-insert-directory): Use them. diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 48a05a7..3eb1bc4 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -246,7 +246,9 @@ pass to the OPERATION." (defun tramp-adb-handle-file-directory-p (filename) "Like `file-directory-p' for Tramp files." - (car (file-attributes (file-truename filename)))) + (eq (tramp-compat-file-attribute-type + (file-attributes (file-truename filename))) + t)) ;; This is derived from `tramp-sh-handle-file-truename'. Maybe the ;; code could be shared? @@ -281,14 +283,15 @@ pass to the OPERATION." (append '("") (reverse result) (list thisstep)) "/")) (setq symlink-target - (nth 0 (file-attributes - (tramp-make-tramp-file-name - method user host - (mapconcat 'identity - (append '("") - (reverse result) - (list thisstep)) - "/"))))) + (tramp-compat-file-attribute-type + (file-attributes + (tramp-make-tramp-file-name + method user host + (mapconcat 'identity + (append '("") + (reverse result) + (list thisstep)) + "/"))))) (cond ((string= "." thisstep) (tramp-message v 5 "Ignoring step `.'")) ((string= ".." thisstep) @@ -712,7 +715,10 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." ;; KEEP-DATE handling. (when keep-date - (set-file-times newname (nth 5 (file-attributes filename)))))) + (set-file-times + newname + (tramp-compat-file-attribute-modification-time + (file-attributes filename)))))) (defun tramp-adb-handle-rename-file (filename newname &optional ok-if-already-exists) diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index 19e48f6..1c0b8d2 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el @@ -261,6 +261,65 @@ process." (memq (process-status process) '(run open listen connect stop)))))) +;; `file-attribute-*' are introduced in Emacs 25.1. + +(if (fboundp 'file-attribute-type) + (defalias 'tramp-compat-file-attribute-type 'file-attribute-type) + (defsubst tramp-compat-file-attribute-type (attributes) + "The type field in ATTRIBUTES returned by `file-attributes'. +The value is either t for directory, string (name linked to) for +symbolic link, or nil." + (nth 0 attributes))) + +(if (fboundp 'file-attribute-link-number) + (defalias 'tramp-compat-file-attribute-link-number + 'file-attribute-link-number) + (defsubst tramp-compat-file-attribute-link-number (attributes) + "Return the number of links in ATTRIBUTES returned by `file-attributes'." + (nth 1 attributes))) + +(if (fboundp 'file-attribute-user-id) + (defalias 'tramp-compat-file-attribute-user-id 'file-attribute-user-id) + (defsubst tramp-compat-file-attribute-user-id (attributes) + "The UID field in ATTRIBUTES returned by `file-attributes'. +This is either a string or a number. If a string value cannot be +looked up, a numeric value, either an integer or a float, is +returned." + (nth 2 attributes))) + +(if (fboundp 'file-attribute-group-id) + (defalias 'tramp-compat-file-attribute-group-id 'file-attribute-group-id) + (defsubst tramp-compat-file-attribute-group-id (attributes) + "The GID field in ATTRIBUTES returned by `file-attributes'. +This is either a string or a number. If a string value cannot be +looked up, a numeric value, either an integer or a float, is +returned." + (nth 3 attributes))) + +(if (fboundp 'file-attribute-modification-time) + (defalias 'tramp-compat-file-attribute-modification-time + 'file-attribute-modification-time) + (defsubst tramp-compat-file-attribute-modification-time (attributes) + "The modification time in ATTRIBUTES returned by `file-attributes'. +This is the time of the last change to the file's contents, and +is a list of integers (HIGH LOW USEC PSEC) in the same style +as (current-time)." + (nth 5 attributes))) + +(if (fboundp 'file-attribute-size) + (defalias 'tramp-compat-file-attribute-size 'file-attribute-size) + (defsubst tramp-compat-file-attribute-size (attributes) + "The size (in bytes) in ATTRIBUTES returned by `file-attributes'. +This is a floating point number if the size is too large for an integer." + (nth 7 attributes))) + +(if (fboundp 'file-attribute-modes) + (defalias 'tramp-compat-file-attribute-modes 'file-attribute-modes) + (defsubst tramp-compat-file-attribute-modes (attributes) + "The file modes in ATTRIBUTES returned by `file-attributes'. +This is a string of ten letters or dashes as in ls -l." + (nth 8 attributes))) + ;; `default-toplevel-value' has been declared in Emacs 24. (unless (fboundp 'default-toplevel-value) (defalias 'default-toplevel-value 'symbol-value)) diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index 398fc87..6f1c013 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el @@ -754,7 +754,8 @@ file names." (with-parsed-tramp-file-name directory nil (if (and recursive (not (file-symlink-p directory))) (mapc (lambda (file) - (if (eq t (car (file-attributes file))) + (if (eq t (tramp-compat-file-attribute-type + (file-attributes file))) (tramp-compat-delete-directory file recursive trash) (tramp-compat-delete-file file trash))) (directory-files @@ -1017,7 +1018,8 @@ file names." (defun tramp-gvfs-handle-file-directory-p (filename) "Like `file-directory-p' for Tramp files." - (eq t (car (file-attributes (file-truename filename))))) + (eq t (tramp-compat-file-attribute-type + (file-attributes (file-truename filename))))) (defun tramp-gvfs-handle-file-executable-p (filename) "Like `file-executable-p' for Tramp files." @@ -1214,7 +1216,9 @@ file-notify events." ;; Set file modification time. (when (or (eq visit t) (stringp visit)) - (set-visited-file-modtime (nth 5 (file-attributes filename)))) + (set-visited-file-modtime + (tramp-compat-file-attribute-modification-time + (file-attributes filename)))) ;; The end. (when (or (eq visit t) (null visit) (stringp visit)) @@ -1589,9 +1593,9 @@ ID-FORMAT valid values are `string' and `integer'." (cond ((and user (equal id-format 'string)) user) (localname - (nth 2 (file-attributes - (tramp-make-tramp-file-name method user host localname) - id-format))) + (tramp-compat-file-attribute-user-id + (file-attributes + (tramp-make-tramp-file-name method user host localname) id-format))) ((equal id-format 'integer) tramp-unknown-id-integer) ((equal id-format 'string) tramp-unknown-id-string))))) @@ -1606,9 +1610,9 @@ ID-FORMAT valid values are `string' and `integer'." (tramp-get-connection-property vec "default-location" nil))) (cond (localname - (nth 3 (file-attributes - (tramp-make-tramp-file-name method user host localname) - id-format))) + (tramp-compat-file-attribute-group-id + (file-attributes + (tramp-make-tramp-file-name method user host localname) id-format))) ((equal id-format 'integer) tramp-unknown-id-integer) ((equal id-format 'string) tramp-unknown-id-string))))) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 61d853f..b6aa3a7 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -1190,14 +1190,15 @@ target of the symlink differ." (append '("") (reverse result) (list thisstep)) "/")) (setq symlink-target - (nth 0 (file-attributes - (tramp-make-tramp-file-name - method user host - (mapconcat 'identity - (append '("") - (reverse result) - (list thisstep)) - "/"))))) + (tramp-compat-file-attribute-type + (file-attributes + (tramp-make-tramp-file-name + method user host + (mapconcat 'identity + (append '("") + (reverse result) + (list thisstep)) + "/"))))) (cond ((string= "." thisstep) (tramp-message v 5 "Ignoring step `.'")) ((string= ".." thisstep) @@ -1448,7 +1449,8 @@ target of the symlink differ." (let* ((remote-file-name-inhibit-cache t) (attr (file-attributes f)) ;; '(-1 65535) means file doesn't exists yet. - (modtime (or (nth 5 attr) '(-1 65535)))) + (modtime (or (tramp-compat-file-attribute-modification-time attr) + '(-1 65535)))) (setq coding-system-used last-coding-system-used) ;; We use '(0 0) as a don't-know value. See also ;; `tramp-do-file-attributes-with-ls'. @@ -1487,7 +1489,7 @@ of." (with-parsed-tramp-file-name f nil (let* ((remote-file-name-inhibit-cache t) (attr (file-attributes f)) - (modtime (nth 5 attr)) + (modtime (tramp-compat-file-attribute-modification-time attr)) (mt (visited-file-modtime))) (cond @@ -1711,9 +1713,16 @@ be non-negative integers." ;; and obtain the result. (let ((fa1 (file-attributes file1)) (fa2 (file-attributes file2))) - (if (and (not (equal (nth 5 fa1) '(0 0))) - (not (equal (nth 5 fa2) '(0 0)))) - (> 0 (tramp-time-diff (nth 5 fa2) (nth 5 fa1))) + (if (and + (not + (equal (tramp-compat-file-attribute-modification-time fa1) + '(0 0))) + (not + (equal (tramp-compat-file-attribute-modification-time fa2) + '(0 0)))) + (> 0 (tramp-time-diff + (tramp-compat-file-attribute-modification-time fa2) + (tramp-compat-file-attribute-modification-time fa1))) ;; If one of them is the dont-know value, then we can ;; still try to run a shell command on the remote host. ;; However, this only works if both files are Tramp @@ -1765,9 +1774,11 @@ be non-negative integers." ;; information would be lost by an (attempted) delete and create. (or (null attributes) (and - (= (nth 2 attributes) (tramp-get-remote-uid v 'integer)) + (= (tramp-compat-file-attribute-user-id attributes) + (tramp-get-remote-uid v 'integer)) (or (not group) - (= (nth 3 attributes) (tramp-get-remote-gid v 'integer))))))))) + (= (tramp-compat-file-attribute-group-id attributes) + (tramp-get-remote-gid v 'integer))))))))) ;; Directory listings. @@ -2066,7 +2077,8 @@ file names." (error "Unknown operation `%s', must be `copy' or `rename'" op)) (let ((t1 (tramp-tramp-file-p filename)) (t2 (tramp-tramp-file-p newname)) - (length (nth 7 (file-attributes (file-truename filename)))) + (length (tramp-compat-file-attribute-size + (file-attributes (file-truename filename)))) (attributes (and preserve-extended-attributes (apply 'file-extended-attributes (list filename))))) @@ -2177,7 +2189,11 @@ KEEP-DATE is non-nil if NEWNAME should have the same timestamp as FILENAME." (set-buffer-multibyte nil) (insert-file-contents-literally filename))) ;; KEEP-DATE handling. - (when keep-date (set-file-times newname (nth 5 (file-attributes filename)))) + (when keep-date + (set-file-times + newname + (tramp-compat-file-attribute-modification-time + (file-attributes filename)))) ;; Set the mode. (set-file-modes newname (tramp-default-file-modes filename)) ;; If the operation was `rename', delete the original file. @@ -2195,7 +2211,8 @@ as FILENAME. PRESERVE-UID-GID, when non-nil, instructs to keep the uid and gid from FILENAME." (let ((t1 (tramp-tramp-file-p filename)) (t2 (tramp-tramp-file-p newname)) - (file-times (nth 5 (file-attributes filename))) + (file-times (tramp-compat-file-attribute-modification-time + (file-attributes filename))) (file-modes (tramp-default-file-modes filename))) (with-parsed-tramp-file-name (if t1 filename newname) nil (let* ((cmd (cond ((and (eq op 'copy) preserve-uid-gid) "cp -f -p") @@ -2559,7 +2576,10 @@ The method used must be an out-of-band method." ;; Handle KEEP-DATE argument. (when (and keep-date (not copy-keep-date)) - (set-file-times newname (nth 5 (file-attributes filename)))) + (set-file-times + newname + (tramp-compat-file-attribute-modification-time + (file-attributes filename)))) ;; Set the mode. (unless (and keep-date copy-keep-date) @@ -3114,7 +3134,8 @@ the result will be a local, non-Tramp, file name." v 'file-error "Cannot make local copy of non-existing file `%s'" filename)) - (let* ((size (nth 7 (file-attributes (file-truename filename)))) + (let* ((size (tramp-compat-file-attribute-size + (file-attributes (file-truename filename)))) (rem-enc (tramp-get-inline-coding v "remote-encoding" size)) (loc-dec (tramp-get-inline-coding v "local-decoding" size)) (tmpfile (tramp-compat-make-temp-file filename))) @@ -3205,9 +3226,11 @@ the result will be a local, non-Tramp, file name." (unless (y-or-n-p (format "File %s exists; overwrite anyway? " filename)) (tramp-error v 'file-error "File not overwritten"))) - (let ((uid (or (nth 2 (file-attributes filename 'integer)) + (let ((uid (or (tramp-compat-file-attribute-user-id + (file-attributes filename 'integer)) (tramp-get-remote-uid v 'integer))) - (gid (or (nth 3 (file-attributes filename 'integer)) + (gid (or (tramp-compat-file-attribute-group-id + (file-attributes filename 'integer)) (tramp-get-remote-gid v 'integer)))) (if (and (tramp-local-host-p v) @@ -3284,7 +3307,8 @@ the result will be a local, non-Tramp, file name." ;; specified. However, if the method _also_ specifies an ;; encoding function, then that is used for encoding the ;; contents of the tmp file. - (let* ((size (nth 7 (file-attributes tmpfile))) + (let* ((size (tramp-compat-file-attribute-size + (file-attributes tmpfile))) (rem-dec (tramp-get-inline-coding v "remote-decoding" size)) (loc-enc (tramp-get-inline-coding v "local-encoding" size))) (cond @@ -3420,9 +3444,9 @@ the result will be a local, non-Tramp, file name." ;; We must pass modtime explicitly, because FILENAME can ;; be different from (buffer-file-name), f.e. if ;; `file-precious-flag' is set. - (nth 5 file-attr)) - (when (and (= (nth 2 file-attr) uid) - (= (nth 3 file-attr) gid)) + (tramp-compat-file-attribute-modification-time file-attr)) + (when (and (= (tramp-compat-file-attribute-user-id file-attr) uid) + (= (tramp-compat-file-attribute-group-id file-attr) gid)) (setq need-chown nil)))) ;; Set the ownership. diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index 05ce604..3b9c49e 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el @@ -531,7 +531,10 @@ pass to the OPERATION." ;; Handle KEEP-DATE argument. (when keep-date - (set-file-times newname (nth 5 (file-attributes dirname)))) + (set-file-times + newname + (tramp-compat-file-attribute-modification-time + (file-attributes dirname)))) ;; Set the mode. (unless keep-date @@ -599,7 +602,10 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." ;; KEEP-DATE handling. (when keep-date - (set-file-times newname (nth 5 (file-attributes filename)))))) + (set-file-times + newname + (tramp-compat-file-attribute-modification-time + (file-attributes filename)))))) (defun tramp-smb-handle-delete-directory (directory &optional recursive) "Like `delete-directory' for Tramp files." @@ -887,7 +893,9 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." (defun tramp-smb-handle-file-directory-p (filename) "Like `file-directory-p' for Tramp files." (and (file-exists-p filename) - (eq ?d (aref (nth 8 (file-attributes filename)) 0)))) + (eq ?d + (aref (tramp-compat-file-attribute-modes (file-attributes filename)) + 0)))) (defun tramp-smb-handle-file-local-copy (filename) "Like `file-local-copy' for Tramp files." @@ -929,7 +937,9 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." (defun tramp-smb-handle-file-writable-p (filename) "Like `file-writable-p' for Tramp files." (if (file-exists-p filename) - (string-match "w" (or (nth 8 (file-attributes filename)) "")) + (string-match + "w" + (or (tramp-compat-file-attribute-modes (file-attributes filename)) "")) (let ((dir (file-name-directory filename))) (and (file-exists-p dir) (file-writable-p dir))))) @@ -1014,11 +1024,11 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." (insert (format "%10s %3d %-8s %-8s %8s %s " - (or (nth 8 attr) (nth 1 x)) ; mode - (or (nth 1 attr) 1) ; inode - (or (nth 2 attr) "nobody") ; uid - (or (nth 3 attr) "nogroup") ; gid - (or (nth 7 attr) (nth 2 x)) ; size + (or (tramp-compat-file-attribute-modes attr) (nth 1 x)) + (or (tramp-compat-file-attribute-link-number attr) 1) + (or (tramp-compat-file-attribute-user-id attr) "nobody") + (or (tramp-compat-file-attribute-group-id attr) "nogroup") + (or (tramp-compat-file-attribute-size attr) (nth 2 x)) (format-time-string (if (time-less-p (time-subtract (current-time) (nth 3 x)) tramp-half-a-year) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 4e9d4c2..ad00f31 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -2856,7 +2856,8 @@ User is always nil." "Like `file-modes' for Tramp files." (let ((truename (or (file-truename filename) filename))) (when (file-exists-p truename) - (tramp-mode-string-to-int (nth 8 (file-attributes truename)))))) + (tramp-mode-string-to-int + (tramp-compat-file-attribute-modes (file-attributes truename)))))) ;; Localname manipulation functions that grok Tramp localnames... (defun tramp-handle-file-name-as-directory (file) @@ -2926,13 +2927,17 @@ User is always nil." (cond ((not (file-exists-p file1)) nil) ((not (file-exists-p file2)) t) - (t (time-less-p (nth 5 (file-attributes file2)) - (nth 5 (file-attributes file1)))))) + (t (time-less-p (tramp-compat-file-attribute-modification-time + (file-attributes file2)) + (tramp-compat-file-attribute-modification-time + (file-attributes file1)))))) (defun tramp-handle-file-regular-p (filename) "Like `file-regular-p' for Tramp files." (and (file-exists-p filename) - (eq ?- (aref (nth 8 (file-attributes filename)) 0)))) + (eq ?- + (aref (tramp-compat-file-attribute-modes (file-attributes filename)) + 0)))) (defun tramp-handle-file-remote-p (filename &optional identification connected) "Like `file-remote-p' for Tramp files." @@ -2958,7 +2963,7 @@ User is always nil." (defun tramp-handle-file-symlink-p (filename) "Like `file-symlink-p' for Tramp files." (with-parsed-tramp-file-name filename nil - (let ((x (car (file-attributes filename)))) + (let ((x (tramp-compat-file-attribute-type (file-attributes filename)))) (when (stringp x) (if (file-name-absolute-p x) (tramp-make-tramp-file-name method user host x) @@ -3279,7 +3284,9 @@ User is always nil." (let ((remote-file-name-inhibit-cache t)) ;; '(-1 65535) means file doesn't exists yet. (setq time-list - (or (nth 5 (file-attributes (buffer-file-name))) '(-1 65535))))) + (or (tramp-compat-file-attribute-modification-time + (file-attributes (buffer-file-name))) + '(-1 65535))))) ;; We use '(0 0) as a don't-know value. (unless (equal time-list '(0 0)) (tramp-run-real-handler 'set-visited-file-modtime (list time-list)))) @@ -3303,7 +3310,7 @@ of." (with-parsed-tramp-file-name f nil (let* ((remote-file-name-inhibit-cache t) (attr (file-attributes f)) - (modtime (nth 5 attr)) + (modtime (tramp-compat-file-attribute-modification-time attr)) (mt (visited-file-modtime))) (cond @@ -3820,7 +3827,7 @@ ID-FORMAT valid values are `string' and `integer'." ;; `group-gid' has been introduced with Emacs 24.4. (if (and (fboundp 'group-gid) (equal id-format 'integer)) (tramp-compat-funcall 'group-gid) - (nth 3 (file-attributes "~/" id-format)))) + (tramp-compat-file-attribute-group-id (file-attributes "~/" id-format)))) (defun tramp-get-local-locale (&optional vec) "Determine locale, supporting UTF8 if possible. @@ -3884,23 +3891,32 @@ be granted." (and file-attr (or - ;; Not a symlink - (eq t (car file-attr)) - (null (car file-attr))) + ;; Not a symlink. + (eq t (tramp-compat-file-attribute-type file-attr)) + (null (tramp-compat-file-attribute-type file-attr))) (or ;; World accessible. - (eq access (aref (nth 8 file-attr) (+ offset 6))) + (eq access + (aref (tramp-compat-file-attribute-modes file-attr) + (+ offset 6))) ;; User accessible and owned by user. (and - (eq access (aref (nth 8 file-attr) offset)) - (or (equal remote-uid (nth 2 file-attr)) - (equal unknown-id (nth 2 file-attr)))) - ;; Group accessible and owned by user's - ;; principal group. + (eq access + (aref (tramp-compat-file-attribute-modes file-attr) offset)) + (or (equal remote-uid + (tramp-compat-file-attribute-user-id file-attr)) + (equal unknown-id + (tramp-compat-file-attribute-user-id file-attr)))) + ;; Group accessible and owned by user's principal group. (and - (eq access (aref (nth 8 file-attr) (+ offset 3))) - (or (equal remote-gid (nth 3 file-attr)) - (equal unknown-id (nth 3 file-attr)))))))))))) + (eq access + (aref (tramp-compat-file-attribute-modes file-attr) + (+ offset 3))) + (or (equal remote-gid + (tramp-compat-file-attribute-group-id file-attr)) + (equal unknown-id + (tramp-compat-file-attribute-group-id + file-attr)))))))))))) ;;;###tramp-autoload (defun tramp-local-host-p (vec) commit 4961cc3f368d9114c305efe6243987bcfa3fd29b Author: Martin Rudalics Date: Tue Aug 30 12:30:29 2016 +0200 In `pop-to-buffer' handle case where `display-buffer' fails (Bug#24332) * lisp/window.el (pop-to-buffer): Don't assume that `display-buffer' has supplied a window (Bug#24332). Rename BUFFER argument to BUFFER-OR-NAME. * doc/lispref/windows.texi (Switching Buffers): Fix `pop-to-buffer' documentation. diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index 36bccdd..3c9df0b 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi @@ -2233,15 +2233,15 @@ This function makes @var{buffer-or-name} the current buffer and displays it in some window, preferably not the window currently selected. It then selects the displaying window. If that window is on a different graphical frame, that frame is given input focus if -possible (@pxref{Input Focus}). The return value is the buffer that -was switched to. +possible (@pxref{Input Focus}). If @var{buffer-or-name} is @code{nil}, it defaults to the buffer returned by @code{other-buffer} (@pxref{Buffer List}). If @var{buffer-or-name} is a string that is not the name of any existing buffer, this function creates a new buffer with that name; the new buffer's major mode is determined by the variable @code{major-mode} -(@pxref{Major Modes}). +(@pxref{Major Modes}). In any case, that buffer is made current and +returned, even when no suitable window was found to display it. If @var{action} is non-@code{nil}, it should be a display action to pass to @code{display-buffer} (@pxref{Choosing Window}). diff --git a/lisp/window.el b/lisp/window.el index cfa10ea..6728ea3 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -6692,8 +6692,7 @@ that allows the selected frame)." (window--display-buffer buffer window 'frame alist display-buffer-mark-dedicated) (unless (cdr (assq 'inhibit-switch-frame alist)) - (window--maybe-raise-frame frame)))) - )) + (window--maybe-raise-frame frame)))))) (defun display-buffer-same-window (buffer alist) "Display BUFFER in the selected window. @@ -7074,12 +7073,12 @@ returned from `display-buffer' in this case." 'fail)) ;;; Display + selection commands: -(defun pop-to-buffer (buffer &optional action norecord) - "Select buffer BUFFER in some window, preferably a different one. -BUFFER may be a buffer, a string (a buffer name), or nil. If it -is a string not naming an existent buffer, create a buffer with -that name. If BUFFER is nil, choose some other buffer. Return -the buffer. +(defun pop-to-buffer (buffer-or-name &optional action norecord) + "Display buffer specified by BUFFER-OR-NAME and select its window. +BUFFER-OR-NAME may be a buffer, a string (a buffer name), or nil. +If it is a string not naming an existent buffer, create a buffer +with that name. If BUFFER-OR-NAME is nil, choose some other +buffer. In either case, make that buffer current and return it. This uses `display-buffer' as a subroutine. The optional ACTION argument is passed to `display-buffer' as its ACTION argument. @@ -7088,24 +7087,30 @@ interactively with a prefix argument, which means to pop to a window other than the selected one even if the buffer is already displayed in the selected window. -If the window to show BUFFER is not on the selected -frame, raise that window's frame and give it input focus. +If a suitable window is found, select that window. If it is not +on the selected frame, raise that window's frame and give it +input focus. Optional third arg NORECORD non-nil means do not put this buffer at the front of the list of recently selected ones." (interactive (list (read-buffer "Pop to buffer: " (other-buffer)) (if current-prefix-arg t))) - (setq buffer (window-normalize-buffer-to-switch-to buffer)) - ;; This should be done by `select-window' below. - ;; (set-buffer buffer) - (let* ((old-frame (selected-frame)) - (window (display-buffer buffer action)) - (frame (window-frame window))) - ;; If we chose another frame, make sure it gets input focus. - (unless (eq frame old-frame) - (select-frame-set-input-focus frame norecord)) - ;; Make sure new window is selected (Bug#8615), (Bug#6954). - (select-window window norecord) + (let* ((buffer (window-normalize-buffer-to-switch-to buffer-or-name)) + (old-frame (selected-frame)) + (window (display-buffer buffer action))) + ;; Don't assume that `display-buffer' has supplied us with a window + ;; (Bug#24332). + (if window + (let ((frame (window-frame window))) + ;; If we chose another frame, make sure it gets input focus. + (unless (eq frame old-frame) + (select-frame-set-input-focus frame norecord)) + ;; Make sure the window is selected (Bug#8615), (Bug#6954) + (select-window window norecord)) + ;; If `display-buffer' failed to supply a window, just make the + ;; buffer current. + (set-buffer buffer)) + ;; Return BUFFER even when we got no window. buffer)) (defun pop-to-buffer-same-window (buffer &optional norecord)