commit 4fbd330fae54a9c45d4a717127aa86d75e9938d5 (HEAD, refs/remotes/origin/master) Author: Philipp Stephani Date: Tue Feb 28 22:21:37 2017 +0100 Protect against an infloop in python-mode There appears to be an edge case caused by using `syntax-ppss' in a narrowed buffer during JIT lock inside of Python triple-quote strings. Unfortunately it is impossible to reproduce without manually destroying the syntactic information in the Python buffer, but it has been observed in practice. In that case it can happen that the syntax caches get sufficiently out of whack so that there appear to be overlapping strings in the buffer. As Python has no nested strings, this situation is impossible and leads to an infloop in `python-nav-end-of-statement'. Protect against this by checking whether the search for the end of the current string makes progress. * python.el (python-nav-end-of-statement): Protect against infloop. * progmodes/python-tests.el (python-tests--python-nav-end-of-statement--infloop): Add unit test. diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 228a448461..2697f1a310 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -1491,10 +1491,18 @@ Optional argument NOEND is internal and makes the logic to not jump to the end of line when moving forward searching for the end of the statement." (interactive "^") - (let (string-start bs-pos) + (let (string-start bs-pos (last-string-end 0)) (while (and (or noend (goto-char (line-end-position))) (not (eobp)) (cond ((setq string-start (python-syntax-context 'string)) + ;; The assertion can only fail if syntax table + ;; text properties and the `syntax-ppss' cache + ;; are somehow out of whack. This has been + ;; observed when using `syntax-ppss' during + ;; narrowing. + (cl-assert (> string-start last-string-end) + :show-args + "Overlapping strings detected") (goto-char string-start) (if (python-syntax-context 'paren) ;; Ended up inside a paren, roll again. @@ -1504,8 +1512,10 @@ of the statement." (goto-char (+ (point) (python-syntax-count-quotes (char-after (point)) (point)))) - (or (re-search-forward (rx (syntax string-delimiter)) nil t) - (goto-char (point-max))))) + (setq last-string-end + (or (re-search-forward + (rx (syntax string-delimiter)) nil t) + (goto-char (point-max)))))) ((python-syntax-context 'paren) ;; The statement won't end before we've escaped ;; at least one level of parenthesis. diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index 1e6b867d30..2f4c2fb849 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -5314,6 +5314,25 @@ class SomeClass: (or enabled (hs-minor-mode -1))))) +(ert-deftest python-tests--python-nav-end-of-statement--infloop () + "Checks that `python-nav-end-of-statement' doesn't infloop in a +buffer with overlapping strings." + (python-tests-with-temp-buffer "''' '\n''' ' '\n" + (syntax-propertize (point-max)) + ;; Create a situation where strings nominally overlap. This + ;; shouldn't happen in practice, but apparently it can happen when + ;; a package calls `syntax-ppss' in a narrowed buffer during JIT + ;; lock. + (put-text-property 4 5 'syntax-table (string-to-syntax "|")) + (remove-text-properties 8 9 '(syntax-table nil)) + (goto-char 4) + (setq-local syntax-propertize-function nil) + ;; The next form should not infloop. We have to disable + ;; ‘debug-on-error’ so that ‘cl-assert’ doesn’t call the debugger. + (should-error (let ((debug-on-error nil)) + (python-nav-end-of-statement))) + (should (eolp)))) + (provide 'python-tests) commit aa0fb4fed8ef1f3599f573476fc6291f8872c7e7 Author: Michael Albinus Date: Thu Mar 23 17:07:55 2017 +0100 * doc/lispref/os.texi (File Notifications): Strengthen the recommendation to use filenotify.el. diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index 9b6752c5e1..438f48c347 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi @@ -2707,7 +2707,10 @@ This does not depend on one of the libraries linked to Emacs. Since all these libraries emit different events on notified file changes, there is the Emacs library @code{filenotify} which provides a -unique interface. +unified interface. Lisp programs that want to receive file +notifications should always use this library in preference to the +native ones. + @defun file-notify-add-watch file flags callback Add a watch for filesystem events pertaining to @var{file}. This commit e6d3eaa69871d800eb078580b64f2bc5806a0fcc Author: Paul Eggert Date: Thu Mar 23 08:51:44 2017 -0700 Merge from gnulib This incorporates: 2017-03-22 getopt: merge from glibc * build-aux/config.sub, lib/getopt.c, lib/getopt.in.h: * lib/getopt1.c, lib/getopt_int.h: Copy from gnulib. * lib/gnulib.mk.in: Regenerate. diff --git a/build-aux/config.sub b/build-aux/config.sub index 87abeab6cd..7203bf1e64 100755 --- a/build-aux/config.sub +++ b/build-aux/config.sub @@ -2,7 +2,7 @@ # Configuration validation subroutine script. # Copyright 1992-2017 Free Software Foundation, Inc. -timestamp='2017-02-07' +timestamp='2017-03-21' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -315,6 +315,7 @@ case $basic_machine in | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | visium \ + | wasm32 \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) @@ -446,6 +447,7 @@ case $basic_machine in | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | visium-* \ + | wasm32-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ @@ -1246,6 +1248,9 @@ case $basic_machine in basic_machine=a29k-wrs os=-vxworks ;; + wasm32) + basic_machine=wasm32-unknown + ;; w65*) basic_machine=w65-wdc os=-none diff --git a/lib/getopt.c b/lib/getopt.c index e40ea8d5ea..7afd0dcabe 100644 --- a/lib/getopt.c +++ b/lib/getopt.c @@ -2,22 +2,22 @@ NOTE: getopt is part of the C library, so if you don't know what "Keep this file name-space clean" means, talk to drepper@gnu.org before changing it! - Copyright (C) 1987-1996, 1998-2004, 2006, 2008-2017 Free Software - Foundation, Inc. + Copyright (C) 1987-2017 Free Software Foundation, Inc. This file is part of the GNU C Library. - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 3 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ + You should have received a copy of the GNU General Public + License along with the GNU C Library; if not, see + . */ #ifndef _LIBC # include @@ -27,8 +27,8 @@ #include #include -#include #include +#include #ifdef _LIBC # include @@ -37,7 +37,7 @@ # define _(msgid) gettext (msgid) #endif -#if defined _LIBC && defined USE_IN_LIBIO +#if defined _LIBC # include #endif @@ -181,7 +181,7 @@ exchange (char **argv, struct _getopt_data *d) { /* Bottom segment is the short one. */ int len = middle - bottom; - register int i; + int i; /* Swap it with the top part of the top segment. */ for (i = 0; i < len; i++) @@ -198,7 +198,7 @@ exchange (char **argv, struct _getopt_data *d) { /* Top segment is the short one. */ int len = top - middle; - register int i; + int i; /* Swap it with the bottom part of the bottom segment. */ for (i = 0; i < len; i++) @@ -564,11 +564,11 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, first.next = ambig_list; ambig_list = &first; -#if defined _LIBC && defined USE_IN_LIBIO +#if defined _LIBC char *buf = NULL; size_t buflen = 0; - FILE *fp = open_memstream (&buf, &buflen); + FILE *fp = __open_memstream (&buf, &buflen); if (fp != NULL) { fprintf (fp, @@ -584,7 +584,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, fputc_unlocked ('\n', fp); - if (__builtin_expect (fclose (fp) != EOF, 1)) + if (__glibc_likely (fclose (fp) != EOF)) { _IO_flockfile (stderr); @@ -642,7 +642,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, { if (print_errors) { -#if defined _LIBC && defined USE_IN_LIBIO +#if defined _LIBC char *buf; int n; #endif @@ -650,7 +650,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, if (argv[d->optind - 1][1] == '-') { /* --option */ -#if defined _LIBC && defined USE_IN_LIBIO +#if defined _LIBC n = __asprintf (&buf, _("\ %s: option '--%s' doesn't allow an argument\n"), argv[0], pfound->name); @@ -663,7 +663,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, else { /* +option or -option */ -#if defined _LIBC && defined USE_IN_LIBIO +#if defined _LIBC n = __asprintf (&buf, _("\ %s: option '%c%s' doesn't allow an argument\n"), argv[0], argv[d->optind - 1][0], @@ -676,7 +676,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, #endif } -#if defined _LIBC && defined USE_IN_LIBIO +#if defined _LIBC if (n >= 0) { _IO_flockfile (stderr); @@ -709,7 +709,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, { if (print_errors) { -#if defined _LIBC && defined USE_IN_LIBIO +#if defined _LIBC char *buf; if (__asprintf (&buf, _("\ @@ -760,7 +760,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, { if (print_errors) { -#if defined _LIBC && defined USE_IN_LIBIO +#if defined _LIBC char *buf; int n; #endif @@ -768,7 +768,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, if (argv[d->optind][1] == '-') { /* --option */ -#if defined _LIBC && defined USE_IN_LIBIO +#if defined _LIBC n = __asprintf (&buf, _("%s: unrecognized option '--%s'\n"), argv[0], d->__nextchar); #else @@ -779,7 +779,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, else { /* +option or -option */ -#if defined _LIBC && defined USE_IN_LIBIO +#if defined _LIBC n = __asprintf (&buf, _("%s: unrecognized option '%c%s'\n"), argv[0], argv[d->optind][0], d->__nextchar); #else @@ -788,7 +788,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, #endif } -#if defined _LIBC && defined USE_IN_LIBIO +#if defined _LIBC if (n >= 0) { _IO_flockfile (stderr); @@ -826,19 +826,19 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, { if (print_errors) { -#if defined _LIBC && defined USE_IN_LIBIO +#if defined _LIBC char *buf; int n; #endif -#if defined _LIBC && defined USE_IN_LIBIO +#if defined _LIBC n = __asprintf (&buf, _("%s: invalid option -- '%c'\n"), argv[0], c); #else fprintf (stderr, _("%s: invalid option -- '%c'\n"), argv[0], c); #endif -#if defined _LIBC && defined USE_IN_LIBIO +#if defined _LIBC if (n >= 0) { _IO_flockfile (stderr); @@ -884,7 +884,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, { if (print_errors) { -#if defined _LIBC && defined USE_IN_LIBIO +#if defined _LIBC char *buf; if (__asprintf (&buf, @@ -958,7 +958,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, { if (print_errors) { -#if defined _LIBC && defined USE_IN_LIBIO +#if defined _LIBC char *buf; if (__asprintf (&buf, _("%s: option '-W %s' is ambiguous\n"), @@ -998,7 +998,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, { if (print_errors) { -#if defined _LIBC && defined USE_IN_LIBIO +#if defined _LIBC char *buf; if (__asprintf (&buf, _("\ @@ -1037,7 +1037,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, { if (print_errors) { -#if defined _LIBC && defined USE_IN_LIBIO +#if defined _LIBC char *buf; if (__asprintf (&buf, _("\ @@ -1112,7 +1112,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, { if (print_errors) { -#if defined _LIBC && defined USE_IN_LIBIO +#if defined _LIBC char *buf; if (__asprintf (&buf, _("\ diff --git a/lib/getopt.in.h b/lib/getopt.in.h index 6cbad8e033..3f57c68a25 100644 --- a/lib/getopt.in.h +++ b/lib/getopt.in.h @@ -1,20 +1,20 @@ /* Declarations for getopt. - Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2017 Free Software - Foundation, Inc. + Copyright (C) 1989-2017 Free Software Foundation, Inc. This file is part of the GNU C Library. - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 3 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ + You should have received a copy of the GNU General Public + License along with the GNU C Library; if not, see + . */ #ifndef _@GUARD_PREFIX@_GETOPT_H @@ -238,6 +238,25 @@ struct option extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) __THROW _GL_ARG_NONNULL ((2, 3)); +#ifndef __GETOPT_PREFIX +# if defined __need_getopt && defined __USE_POSIX2 \ + && !defined __USE_POSIX_IMPLICITLY && !defined __USE_GNU +/* The GNU getopt has more functionality than the standard version. The + additional functionality can be disable at runtime. This redirection + helps to also do this at runtime. */ +# ifdef __REDIRECT + extern int __REDIRECT_NTH (getopt, (int ___argc, char *const *___argv, + const char *__shortopts), + __posix_getopt); +# else +extern int __posix_getopt (int ___argc, char *const *___argv, + const char *__shortopts) + __THROW _GL_ARG_NONNULL ((2, 3)); +# define getopt __posix_getopt +# endif +# endif +#endif + #ifndef __need_getopt extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv, const char *__shortopts, diff --git a/lib/getopt1.c b/lib/getopt1.c index 4d2e8cbac3..166b129533 100644 --- a/lib/getopt1.c +++ b/lib/getopt1.c @@ -1,20 +1,20 @@ /* getopt_long and getopt_long_only entry points for GNU getopt. - Copyright (C) 1987-1994, 1996-1998, 2004, 2006, 2009-2017 Free Software - Foundation, Inc. + Copyright (C) 1987-2017 Free Software Foundation, Inc. This file is part of the GNU C Library. - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 3 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ + You should have received a copy of the GNU General Public + License along with the GNU C Library; if not, see + . */ #ifdef _LIBC # include diff --git a/lib/getopt_int.h b/lib/getopt_int.h index a7ce0e9cc1..c614fcb65b 100644 --- a/lib/getopt_int.h +++ b/lib/getopt_int.h @@ -1,20 +1,20 @@ /* Internal declarations for getopt. - Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2017 Free Software - Foundation, Inc. + Copyright (C) 1989-2017 Free Software Foundation, Inc. This file is part of the GNU C Library. - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 3 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ + You should have received a copy of the GNU General Public + License along with the GNU C Library; if not, see + . */ #ifndef _GETOPT_INT_H #define _GETOPT_INT_H 1 diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index 2c0b689e71..ca95ed7e82 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in @@ -558,7 +558,6 @@ LIBS_GNUSTEP = @LIBS_GNUSTEP@ LIBS_MAIL = @LIBS_MAIL@ LIBS_SYSTEM = @LIBS_SYSTEM@ LIBS_TERMCAP = @LIBS_TERMCAP@ -LIBTESTS_LIBDEPS = @LIBTESTS_LIBDEPS@ LIBTIFF = @LIBTIFF@ LIBXMENU = @LIBXMENU@ LIBXML2_CFLAGS = @LIBXML2_CFLAGS@ commit e1392faae5c5cc7805b52efacbb25a71213afdeb Author: Michael Albinus Date: Thu Mar 23 14:58:04 2017 +0100 Use lexical-bind in Tramp * lisp/net/tramp*.el: Add lexical-binding cookie. Move declarations up. * lisp/net/tramp-adb.el (tramp-adb-parse-device-names): Use `push' rather than `add-to-list'. (tramp-adb-get-device): Remove unused variable. * lisp/net/tramp-gvfs.el (tramp-gvfs-parse-device-names): Remove unused variable. * lisp/net/tramp.el (auto-save-file-name-transforms): Declare. (tramp-find-file-name-coding-system-alist): Use `push' rather than `add-to-list'. * test/lisp/net/tramp-tests.el: Add lexical-binding cookie. Require 'dired. Move declarations up. (tramp-test32-make-nearby-temp-file): Wrap `make-nearby-temp-file' and `temporary-file-directory' calls with `with-no-warnings'. (tramp-test35-asynchronous-requests): Mark unused variable. diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index bf89ab3712..4191c3ec93 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -1,4 +1,4 @@ -;;; tramp-adb.el --- Functions for calling Android Debug Bridge from Tramp +;;; tramp-adb.el --- Functions for calling Android Debug Bridge from Tramp -*- lexical-binding:t -*- ;; Copyright (C) 2011-2017 Free Software Foundation, Inc. @@ -209,7 +209,7 @@ pass to the OPERATION." (tramp-message v 6 "\n%s" (buffer-string)) (goto-char (point-min)) (while (search-forward-regexp "^\\(\\S-+\\)[[:space:]]+device$" nil t) - (add-to-list 'result (list nil (match-string 1)))) + (push (list nil (match-string 1)) result)) ;; Replace ":" by "#". (mapc @@ -1060,8 +1060,7 @@ E.g. a host name \"192.168.1.1#5555\" returns \"192.168.1.1:5555\" ;; unwanted entries first. (tramp-flush-connection-property nil) (with-tramp-connection-property (tramp-get-connection-process vec) "device" - (let* ((method (tramp-file-name-method vec)) - (host (tramp-file-name-host vec)) + (let* ((host (tramp-file-name-host vec)) (port (tramp-file-name-port vec)) (devices (mapcar 'cadr (tramp-adb-parse-device-names nil)))) (replace-regexp-in-string diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el index ce7df02e09..64268cfc25 100644 --- a/lisp/net/tramp-cache.el +++ b/lisp/net/tramp-cache.el @@ -1,4 +1,4 @@ -;;; tramp-cache.el --- file information caching for Tramp +;;; tramp-cache.el --- file information caching for Tramp -*- lexical-binding:t -*- ;; Copyright (C) 2000, 2005-2017 Free Software Foundation, Inc. diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el index 576f9b1ead..c41b5b5659 100644 --- a/lisp/net/tramp-cmds.el +++ b/lisp/net/tramp-cmds.el @@ -1,4 +1,4 @@ -;;; tramp-cmds.el --- Interactive commands for Tramp +;;; tramp-cmds.el --- Interactive commands for Tramp -*- lexical-binding:t -*- ;; Copyright (C) 2007-2017 Free Software Foundation, Inc. diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index 8e5b3e45d1..8f346eb440 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el @@ -1,4 +1,4 @@ -;;; tramp-compat.el --- Tramp compatibility functions +;;; tramp-compat.el --- Tramp compatibility functions -*- lexical-binding:t -*- ;; Copyright (C) 2007-2017 Free Software Foundation, Inc. diff --git a/lisp/net/tramp-ftp.el b/lisp/net/tramp-ftp.el index 85e4f2b0f0..231383fde3 100644 --- a/lisp/net/tramp-ftp.el +++ b/lisp/net/tramp-ftp.el @@ -1,4 +1,4 @@ -;;; tramp-ftp.el --- Tramp convenience functions for Ange-FTP +;;; tramp-ftp.el --- Tramp convenience functions for Ange-FTP -*- lexical-binding:t -*- ;; Copyright (C) 2002-2017 Free Software Foundation, Inc. diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index 7725d40f19..561f6c8f79 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el @@ -1,4 +1,4 @@ -;;; tramp-gvfs.el --- Tramp access functions for GVFS daemon +;;; tramp-gvfs.el --- Tramp access functions for GVFS daemon -*- lexical-binding:t -*- ;; Copyright (C) 2009-2017 Free Software Foundation, Inc. @@ -1874,12 +1874,9 @@ This uses \"avahi-browse\" in case D-Bus is not enabled in Avahi." (lambda (x) (let* ((list (split-string x ";")) (host (nth 6 list)) - (port (nth 8 list)) (text (tramp-compat-funcall 'split-string (nth 9 list) "\" \"" 'omit "\"")) user) -; (when (and port (not (string-equal port "0"))) -; (setq host (format "%s%s%s" host tramp-prefix-port-regexp port))) ;; A user is marked in a TXT field like "u=guest". (while text (when (string-match "u=\\(.+\\)$" (car text)) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index af27d3e28e..486e002fac 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -1,4 +1,4 @@ -;;; tramp-sh.el --- Tramp access functions for (s)sh-like connections +;;; tramp-sh.el --- Tramp access functions for (s)sh-like connections -*- lexical-binding:t -*- ;; Copyright (C) 1998-2017 Free Software Foundation, Inc. @@ -33,6 +33,9 @@ (eval-when-compile (require 'cl) (require 'dired)) + +(declare-function dired-remove-file "dired-aux") +(defvar dired-compress-file-suffixes) (defvar vc-handled-backends) (defvar vc-bzr-program) (defvar vc-git-program) @@ -2593,9 +2596,6 @@ The method used must be an out-of-band method." ;; Dired. -(defvar dired-compress-file-suffixes) -(declare-function dired-remove-file "dired-aux") - (defun tramp-sh-handle-dired-compress-file (file) "Like `dired-compress-file' for Tramp files." ;; Code stolen mainly from dired-aux.el. diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index 91f6956757..eaa8ac655e 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el @@ -1,4 +1,4 @@ -;;; tramp-smb.el --- Tramp access functions for SMB servers +;;; tramp-smb.el --- Tramp access functions for SMB servers -*- lexical-binding:t -*- ;; Copyright (C) 2002-2017 Free Software Foundation, Inc. diff --git a/lisp/net/tramp-uu.el b/lisp/net/tramp-uu.el index 0aa2cc0992..5e5f05da4a 100644 --- a/lisp/net/tramp-uu.el +++ b/lisp/net/tramp-uu.el @@ -1,4 +1,4 @@ -;;; tramp-uu.el --- uuencode in Lisp +;;; tramp-uu.el --- uuencode in Lisp -*- lexical-binding:t -*- ;; Copyright (C) 2002-2017 Free Software Foundation, Inc. diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index fdd4661dec..a9254693ad 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -1,4 +1,4 @@ -;;; tramp.el --- Transparent Remote Access, Multiple Protocol +;;; tramp.el --- Transparent Remote Access, Multiple Protocol -*- lexical-binding:t -*- ;; Copyright (C) 1998-2017 Free Software Foundation, Inc. @@ -60,7 +60,10 @@ ;; Pacify byte-compiler. (eval-when-compile (require 'cl)) +(defvar auto-save-file-name-transforms) (defvar eshell-path-env) +(defvar ls-lisp-use-insert-directory-program) +(defvar outline-regexp) ;;; User Customizable Internal Variables: @@ -1374,8 +1377,6 @@ Point must be at the beginning of a header line. The outline level is equal to the verbosity of the Tramp message." (1+ (string-to-number (match-string 1)))) -(defvar outline-regexp) - (defun tramp-get-debug-buffer (vec) "Get the debug buffer for VEC." (with-current-buffer @@ -1871,13 +1872,12 @@ temporary file names. If `file-coding-system-alist' contains an expression, which matches more than the file name suffix, the coding system might not be determined. This function repairs it." (let (result) - (dolist (elt file-coding-system-alist result) + (dolist (elt file-coding-system-alist (nreverse result)) (when (and (consp elt) (string-match (car elt) filename)) ;; We found a matching entry in `file-coding-system-alist'. ;; So we add a similar entry, but with the temporary file name ;; as regexp. - (add-to-list - 'result (cons (regexp-quote tmpname) (cdr elt)) 'append))))) + (push (cons (regexp-quote tmpname) (cdr elt)) result))))) ;;;###autoload (progn (defun tramp-run-real-handler (operation args) @@ -2328,9 +2328,9 @@ not in completion mode." (when elt (string-match tramp-prefix-regexp elt) (setq elt (replace-match (concat tramp-prefix-format hop) nil nil elt)) - (add-to-list - 'result1 - (substring elt (length (tramp-drop-volume-letter directory)))))) + (push + (substring elt (length (tramp-drop-volume-letter directory))) + result1))) ;; Complete local parts. (append @@ -2955,8 +2955,6 @@ User is always nil." backup-directory-alist))) (tramp-run-real-handler 'find-backup-file-name (list filename))))) -(defvar ls-lisp-use-insert-directory-program) - (defun tramp-handle-insert-directory (filename switches &optional wildcard full-directory-p) "Like `insert-directory' for Tramp files." diff --git a/lisp/net/trampver.el b/lisp/net/trampver.el index 35ad2f0acf..35b5eb6728 100644 --- a/lisp/net/trampver.el +++ b/lisp/net/trampver.el @@ -1,4 +1,4 @@ -;;; trampver.el --- Transparent Remote Access, Multiple Protocol +;;; trampver.el --- Transparent Remote Access, Multiple Protocol -*- lexical-binding:t -*- ;;; lisp/trampver.el. Generated from trampver.el.in by configure. ;; Copyright (C) 2003-2017 Free Software Foundation, Inc. diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 45b4ff2f5a..2a4ef740a0 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -1,4 +1,4 @@ -;;; tramp-tests.el --- Tests of remote file access +;;; tramp-tests.el --- Tests of remote file access -*- lexical-binding:t -*- ;; Copyright (C) 2013-2017 Free Software Foundation, Inc. @@ -37,6 +37,7 @@ ;;; Code: +(require 'dired) (require 'ert) (require 'tramp) (require 'vc) @@ -44,11 +45,11 @@ (require 'vc-git) (require 'vc-hg) -(autoload 'dired-uncache "dired") (declare-function tramp-find-executable "tramp-sh") (declare-function tramp-get-remote-path "tramp-sh") (declare-function tramp-get-remote-stat "tramp-sh") (declare-function tramp-get-remote-perl "tramp-sh") +(defvar auto-save-file-name-transforms) (defvar tramp-copy-size-limit) (defvar tramp-persistency-file-name) (defvar tramp-remote-process-environment) @@ -2083,17 +2084,20 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." (skip-unless (and (fboundp 'make-nearby-temp-file) (fboundp 'temporary-file-directory))) + ;; `make-nearby-temp-file' and `temporary-file-directory' exists + ;; since Emacs 26. We don't want to see compiler warnings for older + ;; Emacsen." (let ((default-directory tramp-test-temporary-file-directory) tmp-file) ;; The remote host shall know a temporary file directory. - (should (stringp (temporary-file-directory))) + (should (stringp (with-no-warnings (temporary-file-directory)))) (should (string-equal (file-remote-p default-directory) - (file-remote-p (temporary-file-directory)))) + (file-remote-p (with-no-warnings (temporary-file-directory))))) ;; The temporary file shall be located on the remote host. - (setq tmp-file (make-nearby-temp-file "tramp-test")) + (setq tmp-file (with-no-warnings (make-nearby-temp-file "tramp-test"))) (should (file-exists-p tmp-file)) (should (file-regular-p tmp-file)) (should @@ -2103,7 +2107,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." (delete-file tmp-file) (should-not (file-exists-p tmp-file)) - (setq tmp-file (make-nearby-temp-file "tramp-test" 'dir)) + (setq tmp-file (with-no-warnings (make-nearby-temp-file "tramp-test" 'dir))) (should (file-exists-p tmp-file)) (should (file-directory-p tmp-file)) (delete-directory tmp-file) @@ -2582,7 +2586,7 @@ process sentinels. They shall not disturb each other." ;; Create temporary buffers. The number of buffers ;; corresponds to the number of processes; it could be ;; increased in order to make pressure on Tramp. - (dotimes (i 5) + (dotimes (_i 5) (add-to-list 'buffers (generate-new-buffer "*temp*"))) ;; Open asynchronous processes. Set process sentinel. commit e472cfe8f3b01f29a49614f6207e4128e8b36b8c Author: Kaushal Modi Date: Fri Mar 17 18:03:23 2017 -0400 Do not include comment start chars in ffap string * lisp/ffap.el (ffap-string-at-point): If the point is in a comment, ensure that the returned string does not contain the comment start characters (especially for major modes that have '//' as comment start characters). Otherwise, in a major mode like c-mode, with `ido-mode' enabled and `ido-use-filename-at-point' set to `guess', doing "C-x C-f" on a "//foo" comment will initiate an attempt to access a path "//foo" (Bug#24057). Co-authored-by: Noam Postavsky diff --git a/lisp/ffap.el b/lisp/ffap.el index d7222bfb68..1ea32b75f1 100644 --- a/lisp/ffap.el +++ b/lisp/ffap.el @@ -1110,32 +1110,67 @@ The arguments CHARS, BEG and END are handled as described in (defun ffap-string-at-point (&optional mode) "Return a string of characters from around point. + MODE (defaults to value of `major-mode') is a symbol used to look up string syntax parameters in `ffap-string-at-point-mode-alist'. + If MODE is not found, we use `file' instead of MODE. + If the region is active, return a string from the region. -Set the variable `ffap-string-at-point' and the variable + +If the point is in a comment, ensure that the returned string does not +contain the comment start characters (especially for major modes that +have '//' as comment start characters). + +Set the variables `ffap-string-at-point' and `ffap-string-at-point-region'. + When the region is active and larger than `ffap-max-region-length', return an empty string, and set `ffap-string-at-point-region' to '(1 1)." (let* ((args (cdr (or (assq (or mode major-mode) ffap-string-at-point-mode-alist) (assq 'file ffap-string-at-point-mode-alist)))) + (region-selected (use-region-p)) (pt (point)) - (beg (if (use-region-p) + (beg (if region-selected (region-beginning) (save-excursion (skip-chars-backward (car args)) (skip-chars-forward (nth 1 args) pt) (point)))) - (end (if (use-region-p) + (end (if region-selected (region-end) (save-excursion (skip-chars-forward (car args)) (skip-chars-backward (nth 2 args) pt) (point)))) (region-len (- (max beg end) (min beg end)))) + + ;; If the initial characters of the to-be-returned string are the + ;; current major mode's comment starter characters, *and* are + ;; not part of a comment, remove those from the returned string + ;; (Bug#24057). + ;; Example comments in `c-mode' (which considers lines beginning + ;; with "//" as comments): + ;; //tmp - This is a comment. It does not contain any path reference. + ;; ///tmp - This is a comment. The "/tmp" portion in that is a path. + ;; ////tmp - This is a comment. The "//tmp" portion in that is a path. + (when (and + ;; Proceed if no region is selected by the user. + (null region-selected) + ;; Check if END character is part of a comment. + (save-excursion + (nth 4 (syntax-ppss end)))) + ;; Move BEG to beginning of comment (after the comment start + ;; characters), or END, whichever comes first. + (save-excursion + (let ((state (syntax-ppss beg))) + ;; (nth 4 (syntax-ppss)) will be nil for comment start chars. + (unless (nth 4 state) + (parse-partial-sexp beg end nil nil state :commentstop) + (setq beg (point)))))) + (if (and (natnump ffap-max-region-length) (< region-len ffap-max-region-length)) ; Bug#25243. (setf ffap-string-at-point-region (list beg end)